AccountClient

Struct AccountClient 

Source
pub struct AccountClient { /* private fields */ }

Implementations§

Source§

impl AccountClient

Source

pub fn new(client: RestClient) -> Self

Examples found in repository?
examples/account_example.rs (line 19)
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}
Source

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?
examples/account_example.rs (line 27)
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}
Source

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?
examples/account_example.rs (line 33)
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}
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

fn clone(&self) -> AccountClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more