Skip to content

Commit

Permalink
feat(bybit): update to new bybit API
Browse files Browse the repository at this point in the history
  • Loading branch information
alextes committed Sep 19, 2024
1 parent d2b01c4 commit fcfbc96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/usd_price/bybit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ use tracing::{debug, info, warn};

use super::EthPrice;

/// Parses a fixed array of len 5 into a `BybitCandle`
#[derive(Debug, Deserialize)]
struct BybitCandle {
timestamp: String,
usd: String,
open: String,
#[allow(unused)]
high: String,
#[allow(unused)]
Expand Down Expand Up @@ -49,9 +50,8 @@ async fn get_eth_candles(
end: DateTime<Utc>,
) -> Result<Vec<EthPrice>> {
let url = FormatUrl::new(BYBIT_API)
.with_path_template("/derivatives/v3/public/index-price-kline")
.with_path_template("/v5/market/index-price-kline")
.with_query_params(vec![
("category", "inverse"),
("symbol", "ETHUSD"),
("interval", "1"),
("start", &start.timestamp_millis().to_string()),
Expand Down Expand Up @@ -98,7 +98,7 @@ pub async fn send_eth_price_request(client: &reqwest::Client, url: &str) -> Resu
.earliest()
.expect("expect bybit candles to contain millisecond timestamps");
let usd = c
.usd
.open
.parse::<f64>()
.expect("expect bybit candles to contain float usd prices");
EthPrice { timestamp, usd }
Expand Down

0 comments on commit fcfbc96

Please sign in to comment.