pub trait Trading: PublicExchange {
// Required methods
fn create_order<'life0, 'async_trait>(
&'life0 self,
params: OrderParams,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cancel_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn cancel_all_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn fetch_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn fetch_open_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: '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>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn market_buy<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn market_sell<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn limit_buy<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
price: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn limit_sell<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
price: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn fetch_closed_orders_u64<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<u64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Trait for order management operations.
This trait provides methods for creating, canceling, and fetching orders. All methods require authentication and are async.
§Supertrait
Requires PublicExchange as a supertrait to access exchange metadata
and capabilities.
§Thread Safety
This trait requires Send + Sync bounds (inherited from PublicExchange)
to ensure safe usage across thread boundaries in async contexts.
Required Methods§
Sourcefn create_order<'life0, 'async_trait>(
&'life0 self,
params: OrderParams,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_order<'life0, 'async_trait>(
&'life0 self,
params: OrderParams,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new order using OrderParams builder.
This is the primary method for creating orders. Use the OrderParams
builder for ergonomic order construction.
§Arguments
params- Order parameters including symbol, side, type, amount, price
§Example
use ccxt_core::types::params::OrderParams;
use rust_decimal_macros::dec;
// Market buy
let order = exchange.create_order(
OrderParams::market_buy("BTC/USDT", dec!(0.01))
).await?;
// Limit sell with custom options
let order = exchange.create_order(
OrderParams::limit_sell("BTC/USDT", dec!(0.01), dec!(50000))
.time_in_force(TimeInForce::IOC)
.client_id("my-order-123")
).await?;Sourcefn cancel_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cancel_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn cancel_all_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_all_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn fetch_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch_order<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
symbol: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn fetch_open_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_open_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch closed orders with pagination.
§Arguments
symbol- Optional trading pair symbolsince- Optional start timestamp in milliseconds (i64) since Unix epochlimit- Optional maximum number of orders to return
§Timestamp Format
The since parameter uses i64 milliseconds since Unix epoch:
1609459200000= January 1, 2021, 00:00:00 UTCchrono::Utc::now().timestamp_millis()= Current timechrono::Utc::now().timestamp_millis() - 86400000= 24 hours ago
§Example
// Recent closed orders
let orders = exchange.fetch_closed_orders(Some("BTC/USDT"), None, Some(100)).await?;
// Closed orders since timestamp
let orders = exchange.fetch_closed_orders(
Some("BTC/USDT"),
Some(1609459200000i64),
Some(50)
).await?;Provided Methods§
Sourcefn market_buy<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn market_buy<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Convenience method for market buy order.
§Arguments
symbol- Trading pair symbol (e.g., “BTC/USDT”)amount- Order amount
Sourcefn market_sell<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn market_sell<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Convenience method for market sell order.
§Arguments
symbol- Trading pair symbolamount- Order amount
Sourcefn limit_buy<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
price: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn limit_buy<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
price: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Convenience method for limit buy order.
§Arguments
symbol- Trading pair symbolamount- Order amountprice- Limit price
Sourcefn limit_sell<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
price: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn limit_sell<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
amount: Decimal,
price: Decimal,
) -> Pin<Box<dyn Future<Output = Result<Order>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Convenience method for limit sell order.
§Arguments
symbol- Trading pair symbolamount- Order amountprice- Limit price
Sourcefn fetch_closed_orders_u64<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<u64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
👎Deprecated since 0.1.0: Use fetch_closed_orders with i64 timestamps. Convert using TimestampUtils::u64_to_i64()
fn fetch_closed_orders_u64<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
since: Option<u64>,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Order>>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch closed orders with u64 timestamp filtering (deprecated).
DEPRECATED: Use fetch_closed_orders with i64 timestamps instead.
This method is provided for backward compatibility during migration.
§Migration
// Old code (deprecated)
let orders = exchange.fetch_closed_orders_u64(Some("BTC/USDT"), Some(1609459200000u64), Some(100)).await?;
// New code (recommended)
let orders = exchange.fetch_closed_orders(Some("BTC/USDT"), Some(1609459200000i64), Some(100)).await?;