Struct lfest::Exchange[][src]

pub struct Exchange { /* fields omitted */ }

The main leveraged futures exchange for simulated trading

Implementations

impl Exchange[src]

pub fn new(config: Config) -> Exchange[src]

Create a new Exchange with the desired config and whether to use candles as infomation source

pub fn set_timestamp(&mut self, timestamp: u64)[src]

Set a timestamp, used for synchronizing orders

pub fn consume_trade(&mut self, trade: &Trade) -> bool[src]

Update the exchange state with a new trade. returns true if position has been liquidated

pub fn consume_candle(&mut self, candle: &Candle) -> bool[src]

Update the exchange status with a new candle. returns true if position has been liquidated

pub fn cancel_order(&mut self, order_id: u64) -> Option<Order>[src]

Cancel an active order returns true if successful with given order_id

pub fn query_active_orders(&self, order_id: u64) -> Option<&Order>[src]

Query an active order by order id Returns some order if found

pub fn submit_order(&mut self, order: Order) -> Result<Order, OrderError>[src]

Submit a new order to the exchange. Returns the order with timestamp and id filled in or OrderError

pub fn order_margin(&self) -> f64[src]

Return the order margin used

pub fn unrealized_pnl(&self) -> f64[src]

Return the unrealized profit and loss of the accounts position

pub fn num_active_orders(&self) -> usize[src]

Return the number of active order

pub fn executed_orders(&mut self) -> Vec<Order>[src]

Return the recently executed orders and clear afterwards

pub fn validate_market_order(&mut self, o: &Order) -> Option<OrderError>[src]

Check if market order is correct

pub fn validate_limit_order(&self, o: &Order) -> Option<OrderError>[src]

Check if a limit order is correct

pub fn validate_stop_market_order(&mut self, o: &Order) -> Option<OrderError>[src]

Check if a stop market order is correct

pub fn roe(&self) -> f64[src]

Return the return on equity of the accounts position

pub fn margin(&self) -> &Margin[src]

Return a reference to internal margin struct

pub fn position(&self) -> &Position[src]

Return a reference to internal position struct

pub fn acc_tracker(&self) -> &AccTracker[src]

Return a reference to internal acc_tracker struct

Trait Implementations

impl Clone for Exchange[src]

impl Debug for Exchange[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.