Skip to main content

BacktestNode

Struct BacktestNode 

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

Orchestrates catalog-driven backtests from run configurations.

BacktestNode connects the ParquetDataCatalog with BacktestEngine to load historical data and run backtests. Supports both oneshot and streaming modes.

Implementations§

Source§

impl BacktestNode

Source

pub fn new(configs: Vec<BacktestRunConfig>) -> Result<Self>

Creates a new BacktestNode instance.

Validates that configs are non-empty and internally consistent:

  • All data config instrument venues must have a matching venue config.
  • L2/L3 book types require order book data in the data configs.
  • Data config time ranges must be valid (start <= end).
§Errors

Returns an error if configs is empty or validation fails.

Source

pub fn configs(&self) -> &[BacktestRunConfig]

Returns the run configurations.

Source

pub fn build(&mut self) -> Result<()>

Builds backtest engines from the run configurations.

For each config, creates a BacktestEngine, adds venues, and loads instruments from the catalog. If building a config fails with BacktestRunConfig::raise_exception disabled, logs the error and skips that config; successful return does not guarantee an engine for every config.

§Errors

Returns an error if building an engine from a config fails and BacktestRunConfig::raise_exception is enabled for that config.

Source

pub fn get_engine_mut(&mut self, id: &str) -> Option<&mut BacktestEngine>

Returns a mutable reference to the engine for the given run config ID.

Source

pub fn get_engine(&self, id: &str) -> Option<&BacktestEngine>

Returns a reference to the engine for the given run config ID.

Source

pub fn get_engines(&self) -> Vec<&BacktestEngine>

Returns all created backtest engines.

Source

pub fn run(&mut self) -> Result<Vec<BacktestResult>>

Runs all configured backtests and returns results.

Automatically calls build() if engines have not been created yet. For each run config, loads data from the catalog and runs the engine. Supports both oneshot (chunk_size = None) and streaming modes. Configs without a built engine are skipped. If a run fails with BacktestRunConfig::raise_exception disabled, logs the error, clears its loaded data, leaves the engine undisposed, and omits its result.

§Errors

Returns an error if building, data loading, or engine execution fails and BacktestRunConfig::raise_exception is enabled for the run config.

Source

pub fn load_catalog(config: &BacktestDataConfig) -> Result<ParquetDataCatalog>

Creates a ParquetDataCatalog from a data config.

§Errors

Returns an error if the catalog cannot be created from the URI.

Source

pub fn load_data_config( config: &BacktestDataConfig, start: Option<UnixNanos>, end: Option<UnixNanos>, ) -> Result<Vec<Data>>

Loads data from the catalog for a specific data config.

§Errors

Returns an error if catalog creation or data querying fails.

Source

pub fn dispose(&mut self)

Disposes all engines and releases resources.

Trait Implementations§

Source§

impl Debug for BacktestNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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