Skip to content

Commit a08f4d3

Browse files
committed
nuke: forgot to remove recv_window for non-sign in definitions themselves
1 parent 424ffa5 commit a08f4d3

File tree

8 files changed

+51
-74
lines changed

8 files changed

+51
-74
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ eyre = "^0.6.12"
2424
futures-util = "^0.3.31"
2525
hex = "^0.4.3"
2626
hmac = "^0.12.1"
27-
jiff = "^0.2.15"
27+
jiff = "^0.2.16"
2828
reqwest = { version = "^0.12.24", features = ["blocking", "json"] }
2929
secrecy = "^0.10.3"
3030
serde = { version = "^1.0.228", features = ["derive"] }
3131
serde_json = "^1.0.145"
3232
serde_plain = "^1.0.2" #TEST
3333
serde_urlencoded = "^0.7.1"
34-
serde_with = "^3.15.1"
34+
serde_with = "^3.16.0"
3535
sha2 = "^0.10.9"
3636
thiserror = "^2.0.17"
3737
tokio = { version = "^1.48.0", features = ["sync", "macros", "io-util", "rt", "rt-multi-thread", "time"] } # enable only features that play with wasm.
3838
tracing = "^0.1.41"
3939
url = "^2.5.7"
40-
v_utils = { version = "^2.9.8", path = "../v_utils/v_utils" } #ga: rm path
40+
v_utils = { version = "^2.9.9", path = "../v_utils/v_utils" } #ga: rm path
4141
#dynosaur = "^0.2.0"
4242

4343
#[dev-dependencies]
44-
insta = "1.43.2"
44+
insta = "1.44.1"

v_exchanges/src/binance/market.rs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,18 @@ use jiff::Timestamp;
55
use serde::{Deserialize, Serialize};
66
use serde_json::{Value, json};
77
use serde_with::{DisplayFromStr, serde_as};
8-
use v_exchanges_adapters::{
9-
GetOptions,
10-
binance::{BinanceHttpUrl, BinanceOption, BinanceOptions},
11-
};
8+
use v_exchanges_adapters::binance::{BinanceHttpUrl, BinanceOption};
129
use v_utils::trades::{Kline, Ohlc};
1310

1411
use super::BinanceTimeframe;
1512
use crate::{
1613
ExchangeError, ExchangeName, Instrument, Symbol,
1714
core::{Klines, OpenInterest, RequestRange},
18-
recv_window_check,
1915
utils::join_params,
2016
};
2117

2218
// klines {{{
23-
pub async fn klines(
24-
client: &v_exchanges_adapters::Client,
25-
symbol: Symbol,
26-
tf: BinanceTimeframe,
27-
range: RequestRange,
28-
recv_window: Option<std::time::Duration>,
29-
) -> Result<Klines, ExchangeError> {
30-
recv_window_check!(recv_window, GetOptions::<BinanceOptions>::default_options(client));
19+
pub async fn klines(client: &v_exchanges_adapters::Client, symbol: Symbol, tf: BinanceTimeframe, range: RequestRange) -> Result<Klines, ExchangeError> {
3120
//TODO: test if embedding params into the url works more consistently (comp number of pairs axum-site is ablle ot get)
3221
range.ensure_allowed(1..=1000, tf.as_ref())?;
3322
let range_params = range.serialize(ExchangeName::Binance);
@@ -44,10 +33,7 @@ pub async fn klines(
4433
_ => unimplemented!(),
4534
};
4635

47-
let mut options = vec![BinanceOption::HttpUrl(base_url)];
48-
if let Some(rw) = recv_window {
49-
options.push(BinanceOption::RecvWindow(rw));
50-
}
36+
let options = vec![BinanceOption::HttpUrl(base_url)];
5137
let kline_responses: Vec<KlineResponse> = client.get(&format!("{endpoint_prefix}/klines"), &params, options).await?;
5238

5339
let r_len = kline_responses.len();
@@ -113,14 +99,7 @@ pub struct KlineResponse {
11399
//,}}}
114100

115101
// open_interest {{{
116-
pub async fn open_interest(
117-
client: &v_exchanges_adapters::Client,
118-
symbol: Symbol,
119-
tf: BinanceTimeframe,
120-
range: RequestRange,
121-
recv_window: Option<std::time::Duration>,
122-
) -> Result<Vec<OpenInterest>, ExchangeError> {
123-
recv_window_check!(recv_window, GetOptions::<BinanceOptions>::default_options(client));
102+
pub async fn open_interest(client: &v_exchanges_adapters::Client, symbol: Symbol, tf: BinanceTimeframe, range: RequestRange) -> Result<Vec<OpenInterest>, ExchangeError> {
124103
range.ensure_allowed(1..=500, tf.as_ref())?;
125104
let range_params = range.serialize(ExchangeName::Binance);
126105
let base_params = json!({
@@ -138,10 +117,7 @@ pub async fn open_interest(
138117
})),
139118
};
140119

141-
let mut options = vec![BinanceOption::HttpUrl(base_url)];
142-
if let Some(rw) = recv_window {
143-
options.push(BinanceOption::RecvWindow(rw));
144-
}
120+
let options = vec![BinanceOption::HttpUrl(base_url)];
145121
let responses: Vec<OpenInterestResponse> = client.get(endpoint, &params, options).await?;
146122

147123
if responses.is_empty() {

v_exchanges/src/binance/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@ impl Exchange for Binance {
3131
self.update_default_option(BinanceOption::RecvWindow(recv_window));
3232
}
3333

34-
async fn exchange_info(&self, instrument: Instrument, _recv_window: Option<std::time::Duration>) -> ExchangeResult<ExchangeInfo> {
34+
async fn exchange_info(&self, instrument: Instrument) -> ExchangeResult<ExchangeInfo> {
3535
match instrument {
3636
Instrument::Perp => perp::general::exchange_info(self).await,
3737
_ => unimplemented!(),
3838
}
3939
}
4040

41-
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, recv_window: Option<std::time::Duration>) -> ExchangeResult<Klines> {
41+
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Klines> {
4242
match symbol.instrument {
43-
Instrument::Spot | Instrument::Margin => market::klines(self, symbol, tf.try_into()?, range, recv_window).await,
44-
Instrument::Perp => market::klines(self, symbol, tf.try_into()?, range, recv_window).await,
43+
Instrument::Spot | Instrument::Margin => market::klines(self, symbol, tf.try_into()?, range).await,
44+
Instrument::Perp => market::klines(self, symbol, tf.try_into()?, range).await,
4545
_ => Err(ExchangeError::Method(MethodError::MethodNotImplemented {
4646
exchange: self.name(),
4747
instrument: symbol.instrument,
4848
})),
4949
}
5050
}
5151

52-
async fn prices(&self, pairs: Option<Vec<Pair>>, instrument: Instrument, _recv_window: Option<std::time::Duration>) -> ExchangeResult<BTreeMap<Pair, f64>> {
52+
async fn prices(&self, pairs: Option<Vec<Pair>>, instrument: Instrument) -> ExchangeResult<BTreeMap<Pair, f64>> {
5353
match instrument {
5454
Instrument::Spot | Instrument::Margin => spot::market::prices(self, pairs).await,
5555
Instrument::Perp => perp::market::prices(self, pairs).await,
5656
_ => Err(ExchangeError::Method(MethodError::MethodNotImplemented { exchange: self.name(), instrument })),
5757
}
5858
}
5959

60-
async fn price(&self, symbol: Symbol, _recv_window: Option<std::time::Duration>) -> ExchangeResult<f64> {
60+
async fn price(&self, symbol: Symbol) -> ExchangeResult<f64> {
6161
match symbol.instrument {
6262
Instrument::Spot | Instrument::Margin => spot::market::price(self, symbol.pair).await,
6363
Instrument::Perp => perp::market::price(self, symbol.pair).await,
@@ -68,9 +68,9 @@ impl Exchange for Binance {
6868
}
6969
}
7070

71-
async fn open_interest(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, recv_window: Option<std::time::Duration>) -> ExchangeResult<Vec<crate::core::OpenInterest>> {
71+
async fn open_interest(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Vec<crate::core::OpenInterest>> {
7272
match symbol.instrument {
73-
Instrument::Perp => market::open_interest(self, symbol, tf.try_into()?, range, recv_window).await,
73+
Instrument::Perp => market::open_interest(self, symbol, tf.try_into()?, range).await,
7474
_ => Err(ExchangeError::Method(MethodError::MethodNotSupported {
7575
exchange: self.name(),
7676
instrument: symbol.instrument,
@@ -88,7 +88,7 @@ impl Exchange for Binance {
8888
async fn balances(&self, instrument: Instrument, recv_window: Option<std::time::Duration>) -> ExchangeResult<Balances> {
8989
match instrument {
9090
Instrument::Perp => {
91-
let prices = self.prices(None, instrument, recv_window).await?;
91+
let prices = self.prices(None, instrument).await?;
9292
perp::account::balances(self, recv_window, &prices).await
9393
}
9494
_ => unimplemented!(),

v_exchanges/src/bybit/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ impl Exchange for Bybit {
3030
self.update_default_option(BybitOption::RecvWindow(recv_window));
3131
}
3232

33-
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, _recv_window: Option<std::time::Duration>) -> ExchangeResult<Klines> {
33+
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Klines> {
3434
match symbol.instrument {
3535
Instrument::Perp => market::klines(self, symbol, tf.try_into()?, range).await,
3636
_ => unimplemented!(),
3737
}
3838
}
3939

40-
async fn price(&self, symbol: Symbol, _recv_window: Option<std::time::Duration>) -> ExchangeResult<f64> {
40+
async fn price(&self, symbol: Symbol) -> ExchangeResult<f64> {
4141
match symbol.instrument {
4242
Instrument::Perp => market::price(self, symbol.pair).await,
4343
_ => unimplemented!(),
4444
}
4545
}
4646

47-
async fn open_interest(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, _recv_window: Option<std::time::Duration>) -> ExchangeResult<Vec<OpenInterest>> {
47+
async fn open_interest(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Vec<OpenInterest>> {
4848
match symbol.instrument {
4949
Instrument::Perp => market::open_interest(self, symbol, tf.try_into()?, range).await,
5050
_ => Err(crate::ExchangeError::Method(crate::MethodError::MethodNotSupported {

v_exchanges/src/core.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ pub trait Exchange: std::fmt::Debug + Send + Sync + std::ops::Deref<Target = Cli
5252

5353
#[allow(unused_variables)]
5454
#[allow(dead_code)]
55-
async fn exchange_info(&self, instrument: Instrument, recv_window: Option<std::time::Duration>) -> ExchangeResult<ExchangeInfo> {
55+
async fn exchange_info(&self, instrument: Instrument) -> ExchangeResult<ExchangeInfo> {
5656
Err(ExchangeError::Method(MethodError::MethodNotSupported { exchange: self.name(), instrument }))
5757
}
5858

5959
//? should I have Self::Pair too? Like to catch the non-existent ones immediately? Although this would increase the error surface on new listings.
6060
#[allow(unused_variables)]
6161
#[allow(dead_code)]
62-
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, recv_window: Option<std::time::Duration>) -> ExchangeResult<Klines> {
62+
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Klines> {
6363
Err(ExchangeError::Method(MethodError::MethodNotSupported {
6464
exchange: self.name(),
6565
instrument: symbol.instrument,
@@ -69,13 +69,13 @@ pub trait Exchange: std::fmt::Debug + Send + Sync + std::ops::Deref<Target = Cli
6969
/// If no pairs are specified, returns for all;
7070
#[allow(unused_variables)]
7171
#[allow(dead_code)]
72-
async fn prices(&self, pairs: Option<Vec<Pair>>, instrument: Instrument, recv_window: Option<std::time::Duration>) -> ExchangeResult<BTreeMap<Pair, f64>> {
72+
async fn prices(&self, pairs: Option<Vec<Pair>>, instrument: Instrument) -> ExchangeResult<BTreeMap<Pair, f64>> {
7373
Err(ExchangeError::Method(MethodError::MethodNotSupported { exchange: self.name(), instrument }))
7474
}
7575

7676
#[allow(unused_variables)]
7777
#[allow(dead_code)]
78-
async fn price(&self, symbol: Symbol, recv_window: Option<std::time::Duration>) -> ExchangeResult<f64> {
78+
async fn price(&self, symbol: Symbol) -> ExchangeResult<f64> {
7979
Err(ExchangeError::Method(MethodError::MethodNotSupported {
8080
exchange: self.name(),
8181
instrument: symbol.instrument,
@@ -86,7 +86,7 @@ pub trait Exchange: std::fmt::Debug + Send + Sync + std::ops::Deref<Target = Cli
8686
/// in output vec: greater the index, fresher the data
8787
#[allow(unused_variables)]
8888
#[allow(dead_code)]
89-
async fn open_interest(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, recv_window: Option<std::time::Duration>) -> ExchangeResult<Vec<OpenInterest>> {
89+
async fn open_interest(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Vec<OpenInterest>> {
9090
Err(ExchangeError::Method(MethodError::MethodNotSupported {
9191
exchange: self.name(),
9292
instrument: symbol.instrument,
@@ -378,6 +378,7 @@ define_str_enum! {
378378
}
379379
}
380380

381+
#[derive(Clone, Debug)]
381382
pub struct Ticker {
382383
pub symbol: Symbol,
383384
pub exchange_name: ExchangeName,

v_exchanges/src/kucoin/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,30 @@ impl Exchange for Kucoin {
3434
tracing::warn!("KuCoin does not support configurable recv_window - uses a fixed 5-second tolerance window for all authenticated requests");
3535
}
3636

37-
async fn exchange_info(&self, instrument: Instrument, recv_window: Option<std::time::Duration>) -> ExchangeResult<ExchangeInfo> {
37+
async fn exchange_info(&self, instrument: Instrument) -> ExchangeResult<ExchangeInfo> {
3838
match instrument {
39-
Instrument::Spot => market::exchange_info(self, recv_window).await,
39+
Instrument::Spot => market::exchange_info(self, None).await,
4040
_ => unimplemented!(),
4141
}
4242
}
4343

44-
async fn price(&self, symbol: Symbol, recv_window: Option<std::time::Duration>) -> ExchangeResult<f64> {
44+
async fn price(&self, symbol: Symbol) -> ExchangeResult<f64> {
4545
match symbol.instrument {
46-
Instrument::Spot => market::price(self, symbol.pair, recv_window).await,
46+
Instrument::Spot => market::price(self, symbol.pair, None).await,
4747
_ => unimplemented!(),
4848
}
4949
}
5050

51-
async fn prices(&self, pairs: Option<Vec<Pair>>, instrument: Instrument, recv_window: Option<std::time::Duration>) -> ExchangeResult<BTreeMap<Pair, f64>> {
51+
async fn prices(&self, pairs: Option<Vec<Pair>>, instrument: Instrument) -> ExchangeResult<BTreeMap<Pair, f64>> {
5252
match instrument {
53-
Instrument::Spot => market::prices(self, pairs, recv_window).await,
53+
Instrument::Spot => market::prices(self, pairs, None).await,
5454
_ => unimplemented!(),
5555
}
5656
}
5757

58-
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange, recv_window: Option<std::time::Duration>) -> ExchangeResult<Klines> {
58+
async fn klines(&self, symbol: Symbol, tf: Timeframe, range: RequestRange) -> ExchangeResult<Klines> {
5959
match symbol.instrument {
60-
Instrument::Spot => market::klines(self, symbol, tf.try_into()?, range, recv_window).await,
60+
Instrument::Spot => market::klines(self, symbol, tf.try_into()?, range, None).await,
6161
_ => unimplemented!(),
6262
}
6363
}

v_exchanges/src/mexc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ impl Exchange for Mexc {
3333
self.update_default_option(MexcOption::RecvWindow(recv_window));
3434
}
3535

36-
async fn prices(&self, _pairs: Option<Vec<Pair>>, instrument: Instrument, _recv_window: Option<std::time::Duration>) -> ExchangeResult<BTreeMap<Pair, f64>> {
36+
async fn prices(&self, _pairs: Option<Vec<Pair>>, instrument: Instrument) -> ExchangeResult<BTreeMap<Pair, f64>> {
3737
match instrument {
3838
Instrument::Perp => unimplemented!("Mexc does not have a multi-asset endpoints for futures"),
3939
_ => unimplemented!(),
4040
}
4141
}
4242

43-
async fn price(&self, symbol: Symbol, recv_window: Option<std::time::Duration>) -> ExchangeResult<f64> {
43+
async fn price(&self, symbol: Symbol) -> ExchangeResult<f64> {
4444
match symbol.instrument {
4545
Instrument::Perp => market::price(self, symbol.pair).await,
4646
_ => unimplemented!(),

0 commit comments

Comments
 (0)