1use crate::client::BybitClient;
22use crate::error::Result;
23use crate::types::{PositionList, WalletBalance};
24
25impl BybitClient {
26 pub async fn get_wallet_balance(&self, account_type: Option<&str>) -> Result<WalletBalance> {
27 let query = account_type.map(|t| vec![("accountType", t)]);
28 self.get("/v5/account/wallet-balance", query).await
29 }
30
31 pub async fn get_position(&self, category: &str, symbol: Option<&str>) -> Result<PositionList> {
32 let mut query = vec![("category", category)];
33 if let Some(s) = symbol {
34 query.push(("symbol", s));
35 }
36 self.get("/v5/position/list", Some(query)).await
37 }
38
39 pub async fn set_leverage(
40 &self,
41 category: &str,
42 symbol: &str,
43 buy_leverage: &str,
44 sell_leverage: &str,
45 ) -> Result<serde_json::Value> {
46 let body = serde_json::json!({
47 "category": category,
48 "symbol": symbol,
49 "buyLeverage": buy_leverage,
50 "sellLeverage": sell_leverage,
51 });
52 self.post("/v5/position/set-leverage", Some(body)).await
53 }
54
55 pub async fn get_execution_list(
56 &self,
57 category: &str,
58 symbol: Option<&str>,
59 ) -> Result<serde_json::Value> {
60 let mut query = vec![("category", category)];
61 if let Some(s) = symbol {
62 query.push(("symbol", s));
63 }
64 self.get("/v5/execution/list", Some(query)).await
65 }
66
67 pub async fn get_closed_pnl(
68 &self,
69 category: &str,
70 symbol: Option<&str>,
71 ) -> Result<serde_json::Value> {
72 let mut query = vec![("category", category)];
73 if let Some(s) = symbol {
74 query.push(("symbol", s));
75 }
76 self.get("/v5/position/closed-pnl", Some(query)).await
77 }
78}
79
80#[cfg(test)]
81mod tests {
82 #[test]
83 fn test_account_module_exists() {}
84}