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

Method parse_position

python/ccxt/paradex.py:2261–2315  ·  view source on GitHub ↗
(self, position: dict, market: Market = None)

Source from the content-addressed store, hash-verified

2259 return self.parse_positions(data, symbols)
2260
2261 def parse_position(self, position: dict, market: Market = None):
2262 #
2263 # {
2264 # "id": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3-BTC-USD-PERP",
2265 # "market": "BTC-USD-PERP",
2266 # "status": "OPEN",
2267 # "side": "LONG",
2268 # "size": "0.01",
2269 # "average_entry_price": "64839.96053748",
2270 # "average_entry_price_usd": "64852.9",
2271 # "realized_pnl": "0",
2272 # "unrealized_pnl": "-2.39677214",
2273 # "unrealized_funding_pnl": "-0.11214013",
2274 # "cost": "648.39960537",
2275 # "cost_usd": "648.529",
2276 # "cached_funding_index": "35202.1002351",
2277 # "last_updated_at": 1718950074249,
2278 # "last_fill_id": "1718947571560201703986670001",
2279 # "seq_no": 1718950074249176253,
2280 # "liquidation_price": ""
2281 # }
2282 #
2283 marketId = self.safe_string(position, 'market')
2284 market = self.safe_market(marketId, market)
2285 symbol = market['symbol']
2286 side = self.safe_string_lower(position, 'side')
2287 quantity = self.safe_string(position, 'size')
2288 if side != 'long':
2289 quantity = Precise.string_mul('-1', quantity)
2290 timestamp = self.safe_integer(position, 'time')
2291 return self.safe_position({
2292 'info': position,
2293 'id': self.safe_string(position, 'id'),
2294 'symbol': symbol,
2295 'entryPrice': self.safe_string(position, 'average_entry_price'),
2296 'markPrice': None,
2297 'notional': None,
2298 'collateral': self.safe_string(position, 'cost'),
2299 'unrealizedPnl': self.safe_string(position, 'unrealized_pnl'),
2300 'side': side,
2301 'contracts': self.parse_number(quantity),
2302 'contractSize': None,
2303 'timestamp': timestamp,
2304 'datetime': self.iso8601(timestamp),
2305 'hedged': None,
2306 'maintenanceMargin': None,
2307 'maintenanceMarginPercentage': None,
2308 'initialMargin': None,
2309 'initialMarginPercentage': None,
2310 'leverage': None,
2311 'liquidationPrice': None,
2312 'marginRatio': None,
2313 'marginMode': None,
2314 'percentage': None,
2315 })
2316
2317 def fetch_my_liquidations(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Liquidation]:
2318 """

Callers

nothing calls this directly

Calls 8

safe_stringMethod · 0.80
safe_string_lowerMethod · 0.80
string_mulMethod · 0.80
safe_integerMethod · 0.80
safe_positionMethod · 0.80
parse_numberMethod · 0.80
safe_marketMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected