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

Method parse_position

python/ccxt/bullish.py:2438–2492  ·  view source on GitHub ↗
(self, position: dict, market: Market = None)

Source from the content-addressed store, hash-verified

2436 return self.filter_by_array_positions(results, 'symbol', symbols, False)
2437
2438 def parse_position(self, position: dict, market: Market = None):
2439 #
2440 # [
2441 # {
2442 # "tradingAccountId": "111000000000001",
2443 # "symbol": "BTC-USDC-PERP",
2444 # "side": "BUY",
2445 # "quantity": "1.00000000",
2446 # "notional": "1.0000",
2447 # "entryNotional": "1.0000",
2448 # "mtmPnl": "1.0000",
2449 # "reportedMtmPnl": "1.0000",
2450 # "reportedFundingPnl": "1.0000",
2451 # "realizedPnl": "1.0000",
2452 # "settlementAssetSymbol": "USDC",
2453 # "createdAtDatetime": "2021-05-20T01:01:01.000Z",
2454 # "createdAtTimestamp": "1621490985000",
2455 # "updatedAtDatetime": "2021-05-20T01:01:01.000Z",
2456 # "updatedAtTimestamp": "1621490985000"
2457 # }
2458 # ]
2459 #
2460 market = self.safe_market(self.safe_string(position, 'symbol'), market)
2461 symbol = market['symbol']
2462 timestamp = self.safe_integer(position, 'createdAtTimestamp')
2463 side = self.safe_string(position, 'side')
2464 return self.safe_position({
2465 'info': position,
2466 'id': None,
2467 'symbol': symbol,
2468 'timestamp': timestamp,
2469 'datetime': self.iso8601(timestamp),
2470 'lastUpdateTimestamp': self.safe_integer(position, 'updatedAtTimestamp'),
2471 'hedged': None,
2472 'side': self.parse_position_side(side),
2473 'contracts': self.safe_number(position, 'quantity'),
2474 'contractSize': None,
2475 'entryPrice': None,
2476 'markPrice': None,
2477 'lastPrice': None,
2478 'notional': self.safe_number(position, 'notional'),
2479 'leverage': None,
2480 'collateral': None,
2481 'initialMargin': None,
2482 'initialMarginPercentage': None,
2483 'maintenanceMargin': None,
2484 'maintenanceMarginPercentage': None,
2485 'unrealizedPnl': None,
2486 'liquidationPrice': None,
2487 'marginMode': None,
2488 'marginRatio': None,
2489 'percentage': None,
2490 'stopLossPrice': None,
2491 'takeProfitPrice': None,
2492 })
2493
2494 def parse_position_side(self, side: Str):
2495 sides = {

Callers

nothing calls this directly

Calls 7

parse_position_sideMethod · 0.95
safe_stringMethod · 0.80
safe_integerMethod · 0.80
safe_positionMethod · 0.80
safe_numberMethod · 0.80
safe_marketMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected