fetch all open positions https://doc.xt.com/#futures_usergetPosition :param str [symbols]: list of unified market symbols, not supported with xt :param dict params: extra parameters specific to the xt api endpoint :returns dict[]: a list of `position struct
(self, symbols: Strings = None, params={})
| 4501 | return None |
| 4502 | |
| 4503 | def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]: |
| 4504 | """ |
| 4505 | fetch all open positions |
| 4506 | |
| 4507 | https://doc.xt.com/#futures_usergetPosition |
| 4508 | |
| 4509 | :param str [symbols]: list of unified market symbols, not supported with xt |
| 4510 | :param dict params: extra parameters specific to the xt api endpoint |
| 4511 | :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>` |
| 4512 | """ |
| 4513 | self.load_markets() |
| 4514 | subType = None |
| 4515 | subType, params = self.handle_sub_type_and_params('fetchPositions', None, params) |
| 4516 | response = None |
| 4517 | if subType == 'inverse': |
| 4518 | response = self.privateInverseGetFutureUserV1PositionList(params) |
| 4519 | else: |
| 4520 | response = self.privateLinearGetFutureUserV1PositionList(params) |
| 4521 | # |
| 4522 | # { |
| 4523 | # "returnCode": 0, |
| 4524 | # "msgInfo": "success", |
| 4525 | # "error": null, |
| 4526 | # "result": [ |
| 4527 | # { |
| 4528 | # "symbol": "btc_usdt", |
| 4529 | # "positionType": "ISOLATED", |
| 4530 | # "positionSide": "SHORT", |
| 4531 | # "contractType": "PERPETUAL", |
| 4532 | # "positionSize": "10", |
| 4533 | # "closeOrderSize": "0", |
| 4534 | # "availableCloseSize": "10", |
| 4535 | # "entryPrice": "27060", |
| 4536 | # "openOrderSize": "0", |
| 4537 | # "isolatedMargin": "1.0824", |
| 4538 | # "openOrderMarginFrozen": "0", |
| 4539 | # "realizedProfit": "-0.00130138", |
| 4540 | # "autoMargin": False, |
| 4541 | # "leverage": 25 |
| 4542 | # }, |
| 4543 | # ] |
| 4544 | # } |
| 4545 | # |
| 4546 | positions = self.safe_value(response, 'result', []) |
| 4547 | result = [] |
| 4548 | for i in range(0, len(positions)): |
| 4549 | entry = positions[i] |
| 4550 | marketId = self.safe_string(entry, 'symbol') |
| 4551 | marketInner = self.safe_market(marketId, None, None, 'contract') |
| 4552 | result.append(self.parse_position(entry, marketInner)) |
| 4553 | return self.filter_by_array_positions(result, 'symbol', symbols, False) |
| 4554 | |
| 4555 | def parse_position(self, position, market: Market = None): |
| 4556 | # |
no test coverage detected