Skip to main content

BacktestModel

Trait BacktestModel 

Source
pub trait BacktestModel {
    type Event;
    type State: Clone;
    type Action: Clone;

    // Required methods
    fn initial_state(&self) -> Self::State;
    fn initial_value(&self, state: &Self::State) -> f64;
    fn timestamp(&self, event: &Self::Event) -> i64;
    fn decide(
        &mut self,
        event: &Self::Event,
        state: &Self::State,
    ) -> Result<Vec<Self::Action>, String>;
    fn apply(
        &mut self,
        event: &Self::Event,
        action: &Self::Action,
        state: &mut Self::State,
    ) -> Result<(), String>;
    fn value(&self, event: &Self::Event, state: &Self::State) -> f64;
}
Expand description

Product-supplied deterministic replay behavior.

Required Associated Types§

Required Methods§

Source

fn initial_state(&self) -> Self::State

Source

fn initial_value(&self, state: &Self::State) -> f64

Source

fn timestamp(&self, event: &Self::Event) -> i64

Source

fn decide( &mut self, event: &Self::Event, state: &Self::State, ) -> Result<Vec<Self::Action>, String>

Produce decisions from the current event and pre-transition state.

Source

fn apply( &mut self, event: &Self::Event, action: &Self::Action, state: &mut Self::State, ) -> Result<(), String>

Apply one decision. The model owns domain-specific transition rules.

Source

fn value(&self, event: &Self::Event, state: &Self::State) -> f64

Mark the state after all actions for the event have been applied.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§