pub struct PositionData {Show 32 fields
pub position_idx: u8,
pub trade_mode: u8,
pub risk_id: u8,
pub risk_limit_value: String,
pub symbol: String,
pub side: Side,
pub size: f64,
pub entry_price: f64,
pub leverage: String,
pub position_value: f64,
pub position_balance: f64,
pub mark_price: f64,
pub position_im: String,
pub position_mm: String,
pub take_profit: f64,
pub stop_loss: f64,
pub trailing_stop: Option<f64>,
pub unrealised_pnl: String,
pub cum_realised_pnl: String,
pub created_time: u64,
pub updated_time: u64,
pub tpsl_mode: String,
pub liq_price: f64,
pub bust_price: Option<f64>,
pub category: String,
pub position_status: String,
pub adl_rank_indicator: u8,
pub auto_add_margin: u8,
pub mmr_sys_updated_time: Option<u64>,
pub leverage_sys_updated_time: Option<u64>,
pub seq: u64,
pub is_reduce_only: bool,
}Expand description
Represents detailed data about a single position in Bybit’s perpetual futures market.
This struct contains comprehensive information about a position, including size, leverage, profit/loss, and risk parameters.
§Bybit API Reference
Part of the position WebSocket stream (https://bybit-exchange.github.io/docs/v5/websocket/private/position).
§Perpetual Futures Context
Position data is critical for risk management in futures trading. Bots use this to monitor margin requirements, unrealized PnL, and liquidation risks.
Fields§
§position_idx: u8The position index (0 for one-way mode, 1 for buy-side hedge, 2 for sell-side hedge).
Indicates the position mode. Bots must handle different indices for hedged vs. one-way positions to manage risk accurately.
trade_mode: u8The trading mode (0 for regular, 1 for isolated margin).
Specifies whether the position uses cross or isolated margin. Bots need to adjust margin calculations based on this mode.
risk_id: u8The risk ID for the position’s risk limit.
Corresponds to Bybit’s risk limit tiers, which define margin requirements. Bots should monitor this to ensure compliance with risk limits.
risk_limit_value: StringThe risk limit value (as a string, e.g., “1000000”).
Represents the maximum exposure allowed for the risk tier. Bots use this to cap position sizes and avoid margin violations.
symbol: StringThe trading pair symbol (e.g., “BTCUSDT”).
Identifies the market for the position. Bots filter by symbol to manage specific markets.
side: SideThe side of the position (“Buy” for long, “Sell” for short).
Indicates the direction of the position. Bots use this to calculate exposure and hedge positions.
size: f64The size of the position (in contracts or base currency).
Represents the volume of the position. Bots monitor this to manage exposure and ensure it aligns with strategy limits.
entry_price: f64The average entry price of the position.
The price at which the position was opened. Bots use this to calculate unrealized PnL and set stop-loss/take-profit levels.
leverage: StringThe leverage used for the position (as a string, e.g., “10”).
Indicates the leverage multiplier (e.g., 10x). Higher leverage increases potential returns but also liquidation risk. Bots must adjust position sizes based on leverage to manage risk.
position_value: f64The total value of the position (in quote currency).
Calculated as size * entry price. Bots use this to assess exposure and margin requirements.
position_balance: f64The margin allocated to the position.
Represents the funds reserved for the position. Bots monitor this to ensure sufficient margin and avoid liquidation.
mark_price: f64The current mark price of the position.
The fair value of the asset, used for PnL and margin calculations. Bots use this to track unrealized PnL and liquidation risks.
position_im: StringThe initial margin requirement (as a string, e.g., “1000”).
The minimum margin needed to open the position. Bots use this to calculate capital requirements and optimize margin usage.
position_mm: StringThe maintenance margin requirement (as a string, e.g., “500”).
The minimum margin needed to maintain the position. Falling below this triggers liquidation. Bots must monitor this closely to avoid forced closures.
take_profit: f64The take-profit price for the position.
The price at which the position will automatically close for a profit. Bots can set this to lock in gains and automate exits.
stop_loss: f64The stop-loss price for the position.
The price at which the position will automatically close to limit losses. Bots use this to manage downside risk.
trailing_stop: Option<f64>The trailing stop price (optional).
A dynamic stop-loss that follows the market price. Bots can use this for trend-following strategies to lock in profits while allowing upside potential.
unrealised_pnl: StringThe unrealized profit and loss (as a string, e.g., “100.50”).
The current profit or loss based on the mark price. Bots use this to monitor performance and make real-time adjustments.
cum_realised_pnl: StringThe cumulative realized profit and loss (as a string, e.g., “500.75”).
The total profit or loss from closed portions of the position. Bots use this to track overall performance.
created_time: u64The timestamp when the position was created (in milliseconds).
Indicates when the position was opened. Bots use this for position aging and strategy timing.
updated_time: u64The timestamp when the position was last updated (in milliseconds).
Indicates the most recent change to the position. Bots use this to track updates and ensure data freshness.
tpsl_mode: StringThe take-profit/stop-loss mode (e.g., “Full” or “Partial”).
Specifies how TP/SL orders are applied. Bots must handle different modes to execute correct exit strategies.
liq_price: f64The liquidation price for the position.
The price at which the position will be forcibly closed due to insufficient margin. Bots must monitor this to avoid unexpected liquidations, especially in volatile markets.
bust_price: Option<f64>The bankruptcy price for the position (optional).
The price at which the position’s margin is completely depleted, leading to a total loss. This is critical for bots to monitor, as it represents the worst-case scenario. Bots should use this to set conservative stop-losses and avoid catastrophic losses.
category: StringThe category of the position (e.g., “linear” for USDT-margined futures).
Specifies the contract type. Bots must handle different categories (e.g., linear vs. inverse) due to differences in margin and settlement.
position_status: StringThe status of the position (e.g., “Normal”).
Indicates whether the position is active or in a special state (e.g., liquidation). Bots use this to filter active positions for management.
adl_rank_indicator: u8The auto-deleveraging (ADL) rank indicator (0-4).
Indicates the likelihood of the position being auto-deleveraged in extreme market conditions. Higher ranks mean higher risk. Bots should monitor this to reduce exposure in volatile markets.
auto_add_margin: u8Whether auto-margin addition is enabled (0 for disabled, 1 for enabled).
If enabled, Bybit automatically adds margin to prevent liquidation. Bots should account for this in margin management to avoid unexpected changes.
mmr_sys_updated_time: Option<u64>The timestamp when the maintenance margin rate was last updated (optional, in milliseconds).
Indicates when margin requirements changed. Bots can use this to track margin updates and adjust strategies.
leverage_sys_updated_time: Option<u64>The timestamp when the leverage was last updated (optional, in milliseconds).
Indicates when leverage settings changed. Bots should monitor this to ensure leverage aligns with risk parameters.
seq: u64The sequence number for the position update.
Used to ensure updates are processed in order. Bots should validate sequence numbers to avoid missing or duplicate updates.
is_reduce_only: boolWhether the position is reduce-only.
If true, the position can only reduce size (e.g., close trades). Bots must respect this to avoid placing invalid orders.
Trait Implementations§
Source§impl Clone for PositionData
impl Clone for PositionData
Source§fn clone(&self) -> PositionData
fn clone(&self) -> PositionData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more