Installation#
TraderSDK is not published to crates.io yet. Depend on the repository directly.
Rust#
Add the crate to Cargo.toml:
[dependencies]
tradersdk = { git = "https://github.com/suenot/tradersdk" }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
anyhow = "1"
The default feature full pulls in all 20 exchanges. To compile only what you use, turn defaults off and list the exchanges:
tradersdk = { git = "https://github.com/suenot/tradersdk", default-features = false, features = ["bybit", "binance"] }
If you ask create_trader for an exchange whose feature is off, it returns Unsupported exchange: <name>. supported_exchanges() lists the names compiled in. See Feature flags for the full list, including the optional utility features.
Pin a commit#
Because there are no releases yet, pin a revision to keep builds reproducible:
tradersdk = { git = "https://github.com/suenot/tradersdk", rev = "<commit sha>" }
Requirements#
- A recent stable Rust toolchain.
- An async runtime. The examples use
tokio. - API keys from the exchange. Use testnet keys while you experiment. See Exchanges for which venues have a testnet and which need a passphrase.
Python#
The Python module is built from the Rust workspace with maturin. It is not on PyPI yet. Python 3.9 or newer.
git clone https://github.com/suenot/tradersdk
cd tradersdk/crates/tradersdk-python
pip install maturin
maturin develop --release
Then import tradersdk. See Python.
Verify the install#
use tradersdk::prelude::*;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let trader = create_trader("bybit", ExchangeCredentials::new("", ""), MarketType::Swap)?;
println!("server time: {}", trader.get_server_time().await?);
Ok(())
}
On Bybit get_server_time is a public endpoint, so empty credentials are enough. Other exchanges may differ. If the call fails, check your network and the exchange name.