(position: Dict, market: Market = undefined)
| 2271 | } |
| 2272 | |
| 2273 | parsePosition (position: Dict, market: Market = undefined) { |
| 2274 | // |
| 2275 | // response similar for REST & WS |
| 2276 | // |
| 2277 | // { |
| 2278 | // instType: 'SWAP', |
| 2279 | // instId: 'LTC-USDT', |
| 2280 | // marginMode: 'cross', |
| 2281 | // positionId: '644159', |
| 2282 | // positionSide: 'net', |
| 2283 | // positions: '1', |
| 2284 | // availablePositions: '1', |
| 2285 | // averagePrice: '68.16', |
| 2286 | // unrealizedPnl: '0.80631223', |
| 2287 | // unrealizedPnlRatio: '0.03548909463028169', |
| 2288 | // leverage: '3', |
| 2289 | // liquidationPrice: '10.116655172370356435', |
| 2290 | // markPrice: '68.96', |
| 2291 | // initialMargin: '22.988770743333333333', |
| 2292 | // margin: '', // this field might not exist in rest response |
| 2293 | // marginRatio: '152.523509620342499273', |
| 2294 | // maintenanceMargin: '0.34483156115', |
| 2295 | // adl: '4', |
| 2296 | // createTime: '1707235776528', |
| 2297 | // updateTime: '1707235776528' |
| 2298 | // } |
| 2299 | // |
| 2300 | // |
| 2301 | // positions-history |
| 2302 | // |
| 2303 | // { |
| 2304 | // "positionId": "1000000722711", |
| 2305 | // "instId": "BTC-USDT", |
| 2306 | // "instType": "SWAP", |
| 2307 | // "marginMode": "cross", |
| 2308 | // "positionSide": "net", |
| 2309 | // "createTime": "1777995583329", |
| 2310 | // "updateTime": "1777995588333", |
| 2311 | // "leverage": "50", |
| 2312 | // "realizedPnl": "-0.058776036", |
| 2313 | // "realizedPnlRatio": "-0.060061275216094155", |
| 2314 | // "fee": "-0.058716036" |
| 2315 | // "historyId": "110307402", |
| 2316 | // "closePositions": "0.0006", |
| 2317 | // "maxPositions": "0.0006", |
| 2318 | // "liquidationPositions": "0", |
| 2319 | // "openAveragePrice": "81550.1", |
| 2320 | // "closeAveragePrice": "81550", |
| 2321 | // }, |
| 2322 | // |
| 2323 | const marketId = this.safeString (position, 'instId'); |
| 2324 | market = this.safeMarket (marketId, market); |
| 2325 | const symbol = market['symbol']; |
| 2326 | const pos = this.safeString (position, 'positions'); |
| 2327 | const contractsAbs = Precise.stringAbs (pos); |
| 2328 | let side = this.safeString (position, 'positionSide'); |
| 2329 | const hedged = side !== 'net'; |
| 2330 | const contracts = this.parseNumber (contractsAbs); |
no test coverage detected