High performance cryptocurrency trading API with support for user defined networking.
Add dependencies in Cargo.toml
:
toml
[dependencies]
tokio = { version = "1", features = ["full"] }
ecbt = { git = "https://github.com/wmjtyd/ecbt", tag = "1.0.0" }
```rust
async fn main() -> Result<()> { let credentials = BinanceCredentials { apikey: "xxx".tostring(), apisecret: "xxx".tostring(), }; let param = BinanceParameters { environment: Sandbox, credentials: Some(credentials), }; let binance = Binance::new(param).await?; let request = GetPriceTickerRequest { marketpair: MarketPair(Currency::ETH, Currency::USDT), }; let s = binance.getprice_ticker(request.borrow()).await?; println!("{:?}", s); Ok(()) } ```
```rust
async fn main() -> Result<()> { let credentials = BinanceCredentials { apikey: "xxx".tostring(), apisecret: "xxx".tostring(), }; let param = BinanceParameters { environment: Sandbox, credentials: Some(credentials), }; let binancews = BinanceWebsocket::new(param).await?; let symbol = MarketPair(Currency::ETH, Currency::USDT).tostring(); binancews .subscribe(BinanceSubscription::Ticker(symbol), callback) .await?;
std::thread::sleep(Duration::from_secs(10));
Ok(())
}
fn call_back(res: &Result
Because there are many exchanges, if ecbt has not been implemented, you may need to implement it yourself.
Contact or join us @oss-jtyd.