pub trait LatencyModel: Debug {
// Required methods
fn get_insert_latency(
&self,
command: &TradingCommand,
ts_now: UnixNanos,
) -> Result<DurationNanos>;
fn get_update_latency(
&self,
command: &TradingCommand,
ts_now: UnixNanos,
) -> Result<DurationNanos>;
fn get_delete_latency(
&self,
command: &TradingCommand,
ts_now: UnixNanos,
) -> Result<DurationNanos>;
fn get_base_latency(&self) -> DurationNanos;
}Expand description
Trait for latency models used in backtesting.
Latency models simulate network delays for order operations during backtesting. Implementations can provide static or dynamic (jittered) latency values.
Required Methods§
Sourcefn get_insert_latency(
&self,
command: &TradingCommand,
ts_now: UnixNanos,
) -> Result<DurationNanos>
fn get_insert_latency( &self, command: &TradingCommand, ts_now: UnixNanos, ) -> Result<DurationNanos>
Returns the latency for order insertion operations.
ts_now is the current clock time (simulation time in backtests).
The command retains its creation timestamp.
§Errors
Returns an error if the model cannot produce a valid delay.
Sourcefn get_update_latency(
&self,
command: &TradingCommand,
ts_now: UnixNanos,
) -> Result<DurationNanos>
fn get_update_latency( &self, command: &TradingCommand, ts_now: UnixNanos, ) -> Result<DurationNanos>
Returns the latency for order update/modify operations.
ts_now is the current clock time (simulation time in backtests).
The command retains its creation timestamp.
§Errors
Returns an error if the model cannot produce a valid delay.
Sourcefn get_delete_latency(
&self,
command: &TradingCommand,
ts_now: UnixNanos,
) -> Result<DurationNanos>
fn get_delete_latency( &self, command: &TradingCommand, ts_now: UnixNanos, ) -> Result<DurationNanos>
Returns the latency for order delete/cancel operations.
ts_now is the current clock time (simulation time in backtests).
The command retains its creation timestamp.
§Errors
Returns an error if the model cannot produce a valid delay.
Sourcefn get_base_latency(&self) -> DurationNanos
fn get_base_latency(&self) -> DurationNanos
Returns the base latency component.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".