pub struct Exchange<A> { /* private fields */ }
Expand description
The main leveraged futures exchange for simulated trading
Implementations
sourceimpl<A> Exchange<A>where
A: AccountTracker,
impl<A> Exchange<A>where
A: AccountTracker,
sourcepub fn new(account_tracker: A, config: Config) -> Self
pub fn new(account_tracker: A, config: Config) -> Self
Create a new Exchange with the desired config and whether to use candles as infomation source
sourcepub fn current_step(&self) -> u64
pub fn current_step(&self) -> u64
Return the current time step
sourcepub fn account_mut(&mut self) -> &mut Account<A>
pub fn account_mut(&mut self) -> &mut Account<A>
Return a mutable reference to Account
sourcepub fn set_account(&mut self, account: Account<A>)
pub fn set_account(&mut self, account: Account<A>)
Set the account, use carefully
sourcepub fn update_state(
&mut self,
timestamp: u64,
market_update: MarketUpdate
) -> (Vec<Order>, bool)
pub fn update_state(
&mut self,
timestamp: u64,
market_update: MarketUpdate
) -> (Vec<Order>, bool)
Update the exchange state with new information
Parameters:
timestamp: Is used in the AccountTracker A and if setting order timestamps is enabled in the config. So can be set to 0 if not required market_update: Newest market information
Returns:
executed orders true if position has been liquidated
sourcepub fn submit_order(&mut self, order: Order) -> Result<Order, OrderError>
pub fn submit_order(&mut self, order: Order) -> Result<Order, OrderError>
Submit a new order to the exchange. Returns the order with timestamp and id filled in or OrderError
Trait Implementations
Auto Trait Implementations
impl<A> RefUnwindSafe for Exchange<A>where
A: RefUnwindSafe,
impl<A> Send for Exchange<A>where
A: Send,
impl<A> Sync for Exchange<A>where
A: Sync,
impl<A> Unpin for Exchange<A>where
A: Unpin,
impl<A> UnwindSafe for Exchange<A>where
A: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more