parse_position_status_report

Function parse_position_status_report 

Source
pub fn parse_position_status_report(
    position: OKXPosition,
    account_id: AccountId,
    instrument_id: InstrumentId,
    size_precision: u8,
    ts_init: UnixNanos,
) -> Result<PositionStatusReport>
Expand description

Parses an OKX position into a Nautilus [PositionStatusReport].

§Position Mode Handling

OKX returns position data differently based on the account’s position mode:

  • Net mode (posSide="net"): The pos field uses signed quantities where positive = long, negative = short. Position side is derived from the sign.

  • Long/Short mode (posSide="long" or "short"): The pos field is always positive regardless of side. Position side is determined from the posSide field. Position IDs are suffixed with -LONG or -SHORT for uniqueness.

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions

§Errors

Returns an error if any numeric fields cannot be parsed into their target types.

§Panics

Panics if position quantity is invalid and cannot be parsed.