Skip to content

Commit 001196a

Browse files
committed
wip
1 parent 0428875 commit 001196a

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

examples/bybit/market.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::env;
22

33
use v_exchanges::{bybit::Client, core::Exchange};
4-
use v_exchanges_adapters::binance::{BinanceHttpUrl, BinanceOption};
4+
use v_exchanges_adapters::bybit::{BybitHttpAuth, BybitHttpUrl, BybitOption};
55

66
#[tokio::main]
77
async fn main() {
@@ -10,6 +10,20 @@ async fn main() {
1010

1111
let mut client = Client::new();
1212

13+
let ticker: serde_json::Value = client
14+
.get("/v5/market/tickers", &[("category", "spot"), ("symbol", "BTCUSDT")], [BybitOption::Default])
15+
.await
16+
.expect("failed to get ticker");
17+
println!("Ticker:\n{ticker}");
18+
19+
if let (Ok(key), Ok(secret)) = (env::var("BYBIT_TIGER_READ_KEY"), env::var("BYBIT_TIGER_READ_SECRET")) {
20+
client.update_default_option(BybitOption::Key(key));
21+
client.update_default_option(BybitOption::Secret(secret));
22+
private(&client).await;
23+
} else {
24+
eprintln!("BYBIT_TIGER_READ_KEY or BYBIT_TIGER_READ_SECRET is missing, skipping private API methods.");
25+
}
26+
1327
//client.update_default_option(BinanceOption::HttpUrl(BinanceHttpUrl::FuturesUsdM));
1428
//let klines = client.futures_klines(("BTC", "USDT").into(), "1m".into(), 2, None, None).await.unwrap();
1529
//let price = client.futures_price(("BTC", "USDT").into()).await.unwrap();
@@ -23,5 +37,12 @@ async fn main() {
2337
//} else {
2438
// eprintln!("BINANCE_TIGER_READ_KEY or BINANCE_TIGER_READ_SECRET is missing, skipping private API methods.");
2539
//}
26-
todo!();
40+
}
41+
42+
async fn private(client: &Client) {
43+
let balance: serde_json::Value = client
44+
.get("/v5/account/wallet-balance", &[("accountType", "UNIFIED")], [BybitOption::HttpAuth(BybitHttpAuth::V3AndAbove)])
45+
.await
46+
.expect("failed to get balance");
47+
println!("Balance:\n{balance}");
2748
}

v_exchanges/src/bybit/account.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ use color_eyre::eyre::Result;
33
use crate::core::AssetBalance;
44

55
pub async fn balances(client: &v_exchanges_adapters::Client) -> Result<Vec<AssetBalance>> {
6+
println!("bybit::account::balances");
67
todo!();
78
}

0 commit comments

Comments
 (0)