pub struct EngineContext<'a> {Show 14 fields
pub place_orders: Vec<PlaceOrder>,
pub batch_orders: Vec<Vec<PlaceOrder>>,
pub cancel_orders: Vec<CancelOrder>,
pub cancel_alls: Vec<CancelAll>,
pub stop_requests: Vec<StopStrategy>,
pub timers: Vec<PendingTimer>,
pub canceled_timers: Vec<TimerId>,
pub quotes: &'a HashMap<InstrumentId, Quote>,
pub instruments: &'a HashMap<InstrumentId, InstrumentMeta>,
pub orders: &'a OrderManager,
pub inventory: &'a InventoryLedger,
pub positions: &'a HashMap<InstrumentId, Position>,
pub exchange_health: &'a HashMap<ExchangeInstance, ExchangeHealth>,
pub now_ms: i64,
}Expand description
Concrete implementation of StrategyContext
Fields§
§place_orders: Vec<PlaceOrder>Single-order commands emitted during the current callback.
batch_orders: Vec<Vec<PlaceOrder>>Batch order commands emitted during the current callback.
cancel_orders: Vec<CancelOrder>Cancel-one commands emitted during the current callback.
cancel_alls: Vec<CancelAll>Cancel-all commands emitted during the current callback.
stop_requests: Vec<StopStrategy>Strategy stop requests emitted during the current callback.
timers: Vec<PendingTimer>Timer registrations emitted during the current callback.
canceled_timers: Vec<TimerId>Timer cancellations emitted during the current callback.
quotes: &'a HashMap<InstrumentId, Quote>Latest quotes by instrument.
instruments: &'a HashMap<InstrumentId, InstrumentMeta>Instrument metadata by instrument.
orders: &'a OrderManagerOrder manager snapshot.
inventory: &'a InventoryLedgerInventory ledger snapshot.
positions: &'a HashMap<InstrumentId, Position>Current positions by instrument.
exchange_health: &'a HashMap<ExchangeInstance, ExchangeHealth>Exchange health by exchange instance.
now_ms: i64Engine clock in milliseconds since the Unix epoch.
Implementations§
Source§impl<'a> EngineContext<'a>
impl<'a> EngineContext<'a>
Sourcepub fn new(
quotes: &'a HashMap<InstrumentId, Quote>,
instruments: &'a HashMap<InstrumentId, InstrumentMeta>,
orders: &'a OrderManager,
inventory: &'a InventoryLedger,
positions: &'a HashMap<InstrumentId, Position>,
exchange_health: &'a HashMap<ExchangeInstance, ExchangeHealth>,
now_ms: i64,
) -> Self
pub fn new( quotes: &'a HashMap<InstrumentId, Quote>, instruments: &'a HashMap<InstrumentId, InstrumentMeta>, orders: &'a OrderManager, inventory: &'a InventoryLedger, positions: &'a HashMap<InstrumentId, Position>, exchange_health: &'a HashMap<ExchangeInstance, ExchangeHealth>, now_ms: i64, ) -> Self
Create an engine context for one strategy callback.
Sourcepub fn take_commands(
&mut self,
) -> (Vec<PlaceOrder>, Vec<Vec<PlaceOrder>>, Vec<CancelOrder>, Vec<CancelAll>, Vec<StopStrategy>)
pub fn take_commands( &mut self, ) -> (Vec<PlaceOrder>, Vec<Vec<PlaceOrder>>, Vec<CancelOrder>, Vec<CancelAll>, Vec<StopStrategy>)
Drain all collected commands
Sourcepub fn take_timers(&mut self) -> (Vec<PendingTimer>, Vec<TimerId>)
pub fn take_timers(&mut self) -> (Vec<PendingTimer>, Vec<TimerId>)
Drain all timer registrations
Trait Implementations§
Source§impl<'a> StrategyContext for EngineContext<'a>
impl<'a> StrategyContext for EngineContext<'a>
Source§fn place_order(&mut self, cmd: PlaceOrder)
fn place_order(&mut self, cmd: PlaceOrder)
Source§fn place_orders(&mut self, cmds: Vec<PlaceOrder>)
fn place_orders(&mut self, cmds: Vec<PlaceOrder>)
Source§fn cancel_order(&mut self, cmd: CancelOrder)
fn cancel_order(&mut self, cmd: CancelOrder)
Source§fn cancel_all(&mut self, cmd: CancelAll)
fn cancel_all(&mut self, cmd: CancelAll)
Source§fn stop_strategy(&mut self, strategy_id: StrategyId, reason: &str)
fn stop_strategy(&mut self, strategy_id: StrategyId, reason: &str)
Source§fn set_timer(&mut self, delay: Duration) -> TimerId
fn set_timer(&mut self, delay: Duration) -> TimerId
delay.Source§fn set_interval(&mut self, interval: Duration) -> TimerId
fn set_interval(&mut self, interval: Duration) -> TimerId
interval.