pub struct Exchange<A, Q, UserOrderId>where
Q: Currency,
Q::PairedCurrency: MarginCurrency,
UserOrderId: Clone + Debug + Eq + PartialEq + Hash,{ /* private fields */ }
Expand description
The main leveraged futures exchange for simulated trading
Implementations§
source§impl<A, Q, UserOrderId> Exchange<A, Q, UserOrderId>where
Q: Currency,
Q::PairedCurrency: MarginCurrency,
UserOrderId: Clone + Debug + Eq + PartialEq + Hash,
impl<A, Q, UserOrderId> Exchange<A, Q, UserOrderId>where
Q: Currency,
Q::PairedCurrency: MarginCurrency,
UserOrderId: Clone + Debug + Eq + PartialEq + Hash,
sourcepub fn config(&self) -> &Config<Q::PairedCurrency>
pub fn config(&self) -> &Config<Q::PairedCurrency>
The exchange configuration.
sourcepub fn market_state(&self) -> &MarketState
pub fn market_state(&self) -> &MarketState
The current state of the simulated market.
sourcepub fn account(&self) -> &Account<Q::PairedCurrency, UserOrderId>
pub fn account(&self) -> &Account<Q::PairedCurrency, UserOrderId>
The main user account.
sourcepub fn account_tracker(&self) -> &A
pub fn account_tracker(&self) -> &A
A performance tracker for the user account.
source§impl<A, Q, UserOrderId> Exchange<A, Q, UserOrderId>where
A: AccountTracker<Q::PairedCurrency>,
Q: Currency,
Q::PairedCurrency: MarginCurrency,
UserOrderId: Clone + Eq + PartialEq + Hash + Debug,
impl<A, Q, UserOrderId> Exchange<A, Q, UserOrderId>where
A: AccountTracker<Q::PairedCurrency>,
Q: Currency,
Q::PairedCurrency: MarginCurrency,
UserOrderId: Clone + Eq + PartialEq + Hash + Debug,
sourcepub fn new(account_tracker: A, config: Config<Q::PairedCurrency>) -> Self
pub fn new(account_tracker: A, config: Config<Q::PairedCurrency>) -> Self
Create a new Exchange with the desired config and whether to use candles as infomation source
sourcepub fn update_state(
&mut self,
timestamp_ns: TimestampNs,
market_update: MarketUpdate<Q>
) -> Result<Vec<LimitOrderUpdate<Q, UserOrderId>>>
pub fn update_state( &mut self, timestamp_ns: TimestampNs, market_update: MarketUpdate<Q> ) -> Result<Vec<LimitOrderUpdate<Q, UserOrderId>>>
sourcepub fn submit_limit_order(
&mut self,
order: LimitOrder<Q, UserOrderId, NewOrder>
) -> Result<LimitOrder<Q, UserOrderId, Pending<Q>>>
pub fn submit_limit_order( &mut self, order: LimitOrder<Q, UserOrderId, NewOrder> ) -> Result<LimitOrder<Q, UserOrderId, Pending<Q>>>
sourcepub fn submit_market_order(
&mut self,
order: MarketOrder<Q, UserOrderId, NewOrder>
) -> Result<MarketOrder<Q, UserOrderId, Filled>>
pub fn submit_market_order( &mut self, order: MarketOrder<Q, UserOrderId, NewOrder> ) -> Result<MarketOrder<Q, UserOrderId, Filled>>
sourcepub fn cancel_limit_order_by_user_id(
&mut self,
user_order_id: UserOrderId
) -> Result<LimitOrder<Q, UserOrderId, Pending<Q>>>
pub fn cancel_limit_order_by_user_id( &mut self, user_order_id: UserOrderId ) -> Result<LimitOrder<Q, UserOrderId, Pending<Q>>>
sourcepub fn cancel_order(
&mut self,
order_id: OrderId
) -> Result<LimitOrder<Q, UserOrderId, Pending<Q>>>
pub fn cancel_order( &mut self, order_id: OrderId ) -> Result<LimitOrder<Q, UserOrderId, Pending<Q>>>
Trait Implementations§
Auto Trait Implementations§
impl<A, Q, UserOrderId> Freeze for Exchange<A, Q, UserOrderId>
impl<A, Q, UserOrderId> RefUnwindSafe for Exchange<A, Q, UserOrderId>where
<Q as Currency>::PairedCurrency: Sized + RefUnwindSafe,
A: RefUnwindSafe,
Q: RefUnwindSafe,
UserOrderId: RefUnwindSafe,
impl<A, Q, UserOrderId> Send for Exchange<A, Q, UserOrderId>
impl<A, Q, UserOrderId> Sync for Exchange<A, Q, UserOrderId>
impl<A, Q, UserOrderId> Unpin for Exchange<A, Q, UserOrderId>
impl<A, Q, UserOrderId> UnwindSafe for Exchange<A, Q, UserOrderId>where
<Q as Currency>::PairedCurrency: Sized + UnwindSafe,
A: UnwindSafe,
Q: UnwindSafe,
UserOrderId: UnwindSafe,
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