bybit_api/api/
spot_margin.rs1use crate::client::BybitClient;
4use crate::error::Result;
5use crate::models::spot_margin::*;
6
7impl BybitClient {
8 pub async fn get_historical_interest_rate(
10 &self,
11 currency: &str,
12 vip_level: Option<&str>,
13 start_time: Option<i64>,
14 end_time: Option<i64>,
15 ) -> Result<GetHistoricalInterestRateResponse> {
16 let start_time_str = start_time.map(|v| v.to_string());
17 let end_time_str = end_time.map(|v| v.to_string());
18 let mut params = vec![("currency", currency)];
19 if let Some(v) = vip_level {
20 params.push(("vipLevel", v));
21 }
22 if let Some(s) = start_time_str.as_deref() {
23 params.push(("startTime", s));
24 }
25 if let Some(s) = end_time_str.as_deref() {
26 params.push(("endTime", s));
27 }
28 self.get("/v5/spot-margin-trade/interest-rate-history", ¶ms)
29 .await
30 }
31
32 pub async fn get_position_tiers(
34 &self,
35 currency: Option<&str>,
36 ) -> Result<GetPositionTiersResponse> {
37 let mut params = vec![];
38 if let Some(c) = currency {
39 params.push(("currency", c));
40 }
41 self.get("/v5/spot-margin-trade/position-tiers", ¶ms)
42 .await
43 }
44
45 pub async fn get_tiered_collateral_ratio(
47 &self,
48 currency: Option<&str>,
49 ) -> Result<GetTieredCollateralRatioResponse> {
50 let mut params = vec![];
51 if let Some(c) = currency {
52 params.push(("currency", c));
53 }
54 self.get_public("/v5/spot-margin-trade/collateral", ¶ms)
55 .await
56 }
57
58 pub async fn get_vip_margin_data(
60 &self,
61 vip_level: Option<&str>,
62 currency: Option<&str>,
63 ) -> Result<GetVipMarginDataResponse> {
64 let mut params = vec![];
65 if let Some(v) = vip_level {
66 params.push(("vipLevel", v));
67 }
68 if let Some(c) = currency {
69 params.push(("currency", c));
70 }
71 self.get_public("/v5/spot-margin-trade/data", ¶ms).await
72 }
73}