crypto_rest_client/exchanges/binance/
binance_spot.rs1use super::{super::utils::http_get, utils::*};
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://api.binance.com";
6
7pub struct BinanceSpotRestClient {
15 _api_key: Option<String>,
16 _api_secret: Option<String>,
17}
18
19impl BinanceSpotRestClient {
20 pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
21 BinanceSpotRestClient { _api_key: api_key, _api_secret: api_secret }
22 }
23
24 pub fn fetch_agg_trades(
30 symbol: &str,
31 from_id: Option<u64>,
32 start_time: Option<u64>,
33 end_time: Option<u64>,
34 ) -> Result<String> {
35 check_symbol(symbol);
36 let symbol = Some(symbol);
37 let limit = Some(1000);
38 gen_api_binance!("/api/v3/aggTrades", symbol, from_id, start_time, end_time, limit)
39 }
40
41 pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
47 check_symbol(symbol);
48 let symbol = Some(symbol);
49 let limit = Some(1000);
50 gen_api_binance!("/api/v3/depth", symbol, limit)
51 }
52}