@@ -4,10 +4,7 @@ use jiff::Timestamp;
44use serde:: { Deserialize , Serialize } ;
55use serde_json:: { Value , json} ;
66use serde_with:: { DisplayFromStr , serde_as} ;
7- use v_exchanges_adapters:: {
8- GetOptions ,
9- bybit:: { BybitOption , BybitOptions } ,
10- } ;
7+ use v_exchanges_adapters:: bybit:: BybitOption ;
118use v_utils:: {
129 trades:: { Kline , Ohlc , Pair } ,
1310 utils:: filter_nulls,
@@ -17,12 +14,10 @@ use super::{BybitInterval, BybitIntervalTime};
1714use crate :: {
1815 ExchangeName , ExchangeResult , Instrument , Symbol ,
1916 core:: { Klines , OpenInterest , RequestRange } ,
20- recv_window_check,
2117} ;
2218
2319// klines {{{
24- pub async fn klines ( client : & v_exchanges_adapters:: Client , symbol : Symbol , tf : BybitInterval , range : RequestRange , recv_window : Option < std:: time:: Duration > ) -> ExchangeResult < Klines > {
25- recv_window_check ! ( recv_window, GetOptions :: <BybitOptions >:: default_options( client) ) ;
20+ pub async fn klines ( client : & v_exchanges_adapters:: Client , symbol : Symbol , tf : BybitInterval , range : RequestRange ) -> ExchangeResult < Klines > {
2621 range. ensure_allowed ( 1 ..=1000 , & tf) ?;
2722 let range_json = range. serialize ( ExchangeName :: Bybit ) ;
2823 let base_params = filter_nulls ( json ! ( {
@@ -36,10 +31,7 @@ pub async fn klines(client: &v_exchanges_adapters::Client, symbol: Symbol, tf: B
3631 base_map. extend ( range_map. clone ( ) ) ;
3732 let params = filter_nulls ( serde_json:: Value :: Object ( base_map) ) ;
3833
39- let mut options = vec ! [ BybitOption :: None ] ;
40- if let Some ( rw) = recv_window {
41- options. push ( BybitOption :: RecvWindow ( rw) ) ;
42- }
34+ let options = vec ! [ BybitOption :: None ] ;
4335 let kline_response: KlineResponse = client. get ( "/v5/market/kline" , & params, options) . await . unwrap ( ) ;
4436
4537 let mut klines = VecDeque :: with_capacity ( kline_response. result . list . len ( ) ) ;
@@ -96,16 +88,12 @@ pub struct KlineData(
9688//,}}}
9789
9890// price {{{
99- pub async fn price ( client : & v_exchanges_adapters:: Client , pair : Pair , recv_window : Option < std:: time:: Duration > ) -> ExchangeResult < f64 > {
100- recv_window_check ! ( recv_window, GetOptions :: <BybitOptions >:: default_options( client) ) ;
91+ pub async fn price ( client : & v_exchanges_adapters:: Client , pair : Pair ) -> ExchangeResult < f64 > {
10192 let params = filter_nulls ( json ! ( {
10293 "category" : "linear" ,
10394 "symbol" : pair. fmt_bybit( ) ,
10495 } ) ) ;
105- let mut options = vec ! [ BybitOption :: None ] ;
106- if let Some ( rw) = recv_window {
107- options. push ( BybitOption :: RecvWindow ( rw) ) ;
108- }
96+ let options = vec ! [ BybitOption :: None ] ;
10997 let response: MarketTickerResponse = client. get ( "/v5/market/tickers" , & params, options) . await ?;
11098 Ok ( response. result . list [ 0 ] . last_price )
11199}
@@ -171,14 +159,7 @@ pub struct MarketTickerData {
171159//,}}}
172160
173161// open_interest {{{
174- pub async fn open_interest (
175- client : & v_exchanges_adapters:: Client ,
176- symbol : Symbol ,
177- tf : BybitIntervalTime ,
178- range : RequestRange ,
179- recv_window : Option < std:: time:: Duration > ,
180- ) -> ExchangeResult < Vec < OpenInterest > > {
181- recv_window_check ! ( recv_window, GetOptions :: <BybitOptions >:: default_options( client) ) ;
162+ pub async fn open_interest ( client : & v_exchanges_adapters:: Client , symbol : Symbol , tf : BybitIntervalTime , range : RequestRange ) -> ExchangeResult < Vec < OpenInterest > > {
182163 range. ensure_allowed ( 1 ..=200 , & tf) ?;
183164 let range_json = range. serialize ( ExchangeName :: Bybit ) ;
184165
@@ -193,10 +174,7 @@ pub async fn open_interest(
193174 base_map. extend ( range_map. clone ( ) ) ;
194175 let params = filter_nulls ( serde_json:: Value :: Object ( base_map) ) ;
195176
196- let mut options = vec ! [ BybitOption :: None ] ;
197- if let Some ( rw) = recv_window {
198- options. push ( BybitOption :: RecvWindow ( rw) ) ;
199- }
177+ let options = vec ! [ BybitOption :: None ] ;
200178 let response: OpenInterestResponse = client. get ( "/v5/market/open-interest" , & params, options) . await ?;
201179
202180 if response. result . list . is_empty ( ) {
@@ -209,10 +187,7 @@ pub async fn open_interest(
209187 "category" : "linear" ,
210188 "symbol" : symbol. pair. fmt_bybit( ) ,
211189 } ) ) ;
212- let mut options = vec ! [ BybitOption :: None ] ;
213- if let Some ( rw) = recv_window {
214- options. push ( BybitOption :: RecvWindow ( rw) ) ;
215- }
190+ let options = vec ! [ BybitOption :: None ] ;
216191 let ticker_response: MarketTickerResponse = client. get ( "/v5/market/tickers" , & params, options) . await ?;
217192 Some ( ticker_response. result . list [ 0 ] . last_price )
218193 } else {
0 commit comments