Account and leverage#
Balance#
let b = trader.get_balance().await?;
println!("{} total, {} available ({})", b.total_balance, b.available_balance, b.currency);
for asset in &b.balances {
println!("{}: free {} locked {}", asset.asset, asset.free, asset.locked);
}
AccountBalance fields:
| Field | Type | Notes |
|---|---|---|
total_balance |
f64 |
|
available_balance |
f64 |
Free to use. |
currency |
String |
Usually USDT. |
margin_balance, used_margin |
Option<f64> |
Perpetuals. |
unrealized_pnl, realized_pnl |
Option<f64> |
|
balances |
Vec<Balance> |
Per asset: asset, free, locked. |
Optional fields are None when the exchange does not report them.
Leverage#
trader.set_leverage(Some("BTCUSDT"), 10).await?;
- Spot traders generally treat this as a no-op that returns
Ok(true). - Some exchanges return an error when the leverage is already at the requested value. Bybit treats "leverage not changed" as success.
- The maximum leverage depends on the symbol and on your account tier.
SymbolInfo.max_leverageand thetradersdk-leverage-cachecrate (cached per-symbol limits) help you stay within it. - Passing
Nonefor the symbol is adapter-specific. On Bybit it returnsOk(true)without changing anything. Pass the symbol explicitly.
Fast entry sets leverage for you before it places the order.
Margin and position mode#
set_margin_mode and set_position_mode exist as capability names and in the models (MarginMode, PositionSide), but they are not methods on the trait today. Configure margin mode and hedge/one-way mode on the exchange side.