crypto_rest_client/exchanges/huobi/huobi_future.rs
1use super::super::utils::http_get;
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://api.hbdm.com";
6
7/// Huobi Future market.
8///
9/// * REST API doc: <https://huobiapi.github.io/docs/dm/v1/en/>
10/// * Trading at: <https://futures.huobi.com/en-us/contract/exchange/>
11/// * Rate Limits: <https://huobiapi.github.io/docs/dm/v1/en/#api-rate-limit-illustration>
12/// * For restful interfaces:all products(futures, coin margined swap, usdt
13/// margined swap ) 800 times/second for one IP at most
14pub struct HuobiFutureRestClient {
15 _api_key: Option<String>,
16 _api_secret: Option<String>,
17}
18
19impl_contract!(HuobiFutureRestClient);
20
21impl HuobiFutureRestClient {
22 /// Get the latest Level2 orderbook snapshot.
23 ///
24 /// Top 150 bids and asks (aggregated) are returned.
25 ///
26 /// For example: <https://api.hbdm.com/market/depth?symbol=BTC_CQ&type=step0>
27 pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
28 gen_api!(format!("/market/depth?symbol={symbol}&type=step0"))
29 }
30
31 /// Get open interest.
32 ///
33 /// For example: <https://api.hbdm.com/api/v1/contract_open_interest?contract_code=BTC211231>
34 pub fn fetch_open_interest(symbol: Option<&str>) -> Result<String> {
35 if let Some(symbol) = symbol {
36 gen_api!(format!("/api/v1/contract_open_interest?contract_code={symbol}"))
37 } else {
38 gen_api!("/api/v1/contract_open_interest")
39 }
40 }
41}