(self, position: dict, market: Market = None)
| 1747 | return self.parse_positions(result, symbols) |
| 1748 | |
| 1749 | def parse_position(self, position: dict, market: Market = None): |
| 1750 | # |
| 1751 | # fetchPosition |
| 1752 | # |
| 1753 | # { |
| 1754 | # "entry_price":null, |
| 1755 | # "size":0, |
| 1756 | # "timestamp":1605454074268079 |
| 1757 | # } |
| 1758 | # |
| 1759 | # |
| 1760 | # fetchPositions |
| 1761 | # |
| 1762 | # { |
| 1763 | # "user_id": 0, |
| 1764 | # "size": 0, |
| 1765 | # "entry_price": "string", |
| 1766 | # "margin": "string", |
| 1767 | # "liquidation_price": "string", |
| 1768 | # "bankruptcy_price": "string", |
| 1769 | # "adl_level": 0, |
| 1770 | # "product_id": 0, |
| 1771 | # "product_symbol": "string", |
| 1772 | # "commission": "string", |
| 1773 | # "realized_pnl": "string", |
| 1774 | # "realized_funding": "string" |
| 1775 | # } |
| 1776 | # |
| 1777 | marketId = self.safe_string(position, 'product_symbol') |
| 1778 | market = self.safe_market(marketId, market) |
| 1779 | symbol = market['symbol'] |
| 1780 | timestamp = self.safe_integer_product(position, 'timestamp', 0.001) |
| 1781 | sizeString = self.safe_string(position, 'size') |
| 1782 | side = None |
| 1783 | if sizeString is not None: |
| 1784 | if Precise.string_gt(sizeString, '0'): |
| 1785 | side = 'buy' |
| 1786 | elif Precise.string_lt(sizeString, '0'): |
| 1787 | side = 'sell' |
| 1788 | return self.safe_position({ |
| 1789 | 'info': position, |
| 1790 | 'id': None, |
| 1791 | 'symbol': symbol, |
| 1792 | 'notional': None, |
| 1793 | 'marginMode': None, |
| 1794 | 'liquidationPrice': self.safe_number(position, 'liquidation_price'), |
| 1795 | 'entryPrice': self.safe_number(position, 'entry_price'), |
| 1796 | 'unrealizedPnl': None, # todo - realized_pnl ? |
| 1797 | 'percentage': None, |
| 1798 | 'contracts': self.parse_number(sizeString), |
| 1799 | 'contractSize': self.safe_number(market, 'contractSize'), |
| 1800 | 'markPrice': None, |
| 1801 | 'side': side, |
| 1802 | 'hedged': None, |
| 1803 | 'timestamp': timestamp, |
| 1804 | 'datetime': self.iso8601(timestamp), |
| 1805 | 'maintenanceMargin': None, |
| 1806 | 'maintenanceMarginPercentage': None, |
no test coverage detected