pub struct PathStatistics {
pub total_paths: usize,
pub profitable_count: usize,
pub loss_count: usize,
pub average_pnl: Decimal,
pub median_pnl: Decimal,
pub std_dev_pnl: Decimal,
pub best_pnl: Decimal,
pub worst_pnl: Decimal,
pub win_rate: Decimal,
pub average_holding_period: Decimal,
}Expand description
Summary statistics over a set of PathOutcomes.
P&L figures are in quote currency; win_rate is a percentage
(0..=100); average_holding_period is in steps.
Fields§
§total_paths: usizeNumber of outcomes summarised.
profitable_count: usizeOutcomes with a strictly positive P&L.
loss_count: usizeOutcomes with a strictly negative P&L.
average_pnl: DecimalMean P&L.
median_pnl: DecimalMedian P&L (mean of the two middle values for an even count).
std_dev_pnl: DecimalSample standard deviation of the P&L (n - 1 denominator; zero for
fewer than two outcomes).
best_pnl: DecimalHighest P&L.
worst_pnl: DecimalLowest P&L.
win_rate: DecimalPercentage of outcomes with a strictly positive P&L.
average_holding_period: DecimalMean holding period in steps.
Implementations§
Source§impl PathStatistics
impl PathStatistics
Sourcepub fn from_outcomes(outcomes: &[PathOutcome]) -> Result<Self, SimulationError>
pub fn from_outcomes(outcomes: &[PathOutcome]) -> Result<Self, SimulationError>
Summarises a set of outcomes.
An outcome without a P&L counts as zero. The median averages the
two middle values for an even count; the standard deviation uses
the sample (n - 1) denominator and is zero for fewer than two
outcomes. An empty set yields all-zero statistics.
§Errors
Returns SimulationError::Decimal when a sum, difference,
product, or the median and variance quotients (which go through
d_div) leave the representable Decimal range, and
SimulationError::InvalidParameters when one of the three
unrounded quotients (mean, win rate, average holding period) does or
the holding-period total overflows usize.
Trait Implementations§
Source§impl Clone for PathStatistics
impl Clone for PathStatistics
Source§impl Debug for PathStatistics
impl Debug for PathStatistics
Source§impl Default for PathStatistics
impl Default for PathStatistics
Source§impl<'de> Deserialize<'de> for PathStatistics
impl<'de> Deserialize<'de> for PathStatistics
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PathStatistics
Source§impl PartialEq for PathStatistics
impl PartialEq for PathStatistics
Source§impl Serialize for PathStatistics
impl Serialize for PathStatistics
impl StructuralPartialEq for PathStatistics
Auto Trait Implementations§
impl Freeze for PathStatistics
impl RefUnwindSafe for PathStatistics
impl Send for PathStatistics
impl Sync for PathStatistics
impl Unpin for PathStatistics
impl UnsafeUnpin for PathStatistics
impl UnwindSafe for PathStatistics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.