pub struct AccountClient { /* private fields */ }Implementations§
Source§impl AccountClient
impl AccountClient
Sourcepub fn new(client: RestClient) -> Self
pub fn new(client: RestClient) -> Self
Examples found in repository?
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let api_key = env::var("BYBIT_API_KEY").unwrap_or_else(|_| "YOUR_API_KEY".to_string());
9 let api_secret = env::var("BYBIT_API_SECRET").unwrap_or_else(|_| "YOUR_API_SECRET".to_string());
10
11 // Using testnet by default
12 let base_url = "https://api-testnet.bybit.com".to_string();
13
14 // ApiKeyPair takes (profile_name, key, secret)
15 let key_pair = ApiKeyPair::new("account_demo".to_string(), api_key, api_secret);
16 let client = RestClient::new(key_pair, base_url);
17
18 // AccountClient takes ownership of RestClient
19 let account_client = AccountClient::new(client);
20
21 println!("--- Testing get_wallet_balance ---");
22 let params = GetWalletBalanceParams {
23 account_type: AccountType::UNIFIED,
24 coin: None,
25 };
26
27 match account_client.get_wallet_balance(params).await {
28 Ok(response) => println!("Success: {:?}", response),
29 Err(e) => println!("Error: {:?}", e),
30 }
31
32 println!("\n--- Testing get_fee_rate ---");
33 match account_client.get_fee_rate("spot", None, None).await {
34 Ok(response) => println!("Success: {:?}", response),
35 Err(e) => println!("Error: {:?}", e),
36 }
37
38 Ok(())
39}Sourcepub async fn get_wallet_balance(
&self,
params: GetWalletBalanceParams,
) -> Result<ServerResponse<WalletBalanceResult>>
pub async fn get_wallet_balance( &self, params: GetWalletBalanceParams, ) -> Result<ServerResponse<WalletBalanceResult>>
Get wallet balance
API: GET /v5/account/wallet-balance https://bybit-exchange.github.io/docs/v5/account/wallet-balance
Examples found in repository?
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let api_key = env::var("BYBIT_API_KEY").unwrap_or_else(|_| "YOUR_API_KEY".to_string());
9 let api_secret = env::var("BYBIT_API_SECRET").unwrap_or_else(|_| "YOUR_API_SECRET".to_string());
10
11 // Using testnet by default
12 let base_url = "https://api-testnet.bybit.com".to_string();
13
14 // ApiKeyPair takes (profile_name, key, secret)
15 let key_pair = ApiKeyPair::new("account_demo".to_string(), api_key, api_secret);
16 let client = RestClient::new(key_pair, base_url);
17
18 // AccountClient takes ownership of RestClient
19 let account_client = AccountClient::new(client);
20
21 println!("--- Testing get_wallet_balance ---");
22 let params = GetWalletBalanceParams {
23 account_type: AccountType::UNIFIED,
24 coin: None,
25 };
26
27 match account_client.get_wallet_balance(params).await {
28 Ok(response) => println!("Success: {:?}", response),
29 Err(e) => println!("Error: {:?}", e),
30 }
31
32 println!("\n--- Testing get_fee_rate ---");
33 match account_client.get_fee_rate("spot", None, None).await {
34 Ok(response) => println!("Success: {:?}", response),
35 Err(e) => println!("Error: {:?}", e),
36 }
37
38 Ok(())
39}Sourcepub async fn get_fee_rate(
&self,
category: &str,
symbol: Option<&str>,
base_coin: Option<&str>,
) -> Result<ServerResponse<FeeRateResult>>
pub async fn get_fee_rate( &self, category: &str, symbol: Option<&str>, base_coin: Option<&str>, ) -> Result<ServerResponse<FeeRateResult>>
Get fee rate
API: GET /v5/account/fee-rate https://bybit-exchange.github.io/docs/v5/account/fee-rate
Examples found in repository?
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let api_key = env::var("BYBIT_API_KEY").unwrap_or_else(|_| "YOUR_API_KEY".to_string());
9 let api_secret = env::var("BYBIT_API_SECRET").unwrap_or_else(|_| "YOUR_API_SECRET".to_string());
10
11 // Using testnet by default
12 let base_url = "https://api-testnet.bybit.com".to_string();
13
14 // ApiKeyPair takes (profile_name, key, secret)
15 let key_pair = ApiKeyPair::new("account_demo".to_string(), api_key, api_secret);
16 let client = RestClient::new(key_pair, base_url);
17
18 // AccountClient takes ownership of RestClient
19 let account_client = AccountClient::new(client);
20
21 println!("--- Testing get_wallet_balance ---");
22 let params = GetWalletBalanceParams {
23 account_type: AccountType::UNIFIED,
24 coin: None,
25 };
26
27 match account_client.get_wallet_balance(params).await {
28 Ok(response) => println!("Success: {:?}", response),
29 Err(e) => println!("Error: {:?}", e),
30 }
31
32 println!("\n--- Testing get_fee_rate ---");
33 match account_client.get_fee_rate("spot", None, None).await {
34 Ok(response) => println!("Success: {:?}", response),
35 Err(e) => println!("Error: {:?}", e),
36 }
37
38 Ok(())
39}Sourcepub async fn get_account_info(
&self,
) -> Result<ServerResponse<AccountInfoResult>>
pub async fn get_account_info( &self, ) -> Result<ServerResponse<AccountInfoResult>>
Get account info
API: GET /v5/account/info https://bybit-exchange.github.io/docs/v5/account/account-info
Sourcepub async fn get_transaction_log(
&self,
params: GetTransactionLogParams,
) -> Result<ServerResponse<TransactionLogResult>>
pub async fn get_transaction_log( &self, params: GetTransactionLogParams, ) -> Result<ServerResponse<TransactionLogResult>>
Get transaction log
API: GET /v5/account/transaction-log https://bybit-exchange.github.io/docs/v5/account/transaction-log
Sourcepub async fn set_margin_mode(
&self,
margin_mode: &str,
) -> Result<ServerResponse<Value>>
pub async fn set_margin_mode( &self, margin_mode: &str, ) -> Result<ServerResponse<Value>>
Set margin mode
API: POST /v5/account/set-margin-mode https://bybit-exchange.github.io/docs/v5/account/set-margin-mode
Sourcepub async fn set_mmp(
&self,
params: ModifyMmpParams,
) -> Result<ServerResponse<Value>>
pub async fn set_mmp( &self, params: ModifyMmpParams, ) -> Result<ServerResponse<Value>>
Set MMP
API: POST /v5/account/mmp-modify https://bybit-exchange.github.io/docs/v5/account/set-mmp
Sourcepub async fn reset_mmp(&self, base_coin: &str) -> Result<ServerResponse<Value>>
pub async fn reset_mmp(&self, base_coin: &str) -> Result<ServerResponse<Value>>
Reset MMP
API: POST /v5/account/mmp-reset https://bybit-exchange.github.io/docs/v5/account/reset-mmp
Sourcepub async fn get_mmp_state(
&self,
base_coin: &str,
) -> Result<ServerResponse<MmpStateResult>>
pub async fn get_mmp_state( &self, base_coin: &str, ) -> Result<ServerResponse<MmpStateResult>>
Get MMP state
API: GET /v5/account/mmp-state https://bybit-exchange.github.io/docs/v5/account/get-mmp-state
Sourcepub async fn get_smp_group_list(&self) -> Result<ServerResponse<Value>>
pub async fn get_smp_group_list(&self) -> Result<ServerResponse<Value>>
Get SMP group list
API: GET /v5/account/smp-group https://bybit-exchange.github.io/docs/v5/account/smp-group
Sourcepub async fn get_coin_greeks(
&self,
base_coin: Option<&str>,
) -> Result<ServerResponse<Value>>
pub async fn get_coin_greeks( &self, base_coin: Option<&str>, ) -> Result<ServerResponse<Value>>
Get coin Greeks
API: GET /v5/asset/coin-greeks https://bybit-exchange.github.io/docs/v5/account/coin-greeks
Sourcepub async fn get_collateral_info(
&self,
currency: Option<&str>,
) -> Result<ServerResponse<CollateralInfoResult>>
pub async fn get_collateral_info( &self, currency: Option<&str>, ) -> Result<ServerResponse<CollateralInfoResult>>
Get collateral info
API: GET /v5/account/collateral-info https://bybit-exchange.github.io/docs/v5/account/collateral-info
Sourcepub async fn get_borrow_history(
&self,
currency: Option<&str>,
start_time: Option<i64>,
end_time: Option<i64>,
limit: Option<i32>,
cursor: Option<&str>,
) -> Result<ServerResponse<BorrowHistoryResult>>
pub async fn get_borrow_history( &self, currency: Option<&str>, start_time: Option<i64>, end_time: Option<i64>, limit: Option<i32>, cursor: Option<&str>, ) -> Result<ServerResponse<BorrowHistoryResult>>
Get borrow history
API: GET /v5/account/borrow-history https://bybit-exchange.github.io/docs/v5/account/borrow-history
Sourcepub async fn set_disconnect_cancel_all(
&self,
time_window: i32,
) -> Result<ServerResponse<Value>>
pub async fn set_disconnect_cancel_all( &self, time_window: i32, ) -> Result<ServerResponse<Value>>
Set disconnect cancel all
API: POST /v5/order/disconnected-cancel-all https://bybit-exchange.github.io/docs/v5/account/set-dcp
Sourcepub async fn upgrade_to_unified_account(&self) -> Result<ServerResponse<Value>>
pub async fn upgrade_to_unified_account(&self) -> Result<ServerResponse<Value>>
Upgrade to unified account
API: POST /v5/account/upgrade-to-uta https://bybit-exchange.github.io/docs/v5/account/upgrade-unified-account
Sourcepub async fn get_contract_transaction_log(
&self,
params: GetContractTransactionLogParams,
) -> Result<ServerResponse<ContractTransactionLogResult>>
pub async fn get_contract_transaction_log( &self, params: GetContractTransactionLogParams, ) -> Result<ServerResponse<ContractTransactionLogResult>>
Get contract transaction log
API: GET /v5/account/contract-transaction-log https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
Sourcepub async fn query_dcp_info(&self) -> Result<ServerResponse<Value>>
pub async fn query_dcp_info(&self) -> Result<ServerResponse<Value>>
Query DCP information
API: GET /v5/account/query-dcp-info https://bybit-exchange.github.io/docs/v5/account/query-dcp-info
Trait Implementations§
Source§impl Clone for AccountClient
impl Clone for AccountClient
Source§fn clone(&self) -> AccountClient
fn clone(&self) -> AccountClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more