pub struct BacktestRunner { /* private fields */ }Expand description
Orchestrates a backtest by driving the engine with data and actions.
Implementations§
Source§impl BacktestRunner
impl BacktestRunner
Sourcepub fn new(config: BacktestConfig) -> Self
pub fn new(config: BacktestConfig) -> Self
Create a new runner with the given configuration.
Sourcepub fn new_future(
config: BacktestConfig,
future_config: FutureQuoteConfig,
) -> Self
pub fn new_future( config: BacktestConfig, future_config: FutureQuoteConfig, ) -> Self
Create a runner using deterministic FutureQuoteV1 scheduling and pricing.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a runner with default configuration.
Sourcepub fn with_evaluation_options(self, options: EvaluationOptions) -> Self
pub fn with_evaluation_options(self, options: EvaluationOptions) -> Self
Apply typed provider-evaluation options to FutureQuoteV1 results. Legacy execution ignores these options and preserves its existing report.
Sourcepub fn engine(&self) -> &TradeEngine
pub fn engine(&self) -> &TradeEngine
Access the underlying engine (e.g. for inspection between runs).
Sourcepub fn executor(&self) -> &BacktestExecutor
pub fn executor(&self) -> &BacktestExecutor
Access the underlying executor.
Sourcepub fn run_strategy<F: DataFeed, S: Strategy>(
self,
feed: &mut F,
strategy: &mut S,
) -> BacktestResult
pub fn run_strategy<F: DataFeed, S: Strategy>( self, feed: &mut F, strategy: &mut S, ) -> BacktestResult
Run a strategy-driven backtest.
For every event in the data feed:
- The event is converted to a
PriceQuoteand fed to the engine (which checks pending fills and evaluates rules). - The strategy’s
on_eventis called; any returned actions are applied to the engine. - All resulting effects are forwarded to the executor for P&L tracking.
When the feed is exhausted, Strategy::on_finished is called for any
final actions, and (if configured) remaining positions are closed.
Sourcepub fn run_raw_signals<F: DataFeed>(
self,
feed: &mut F,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
) -> BacktestResult
pub fn run_raw_signals<F: DataFeed>( self, feed: &mut F, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, ) -> BacktestResult
Run a raw-signal-replay backtest.
raw_signals must be sorted by timestamp (ascending). Entry
signals are optionally transformed through a ManagementProfile,
while management signals are resolved against live engine state and
passed through directly.
Sourcepub fn run_raw_signals_controlled<F, C, P>(
self,
feed: &mut F,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
is_cancelled: C,
on_progress: P,
) -> Result<BacktestResult, ReplayCancelled>
pub fn run_raw_signals_controlled<F, C, P>( self, feed: &mut F, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, is_cancelled: C, on_progress: P, ) -> Result<BacktestResult, ReplayCancelled>
Run a raw-signal replay with cooperative cancellation and progress updates.
Cancellation is checked at every market-event and signal boundary. Progress callbacks are rate-limited for long event streams while always reporting the initial and terminal counters.
Sourcepub fn run_raw_signals_future<F: DataFeed>(
self,
feed: &mut F,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
) -> BacktestResult
pub fn run_raw_signals_future<F: DataFeed>( self, feed: &mut F, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, ) -> BacktestResult
Run raw signals with FutureQuoteV1 scheduling and execution.
Quotes are validated, required to be nondecreasing per symbol in source
order, and then globally stable-sorted by timestamp. Signals are sorted by
effective time (signal timestamp + latency).
Sourcepub fn run_raw_signals_future_streaming_controlled<F, C, P>(
self,
feed: &mut F,
primary_eod: Option<NaiveDateTime>,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
is_cancelled: C,
on_progress: P,
) -> Result<BacktestResult, StreamingReplayError<F::Error>>
pub fn run_raw_signals_future_streaming_controlled<F, C, P>( self, feed: &mut F, primary_eod: Option<NaiveDateTime>, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, is_cancelled: C, on_progress: P, ) -> Result<BacktestResult, StreamingReplayError<F::Error>>
Run FutureQuoteV1 directly from a fallible stream of complete timestamp batches.
primary_eod must be determined before replay from valid primary quotes. The feed must already be globally ordered and preserve all events at a timestamp in one batch. Event totals are unknown until the stream terminates, so terminal progress reports total_events == processed_events.
Sourcepub fn run_raw_signals_future_fallible<F: FallibleBatchFeed>(
self,
feed: &mut F,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
) -> Result<BacktestResult, F::Error>
pub fn run_raw_signals_future_fallible<F: FallibleBatchFeed>( self, feed: &mut F, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, ) -> Result<BacktestResult, F::Error>
Consume a fallible stream of complete timestamp batches and run FutureQuoteV1.
Feed errors are returned without being converted into a backtest result. Batches are buffered so global ordering and primary EOD semantics remain identical to the compatible DataFeed entry point.
Sourcepub fn run_raw_signals_future_fallible_with_config<F: FallibleBatchFeed>(
self,
feed: &mut F,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
future: FutureQuoteConfig,
) -> Result<BacktestResult, F::Error>
pub fn run_raw_signals_future_fallible_with_config<F: FallibleBatchFeed>( self, feed: &mut F, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, future: FutureQuoteConfig, ) -> Result<BacktestResult, F::Error>
Consume a fallible timestamp-batch stream with explicit FutureQuote settings.
Sourcepub fn run_raw_signals_future_with_config<F: DataFeed>(
self,
source_feed: &mut F,
raw_signals: Vec<RawSignal>,
profile: Option<&ManagementProfile>,
future: FutureQuoteConfig,
) -> BacktestResult
pub fn run_raw_signals_future_with_config<F: DataFeed>( self, source_feed: &mut F, raw_signals: Vec<RawSignal>, profile: Option<&ManagementProfile>, future: FutureQuoteConfig, ) -> BacktestResult
Run raw signals using deterministic FutureQuoteV1 execution.
Fill-bearing actions never reuse a quote older than their effective
timestamp. Signals are stably ordered by (effective_ts, input_sequence);
existing pending orders and rules win ties against signals at the exact
quote timestamp.