#[non_exhaustive]pub struct StrategyPerformance {Show 23 fields
pub closed_trades: usize,
pub open_trades: usize,
pub winning_trades: usize,
pub losing_trades: usize,
pub net_profit: f64,
pub net_profit_fraction: Option<f64>,
pub gross_profit: f64,
pub gross_loss: f64,
pub total_fees: f64,
pub profit_factor: Option<f64>,
pub win_rate: Option<f64>,
pub average_trade: Option<f64>,
pub largest_winning_trade: Option<f64>,
pub largest_losing_trade: Option<f64>,
pub max_consecutive_wins: usize,
pub max_consecutive_losses: usize,
pub max_drawdown: Option<f64>,
pub max_drawdown_fraction: Option<f64>,
pub sharpe_ratio: Option<f64>,
pub sortino_ratio: Option<f64>,
pub periods_per_year: Option<f64>,
pub skipped_trades: usize,
pub skipped_equity_points: usize,
}Expand description
Metrics of a StrategyReport, from StrategyReport::performance.
Fractions throughout: 0.4 is a 40% win rate. A metric that is undefined for the run is None,
never 0 or infinity, and no Option metric is ever NaN or infinite. The sums add finite values and
are finite unless they exceed the range of f64.
Trade metrics use the closed valid trades, with p the net profit of each. Curve metrics use the
usable equity curve: the points with a finite value, provided they are in strictly increasing time
order. A curve out of order is unusable as a whole, so the curve metrics are None rather than
computed on part of it.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.closed_trades: usizeValid trades with an exit.
open_trades: usizeValid trades without an exit. They enter no trade metric; their value is in the equity curve.
winning_trades: usizeClosed trades with p > 0.
losing_trades: usizeClosed trades with p < 0. A breakeven trade is neither a winner nor a loser.
net_profit: f64Sum of p; 0 without closed trades.
net_profit_fraction: Option<f64>net_profit / initial_capital. None when the initial capital is not positive and finite.
gross_profit: f64Sum of p over the winners.
gross_loss: f64Sum of -p over the losers, a positive number.
total_fees: f64Sum of the fees of the closed trades, already included in net_profit.
profit_factor: Option<f64>gross_profit / gross_loss. None without a losing trade.
win_rate: Option<f64>winning_trades / closed_trades, breakeven trades included in the denominator. None without
closed trades.
average_trade: Option<f64>net_profit / closed_trades. None without closed trades.
largest_winning_trade: Option<f64>Largest positive net profit, or None without a winning trade.
largest_losing_trade: Option<f64>Most negative net profit, or None without a losing trade.
max_consecutive_wins: usizeLongest winning run in exit-time order; ties keep input order. Breakeven trades break runs; open and invalid trades do not participate.
max_consecutive_losses: usizeLongest losing run, with the same ordering and breaks as max_consecutive_wins.
max_drawdown: Option<f64>The largest fall of equity from its highest earlier point, in money, over the curve from its
first point. None without a usable equity point.
max_drawdown_fraction: Option<f64>The largest fall of equity as a fraction of its highest earlier point, found separately from
max_drawdown, so the two can come from different points. Above 1 when equity falls below zero.
None without a usable equity point or when the first point is not positive.
sharpe_ratio: Option<f64>Annualised Sharpe ratio: the mean excess return per step of the curve over the sample standard
deviation of the returns, times the square root of periods_per_year. Returns are simple
returns between consecutive usable points, and the excess is over the risk-free rate per step,
(1 + risk_free_rate)^(1 / periods_per_year) - 1. None when periods_per_year is, with
fewer than 2 returns, when the returns do not vary beyond rounding (a deviation of at most 16
machine epsilons, as for a curve growing at a constant rate), when equity before the last
point is not positive, or when the risk-free rate is not finite or not above -1.
sortino_ratio: Option<f64>Annualised Sortino ratio: as sharpe_ratio, over the downside deviation instead, the root mean
square of the shortfalls of the returns below the risk-free rate per step, taken over all
returns. None when sharpe_ratio is, or when no return falls short.
periods_per_year: Option<f64>Steps of the usable curve per year: the number of returns over the span from the first to the last point, in years of 365.25 days. Counting the bars a run actually contains follows the interval and the market’s sessions without configuration.
None unless the curve spans at least 13 weeks. The span leaves out the closed time before
the first point and after the last, so a short run overstates the periods per year of a
market with sessions: two sessions of 1-minute bars of a stock count about 224,000 a year
instead of about 98,000, and the ratios come out about 1.5 times too high. Thirteen weeks
contain every weekly closed period (nights, weekends) many times over, so from 13 weeks on the
estimate is at most about 6% high, and the ratios about 3%, a small fraction of the sampling
error of a ratio measured over a quarter.
skipped_trades: usizeInvalid trades, left out of every metric (see StrategyTrade).
skipped_equity_points: usizeEquity points with a non-finite value, or every point when the curve is not in strictly increasing time order.
Trait Implementations§
Source§impl Clone for StrategyPerformance
impl Clone for StrategyPerformance
Source§fn clone(&self) -> StrategyPerformance
fn clone(&self) -> StrategyPerformance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StrategyPerformance
impl Debug for StrategyPerformance
Source§impl Default for StrategyPerformance
impl Default for StrategyPerformance
Source§fn default() -> StrategyPerformance
fn default() -> StrategyPerformance
Source§impl PartialEq for StrategyPerformance
impl PartialEq for StrategyPerformance
impl StructuralPartialEq for StrategyPerformance
Auto Trait Implementations§
impl Freeze for StrategyPerformance
impl RefUnwindSafe for StrategyPerformance
impl Send for StrategyPerformance
impl Sync for StrategyPerformance
impl Unpin for StrategyPerformance
impl UnsafeUnpin for StrategyPerformance
impl UnwindSafe for StrategyPerformance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more