Skip to main content

LatencyModel

Trait LatencyModel 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§