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
impl BacktestNode
Sourcepub fn new(configs: Vec<BacktestRunConfig>) -> Result<Self>
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.
Sourcepub fn configs(&self) -> &[BacktestRunConfig]
pub fn configs(&self) -> &[BacktestRunConfig]
Returns the run configurations.
Sourcepub fn build(&mut self) -> Result<()>
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.
§Errors
Returns an error if engine creation, venue setup, or instrument loading fails.
Sourcepub fn get_engine_mut(&mut self, id: &str) -> Option<&mut BacktestEngine>
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.
Sourcepub fn get_engine(&self, id: &str) -> Option<&BacktestEngine>
pub fn get_engine(&self, id: &str) -> Option<&BacktestEngine>
Returns a reference to the engine for the given run config ID.
Sourcepub fn get_engines(&self) -> Vec<&BacktestEngine>
pub fn get_engines(&self) -> Vec<&BacktestEngine>
Returns all created backtest engines.
Sourcepub fn run(&mut self) -> Result<Vec<BacktestResult>>
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.
§Errors
Returns an error if building, data loading, or engine execution fails.
Sourcepub fn load_catalog(config: &BacktestDataConfig) -> Result<ParquetDataCatalog>
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.
Sourcepub fn load_data_config(
config: &BacktestDataConfig,
start: Option<UnixNanos>,
end: Option<UnixNanos>,
) -> Result<Vec<Data>>
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.
Trait Implementations§
Source§impl Debug for BacktestNode
impl Debug for BacktestNode
Source§impl<'py> IntoPyObject<'py> for BacktestNode
impl<'py> IntoPyObject<'py> for BacktestNode
Source§type Target = BacktestNode
type Target = BacktestNode
Source§type Output = Bound<'py, <BacktestNode as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <BacktestNode as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for BacktestNode
impl PyClass for BacktestNode
Source§impl PyClassImpl for BacktestNode
impl PyClassImpl for BacktestNode
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// 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.
const RAW_DOC: &'static CStr = /// 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.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<BacktestNode as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<BacktestNode>
type Layout = <<BacktestNode as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<BacktestNode>
Source§type ThreadChecker = ThreadCheckerImpl
type ThreadChecker = ThreadCheckerImpl
type Inventory = Pyo3MethodsInventoryForBacktestNode
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyClassNewTextSignature for BacktestNode
impl PyClassNewTextSignature for BacktestNode
const TEXT_SIGNATURE: &'static str = "(configs)"
Source§impl PyStubType for BacktestNode
impl PyStubType for BacktestNode
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
§fn type_input() -> TypeInfo
fn type_input() -> TypeInfo
Source§impl PyTypeInfo for BacktestNode
impl PyTypeInfo for BacktestNode
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for BacktestNode
impl ExtractPyClassWithClone for BacktestNode
Auto Trait Implementations§
impl Freeze for BacktestNode
impl !RefUnwindSafe for BacktestNode
impl !Send for BacktestNode
impl !Sync for BacktestNode
impl Unpin for BacktestNode
impl UnsafeUnpin for BacktestNode
impl !UnwindSafe for BacktestNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more