pub struct BaseStrategy<E: Exchange + 'static> {
pub exchange: Arc<E>,
pub market_id: String,
pub market: Option<Market>,
pub state: StrategyState,
pub config: StrategyConfig,
pub positions: Vec<Position>,
pub open_orders: Vec<Order>,
pub event_tx: Sender<StrategyEvent>,
/* private fields */
}Fields§
§exchange: Arc<E>§market_id: String§market: Option<Market>§state: StrategyState§config: StrategyConfig§positions: Vec<Position>§open_orders: Vec<Order>§event_tx: Sender<StrategyEvent>Implementations§
Source§impl<E: Exchange + 'static> BaseStrategy<E>
impl<E: Exchange + 'static> BaseStrategy<E>
pub fn new(exchange: Arc<E>, market_id: String, config: StrategyConfig) -> Self
pub fn subscribe(&self) -> Receiver<StrategyEvent>
pub async fn refresh_state(&mut self) -> Result<(), DrmError>
pub async fn cancel_all_orders(&mut self) -> Result<(), DrmError>
pub fn get_position(&self, outcome: &str) -> Option<&Position>
pub fn get_net_position(&self) -> f64
pub async fn place_order( &mut self, outcome: &str, side: OrderSide, price: f64, size: f64, token_id: Option<&str>, ) -> Result<Order, DrmError>
pub fn log(&self, message: &str)
pub fn is_running(&self) -> bool
pub async fn signal_stop(&self)
pub async fn should_stop(&self) -> bool
pub async fn reset_stop_signal(&self)
pub async fn run_loop<F, Fut>(&mut self, on_tick: F) -> Result<(), DrmError>
pub fn pause(&mut self)
pub fn resume(&mut self)
pub async fn get_account_state(&self) -> Result<AccountState, DrmError>
pub fn calculate_order_size(&self, price: f64, max_exposure: f64) -> f64
pub fn calculate_spread_prices( &self, mid_price: f64, spread_bps: u32, ) -> (f64, f64)
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for BaseStrategy<E>
impl<E> !RefUnwindSafe for BaseStrategy<E>
impl<E> Send for BaseStrategy<E>
impl<E> Sync for BaseStrategy<E>
impl<E> Unpin for BaseStrategy<E>
impl<E> !UnwindSafe for BaseStrategy<E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more