use crate::commands::*;
use crate::events::Event;
use crate::types::*;
use std::time::Duration;
pub struct TimerHandle {
pub id: TimerId,
}
pub trait StrategyContext {
fn place_order(&mut self, cmd: PlaceOrder);
fn place_orders(&mut self, cmds: Vec<PlaceOrder>);
fn cancel_order(&mut self, cmd: CancelOrder);
fn cancel_all(&mut self, cmd: CancelAll);
fn stop_strategy(&mut self, strategy_id: StrategyId, reason: &str);
fn set_timer(&mut self, delay: Duration) -> TimerId;
fn set_interval(&mut self, interval: Duration) -> TimerId;
fn cancel_timer(&mut self, timer_id: TimerId);
fn mid_price(&self, instrument: &InstrumentId) -> Option<Price>;
fn quote(&self, instrument: &InstrumentId) -> Option<Quote>;
fn instrument_meta(&self, instrument: &InstrumentId) -> Option<&InstrumentMeta>;
fn balance(&self, asset: &AssetId) -> Balance;
fn position(&self, instrument: &InstrumentId) -> Position;
fn exchange_health(&self, exchange: &ExchangeInstance) -> ExchangeHealth;
fn order(&self, client_id: &ClientOrderId) -> Option<&LiveOrder>;
fn now_ms(&self) -> i64;
fn log_info(&self, msg: &str);
fn log_warn(&self, msg: &str);
fn log_error(&self, msg: &str);
fn log_debug(&self, msg: &str);
}
pub trait Strategy: Send + 'static {
fn id(&self) -> &StrategyId;
fn sync_mechanism(&self) -> SyncMechanism {
SyncMechanism::Poll
}
fn on_start(&mut self, ctx: &mut dyn StrategyContext);
fn on_event(&mut self, ctx: &mut dyn StrategyContext, event: &Event);
fn on_timer(&mut self, ctx: &mut dyn StrategyContext, timer_id: TimerId);
fn on_stop(&mut self, ctx: &mut dyn StrategyContext);
}