Skip to main content

run_backtest_with_liquidation

Function run_backtest_with_liquidation 

Source
pub fn run_backtest_with_liquidation<M, D>(
    engine: &mut Engine<M, D>,
    dt_years: f64,
    liquidation_half_spread: f64,
) -> BacktestResult
where M: Matcher, D: DataSource,
Expand description

Run backtest with terminal liquidation applied uniformly at the end. liquidation_half_spread is the half-spread cost per unit of residual inventory: |final_q| * liquidation_half_spread is deducted from both pnl_spread and final_equity so all strategies are evaluated on equal footing regardless of whether they have their own terminal flattening logic.