Dry-run checks#
Order sizing#
test_market_order and test_limit_order compute what an order would be, without sending it.
let t = trader.test_market_order("BTCUSDT", OrderSide::Buy, 100.0).await?;
println!("{} {} @ {:?} ~ {} USDT", t.side, t.quantity, t.price, t.estimated_cost);
let l = trader.test_limit_order("BTCUSDT", OrderSide::Buy, 100.0, 60_000.0).await?;
Both return OrderTestResult:
| Field | Type | Meaning |
|---|---|---|
valid |
bool |
Whether the check passed. |
order_type |
String |
"MARKET" or "LIMIT". |
side, symbol |
String |
|
quantity |
f64 |
usdt_amount / price. |
price |
Option<f64> |
Price used. |
estimated_cost |
f64 |
The usdt_amount you passed. |
error |
Option<String> |
Reason, when not valid. |
The default implementation fetches the current price (market) or uses your price (limit) and divides. It does not ask the exchange to validate the order, so it will not catch minimum-size or precision rejections. The bundled adapters use these defaults; none overrides them today.
Quantity here ignores leverage. It is the unleveraged usdt_amount / price.
WebSocket tests#
Confirm that a subscription connects and delivers data before you depend on it:
let r = trader.test_ws_orderbook("BTCUSDT", 20, 5_000).await?;
println!("connected={} latency={}ms messages={}", r.connected, r.latency_ms, r.messages_received);
let t = trader.test_ws_trades("BTCUSDT", 5_000).await?;
let k = trader.test_ws_ticker("BTCUSDT", 5_000).await?;
The last argument is the timeout in milliseconds. WsTestResult has connected, latency_ms, messages_received, subscription_type and an optional data_sample. Adapters without WebSocket support return a "not implemented" error. See ws_orderbook, ws_trades and ws_ticker in the exchange matrix.