open source · rust · MIT
TraderSDK
One Rust trait. Twenty crypto exchanges. Spot and perpetuals. Write the strategy once, change one string to move it.
Every exchange speaks its own dialect: symbols, signatures, rate limits, order quirks. Your strategy should not have to learn twenty of them.
01 · swap one string
Same code.
Different exchange.
Pick an exchange. Only the highlighted string changes; the rest of your program stays the same.
use tradersdk::prelude::*; #[tokio::main] async fn main() -> anyhow::Result<()> { let credentials = ExchangeCredentials { api_key: "your_key".into(), api_secret: "your_secret".into(), passphrase: None, testnet: true, }; let trader = create_trader("bybit", credentials, MarketType::Swap)?; let price = trader.get_current_price("BTCUSDT").await?; println!("BTC: {price}"); Ok(()) }
02 · the contract
One trait
holds it together.
Every adapter implements ExchangeTrader. Call it and you are exchange-agnostic. Implement it and a new exchange works with everything else in the SDK.
Capabilities
Coverage is not uniform across exchanges, so every adapter says what it supports. Check before you call instead of finding out at runtime.
fn exchange_name(&self) -> &str; fn market_type(&self) -> MarketType; fn capabilities(&self) -> ExchangeCapabilities;
Market data
Prices, tickers, order books, funding rate and open interest history in one shape for every venue.
async fn get_current_price(&self, symbol: &str) -> Result<f64>; async fn get_ticker(&self, symbol: &str) -> Result<TickerInfo>; async fn get_orderbook(&self, symbol: &str, depth: u32) -> Result<Orderbook>; async fn get_funding_rate_history(..) -> Result<Vec<FundingRateEntry>>; async fn get_open_interest_history(..) -> Result<Vec<OpenInterestEntry>>;
Account
Balances and leverage, normalized.
async fn get_balance(&self) -> Result<AccountBalance>; async fn set_leverage(&self, symbol: Option<&str>, leverage: u32) -> Result<bool>;
Trading
Market and limit orders, cancel, status, close a position. Plus one call that sets leverage, sizes the position and enters at market.
async fn place_market_order(&self, symbol, side, quantity) -> Result<OrderResult>; async fn place_limit_order(&self, symbol, side, quantity, price, reduce_only) -> ..; async fn execute_fast_entry(&self, symbol, direction, usdt_amount, leverage, tp, sl, ..) -> ..; async fn cancel_order(&self, symbol: &str, order_id: &str) -> Result<bool>; async fn get_order_status(&self, symbol: &str, order_id: &str) -> Result<OrderStatus>; async fn close_position(&self, symbol: &str) -> Result<OrderResult>;
03 · execute_fast_entry
One call.
Sized, leveraged, sent.
execute_fast_entry sets leverage, sizes the position from a USDT amount and sends a market order in one SDK call. Take-profit and stop-loss are attached on Bybit and Phemex, as follow-up requests; the other adapters ignore them.
let order = trader.execute_fast_entry( "BTCUSDT", "long", /* usdt */ 100.0, /* leverage */ 10, Some(2.0), Some(1.0), None, // TP +2%, SL -1% (Bybit, Phemex) ).await?;
04 · coverage
20 exchanges.
Each behind a feature flag.
The default full feature pulls all twenty. Compile only the adapters you use and keep the build small.
05 · workspace
Small crates.
Take what you need.
Depend on the tradersdk facade for everything, or pick individual crates. One crate per exchange adapter, plus the tools a trading bot needs around them.
06 · python
Rust speed,
Python ergonomics.
PyO3 bindings expose the same trader as async Python classes. Python 3.9+.
- today Bybit and BingX traders
- build from source with maturin
- pypi not published yet
# build the extension into your venv
pip install maturin
cd crates/tradersdk-python
maturin develop --release
import asyncio from tradersdk import BybitTrader async def main(): trader = BybitTrader("key", "secret", testnet=True, market_type="swap") print(await trader.get_current_price("BTCUSDT")) asyncio.run(main())
07 · get started
Add one line
to Cargo.toml.
Not on crates.io yet. Depend on the repository directly:
[dependencies] tradersdk = { git = "https://github.com/suenot/tradersdk" }
Only the exchanges you trade on:
tradersdk = { git = "https://github.com/suenot/tradersdk",
default-features = false, features = ["bybit", "binance"] }
status
Pre-1.0. The trait is stable in shape but not frozen: minor releases may change it while adapter coverage fills in. Pin a commit if that matters to you.
license
MIT. Use it in closed bots, fork it, ship it.
contribute
Add an exchange by implementing one trait. Issues and pull requests are welcome on GitHub.