fetch all open positions https://docs.dydx.xyz/indexer-client/http#list-positions :param str[] [symbols]: list of unified market symbols :param dict [params]: extra parameters specific to the exchange API endpoint :param str [params.address]: wallet address
(self, symbols: Strings = None, params={})
| 1110 | return self.safe_dict(positions, 0, {}) |
| 1111 | |
| 1112 | def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]: |
| 1113 | """ |
| 1114 | fetch all open positions |
| 1115 | |
| 1116 | https://docs.dydx.xyz/indexer-client/http#list-positions |
| 1117 | |
| 1118 | :param str[] [symbols]: list of unified market symbols |
| 1119 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1120 | :param str [params.address]: wallet address that made trades |
| 1121 | :param str [params.subAccountNumber]: sub account number |
| 1122 | :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>` |
| 1123 | """ |
| 1124 | userAddress = None |
| 1125 | subAccountNumber = None |
| 1126 | userAddress, params = self.handle_public_address('fetchPositions', params) |
| 1127 | subAccountNumber, params = self.handle_option_and_params(params, 'fetchOrders', 'subAccountNumber', '0') |
| 1128 | self.load_markets() |
| 1129 | request = { |
| 1130 | 'address': userAddress, |
| 1131 | 'subaccountNumber': subAccountNumber, |
| 1132 | 'status': 'OPEN', # ['OPEN', 'CLOSED', 'LIQUIDATED'] |
| 1133 | } |
| 1134 | response = self.indexerGetPerpetualPositions(self.extend(request, params)) |
| 1135 | # |
| 1136 | # { |
| 1137 | # "positions": [ |
| 1138 | # { |
| 1139 | # "market": "BTC-USD", |
| 1140 | # "status": "OPEN", |
| 1141 | # "side": "SHORT", |
| 1142 | # "size": "-0.407", |
| 1143 | # "maxSize": "-0.009", |
| 1144 | # "entryPrice": "118692.04840909090909090909", |
| 1145 | # "exitPrice": "119526.565625", |
| 1146 | # "realizedPnl": "476.42665909090909090909088", |
| 1147 | # "unrealizedPnl": "-57.26681734000000000000037", |
| 1148 | # "createdAt": "2025-07-14T07:53:55.631Z", |
| 1149 | # "createdAtHeight": "44140908", |
| 1150 | # "closedAt": null, |
| 1151 | # "sumOpen": "0.44", |
| 1152 | # "sumClose": "0.032", |
| 1153 | # "netFunding": "503.13121", |
| 1154 | # "subaccountNumber": 0 |
| 1155 | # } |
| 1156 | # ] |
| 1157 | # } |
| 1158 | # |
| 1159 | rows = self.safe_list(response, 'positions', []) |
| 1160 | return self.parse_positions(rows, symbols) |
| 1161 | |
| 1162 | def hash_message(self, message): |
| 1163 | return self.hash(message, 'keccak', 'hex') |
no test coverage detected