(position: Dict, market: Market = undefined)
| 2353 | } |
| 2354 | |
| 2355 | parsePosition (position: Dict, market: Market = undefined) { |
| 2356 | // |
| 2357 | // { |
| 2358 | // "event_time": "1765258069092857642", |
| 2359 | // "sub_account_id": "2147050003876484", |
| 2360 | // "instrument": "BTC_USDT_Perp", |
| 2361 | // "size": "0.001", |
| 2362 | // "notional": "89.8169", |
| 2363 | // "entry_price": "90000.0", |
| 2364 | // "exit_price": "0.0", |
| 2365 | // "mark_price": "89816.900008979", |
| 2366 | // "unrealized_pnl": "-0.183099", |
| 2367 | // "realized_pnl": "0.0", |
| 2368 | // "total_pnl": "-0.183099", |
| 2369 | // "roi": "-0.2034", |
| 2370 | // "quote_index_price": "1.00017885", |
| 2371 | // "est_liquidation_price": "77951.450008979", |
| 2372 | // "leverage": "28.0", |
| 2373 | // "cumulative_fee": "-0.00009", |
| 2374 | // "cumulative_realized_funding_payment": "0.033862" |
| 2375 | // } |
| 2376 | // |
| 2377 | const marketId = this.safeString (position, 'instrument'); |
| 2378 | const timestamp = this.safeIntegerProduct (position, 'event_time', 0.000001); |
| 2379 | const sizeRaw = this.safeString (position, 'size'); |
| 2380 | const isLong = (Precise.stringGe (sizeRaw, '0')); |
| 2381 | const side = isLong ? 'long' : 'short'; |
| 2382 | return this.safePosition ({ |
| 2383 | 'info': position, |
| 2384 | 'id': undefined, |
| 2385 | 'symbol': this.safeSymbol (marketId, market), |
| 2386 | 'notional': this.parseNumber (Precise.stringAbs (this.safeString (position, 'notional'))), |
| 2387 | 'marginMode': undefined, |
| 2388 | 'liquidationPrice': this.safeNumber (position, 'est_liquidation_price'), |
| 2389 | 'entryPrice': this.safeNumber (position, 'entry_price'), |
| 2390 | 'unrealizedPnl': this.safeNumber (position, 'unrealized_pnl'), |
| 2391 | 'realizedPnl': this.safeNumber (position, 'realized_pnl'), |
| 2392 | 'percentage': undefined, |
| 2393 | 'contracts': this.parseNumber (Precise.stringAbs (sizeRaw)), |
| 2394 | 'markPrice': this.safeNumber (position, 'mark_price'), |
| 2395 | 'lastPrice': undefined, |
| 2396 | 'side': side, |
| 2397 | 'hedged': undefined, |
| 2398 | 'timestamp': timestamp, |
| 2399 | 'datetime': this.iso8601 (timestamp), |
| 2400 | 'lastUpdateTimestamp': this.safeInteger (position, 'lastUpdateTime'), |
| 2401 | 'maintenanceMargin': this.safeNumber (position, 'maintenanceMargin'), |
| 2402 | 'maintenanceMarginPercentage': undefined, |
| 2403 | 'collateral': undefined, |
| 2404 | 'initialMargin': this.safeNumber (position, 'initialMargin'), |
| 2405 | 'initialMarginPercentage': undefined, |
| 2406 | 'leverage': this.safeNumber (position, 'leverage'), |
| 2407 | 'marginRatio': undefined, |
| 2408 | 'stopLossPrice': undefined, |
| 2409 | 'takeProfitPrice': undefined, |
| 2410 | }); |
| 2411 | } |
| 2412 |
no test coverage detected