Skip to main content

SubsetStats

Struct SubsetStats 

Source
pub struct SubsetStats {
Show 18 fields pub total_trades: usize, pub winning_trades: usize, pub losing_trades: usize, pub breakeven_trades: usize, pub total_pnl: f64, pub gross_profit: f64, pub gross_loss: f64, pub win_rate: f64, pub profit_factor: f64, pub avg_win: f64, pub avg_loss: f64, pub win_loss_ratio: f64, pub expectancy: f64, pub largest_win: f64, pub largest_loss: f64, pub commission: f64, pub swap: f64, pub gross_pnl: Option<f64>,
}
Expand description

Reusable statistics block computed from any subset of trades.

Fields§

§total_trades: usize

Number of trades in this subset.

§winning_trades: usize

Trades with positive P&L.

§losing_trades: usize

Trades with negative P&L.

§breakeven_trades: usize

Trades with exactly zero P&L.

§total_pnl: f64

Sum of all P&L.

§gross_profit: f64

Sum of positive P&L.

§gross_loss: f64

Sum of absolute negative P&L.

§win_rate: f64

winning / total (0.0 if no trades).

§profit_factor: f64

gross_profit / gross_loss (INFINITY if no losers, 0.0 if no trades).

§avg_win: f64

gross_profit / winning_trades (0.0 if no winners).

§avg_loss: f64

gross_loss / losing_trades (0.0 if no losers).

§win_loss_ratio: f64

avg_win / avg_loss (INFINITY if no losers, 0.0 if no winners).

§expectancy: f64

(win_rate * avg_win) - (loss_rate * avg_loss). Expected P&L per trade.

§largest_win: f64

Largest single winning trade P&L.

§largest_loss: f64

Largest single losing trade (as positive number).

§commission: f64

Commission settled on this subset’s rows.

A subset that contains every row of a position reports that position’s complete commission, because the row that fully closes a position settles its entry commission. A subset that splits a position reports only the commission settled on the rows it kept.

§swap: f64

Swap settled on this subset’s rows, under the same subset rule as commission.

§gross_pnl: Option<f64>

Subset profit and loss before commission and swap, present only when either was settled.

Implementations§

Source§

impl SubsetStats

Source

pub fn from_trades(trades: &[&TradeResult]) -> Self

Compute statistics from a slice of trade references.

Source

pub fn from_trade_slice(trades: &[TradeResult]) -> Self

Compute statistics from an owned slice (convenience wrapper).

Trait Implementations§

Source§

impl Clone for SubsetStats

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubsetStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SubsetStats

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SubsetStats

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V