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,
bid: f64,
ask: f64,
timestamp: u64,
high: f64,
low: f64
) -> (Vec<Order>, bool)
pub fn update_state(
&mut self,
bid: f64,
ask: f64,
timestamp: u64,
high: f64,
low: f64
) -> (Vec<Order>, bool)
Update the exchange state with new information
Parameters
bid: bid price ask: ask price timestamp: timestamp usually in milliseconds high: highest price over last period, use when feeding in candle info, otherwise set high == ask low: lowest price over last period, use when feeding in candle info, otherwise set low == bid ### 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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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