pub trait Exchange:
Send
+ Sync
+ 'static {
// Required methods
fn exchange_id(&self) -> &ExchangeId;
fn environment(&self) -> Environment;
fn place_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
orders: &'life1 [OrderInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<PlaceOrderResult>, ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn cancel_order<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
instrument: &'life1 InstrumentId,
market_index: &'life2 MarketIndex,
client_id: &'life3 ClientOrderId,
exchange_order_id: Option<&'life4 ExchangeOrderId>,
) -> Pin<Box<dyn Future<Output = Result<(), ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn cancel_all_orders<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
instrument: &'life1 InstrumentId,
market_index: &'life2 MarketIndex,
) -> Pin<Box<dyn Future<Output = Result<u32, ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn poll_user_fills<'life0, 'life1, 'async_trait>(
&'life0 self,
cursor: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Fill>, ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn poll_quotes<'life0, 'life1, 'async_trait>(
&'life0 self,
instruments: &'life1 [InstrumentId],
) -> Pin<Box<dyn Future<Output = Result<Vec<Quote>, ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn poll_account_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AccountState, ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn instance(&self) -> ExchangeInstance { ... }
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ExchangeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Exchange adapter trait - what each exchange must implement.
All methods are async and return Results to handle network errors. The engine calls these methods and translates results into canonical events.
Required Methods§
Sourcefn exchange_id(&self) -> &ExchangeId
fn exchange_id(&self) -> &ExchangeId
Get the exchange ID
Sourcefn environment(&self) -> Environment
fn environment(&self) -> Environment
Get the environment (mainnet/testnet)
Sourcefn place_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
orders: &'life1 [OrderInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<PlaceOrderResult>, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn place_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
orders: &'life1 [OrderInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<PlaceOrderResult>, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Place multiple limit orders in a single batch API call. Returns a Vec of results, one for each order in the same order as the input.
Sourcefn cancel_order<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
instrument: &'life1 InstrumentId,
market_index: &'life2 MarketIndex,
client_id: &'life3 ClientOrderId,
exchange_order_id: Option<&'life4 ExchangeOrderId>,
) -> Pin<Box<dyn Future<Output = Result<(), ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn cancel_order<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
instrument: &'life1 InstrumentId,
market_index: &'life2 MarketIndex,
client_id: &'life3 ClientOrderId,
exchange_order_id: Option<&'life4 ExchangeOrderId>,
) -> Pin<Box<dyn Future<Output = Result<(), ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Cancel an order by client_id or exchange_order_id.
Sourcefn cancel_all_orders<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
instrument: &'life1 InstrumentId,
market_index: &'life2 MarketIndex,
) -> Pin<Box<dyn Future<Output = Result<u32, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cancel_all_orders<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
instrument: &'life1 InstrumentId,
market_index: &'life2 MarketIndex,
) -> Pin<Box<dyn Future<Output = Result<u32, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Cancel all orders for an instrument. Returns number of orders canceled.
Sourcefn poll_user_fills<'life0, 'life1, 'async_trait>(
&'life0 self,
cursor: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Fill>, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn poll_user_fills<'life0, 'life1, 'async_trait>(
&'life0 self,
cursor: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Fill>, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Poll user fills since cursor. This is the primary execution event source. cursor is opaque string (implementation-specific).
Sourcefn poll_quotes<'life0, 'life1, 'async_trait>(
&'life0 self,
instruments: &'life1 [InstrumentId],
) -> Pin<Box<dyn Future<Output = Result<Vec<Quote>, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn poll_quotes<'life0, 'life1, 'async_trait>(
&'life0 self,
instruments: &'life1 [InstrumentId],
) -> Pin<Box<dyn Future<Output = Result<Vec<Quote>, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Poll current quotes/prices.
Sourcefn poll_account_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AccountState, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn poll_account_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AccountState, ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Poll account state (absolute). Used for snapshot-based synchronization.
Provided Methods§
Sourcefn instance(&self) -> ExchangeInstance
fn instance(&self) -> ExchangeInstance
Get the exchange instance key
Sourcefn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize the exchange connection and perform startup validations. Called by the runner before entering the main loop. Implementations can validate: connectivity, vault ownership, account balance, etc.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".