crypto_rest_client/exchanges/gate/
gate_future.rs1use super::super::utils::http_get;
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://api.gateio.ws/api/v4";
6
7pub struct GateFutureRestClient {
12 _api_key: Option<String>,
13 _api_secret: Option<String>,
14}
15
16impl GateFutureRestClient {
17 pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
18 GateFutureRestClient { _api_key: api_key, _api_secret: api_secret }
19 }
20
21 pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
30 let without_date = &symbol[..(symbol.len() - 8)];
31 let settle = if without_date.ends_with("_USD_") {
32 "btc"
33 } else if without_date.ends_with("_USDT_") {
34 "usdt"
35 } else {
36 panic!("Unknown symbol {symbol}");
37 };
38 gen_api!(format!("/delivery/{settle}/order_book?contract={symbol}&limit=50"))
39 }
40}