(self, position: dict)
| 5266 | return self.markets |
| 5267 | |
| 5268 | def safe_position(self, position: dict): |
| 5269 | # simplified version of: /pull/12765/ |
| 5270 | unrealizedPnlString = self.safe_string(position, 'unrealisedPnl') |
| 5271 | initialMarginString = self.safe_string(position, 'initialMargin') |
| 5272 | # |
| 5273 | # PERCENTAGE |
| 5274 | # |
| 5275 | percentage = self.safe_value(position, 'percentage') |
| 5276 | if (percentage is None) and (unrealizedPnlString is not None) and (initialMarginString is not None): |
| 5277 | # was done in all implementations( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex ) |
| 5278 | percentageString = Precise.string_mul(Precise.string_div(unrealizedPnlString, initialMarginString, 4), '100') |
| 5279 | position['percentage'] = self.parse_number(percentageString) |
| 5280 | # if contractSize is None get from market |
| 5281 | contractSize = self.safe_number(position, 'contractSize') |
| 5282 | symbol = self.safe_string(position, 'symbol') |
| 5283 | market = None |
| 5284 | if symbol is not None: |
| 5285 | market = self.safe_value(self.markets, symbol) |
| 5286 | if contractSize is None and market is not None: |
| 5287 | contractSize = self.safe_number(market, 'contractSize') |
| 5288 | position['contractSize'] = contractSize |
| 5289 | return position |
| 5290 | |
| 5291 | def parse_positions(self, positions: List[Any], symbols: List[str] = None, params={}): |
| 5292 | symbols = self.market_symbols(symbols) |
no test coverage detected