pub trait Exchange: Send + Sync {
Show 26 methods
// Required methods
fn id(&self) -> &str;
fn name(&self) -> &str;
fn capabilities(&self) -> ExchangeCapabilities;
fn fetch_markets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Market>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn load_markets<'life0, 'async_trait>(
&'life0 self,
reload: bool,
) -> Pin<Box<dyn Future<Output = Result<Arc<HashMap<String, Arc<Market>>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn fetch_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Ticker, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_tickers<'life0, 'life1, 'async_trait>(
&'life0 self,
symbols: Option<&'life1 [String]>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_order_book<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<OrderBook, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Trade>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_ohlcv<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
timeframe: Timeframe,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ohlcv>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn create_order<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
order_type: OrderType,
side: OrderSide,
amount: Amount,
price: Option<Price>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn cancel_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn cancel_all_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn fetch_open_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_closed_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn fetch_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn fetch_my_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Trade>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn market<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<Market>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn markets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<HashMap<String, Arc<Market>>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn version(&self) -> &'static str { ... }
fn certified(&self) -> bool { ... }
fn has_websocket(&self) -> bool { ... }
fn timeframes(&self) -> Vec<Timeframe> { ... }
fn rate_limit(&self) -> u32 { ... }
fn is_symbol_active<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Core Exchange trait - the unified interface for all exchanges
This trait defines the standard API that all exchange implementations
must provide. It is designed to be object-safe for dynamic dispatch,
allowing exchanges to be used polymorphically via dyn Exchange.
§Relationship to Modular Traits
The Exchange trait provides a unified interface that combines functionality
from the modular trait hierarchy:
PublicExchange: Metadata and capabilities (id, name, capabilities, etc.)MarketData: Public market data (fetch_markets, fetch_ticker, etc.)Trading: Order management (create_order, cancel_order, etc.)Account: Account operations (fetch_balance, fetch_my_trades)Margin: Margin/futures operations (available via separate trait)Funding: Deposit/withdrawal operations (available via separate trait)
For new implementations, consider implementing the modular traits instead,
which allows for more granular capability composition. Types implementing
all modular traits automatically satisfy the requirements for Exchange.
§Thread Safety
All implementations must be Send + Sync to allow safe usage across
thread boundaries.
§Backward Compatibility
This trait maintains full backward compatibility with existing code. All methods from the original monolithic trait are still available. Existing implementations continue to work without modification.
§Example
use ccxt_core::exchange::Exchange;
async fn print_exchange_info(exchange: &dyn Exchange) {
println!("Exchange: {} ({})", exchange.name(), exchange.id());
println!("Version: {}", exchange.version());
println!("Certified: {}", exchange.certified());
}Required Methods§
Sourcefn id(&self) -> &str
fn id(&self) -> &str
Returns the exchange identifier (e.g., “binance”, “coinbase”)
This is a lowercase, URL-safe identifier used internally.
Sourcefn capabilities(&self) -> ExchangeCapabilities
fn capabilities(&self) -> ExchangeCapabilities
Returns the exchange capabilities
Use this to check which features are supported before calling methods.
Sourcefn fetch_markets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Market>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn fetch_markets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Market>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Sourcefn load_markets<'life0, 'async_trait>(
&'life0 self,
reload: bool,
) -> Pin<Box<dyn Future<Output = Result<Arc<HashMap<String, Arc<Market>>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn load_markets<'life0, 'async_trait>(
&'life0 self,
reload: bool,
) -> Pin<Box<dyn Future<Output = Result<Arc<HashMap<String, Arc<Market>>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Ticker, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Ticker, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_tickers<'life0, 'life1, 'async_trait>(
&'life0 self,
symbols: Option<&'life1 [String]>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_tickers<'life0, 'life1, 'async_trait>(
&'life0 self,
symbols: Option<&'life1 [String]>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ticker>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_order_book<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<OrderBook, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_order_book<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<OrderBook, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Trade>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Trade>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_ohlcv<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
timeframe: Timeframe,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ohlcv>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_ohlcv<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
timeframe: Timeframe,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Ohlcv>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn create_order<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
order_type: OrderType,
side: OrderSide,
amount: Amount,
price: Option<Price>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create_order<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
order_type: OrderType,
side: OrderSide,
amount: Amount,
price: Option<Price>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Create a new order
§Arguments
symbol- Trading pair symbolorder_type- Order type (limit, market, etc.)side- Order side (buy or sell)amount- Order amount (type-safe Amount wrapper)price- Optional price (required for limit orders, type-safe Price wrapper)
§Returns
The created order.
§Errors
Returns an error if authentication fails or the order is invalid.
Sourcefn cancel_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn cancel_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Sourcefn cancel_all_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn cancel_all_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn fetch_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Order, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_open_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_open_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_closed_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_closed_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn fetch_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Sourcefn fetch_my_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Trade>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn fetch_my_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<i64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Trade>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Provided Methods§
Sourcefn certified(&self) -> bool
fn certified(&self) -> bool
Returns whether this exchange is CCXT certified
Certified exchanges have been thoroughly tested and verified.
Sourcefn has_websocket(&self) -> bool
fn has_websocket(&self) -> bool
Returns whether this exchange supports WebSocket (pro features)
Sourcefn timeframes(&self) -> Vec<Timeframe>
fn timeframes(&self) -> Vec<Timeframe>
Returns supported timeframes for OHLCV data
Sourcefn rate_limit(&self) -> u32
fn rate_limit(&self) -> u32
Returns the rate limit (requests per second)