use crate::client::BybitClient;
use crate::error::Result;
use crate::models::account::*;
use crate::models::*;
impl BybitClient {
pub async fn get_wallet_balance(&self, account_type: AccountType) -> Result<WalletBalance> {
let account_type_str = format!("{:?}", account_type);
let params = vec![("accountType", account_type_str.as_str())];
self.get("/v5/account/wallet-balance", ¶ms).await
}
pub async fn get_account_info(&self) -> Result<AccountInfo> {
self.get("/v5/account/info", &[]).await
}
pub async fn get_fee_rate(&self, category: Category, symbol: Option<&str>) -> Result<FeeRates> {
let cat_str = category.to_string();
let mut params = vec![("category", cat_str.as_str())];
if let Some(s) = symbol {
params.push(("symbol", s));
}
self.get("/v5/account/fee-rate", ¶ms).await
}
pub async fn get_transaction_log(
&self,
category: Option<Category>,
limit: Option<u32>,
) -> Result<TransactionLogs> {
let limit_str = limit.unwrap_or(20).to_string();
let mut params = vec![("limit", limit_str.as_str())];
let cat_str;
if let Some(c) = category {
cat_str = c.to_string();
params.push(("category", cat_str.as_str()));
}
self.get("/v5/account/transaction-log", ¶ms).await
}
pub async fn set_margin_mode(&self, margin_mode: MarginMode) -> Result<serde_json::Value> {
let mode_str = format!("{:?}", margin_mode);
let params = SetMarginModeParams {
set_margin_mode: mode_str,
};
self.post("/v5/account/set-margin-mode", ¶ms).await
}
pub async fn get_collateral_info(&self, currency: Option<&str>) -> Result<CollateralInfo> {
let mut params = vec![];
if let Some(c) = currency {
params.push(("currency", c));
}
self.get("/v5/account/collateral-info", ¶ms).await
}
pub async fn get_borrow_history(
&self,
currency: Option<&str>,
limit: Option<u32>,
) -> Result<BorrowHistory> {
let limit_str = limit.unwrap_or(20).to_string();
let mut params = vec![("limit", limit_str.as_str())];
if let Some(c) = currency {
params.push(("currency", c));
}
self.get("/v5/account/borrow-history", ¶ms).await
}
}