barter_execution

Trait ExecutionClient

source
pub trait ExecutionClient {
    type Config;

    const CLIENT: ExecutionId;

    // Required methods
    fn init<'async_trait>(
        config: Self::Config,
        event_tx: UnboundedSender<AccountEvent>,
    ) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn fetch_orders_open<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Order<Open>>, ExecutionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_balances<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SymbolBalance>, ExecutionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn open_orders<'life0, 'async_trait>(
        &'life0 self,
        open_requests: Vec<Order<RequestOpen>>,
    ) -> Pin<Box<dyn Future<Output = Vec<Result<Order<Open>, ExecutionError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel_orders<'life0, 'async_trait>(
        &'life0 self,
        cancel_requests: Vec<Order<RequestCancel>>,
    ) -> Pin<Box<dyn Future<Output = Vec<Result<Order<Cancelled>, ExecutionError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel_orders_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Order<Cancelled>>, ExecutionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Defines the communication with the exchange. Each exchange integration requires it’s own implementation.

Required Associated Constants§

Required Associated Types§

Required Methods§

source

fn init<'async_trait>( config: Self::Config, event_tx: UnboundedSender<AccountEvent>, ) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>
where Self: 'async_trait,

Initialise a new ExecutionClient with the provided Self::Config and AccountEvent transmitter.

Note: Usually entails spawning an asynchronous WebSocket event loop to consume AccountEvents from the exchange, as well as returning the HTTP client Self.

source

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

Fetch account Order<Open>s.

source

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

Fetch account SymbolBalances.

source

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

Open orders.

source

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

Cancel Order<Open>s.

source

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

Cancel all account Order<Open>s.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§