pub struct SimulationResult {Show 13 fields
pub simulation_count: usize,
pub risk_metrics: Option<RiskMetricsSimulation>,
pub final_equity_percentiles: HashMap<u8, Decimal>,
pub max_premium: Decimal,
pub min_premium: Decimal,
pub avg_premium: Decimal,
pub hit_take_profit: bool,
pub hit_stop_loss: bool,
pub expired: bool,
pub expiration_premium: Option<Decimal>,
pub pnl: PnL,
pub holding_period: usize,
pub exit_reason: ExitPolicy,
}Expand description
SimulationResult represents the outcome of a financial or trading simulation,
capturing the details of the simulation’s performance and metrics.
§Fields
simulation_count- The total number of simulation runs performed.risk_metrics- Optional risk metrics derived from the simulations.final_equity_percentiles- A map containing the percentiles of the final equity distribution. The keys represent the percentile (e.g., 5, 50, 95), and the values are the corresponding equity values.max_premium- The maximum premium value observed during the simulation.min_premium- The minimum premium value observed during the simulation.avg_premium- The average premium value observed during the simulation.hit_take_profit- A boolean indicating if the take profit target was achieved, defined as a 50% reduction in premium.hit_stop_loss- A boolean indicating if the stop loss condition was triggered, defined as a 100% increase in premium.expired- A boolean indicating if the option expired without hitting the take profit or stop loss conditions.expiration_premium- Optional final premium value at expiration. Only available if the option expired.pnl- The final profit or loss (P&L) resulting from the simulation.holding_period- The number of simulation steps during which the asset was held.exit_reason- The reason or policy that triggered the exit from the position (e.g., take profit, stop loss, expiration).
§Notes
SimulationResult is a serializable and cloneable structure, making it convenient
for storing, displaying, and transmitting simulation outcomes. It also provides
a user-friendly debug and display interface through derived traits.
Fields§
§simulation_count: usizeNumber of simulation runs
risk_metrics: Option<RiskMetricsSimulation>Risk metrics calculated from simulations
final_equity_percentiles: HashMap<u8, Decimal>Percentiles of final equity distribution
Maximum premium value during the simulation
Minimum premium value during the simulation
Average premium value during the simulation
hit_take_profit: boolWhether the exit policy’s take-profit condition closed the run
hit_stop_loss: boolWhether the exit policy’s stop-loss condition closed the run
expired: boolWhether the option expired without hitting take profit or stop loss
Final premium value at expiration (only if expired)
pnl: PnLFinal P&L
holding_period: usizeHolding period in steps
exit_reason: ExitPolicyExit policy that triggered the exit
Trait Implementations§
Source§impl Clone for SimulationResult
impl Clone for SimulationResult
Source§impl ComposeSchema for SimulationResult
impl ComposeSchema for SimulationResult
Source§impl Debug for SimulationResult
impl Debug for SimulationResult
Source§impl Default for SimulationResult
impl Default for SimulationResult
Source§impl<'de> Deserialize<'de> for SimulationResult
impl<'de> Deserialize<'de> for SimulationResult
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>,
Source§impl Display for SimulationResult
impl Display for SimulationResult
Source§impl From<&SimulationResult> for PathOutcome
impl From<&SimulationResult> for PathOutcome
Source§fn from(result: &SimulationResult) -> Self
fn from(result: &SimulationResult) -> Self
Projects a strategy-bound result onto the generic outcome.
pnl is PnL::total_pnl (realized plus unrealized), which is the
figure the aggregate statistics have always been computed from.
Source§impl From<PathOutcome> for SimulationResult
impl From<PathOutcome> for SimulationResult
Source§fn from(outcome: PathOutcome) -> Self
fn from(outcome: PathOutcome) -> Self
Lifts a generic outcome into the strategy-bound result.
The path P&L becomes the realized leg of a PnL with no costs,
no income and the current timestamp; simulation_count is one and
the risk fields are empty, exactly as the strategy simulations have
always filled them.
Source§impl Serialize for SimulationResult
impl Serialize for SimulationResult
Auto Trait Implementations§
impl Freeze for SimulationResult
impl RefUnwindSafe for SimulationResult
impl Send for SimulationResult
impl Sync for SimulationResult
impl Unpin for SimulationResult
impl UnsafeUnpin for SimulationResult
impl UnwindSafe for SimulationResult
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<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> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
Source§impl<T> Pointable for T
impl<T> Pointable 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.