pub struct SubsetStats {Show 15 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,
}Expand description
Reusable statistics block computed from any subset of trades.
Fields§
§total_trades: usizeNumber of trades in this subset.
winning_trades: usizeTrades with positive P&L.
losing_trades: usizeTrades with negative P&L.
breakeven_trades: usizeTrades with exactly zero P&L.
total_pnl: f64Sum of all P&L.
gross_profit: f64Sum of positive P&L.
gross_loss: f64Sum of absolute negative P&L.
win_rate: f64winning / total (0.0 if no trades).
profit_factor: f64gross_profit / gross_loss (INFINITY if no losers, 0.0 if no trades).
avg_win: f64gross_profit / winning_trades (0.0 if no winners).
avg_loss: f64gross_loss / losing_trades (0.0 if no losers).
win_loss_ratio: f64avg_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: f64Largest single winning trade P&L.
largest_loss: f64Largest single losing trade (as positive number).
Implementations§
Source§impl SubsetStats
impl SubsetStats
Sourcepub fn from_trades(trades: &[&TradeResult]) -> Self
pub fn from_trades(trades: &[&TradeResult]) -> Self
Compute statistics from a slice of trade references.
Sourcepub fn from_trade_slice(trades: &[TradeResult]) -> Self
pub fn from_trade_slice(trades: &[TradeResult]) -> Self
Compute statistics from an owned slice (convenience wrapper).
Trait Implementations§
Source§impl Clone for SubsetStats
impl Clone for SubsetStats
Source§fn clone(&self) -> SubsetStats
fn clone(&self) -> SubsetStats
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more