Skip to main content

run_stream

Function run_stream 

Source
pub fn run_stream<F>(
    spec: &StrategySpec,
    candles: &[Candle],
    capital: f64,
    on_bar: F,
) -> Result<BacktestReport>
where F: FnMut(usize, &StreamingBacktest<'_>),
Expand description

Run a backtest over a candle stream, invoking on_bar with the streaming state after each bar — the streaming entry point for a live tail or for emitting the equity curve incrementally.

This is exactly the same step loop as run_with_capital, so the returned report is byte-identical; on_bar simply observes the state after each StreamingBacktest::step (e.g. to read StreamingBacktest::latest_equity). Pointing the same loop at a live feed turns the engine into the live bot.