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 run_portfolio_future<F>(
self,
source_feed: &mut F,
instances: Vec<ConfiguredInstance>,
supervisor: Option<PortfolioSupervisor>,
retention: StrategyRetentionLimits,
) -> Result<PortfolioBacktestResult, PortfolioReplayError<Infallible>>where
F: DataFeed,
pub fn run_portfolio_future<F>(
self,
source_feed: &mut F,
instances: Vec<ConfiguredInstance>,
supervisor: Option<PortfolioSupervisor>,
retention: StrategyRetentionLimits,
) -> Result<PortfolioBacktestResult, PortfolioReplayError<Infallible>>where
F: DataFeed,
Run several configured strategy instances from a materialized data feed against one account.
Sourcepub fn run_mixed_portfolio_future<F, E>(
self,
source_feed: &mut F,
configured: Vec<ConfiguredInstance>,
direct: Vec<DirectPortfolioInstance<E>>,
supervisor: Option<PortfolioSupervisor>,
retention: StrategyRetentionLimits,
) -> Result<MixedPortfolioBacktestResult, MixedPortfolioReplayError<Infallible>>
pub fn run_mixed_portfolio_future<F, E>( self, source_feed: &mut F, configured: Vec<ConfiguredInstance>, direct: Vec<DirectPortfolioInstance<E>>, supervisor: Option<PortfolioSupervisor>, retention: StrategyRetentionLimits, ) -> Result<MixedPortfolioBacktestResult, MixedPortfolioReplayError<Infallible>>
Run configured and caller-compiled strategies against one shared account while preserving their distinct bar timing.
pub fn run_mixed_portfolio_future_streaming_controlled<F, E, C, P>( self, feed: &mut F, primary_eod: Option<NaiveDateTime>, configured: Vec<ConfiguredInstance>, direct: Vec<DirectPortfolioInstance<E>>, supervisor: Option<PortfolioSupervisor>, retention: StrategyRetentionLimits, is_cancelled: C, on_progress: P, ) -> Result<MixedPortfolioBacktestResult, MixedPortfolioReplayError<F::Error>>
Sourcepub fn run_portfolio_future_streaming_controlled<F, C, P>(
self,
feed: &mut F,
primary_eod: Option<NaiveDateTime>,
instances: Vec<ConfiguredInstance>,
supervisor: Option<PortfolioSupervisor>,
retention: StrategyRetentionLimits,
is_cancelled: C,
on_progress: P,
) -> Result<PortfolioBacktestResult, PortfolioReplayError<F::Error>>
pub fn run_portfolio_future_streaming_controlled<F, C, P>( self, feed: &mut F, primary_eod: Option<NaiveDateTime>, instances: Vec<ConfiguredInstance>, supervisor: Option<PortfolioSupervisor>, retention: StrategyRetentionLimits, is_cancelled: C, on_progress: P, ) -> Result<PortfolioBacktestResult, PortfolioReplayError<F::Error>>
Run several configured strategy instances from complete ordered timestamp batches against one account, with cooperative cancellation and replay progress.
Each instance keeps its own series, analysis, decisions, and entry profiles; fills, balance, costs, marks, and drawdown are shared. When a supervisor is supplied, every Entry and scale-in an instance generates is reviewed before it is scheduled, and a refused one reaches the instance as a rejected command.
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_entry_profiles(self, profiles: PreparedEntryProfiles) -> Self
pub fn with_entry_profiles(self, profiles: PreparedEntryProfiles) -> Self
Apply an immutable per-entry profile routing snapshot.
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 with_strategy_research_limits(
self,
limits: StrategyResearchLimits,
) -> Self
pub fn with_strategy_research_limits( self, limits: StrategyResearchLimits, ) -> Self
Apply journal bounds to historical strategy replay.
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_historical_strategy_future<F, S>(
self,
source_feed: &mut F,
strategy: &mut S,
series_specs: Vec<BarSeriesSpec>,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
) -> Result<StrategyBacktestResult, StrategyReplayError<Infallible, S::Error>>
pub fn run_historical_strategy_future<F, S>( self, source_feed: &mut F, strategy: &mut S, series_specs: Vec<BarSeriesSpec>, analysis: AnalysisPipeline, retention: StrategyRetentionLimits, profile: Option<&ManagementProfile>, ) -> Result<StrategyBacktestResult, StrategyReplayError<Infallible, S::Error>>
Run a historical strategy from a materialized data feed through FutureQuote.
Sourcepub fn run_historical_strategy_future_streaming<F, S>(
self,
feed: &mut F,
primary_eod: Option<NaiveDateTime>,
strategy: &mut S,
series_specs: Vec<BarSeriesSpec>,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
) -> Result<StrategyBacktestResult, StrategyReplayError<F::Error, S::Error>>
pub fn run_historical_strategy_future_streaming<F, S>( self, feed: &mut F, primary_eod: Option<NaiveDateTime>, strategy: &mut S, series_specs: Vec<BarSeriesSpec>, analysis: AnalysisPipeline, retention: StrategyRetentionLimits, profile: Option<&ManagementProfile>, ) -> Result<StrategyBacktestResult, StrategyReplayError<F::Error, S::Error>>
Run a historical strategy from complete ordered timestamp batches.
Sourcepub fn run_configured_strategy_future<F>(
self,
source_feed: &mut F,
adapter: &mut BacktestConfiguredStrategyAdapter,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
) -> Result<StrategyBacktestResult, StrategyReplayError<Infallible, ConfiguredStrategyAdapterError>>where
F: DataFeed,
pub fn run_configured_strategy_future<F>(
self,
source_feed: &mut F,
adapter: &mut BacktestConfiguredStrategyAdapter,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
) -> Result<StrategyBacktestResult, StrategyReplayError<Infallible, ConfiguredStrategyAdapterError>>where
F: DataFeed,
Run a configured strategy from a materialized data feed through FutureQuote.
Sourcepub fn run_configured_strategy_future_streaming<F>(
self,
feed: &mut F,
primary_eod: Option<NaiveDateTime>,
adapter: &mut BacktestConfiguredStrategyAdapter,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
) -> Result<StrategyBacktestResult, StrategyReplayError<F::Error, ConfiguredStrategyAdapterError>>where
F: FallibleBatchFeed,
pub fn run_configured_strategy_future_streaming<F>(
self,
feed: &mut F,
primary_eod: Option<NaiveDateTime>,
adapter: &mut BacktestConfiguredStrategyAdapter,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
) -> Result<StrategyBacktestResult, StrategyReplayError<F::Error, ConfiguredStrategyAdapterError>>where
F: FallibleBatchFeed,
Run a configured strategy from complete ordered timestamp batches.
Sourcepub fn run_configured_strategy_future_streaming_controlled<F, C, P>(
self,
feed: &mut F,
primary_eod: Option<NaiveDateTime>,
adapter: &mut BacktestConfiguredStrategyAdapter,
analysis: AnalysisPipeline,
retention: StrategyRetentionLimits,
profile: Option<&ManagementProfile>,
is_cancelled: C,
on_progress: P,
) -> Result<StrategyBacktestResult, StrategyReplayError<F::Error, ConfiguredStrategyAdapterError>>
pub fn run_configured_strategy_future_streaming_controlled<F, C, P>( self, feed: &mut F, primary_eod: Option<NaiveDateTime>, adapter: &mut BacktestConfiguredStrategyAdapter, analysis: AnalysisPipeline, retention: StrategyRetentionLimits, profile: Option<&ManagementProfile>, is_cancelled: C, on_progress: P, ) -> Result<StrategyBacktestResult, StrategyReplayError<F::Error, ConfiguredStrategyAdapterError>>
Run a configured strategy from complete ordered timestamp batches with cooperative cancellation and replay progress, as the retained-job service does for raw-signal replay.
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.