ExecutionEngine

Trait ExecutionEngine 

Source
pub trait ExecutionEngine: Send + Sync {
    // Required methods
    fn place_order<'life0, 'async_trait>(
        &'life0 self,
        order: Order,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel_order<'life0, 'life1, 'async_trait>(
        &'life0 self,
        order_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_order_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        order_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<OrderStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_open_orders<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_positions<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Position>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_position<'life0, 'life1, 'async_trait>(
        &'life0 self,
        symbol: &'life1 Symbol,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Position>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn close_position<'life0, 'life1, 'async_trait>(
        &'life0 self,
        symbol: &'life1 Symbol,
        percentage: f64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn close_all_positions<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_cash_balance<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Decimal>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_equity<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Decimal>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for order execution engines

Handles order routing, execution, and tracking.

Required Methods§

Source

fn place_order<'life0, 'async_trait>( &'life0 self, order: Order, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Place a new order

§Arguments
  • order - Order to place
§Returns

Broker’s order ID

Source

fn cancel_order<'life0, 'life1, 'async_trait>( &'life0 self, order_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Cancel an existing order

§Arguments
  • order_id - Broker’s order ID
Source

fn get_order_status<'life0, 'life1, 'async_trait>( &'life0 self, order_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<OrderStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get order status

§Arguments
  • order_id - Broker’s order ID
Source

fn get_open_orders<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all open orders

Source

fn get_positions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Position>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current positions

Source

fn get_position<'life0, 'life1, 'async_trait>( &'life0 self, symbol: &'life1 Symbol, ) -> Pin<Box<dyn Future<Output = Result<Option<Position>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get position for a specific symbol

Source

fn close_position<'life0, 'life1, 'async_trait>( &'life0 self, symbol: &'life1 Symbol, percentage: f64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Close position for a symbol

§Arguments
  • symbol - Symbol to close
  • percentage - Percentage of position to close (0.0-1.0)
Source

fn close_all_positions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close all positions

Source

fn get_cash_balance<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Decimal>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get account cash balance

Source

fn get_equity<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Decimal>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get account equity (cash + positions)

Implementors§