Skip to main content

WalletData

Struct WalletData 

Source
pub struct WalletData {
    pub account_im_rate: Option<f64>,
    pub account_mm_rate: Option<f64>,
    pub total_equity: f64,
    pub total_wallet_balance: f64,
    pub total_margin_balance: Option<f64>,
    pub total_available_balance: Option<f64>,
    pub total_perp_upl: f64,
    pub total_initial_margin: Option<f64>,
    pub total_maintenance_margin: Option<f64>,
    pub coin: Vec<CoinData>,
    pub account_ltv: Option<f64>,
    pub account_type: Option<String>,
}
Expand description

Represents wallet data, including balances and margin metrics, for a Bybit account.

This struct provides a snapshot of the account’s financial state, used for monitoring margin, equity, and risk in perpetual futures trading (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). For trading bots, wallet data is critical for ensuring sufficient margin, avoiding liquidations, and optimizing capital allocation.

Fields§

§account_im_rate: Option<f64>

Initial margin rate for the account, as a string (e.g., “0.1” for 10%).

This represents the ratio of initial margin to total equity, a key risk metric in perpetual futures. A higher rate indicates greater leverage and risk (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots monitor account_im_rate to ensure compliance with Bybit’s margin requirements, adjusting positions to avoid margin calls.

§account_mm_rate: Option<f64>

Maintenance margin rate for the account, as a string (e.g., “0.05” for 5%).

This is the minimum margin ratio required to maintain open positions. Falling below this triggers a margin call or liquidation (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots prioritize account_mm_rate to prevent forced liquidations, especially in volatile markets where margin requirements can spike.

§total_equity: f64

Total equity in the account, in USDT or the base currency.

This represents the account’s net worth, including wallet balance and unrealized PNL (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots use total_equity to assess overall account health and allocate capital across positions, ensuring sufficient buffer for market swings.

§total_wallet_balance: f64

Total wallet balance, excluding unrealized PNL.

This is the actual cash balance in the account, available for trading or withdrawal (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots track total_wallet_balance to ensure liquidity for new trades and margin requirements, avoiding funding shortages.

§total_margin_balance: Option<f64>

Total margin balance, including wallet balance and unrealized PNL.

This reflects the account’s total margin capacity, used to support open positions (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots use total_margin_balance to calculate leverage limits and ensure positions are adequately margined.

§total_available_balance: Option<f64>

Total available balance for new trades or withdrawals.

This is the portion of the wallet balance not tied up in margin or open positions (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots rely on total_available_balance to determine capacity for new trades, ensuring no over-allocation of funds.

§total_perp_upl: f64

Total unrealized profit and loss for perpetual futures positions.

This reflects the paper gains or losses on open positions, impacting equity and margin calculations (https://bybit-exchange.github.io/docs/v5/account/position). Bot Implication: Bots monitor total_perp_upl to assess position performance and adjust risk controls, as large unrealized losses can trigger liquidations.

§total_initial_margin: Option<f64>

Total initial margin required for open positions and orders.

This is the collateral required to open and maintain positions, based on Bybit’s risk limits (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots track total_initial_margin to ensure sufficient margin allocation, preventing rejections or forced closures.

§total_maintenance_margin: Option<f64>

Total maintenance margin required to keep positions open.

This is the minimum collateral needed to avoid liquidation, typically lower than initial margin (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots prioritize total_maintenance_margin to maintain account stability, as falling below this triggers risk management actions.

§coin: Vec<CoinData>

List of coin-specific balance data for the account.

This breaks down the wallet by currency, providing granular balance and margin details (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots use coin to manage multi-currency accounts, ensuring proper funding and collateral allocation per currency.

§account_ltv: Option<f64>

Loan-to-value ratio for the account, as a string (e.g., “0.2” for 20%).

This measures borrowed funds relative to total equity, a leverage risk indicator in Bybit’s unified margin account (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots monitor account_ltv to control leverage risk, as high LTV increases liquidation probability in adverse markets.

§account_type: Option<String>

Type of account, e.g., “UNIFIED”, if specified.

This indicates the account’s margin mode, such as unified (cross-margin) or isolated (per-position margin) (https://bybit-exchange.github.io/docs/v5/account/margin-mode). Bot Implication: Bots must align strategies with account_type, as margin modes affect risk calculations and liquidation mechanics.

Trait Implementations§

Source§

impl Clone for WalletData

Source§

fn clone(&self) -> WalletData

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
Source§

impl Debug for WalletData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WalletData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for WalletData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,