Skip to content

Commit a575fed

Browse files
committed
fix: some tickers on Bybit were failing to init charts
-- was caused by tickers that dont have a "tickSize" info needed for the action: Bybit api have a limited response on the related end by default. Increased the limit by a provided param to get more tickers from this end -- && introduced volume thresholds to get approx. the same amt. of tickers from each exchange
1 parent e09d7fa commit a575fed

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/data_providers/binance.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,9 @@ pub async fn fetch_ticksize(market_type: MarketType) -> Result<HashMap<Ticker, O
844844
Ok(ticker_info_map)
845845
}
846846

847+
const PERP_FILTER_VOLUME: f32 = 32_000_000.0;
848+
const SPOT_FILTER_VOLUME: f32 = 9_000_000.0;
849+
847850
pub async fn fetch_ticker_prices(market: MarketType) -> Result<HashMap<Ticker, TickerStats>, StreamError> {
848851
let url = match market {
849852
MarketType::Spot => "https://api.binance.com/api/v3/ticker/24hr".to_string(),
@@ -860,8 +863,8 @@ pub async fn fetch_ticker_prices(market: MarketType) -> Result<HashMap<Ticker, T
860863
let re = Regex::new(r"^[a-zA-Z0-9]+$").unwrap();
861864

862865
let volume_threshold = match market {
863-
MarketType::Spot => 9_000_000.0,
864-
MarketType::LinearPerps => 29_000_000.0,
866+
MarketType::Spot => SPOT_FILTER_VOLUME,
867+
MarketType::LinearPerps => PERP_FILTER_VOLUME,
865868
};
866869

867870
for item in value {

src/data_providers/bybit.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,11 @@ pub async fn fetch_ticksize(market_type: MarketType) -> Result<HashMap<Ticker, O
676676
MarketType::LinearPerps => "linear",
677677
};
678678

679-
let url = format!("https://api.bybit.com/v5/market/instruments-info?category={market}");
679+
let url = format!(
680+
"https://api.bybit.com/v5/market/instruments-info?category={}&limit=1000",
681+
market,
682+
);
683+
680684
let response = reqwest::get(&url).await.map_err(StreamError::FetchError)?;
681685
let text = response.text().await.map_err(StreamError::FetchError)?;
682686

@@ -718,10 +722,13 @@ pub async fn fetch_ticksize(market_type: MarketType) -> Result<HashMap<Ticker, O
718722
Ok(ticker_info_map)
719723
}
720724

725+
const PERP_FILTER_VOLUME: f32 = 12_000_000.0;
726+
const SPOT_FILTER_VOLUME: f32 = 4_000_000.0;
727+
721728
pub async fn fetch_ticker_prices(market_type: MarketType) -> Result<HashMap<Ticker, TickerStats>, StreamError> {
722-
let market = match market_type {
723-
MarketType::Spot => "spot",
724-
MarketType::LinearPerps => "linear",
729+
let (market, volume_threshold) = match market_type {
730+
MarketType::Spot => ("spot", SPOT_FILTER_VOLUME),
731+
MarketType::LinearPerps => ("linear", PERP_FILTER_VOLUME),
725732
};
726733

727734
let url = format!("https://api.bybit.com/v5/market/tickers?category={market}");
@@ -770,7 +777,7 @@ pub async fn fetch_ticker_prices(market_type: MarketType) -> Result<HashMap<Tick
770777

771778
let quote_volume = daily_volume * mark_price;
772779

773-
if quote_volume < 4_000_000.0 {
780+
if quote_volume < volume_threshold {
774781
continue;
775782
}
776783

0 commit comments

Comments
 (0)