pub struct AccountService { /* private fields */ }Expand description
Account service for wallet and account management endpoints.
Implementations§
Source§impl AccountService
impl AccountService
Sourcepub fn new(http: HttpClient) -> Self
pub fn new(http: HttpClient) -> Self
Create a new account service.
Sourcepub async fn get_wallet_balance(
&self,
params: &GetWalletBalanceParams,
) -> Result<WalletBalanceResult, BybitError>
pub async fn get_wallet_balance( &self, params: &GetWalletBalanceParams, ) -> Result<WalletBalanceResult, BybitError>
Get wallet balance.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = GetWalletBalanceParams::new(AccountType::Unified);
let result = client.account().get_wallet_balance(¶ms).await?;
for wallet in &result.list {
println!("Total equity: {}", wallet.total_equity);
for coin in &wallet.coin {
println!(" {}: {}", coin.coin, coin.wallet_balance);
}
}Sourcepub async fn get_account_info(&self) -> Result<AccountInfo, BybitError>
pub async fn get_account_info(&self) -> Result<AccountInfo, BybitError>
Get account information.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let info = client.account().get_account_info().await?;
println!("Margin mode: {}", info.margin_mode);Sourcepub async fn get_fee_rates(
&self,
params: &GetFeeRatesParams,
) -> Result<FeeRateResult, BybitError>
pub async fn get_fee_rates( &self, params: &GetFeeRatesParams, ) -> Result<FeeRateResult, BybitError>
Get fee rates for trading.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = GetFeeRatesParams::new(Category::Linear)
.symbol("BTCUSDT");
let result = client.account().get_fee_rates(¶ms).await?;
for fee in &result.list {
println!("{}: maker={}, taker={}",
fee.symbol, fee.maker_fee_rate, fee.taker_fee_rate);
}Sourcepub async fn get_borrow_history(
&self,
params: &GetBorrowHistoryParams,
) -> Result<BorrowHistoryResult, BybitError>
pub async fn get_borrow_history( &self, params: &GetBorrowHistoryParams, ) -> Result<BorrowHistoryResult, BybitError>
Get borrow history.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = GetBorrowHistoryParams::new()
.currency("USDT")
.limit(20);
let result = client.account().get_borrow_history(¶ms).await?;Sourcepub async fn get_collateral_info(
&self,
params: &GetCollateralInfoParams,
) -> Result<CollateralInfoResult, BybitError>
pub async fn get_collateral_info( &self, params: &GetCollateralInfoParams, ) -> Result<CollateralInfoResult, BybitError>
Get collateral information.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = GetCollateralInfoParams::new();
let result = client.account().get_collateral_info(¶ms).await?;
for info in &result.list {
println!("{}: borrowable={}", info.currency, info.borrowable);
}Sourcepub async fn set_collateral_coin(
&self,
params: &SetCollateralCoinParams,
) -> Result<(), BybitError>
pub async fn set_collateral_coin( &self, params: &SetCollateralCoinParams, ) -> Result<(), BybitError>
Set collateral coin switch.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
// Enable BTC as collateral
let params = SetCollateralCoinParams::enable("BTC");
client.account().set_collateral_coin(¶ms).await?;Sourcepub async fn get_coin_greeks(
&self,
params: &GetCoinGreeksParams,
) -> Result<CoinGreeksResult, BybitError>
pub async fn get_coin_greeks( &self, params: &GetCoinGreeksParams, ) -> Result<CoinGreeksResult, BybitError>
Get coin greeks (for options).
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = GetCoinGreeksParams::new().base_coin("BTC");
let result = client.account().get_coin_greeks(¶ms).await?;
for greeks in &result.list {
println!("{}: delta={}", greeks.base_coin, greeks.total_delta);
}Sourcepub async fn get_transaction_log(
&self,
params: &GetTransactionLogParams,
) -> Result<TransactionLogResult, BybitError>
pub async fn get_transaction_log( &self, params: &GetTransactionLogParams, ) -> Result<TransactionLogResult, BybitError>
Get transaction log.
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = GetTransactionLogParams::new()
.currency("USDT")
.limit(50);
let result = client.account().get_transaction_log(¶ms).await?;
for log in &result.list {
println!("{}: {} - {}", log.transaction_time, log.transaction_type, log.change);
}Sourcepub async fn set_margin_mode(
&self,
params: &SetMarginModeParams,
) -> Result<MarginModeResult, BybitError>
pub async fn set_margin_mode( &self, params: &SetMarginModeParams, ) -> Result<MarginModeResult, BybitError>
Set margin mode (regular or portfolio margin).
§Example
let client = BybitClient::new("api_key", "api_secret")?;
let params = SetMarginModeParams::portfolio_margin();
client.account().set_margin_mode(¶ms).await?;Trait Implementations§
Source§impl Clone for AccountService
impl Clone for AccountService
Source§fn clone(&self) -> AccountService
fn clone(&self) -> AccountService
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for AccountService
impl !RefUnwindSafe for AccountService
impl Send for AccountService
impl Sync for AccountService
impl Unpin for AccountService
impl !UnwindSafe for AccountService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more