Skip to main content

SingleLegSimulation

Trait SingleLegSimulation 

Source
pub trait SingleLegSimulation: PnLCalculator + Positionable {
    const IS_LONG: bool;

    // Provided methods
    fn mark_adjustment(&self) -> Result<Positive, BacktestError> { ... }
    fn simulated_option(&self) -> Result<&Options, SimulationError> { ... }
}
Expand description

A strategy made of one option leg that can be marked along a price path.

Implemented for the four single-leg strategies. The leg is read through Positionable::get_positions, so the strategy needs no extra state; the implementation only states the side and the fee adjustment.

Required Associated Constants§

Source

const IS_LONG: bool

Whether the leg is long (bought) or short (sold). Drives the exit policy evaluation and the sign of the premium move.

Provided Methods§

Source

fn mark_adjustment(&self) -> Result<Positive, BacktestError>

Amount added to every premium mark after the opening one, in quote currency. Zero by default; ShortPut adds its fees.

§Errors

Returns SimulationError when the adjustment cannot be computed.

Source

fn simulated_option(&self) -> Result<&Options, SimulationError>

The single leg of the strategy.

§Errors

Returns SimulationError::InvalidParameters when the strategy does not hold exactly one position.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SingleLegSimulation for LongCall

Source§

const IS_LONG: bool = true

Source§

impl SingleLegSimulation for LongPut

Source§

const IS_LONG: bool = true

Source§

impl SingleLegSimulation for ShortCall

Source§

const IS_LONG: bool = false

Source§

impl SingleLegSimulation for ShortPut

Implementors§