MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetch_position

Method fetch_position

python/ccxt/kucoin.py:9508–9606  ·  view source on GitHub ↗

https://www.kucoin.com/docs-new/rest/futures-trading/positions/get-position-details https://www.kucoin.com/docs-new/rest/ua/get-position-list-uta fetch data on an open position :param str symbol: unified market symbol of the market the position is held in :

(self, symbol: str, params={})

Source from the content-addressed store, hash-verified

9506 return fees
9507
9508 def fetch_position(self, symbol: str, params={}):
9509 """
9510
9511 https://www.kucoin.com/docs-new/rest/futures-trading/positions/get-position-details
9512 https://www.kucoin.com/docs-new/rest/ua/get-position-list-uta
9513
9514 fetch data on an open position
9515 :param str symbol: unified market symbol of the market the position is held in
9516 :param dict [params]: extra parameters specific to the exchange API endpoint
9517 :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
9518 :param integer [params.pageSize]: *uta only* page size for the uta endpoint(default 50, max 200)
9519 :param integer [params.pageNumber]: *uta only* page number for the uta endpoint(default 1)
9520 :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>`
9521 """
9522 self.load_markets()
9523 market = self.market(symbol)
9524 request = {
9525 'symbol': market['id'],
9526 }
9527 uta = self.is_uta_enabled()
9528 uta, params = self.handle_option_and_params(params, 'fetchPosition', 'uta', uta)
9529 response = None
9530 position = None
9531 if uta:
9532 request['accountMode'] = 'unified'
9533 response = self.utaPrivateGetAccountModePositionOpenList(self.extend(request, params))
9534 #
9535 # {
9536 # "code": "200000",
9537 # "data": [
9538 # {
9539 # "symbol": "DOGEUSDTM",
9540 # "id": "30000000000084351",
9541 # "marginMode": "CROSS",
9542 # "size": "2",
9543 # "entryPrice": "0.093795",
9544 # "positionValue": "18.298",
9545 # "markPrice": "0.09149",
9546 # "leverage": "3",
9547 # "unrealizedPnL": "-0.461",
9548 # "realizedPnL": "-0.01122489",
9549 # "initialMargin": "6.0993333327234",
9550 # "mmr": "0.007",
9551 # "maintenanceMargin": "0.128086",
9552 # "creationTime": 1774469753178000000
9553 # }
9554 # ]
9555 # }
9556 #
9557 data = self.safe_list(response, 'data', [])
9558 position = self.safe_dict(data, 0, {})
9559 else:
9560 response = self.futuresPrivateGetPosition(self.extend(request, params))
9561 #
9562 # {
9563 # "code": "200000",
9564 # "data": {
9565 # "id": "6505ee6eaff4070001f651c4",

Callers

nothing calls this directly

Calls 10

is_uta_enabledMethod · 0.95
parse_positionMethod · 0.95
safe_listMethod · 0.80
safe_dictMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected