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§
Sourcefn initial_state(&self) -> Self::State
fn initial_state(&self) -> Self::State
State before the first event.
Sourcefn initial_value(&self, state: &Self::State) -> f64
fn initial_value(&self, state: &Self::State) -> f64
Starting value used for return and drawdown.
Sourcefn decide(
&mut self,
event: &Self::Event,
state: &Self::State,
) -> Result<Vec<Self::Action>, String>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".