Struct PositionInfo

Source
pub struct PositionInfo {
Show 31 fields pub position_idx: i32, pub risk_id: i32, pub risk_limit_value: f64, pub symbol: String, pub side: Option<Side>, pub size: f64, pub avg_price: Option<f64>, pub position_value: Option<f64>, pub trade_mode: i32, pub position_status: String, pub auto_add_margin: i32, pub adl_rank_indicator: i32, pub leverage: Option<f64>, pub position_balance: f64, pub mark_price: f64, pub liq_price: Option<f64>, pub bust_price: Option<f64>, pub position_mm: Option<f64>, pub position_im: Option<f64>, pub tpsl_mode: String, pub take_profit: Option<f64>, pub stop_loss: Option<f64>, pub trailing_stop: String, pub unrealised_pnl: Option<f64>, pub cum_realised_pnl: Option<f64>, pub seq: i64, pub is_reduce_only: bool, pub mmr_sys_updated_time: Option<u64>, pub leverage_sys_updated_time: Option<u64>, pub created_time: u64, pub updated_time: u64,
}
Expand description

Represents detailed information about a single position.

Returned as part of the InfoResponse, this struct provides comprehensive position data, including size, entry price, leverage, and P&L. Bots use this to monitor and manage open positions in perpetual futures.

Fields§

§position_idx: i32

The position index (e.g., 0 for one-way mode, 1 or 2 for hedge mode).

Indicates the position type in Bybit’s position management system. Bots use this to distinguish between long and short positions in hedge mode for perpetual futures.

§risk_id: i32

The risk ID associated with the position.

Identifies the risk limit tier applied to the position. Bots use this to verify compliance with risk management settings.

§risk_limit_value: f64

The risk limit value for the position.

The maximum exposure allowed for the position, in the settlement currency. Bots use this to ensure positions stay within risk limits.

§symbol: String

The trading pair symbol (e.g., “BTCUSDT”).

Identifies the perpetual futures contract for the position. Bots should verify this matches the expected symbol.

§side: Option<Side>

The position side (Buy, Sell, or None).

Indicates whether the position is long (Buy), short (Sell), or closed (None). Bots use this to track position direction and calculate net exposure.

§size: f64

The position size (in base asset).

The quantity of the base asset held in the position (e.g., BTC in BTCUSDT). Bots use this to calculate position value and risk exposure.

§avg_price: Option<f64>

The average entry price of the position (optional).

The average price at which the position was opened. Bots use this to calculate unrealized P&L and assess position profitability.

§position_value: Option<f64>

The position value (optional).

The monetary value of the position (size * avg_price). Bots use this to calculate margin requirements and exposure in the settlement currency.

§trade_mode: i32

The trade mode (0 for cross margin, 1 for isolated margin).

Indicates whether the position uses cross margin (shared across positions) or isolated margin (specific to this position). Bots use this to manage margin allocation strategies.

§position_status: String

The position status (e.g., “Normal”, “Liq”).

Indicates the current state of the position, such as active or in liquidation. Bots use this to trigger risk management actions if the position is at risk.

§auto_add_margin: i32

Auto-margin addition status (0 or 1).

Indicates whether auto-margin addition is enabled (1) or disabled (0). Bots use this to monitor margin settings and prevent unexpected margin calls.

§adl_rank_indicator: i32

The Auto-Deleveraging (ADL) rank indicator.

Indicates the position’s priority for auto-deleveraging in case of market stress. Higher ranks (e.g., 4) are deleveraged first. Bots use this to assess liquidation risk.

§leverage: Option<f64>

The leverage applied to the position (optional).

The leverage multiplier (e.g., 10 for 10x). Bots use this to calculate margin requirements and assess risk exposure.

§position_balance: f64

The position’s margin balance.

The amount of margin allocated to the position. Bots use this to monitor margin health and prevent liquidation.

§mark_price: f64

The mark price of the position.

The current mark price used for P&L calculations in perpetual futures. Bots use this to calculate unrealized P&L and assess position health.

§liq_price: Option<f64>

The liquidation price (optional).

The price at which the position will be liquidated. Bots use this to set stop-loss orders or trigger risk management actions.

§bust_price: Option<f64>

The bankruptcy price (optional).

The price at which the position would result in account bankruptcy. Bots use this as a critical risk threshold for position management.

§position_mm: Option<f64>

The maintenance margin for the position (optional).

The minimum margin required to maintain the position. Bots use this to calculate margin ratios and avoid liquidation.

§position_im: Option<f64>

The initial margin for the position (optional).

The initial margin required to open the position. Bots use this to calculate leverage and margin utilization.

§tpsl_mode: String

The take-profit/stop-loss mode (e.g., “Full”, “Partial”).

Indicates whether take-profit and stop-loss orders are applied to the entire position (Full) or partially. Bots use this to manage exit strategies.

§take_profit: Option<f64>

The take-profit price (optional).

The price at which the position will automatically close for a profit. Bots use this to implement automated exit strategies.

§stop_loss: Option<f64>

The stop-loss price (optional).

The price at which the position will automatically close to limit losses. Bots use this to manage downside risk.

§trailing_stop: String

The trailing stop value.

The trailing stop offset, if enabled. Bots use this to implement dynamic stop-loss strategies that follow market movements.

§unrealised_pnl: Option<f64>

The unrealized profit and loss (optional).

The current unrealized P&L for the position, based on the mark price. Bots use this to monitor position profitability in real time.

§cum_realised_pnl: Option<f64>

The cumulative realized profit and loss (optional).

The total realized P&L for the position from all executions. Bots use this to track historical performance.

§seq: i64

The sequence number of the position update.

A unique sequence ID for ordering position updates. Bots use this to ensure proper chronological processing of position data.

§is_reduce_only: bool

Indicates if the position is reduce-only.

true if the position can only be reduced (e.g., closing trades only). Bots use this to enforce position management rules.

§mmr_sys_updated_time: Option<u64>

The timestamp of the last margin maintenance update (optional).

Indicates when the margin maintenance requirements were last updated. Bots use this to monitor margin health over time.

§leverage_sys_updated_time: Option<u64>

The timestamp of the last leverage update (optional).

Indicates when the leverage settings were last updated. Bots use this to track changes in risk exposure.

§created_time: u64

The timestamp when the position was created.

Indicates when the position was opened. Bots use this to calculate position duration and align with other time-series data.

§updated_time: u64

The timestamp of the last position update.

Indicates when the position was last modified (e.g., size or margin changes). Bots use this to track position changes in real time.

Trait Implementations§

Source§

impl Clone for PositionInfo

Source§

fn clone(&self) -> PositionInfo

Returns a copy 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 PositionInfo

Source§

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

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

impl<'de> Deserialize<'de> for PositionInfo

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 PositionInfo

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