MCPcopy Create free account
hub / github.com/ccxt/ccxt / parsePosition

Method parsePosition

ts/src/woo.ts:3886–3990  ·  view source on GitHub ↗
(position: Dict, market: Market = undefined)

Source from the content-addressed store, hash-verified

3884 }
3885
3886 parsePosition (position: Dict, market: Market = undefined) {
3887 //
3888 // v1PrivateGetPositionSymbol
3889 // {
3890 // "symbol": "PERP_ETH_USDT",
3891 // "position_side": "BOTH",
3892 // "leverage": 10,
3893 // "margin_mode": "CROSS",
3894 // "average_open_price": 3139.9,
3895 // "isolated_margin_amount": 0.0,
3896 // "isolated_margin_token": "",
3897 // "opening_time": "1720627963.094",
3898 // "mark_price": 3155.19169891,
3899 // "pending_short_qty": 0.0,
3900 // "pending_long_qty": 0.0,
3901 // "holding": -0.7,
3902 // "pnl_24_h": 0.0,
3903 // "est_liq_price": 9107.40055552,
3904 // "settle_price": 3151.0319904,
3905 // "success": true,
3906 // "fee_24_h": 0.0,
3907 // "isolated_frozen_long": 0.0,
3908 // "isolated_frozen_short": 0.0,
3909 // "timestamp": "1720867502.544"
3910 // }
3911 //
3912 // v3PrivateGetPositions
3913 // {
3914 // "symbol": "PERP_LTC_USDT",
3915 // "holding": "0.1",
3916 // "pendingLongQty": "0",
3917 // "pendingShortQty": "0",
3918 // "settlePrice": "96.87",
3919 // "averageOpenPrice": "96.87",
3920 // "pnl24H": "0",
3921 // "fee24H": "0.0048435",
3922 // "markPrice": "96.83793449",
3923 // "estLiqPrice": "0",
3924 // "timestamp": 1752500555823,
3925 // "adlQuantile": 2,
3926 // "positionSide": "BOTH",
3927 // "marginMode": "CROSS",
3928 // "isolatedMarginToken": "",
3929 // "isolatedMarginAmount": "0",
3930 // "isolatedFrozenLong": "0",
3931 // "isolatedFrozenShort": "0",
3932 // "leverage": 10
3933 // }
3934 //
3935 const contract = this.safeString (position, 'symbol');
3936 market = this.safeMarket (contract, market);
3937 let size = this.safeString (position, 'holding');
3938 let side: Str = undefined;
3939 if (Precise.stringGt (size, '0')) {
3940 side = 'long';
3941 } else {
3942 side = 'short';
3943 }

Callers 2

fetchPositionMethod · 0.95
handlePositionsMethod · 0.95

Calls 15

safeStringMethod · 0.45
safeMarketMethod · 0.45
stringGtMethod · 0.45
safeString2Method · 0.45
safeTimestampMethod · 0.45
safeIntegerMethod · 0.45
stringSubMethod · 0.45
stringMulMethod · 0.45
stringAbsMethod · 0.45
safePositionMethod · 0.45
iso8601Method · 0.45
parseNumberMethod · 0.45

Tested by

no test coverage detected