Struct lfest::Exchange [−][src]
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 unrealized_pnl(&self) -> f64
[src]
Return the unrealized profit and loss of the accounts position
pub fn executed_orders(&mut self) -> Vec<Order>
[src]
Return the recently executed orders and clear afterwards
pub fn active_limit_orders(&self) -> &Vec<Order>
[src]
Return the currently active limit orders
pub fn active_stop_orders(&self) -> &Vec<Order>
[src]
Return the currently active stop orders
pub fn validate_market_order(&mut self, o: &Order) -> Result<(), OrderError>
[src]
Check if market order is correct
pub fn validate_limit_order(&self, o: &Order) -> Result<(), OrderError>
[src]
Check if a limit order is correct
pub fn validate_stop_market_order(
&mut self,
o: &Order
) -> Result<(), OrderError>
[src]
&mut self,
o: &Order
) -> Result<(), OrderError>
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
Auto Trait Implementations
impl RefUnwindSafe for Exchange
impl Send for Exchange
impl Sync for Exchange
impl Unpin for Exchange
impl UnwindSafe for Exchange
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,