Skip to main content

CoinData

Struct CoinData 

Source
pub struct CoinData {
Show 18 fields pub coin: String, pub equity: f64, pub usd_value: f64, pub wallet_balance: f64, pub available_to_withdraw: Option<f64>, pub available_to_borrow: Option<f64>, pub borrow_amount: f64, pub accrued_interest: f64, pub total_order_im: f64, pub total_position_im: f64, pub total_position_mm: f64, pub unrealised_pnl: f64, pub cum_realised_pnl: f64, pub bonus: f64, pub collateral_switch: bool, pub margin_collateral: bool, pub locked: f64, pub spot_hedging_qty: f64,
}
Expand description

Represents balance and margin data for a specific currency in the account.

This struct details the financial state of a single currency (e.g., USDT, BTC) within a Bybit account, used for multi-currency margin management (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). For trading bots, CoinData is critical for allocating collateral, managing borrowing, and tracking currency-specific PNL in perpetual futures.

Fields§

§coin: String

The currency, e.g., “USDT”, “BTC”.

This identifies the coin for which balance and margin data is provided, critical for multi-currency accounts (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots use coin to route funds and collateral correctly, ensuring proper currency alignment for trades and margin.

§equity: f64

Total equity for the currency, including wallet balance and unrealized PNL.

This represents the net worth of the currency in the account, used for leverage and risk calculations (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots monitor equity to assess currency-specific financial health, guiding allocation and risk decisions.

§usd_value: f64

USD value of the currency’s equity, converted at the current market rate.

This normalizes the currency’s equity to USD for cross-currency comparisons and risk aggregation (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots use usd_value to standardize risk exposure across currencies, simplifying account-level risk management.

§wallet_balance: f64

Available balance for the currency, excluding margin and locked funds.

This is the liquid balance available for trading or withdrawal in the specific currency (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots track wallet_balance to ensure sufficient liquidity for new positions or margin top-ups in the currency.

§available_to_withdraw: Option<f64>

Amount available for withdrawal in the currency, if specified.

This reflects the portion of the wallet balance that can be withdrawn, accounting for restrictions like pending orders (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots use available_to_withdraw to manage cash flow, ensuring funds are accessible when needed without disrupting trading.

§available_to_borrow: Option<f64>

Amount available to borrow in the currency, if specified.

This indicates the additional leverage available for the currency in Bybit’s unified margin account (https://bybit-exchange.github.io/docs/v5/account/borrow). Bot Implication: bots use available_to_borrow to expand positions, but must balance borrowing with liquidation risks in volatile markets.

§borrow_amount: f64

Total borrowed amount in the currency.

This tracks loans taken in the currency, impacting leverage and interest costs (https://bybit-exchange.github.io/docs/v5/account/borrow). Bot Implication: Bots monitor borrow_amount to manage interest expenses and ensure borrowed funds don’t exceed risk thresholds.

§accrued_interest: f64

Accrued interest on borrowed funds in the currency.

This represents the cost of borrowing, which accumulates over time and affects profitability (https://bybit-exchange.github.io/docs/v5/account/borrow). Bot Implication: Bots track accrued_interest to optimize borrowing strategies, minimizing costs while maintaining leverage.

§total_order_im: f64

Initial margin for orders in the currency.

This is the collateral required for open orders in the currency, impacting available balance (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots use total_order_im to allocate margin efficiently, ensuring orders don’t overcommit funds.

§total_position_im: f64

Initial margin for positions in the currency, as a string.

This is the collateral tied up in open positions, expressed as a string for precision (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots monitor total_position_im to manage position margin, preventing over-leveraging or margin shortages.

§total_position_mm: f64

Maintenance margin for positions in the currency, as a string.

This is the minimum collateral needed to maintain positions, critical for avoiding liquidations (https://bybit-exchange.github.io/docs/v5/account/risk-limit). Bot Implication: Bots prioritize total_position_mm to ensure positions remain funded, adjusting leverage or topping up margin as needed.

§unrealised_pnl: f64

Unrealized profit and loss for positions in the currency.

This reflects paper gains or losses on open positions, affecting equity and margin (https://bybit-exchange.github.io/docs/v5/account/position). Bot Implication: Bots use unrealised_pnl to evaluate position performance and adjust risk controls, as large losses can trigger margin calls.

§cum_realised_pnl: f64

Cumulative realized profit and loss for the currency.

This tracks the net realized gains or losses from closed positions, impacting account equity (https://bybit-exchange.github.io/docs/v5/account/position). Bot Implication: Bots use cum_realised_pnl to assess strategy performance and update capital allocation based on realized outcomes.

§bonus: f64

Bonus balance in the currency, e.g., promotional credits.

This represents non-withdrawable funds, often from Bybit promotions, used for trading (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots account for bonus in balance calculations, but must adjust for withdrawal restrictions when planning cash flow.

§collateral_switch: bool

Indicates if the currency can be used as collateral.

When true, the currency is eligible for margin calculations in Bybit’s unified account (https://bybit-exchange.github.io/docs/v5/account/margin-mode). Bot Implication: Bots check collateral_switch to ensure only eligible currencies are used for margin, avoiding funding errors.

§margin_collateral: bool

Indicates if the currency is used as margin collateral.

When true, the currency actively contributes to margin requirements (https://bybit-exchange.github.io/docs/v5/account/margin-mode). Bot Implication: Bots prioritize margin_collateral currencies for margin allocation, optimizing collateral efficiency.

§locked: f64

Amount of the currency locked, e.g., for pending orders, as a string.

This represents funds tied up in non-withdrawable states, reducing available balance (https://bybit-exchange.github.io/docs/v5/account/wallet-balance). Bot Implication: Bots track locked to avoid overestimating available funds, ensuring accurate liquidity planning.

§spot_hedging_qty: f64

Quantity of the currency used for spot hedging.

This reflects the amount allocated to spot positions for hedging futures exposure, as a string (https://bybit-exchange.github.io/docs/v5/account/position). Bot Implication: Bots use spot_hedging_qty to balance futures and spot positions, minimizing directional risk in hedging strategies.

Trait Implementations§

Source§

impl Clone for CoinData

Source§

fn clone(&self) -> CoinData

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 CoinData

Source§

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

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

impl<'de> Deserialize<'de> for CoinData

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 CoinData

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>,