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 bid(&self) -> f64[src]

Return the bid price

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

Return the ask price

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

Return the high price of the last candle

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

Return the low price of the last candle

pub fn set_position(&mut self, position: Position) -> bool[src]

Set a new position manually, be sure that you know what you are doing Returns true if successful

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

Return a reference to internal position

pub fn set_margin(&mut self, margin: Margin) -> bool[src]

Set a new margin manually, be sure that you know what you are doing when using this method Returns true if successful

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

Return a reference to internal margin

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 Some order if successful with given order_id

pub fn cancel_all_orders(&mut self)[src]

Cancel all active orders

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]

👎 Deprecated

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 active_orders(&self) -> &Vec<Order>[src]

Return the currently active orders

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 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.