fetch all open positions https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary :param str[] [symbols]: list of unified market symbols :param dict [params]: extra parameters specific to
(self, symbols: Strings = None, params={})
| 3385 | return dexName |
| 3386 | |
| 3387 | def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]: |
| 3388 | """ |
| 3389 | fetch all open positions |
| 3390 | |
| 3391 | https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary |
| 3392 | |
| 3393 | :param str[] [symbols]: list of unified market symbols |
| 3394 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 3395 | :param str [params.user]: user address, will default to self.walletAddress if not provided |
| 3396 | :param str [params.subAccountAddress]: sub account user address |
| 3397 | :param str [params.dex]: perp dex name, eg: XYZ |
| 3398 | :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>` |
| 3399 | """ |
| 3400 | self.load_markets() |
| 3401 | userAddress = None |
| 3402 | userAddress, params = self.handle_public_address('fetchPositions', params) |
| 3403 | symbols = self.market_symbols(symbols) |
| 3404 | request = { |
| 3405 | 'type': 'clearinghouseState', |
| 3406 | 'user': userAddress, |
| 3407 | } |
| 3408 | dexName = self.get_dex_from_symbols('fetchPositions', symbols) |
| 3409 | if dexName is not None: |
| 3410 | request['dex'] = dexName |
| 3411 | response = self.publicPostInfo(self.extend(request, params)) |
| 3412 | # |
| 3413 | # { |
| 3414 | # "assetPositions": [ |
| 3415 | # { |
| 3416 | # "position": { |
| 3417 | # "coin": "ETH", |
| 3418 | # "cumFunding": { |
| 3419 | # "allTime": "0.0", |
| 3420 | # "sinceChange": "0.0", |
| 3421 | # "sinceOpen": "0.0" |
| 3422 | # }, |
| 3423 | # "entryPx": "2213.9", |
| 3424 | # "leverage": { |
| 3425 | # "rawUsd": "-475.23904", |
| 3426 | # "type": "isolated", |
| 3427 | # "value": "20" |
| 3428 | # }, |
| 3429 | # "liquidationPx": "2125.00856238", |
| 3430 | # "marginUsed": "24.88097", |
| 3431 | # "maxLeverage": "50", |
| 3432 | # "positionValue": "500.12001", |
| 3433 | # "returnOnEquity": "0.0", |
| 3434 | # "szi": "0.2259", |
| 3435 | # "unrealizedPnl": "0.0" |
| 3436 | # }, |
| 3437 | # "type": "oneWay" |
| 3438 | # } |
| 3439 | # ], |
| 3440 | # "crossMaintenanceMarginUsed": "0.0", |
| 3441 | # "crossMarginSummary": { |
| 3442 | # "accountValue": "100.0", |
| 3443 | # "totalMarginUsed": "0.0", |
| 3444 | # "totalNtlPos": "0.0", |
no test coverage detected