Skip to main content

Position

Struct Position 

Source
pub struct Position {
Show 35 fields pub position_idx: PositionIdx, pub risk_id: i64, pub risk_limit_value: Option<Decimal>, pub symbol: String, pub side: Option<Side>, pub size: Decimal, pub avg_price: Decimal, pub position_value: Option<Decimal>, pub auto_add_margin: bool, pub position_status: PositionStatus, pub leverage: Decimal, pub mark_price: Decimal, pub liq_price: Option<Decimal>, pub position_im: Option<Decimal>, pub position_im_by_mp: Option<Decimal>, pub position_mm: Option<Decimal>, pub position_mm_by_mp: Option<Decimal>, pub take_profit: Option<Decimal>, pub stop_loss: Option<Decimal>, pub trailing_stop: Option<Decimal>, pub session_avg_price: Option<Decimal>, pub delta: Option<String>, pub gamma: Option<String>, pub vega: Option<String>, pub theta: Option<String>, pub unrealised_pnl: Option<Decimal>, pub cur_realised_pnl: Decimal, pub cum_realised_pnl: Decimal, pub adl_rank_indicator: AdlRankIndicator, pub created_time: Timestamp, pub updated_time: Timestamp, pub seq: i64, pub is_reduce_only: bool, pub mmr_sys_updated_time: Option<Timestamp>, pub leverage_sys_updated_time: Option<Timestamp>,
}

Fields§

§position_idx: PositionIdx

Position idx, used to identify positions in different position modes 0: One-Way Mode 1: Buy side of both side mode 2: Sell side of both side mode

§risk_id: i64

Risk tier ID for portfolio margin mode, this field returns 0, which means risk limit rules are invalid

§risk_limit_value: Option<Decimal>

Risk limit value for portfolio margin mode, this field returns 0, which means risk limit rules are invalid

§symbol: String

Symbol name

§side: Option<Side>

Position side. Buy: long, Sell: short one-way mode: classic & UTA1.0(inverse), an empty position returns None. UTA2.0(linear, inverse) & UTA1.0(linear): either one-way or hedge mode returns an empty string “” for an empty position.

§size: Decimal

Position size, always positive

§avg_price: Decimal

Average entry price For USDC Perp & Futures, it indicates average entry price, and it will not be changed with 8-hour session settlement

§position_value: Option<Decimal>

Position value

§auto_add_margin: bool

Whether to add margin automatically when using isolated margin mode 0: false 1: true

§position_status: PositionStatus

Position status. Normal, Liq, Adl

§leverage: Decimal

Position leverage for portfolio margin mode, this field returns “”, which means leverage rules are invalid

§mark_price: Decimal

Mark price

§liq_price: Option<Decimal>

Position liquidation price UTA2.0(isolated margin), UTA1.0(isolated margin), UTA1.0(inverse), Classic account: it is the real price for isolated and cross positions, and keeps “” when liqPrice <= minPrice or liqPrice >= maxPrice UTA2.0(Cross margin), UTA1.0(Cross margin): it is an estimated price for cross positions(because the unified mode controls the risk rate according to the account), and keeps “” when liqPrice <= minPrice or liqPrice >= maxPrice this field is empty for Portfolio Margin Mode, and no liquidation price will be provided

§position_im: Option<Decimal>

Initial margin Classic & UTA1.0(inverse): ignore this field UTA portfolio margin mode, it returns “”

§position_im_by_mp: Option<Decimal>

Initial margin calculated by mark price Classic & UTA1.0(inverse) : ignore this field UTA portfolio margin mode, it returns “”

§position_mm: Option<Decimal>

Maintenance margin Classic & UTA1.0(inverse): ignore this field UTA portfolio margin mode, it returns “”

§position_mm_by_mp: Option<Decimal>

Maintenance margin calculated by mark price Classic & UTA1.0(inverse) : ignore this field UTA portfolio margin mode, it returns “”

§take_profit: Option<Decimal>

Take profit price

§stop_loss: Option<Decimal>

Stop loss price

§trailing_stop: Option<Decimal>

Trailing stop (The distance from market price)

§session_avg_price: Option<Decimal>

USDC contract session avg price, it is the same figure as avg entry price shown in the web UI

§delta: Option<String>

Delta

§gamma: Option<String>

Gamma

§vega: Option<String>

Vega

§theta: Option<String>

Theta

§unrealised_pnl: Option<Decimal>

Unrealised PnL

§cur_realised_pnl: Decimal

The realised PnL for the current holding position

§cum_realised_pnl: Decimal

Cumulative realised pnl Futures & Perpetuals: it is the all time cumulative realised P&L Option: always “”, meaningless

§adl_rank_indicator: AdlRankIndicator

Auto-deleverage rank indicator. What is Auto-Deleveraging?

§created_time: Timestamp

Timestamp of the first time a position was created on this symbol (ms)

§updated_time: Timestamp

Position updated timestamp (ms)

§seq: i64

Cross sequence, used to associate each fill and each position update Different symbols may have the same seq, please use seq + symbol to check unique Returns “-1” if the symbol has never been traded Returns the seq updated by the last transaction when there are settings like leverage, risk limit

§is_reduce_only: bool

Useful when Bybit lower the risk limit true: Only allowed to reduce the position. You can consider a series of measures, e.g., lower the risk limit, decrease leverage or reduce the position, add margin, or cancel orders, after these operations, you can call confirm new risk limit endpoint to check if your position can be removed the reduceOnly mark false: There is no restriction, and it means your position is under the risk when the risk limit is systematically adjusted Only meaningful for isolated margin & cross margin of USDT Perp, USDC Perp, USDC Futures, Inverse Perp and Inverse Futures, meaningless for others

§mmr_sys_updated_time: Option<Timestamp>

Useful when Bybit lower the risk limit When isReduceOnly=true: the timestamp (ms) when the MMR will be forcibly adjusted by the system When isReduceOnly=false: the timestamp when the MMR had been adjusted by system It returns the timestamp when the system operates, and if you manually operate, there is no timestamp Keeps “” by default, if there was a lower risk limit system adjustment previously, it shows that system operation timestamp Only meaningful for isolated margin & cross margin of USDT Perp, USDC Perp, USDC Futures, Inverse Perp and Inverse Futures, meaningless for others

§leverage_sys_updated_time: Option<Timestamp>

Useful when Bybit lower the risk limit When isReduceOnly=true: the timestamp (ms) when the leverage will be forcibly adjusted by the system When isReduceOnly=false: the timestamp when the leverage had been adjusted by system It returns the timestamp when the system operates, and if you manually operate, there is no timestamp Keeps “” by default, if there was a lower risk limit system adjustment previously, it shows that system operation timestamp Only meaningful for isolated margin & cross margin of USDT Perp, USDC Perp, USDC Futures, Inverse Perp and Inverse Futures, meaningless for others

Implementations§

Source§

impl Position

Source

pub fn update(&mut self, msg: PositionMsg)

Source

pub fn update_with_a_wallet_coin(&mut self, msg: &WalletCoin)

Trait Implementations§

Source§

impl Debug for Position

Source§

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

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

impl<'de> Deserialize<'de> for Position

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 PartialEq for Position

Source§

fn eq(&self, other: &Position) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Position

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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