Skip to content

Commit a0f5c6a

Browse files
committed
Fix exchange endpoint
Signed-off-by: Herklos <herklos@drakkar.software>
1 parent 129ad97 commit a0f5c6a

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

rust/src/exchange.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,11 +2803,12 @@ pub trait Exchange: ValueTrait {
28032803
request.set("symbol".into(), symbol.clone());
28042804
if limit.is_nonnullish() { request.set("limit".into(), limit.clone()); }
28052805
let mut dynamic_calls: Vec<(String, String, String)> = vec![];
2806-
if let Value::Json(serde_json::Value::Object(api_map)) = <Self as Exchange>::describe(self).get("api".into()) {
2806+
if let Value::Json(serde_json::Value::Object(api_map)) = self.get("api".into()) {
28072807
for (api_name, node) in api_map { collect_routes(&node, &api_name, &mut dynamic_calls); }
28082808
}
28092809
for token in ["depth", "orderbook", "order_book"] {
28102810
for (api_name, method_name, path_name) in &dynamic_calls {
2811+
if api_name.as_str() != "public" { continue; }
28112812
if method_name.as_str() != "GET" || path_name.contains('{') { continue; }
28122813
let p = path_name.to_lowercase();
28132814
if p == token || p.contains(token) {
@@ -3174,16 +3175,19 @@ pub trait Exchange: ValueTrait {
31743175
}
31753176
let mut request = if params.is_object() { params.clone() } else { Value::new_object() };
31763177
request.set("symbol".into(), symbol.clone());
3177-
request.set("timeframe".into(), timeframe.clone());
31783178
request.set("interval".into(), timeframe.clone());
31793179
if since.is_nonnullish() { request.set("since".into(), since.clone()); request.set("startTime".into(), since.clone()); }
31803180
if limit.is_nonnullish() { request.set("limit".into(), limit.clone()); }
31813181
let mut dynamic_calls: Vec<(String, String, String)> = vec![];
3182-
if let Value::Json(serde_json::Value::Object(api_map)) = <Self as Exchange>::describe(self).get("api".into()) {
3182+
if let Value::Json(serde_json::Value::Object(api_map)) = self.get("api".into()) {
31833183
for (api_name, node) in api_map { collect_routes(&node, &api_name, &mut dynamic_calls); }
31843184
}
31853185
for token in ["klines", "candles", "ohlcv"] {
31863186
for (api_name, method_name, path_name) in &dynamic_calls {
3187+
// Skip non-public APIs (futures, options, etc.) — they require
3188+
// different params (e.g. 'pair' instead of 'symbol') and are not
3189+
// appropriate for generic spot OHLCV fetching.
3190+
if api_name.as_str() != "public" { continue; }
31873191
if method_name.as_str() != "GET" || path_name.contains('{') { continue; }
31883192
let p = path_name.to_lowercase();
31893193
if p == token || p.contains(token) {
@@ -3405,7 +3409,7 @@ pub trait Exchange: ValueTrait {
34053409
}
34063410
}
34073411

3408-
let urls_api = <Self as Exchange>::describe(self).get("urls".into()).get("api".into());
3412+
let urls_api = self.get("urls".into()).get("api".into());
34093413
let mut base = urls_api.get(api.clone());
34103414
if !base.is_string() {
34113415
base = urls_api.get("public".into());
@@ -3429,7 +3433,7 @@ pub trait Exchange: ValueTrait {
34293433
return Value::Undefined;
34303434
}
34313435
let mut base_url = base.unwrap_str().to_string();
3432-
let hostname = <Self as Exchange>::describe(self).get("hostname".into());
3436+
let hostname = self.get("hostname".into());
34333437
if hostname.is_string() {
34343438
base_url = base_url.replace("{hostname}", hostname.unwrap_str());
34353439
}
@@ -3763,11 +3767,12 @@ pub trait Exchange: ValueTrait {
37633767
let mut request = if params.is_object() { params.clone() } else { Value::new_object() };
37643768
request.set("symbol".into(), symbol.clone());
37653769
let mut dynamic_calls: Vec<(String, String, String)> = vec![];
3766-
if let Value::Json(serde_json::Value::Object(api_map)) = <Self as Exchange>::describe(self).get("api".into()) {
3770+
if let Value::Json(serde_json::Value::Object(api_map)) = self.get("api".into()) {
37673771
for (api_name, node) in api_map { collect_routes(&node, &api_name, &mut dynamic_calls); }
37683772
}
37693773
for token in ["ticker/24hr", "ticker", "ticker/price", "bookticker", "tickers"] {
37703774
for (api_name, method_name, path_name) in &dynamic_calls {
3775+
if api_name.as_str() != "public" { continue; }
37713776
if method_name.as_str() != "GET" || path_name.contains('{') { continue; }
37723777
let p = path_name.to_lowercase();
37733778
if p == token || p.contains(token) {

0 commit comments

Comments
 (0)