fetch data on a single open contract trade position https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/international-derivatives/get-perpetuals-position https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/us-derivatives/get-futures-p
(self, symbol: str, params={})
| 4554 | return self.parse_positions(positions, symbols) |
| 4555 | |
| 4556 | def fetch_position(self, symbol: str, params={}): |
| 4557 | """ |
| 4558 | fetch data on a single open contract trade position |
| 4559 | |
| 4560 | https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/international-derivatives/get-perpetuals-position |
| 4561 | https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/us-derivatives/get-futures-position |
| 4562 | |
| 4563 | :param str symbol: unified market symbol of the market the position is held in, default is None |
| 4564 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 4565 | :param str [params.product_id]: *futures only* the product id of the position to fetch, required for futures markets only |
| 4566 | :param str [params.portfolio]: *perpetual/swaps only* the portfolio UUID to fetch the position for, required for perpetual/swaps markets only |
| 4567 | :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>` |
| 4568 | """ |
| 4569 | self.load_markets() |
| 4570 | market = self.market(symbol) |
| 4571 | response = None |
| 4572 | if market['future']: |
| 4573 | productId = self.safe_string(market, 'product_id') |
| 4574 | if productId is None: |
| 4575 | raise ArgumentsRequired(self.id + ' fetchPosition() requires a "product_id" in params') |
| 4576 | futureRequest = { |
| 4577 | 'product_id': productId, |
| 4578 | } |
| 4579 | response = self.v3PrivateGetBrokerageCfmPositionsProductId(self.extend(futureRequest, params)) |
| 4580 | else: |
| 4581 | portfolio = None |
| 4582 | portfolio, params = self.handle_option_and_params(params, 'fetchPositions', 'portfolio') |
| 4583 | if portfolio is None: |
| 4584 | raise ArgumentsRequired(self.id + ' fetchPosition() requires a "portfolio" value in params(eg: dbcb91e7-2bc9-515), or set.options["portfolio"]. You can get a list of portfolios with fetchPortfolios()') |
| 4585 | request = { |
| 4586 | 'symbol': market['id'], |
| 4587 | 'portfolio_uuid': portfolio, |
| 4588 | } |
| 4589 | response = self.v3PrivateGetBrokerageIntxPositionsPortfolioUuidSymbol(self.extend(request, params)) |
| 4590 | position = self.safe_dict(response, 'position', {}) |
| 4591 | return self.parse_position(position, market) |
| 4592 | |
| 4593 | def parse_position(self, position: dict, market: Market = None): |
| 4594 | # |
nothing calls this directly
no test coverage detected