crypto_rest_client/exchanges/
bitfinex.rs1use super::utils::http_get;
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://api-pub.bitfinex.com";
6
7pub struct BitfinexRestClient {
14 _api_key: Option<String>,
15 _api_secret: Option<String>,
16}
17
18impl BitfinexRestClient {
19 pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
20 BitfinexRestClient { _api_key: api_key, _api_secret: api_secret }
21 }
22
23 pub fn fetch_trades(
25 symbol: &str,
26 limit: Option<u16>,
27 start: Option<u64>,
28 end: Option<u64>,
29 sort: Option<i8>,
30 ) -> Result<String> {
31 gen_api!(format!("/v2/trades/{symbol}/hist"), limit, start, end, sort)
32 }
33
34 pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
42 let len = Some(100);
43 gen_api!(format!("/v2/book/{symbol}/P0"), len)
44 }
45
46 pub fn fetch_l3_snapshot(symbol: &str) -> Result<String> {
52 let len = Some(100);
53 gen_api!(format!("/v2/book/{symbol}/R0"), len)
54 }
55}