Skip to main content

BacktestRunner

Struct BacktestRunner 

Source
pub struct BacktestRunner { /* private fields */ }
Expand description

Orchestrates a backtest by driving the engine with data and actions.

Implementations§

Source§

impl BacktestRunner

Source

pub fn new(config: BacktestConfig) -> Self

Create a new runner with the given configuration.

Source

pub fn new_future( config: BacktestConfig, future_config: FutureQuoteConfig, ) -> Self

Create a runner using deterministic FutureQuoteV1 scheduling and pricing.

Source

pub fn with_defaults() -> Self

Create a runner with default configuration.

Source

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.

Source

pub fn engine(&self) -> &TradeEngine

Access the underlying engine (e.g. for inspection between runs).

Source

pub fn executor(&self) -> &BacktestExecutor

Access the underlying executor.

Source

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:

  1. The event is converted to a PriceQuote and fed to the engine (which checks pending fills and evaluates rules).
  2. The strategy’s on_event is called; any returned actions are applied to the engine.
  3. 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.

Source

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.

Source

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>
where F: DataFeed, C: FnMut() -> bool, P: FnMut(ReplayProgress),

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V