pub trait SimulationModule {
// Required methods
fn pre_process(&self, data: &Data);
fn process(
&self,
ts_now: UnixNanos,
ctx: &ExchangeContext<'_>,
) -> Vec<Money>;
fn log_diagnostics(&self);
fn reset(&self);
}Expand description
Trait for custom simulation modules that extend backtesting functionality.
Implementations can add specialized behavior such as rollover interest, market makers, price impact models, or other venue-specific simulation logic that runs alongside the core backtesting engine.
Modules use interior mutability (Cell/RefCell) for state since they
are stored inside SimulatedExchange and invoked through shared references.
Required Methods§
Sourcefn pre_process(&self, data: &Data)
fn pre_process(&self, data: &Data)
Pre-processes market data before matching engine processing.
Sourcefn process(&self, ts_now: UnixNanos, ctx: &ExchangeContext<'_>) -> Vec<Money>
fn process(&self, ts_now: UnixNanos, ctx: &ExchangeContext<'_>) -> Vec<Money>
Processes simulation logic at the given timestamp.
Returns account balance adjustments to be applied by the exchange.
Sourcefn log_diagnostics(&self)
fn log_diagnostics(&self)
Logs diagnostic information about the module’s state.
Trait Implementations§
Source§impl From<SimulationModuleAny> for Box<dyn SimulationModule>
impl From<SimulationModuleAny> for Box<dyn SimulationModule>
Source§fn from(value: SimulationModuleAny) -> Self
fn from(value: SimulationModuleAny) -> Self
Converts to this type from the input type.