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"): Theposfield uses signed quantities where positive = long, negative = short. Position side is derived from the sign. -
Long/Short mode (
posSide="long"or"short"): Theposfield is always positive regardless of side. Position side is determined from theposSidefield. Position IDs are suffixed with-LONGor-SHORTfor 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.