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

Method fetch_option_positions

python/ccxt/binance.py:10386–10438  ·  view source on GitHub ↗

fetch data on open options positions https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information :param str[]|None symbols: list of unified market symbols :param dict [params]: extra parameters specific to the exchange API endpoint

(self, symbols: Strings = None, params={})

Source from the content-addressed store, hash-verified

10384 return self.parse_option_position(response[0], market)
10385
10386 def fetch_option_positions(self, symbols: Strings = None, params={}):
10387 """
10388 fetch data on open options positions
10389
10390 https://developers.binance.com/docs/derivatives/option/trade/Option-Position-Information
10391
10392 :param str[]|None symbols: list of unified market symbols
10393 :param dict [params]: extra parameters specific to the exchange API endpoint
10394 :returns dict[]: a list of `position structures <https://docs.ccxt.com/?id=position-structure>`
10395 """
10396 self.load_markets()
10397 symbols = self.market_symbols(symbols)
10398 request = {}
10399 market = None
10400 if symbols is not None:
10401 symbol = None
10402 if isinstance(symbols, list):
10403 symbolsLength = len(symbols)
10404 if symbolsLength > 1:
10405 raise BadRequest(self.id + ' fetchPositions() symbols argument cannot contain more than 1 symbol')
10406 symbol = symbols[0]
10407 else:
10408 symbol = symbols
10409 market = self.market(symbol)
10410 request['symbol'] = market['id']
10411 response = self.eapiPrivateGetPosition(self.extend(request, params))
10412 #
10413 # [
10414 # {
10415 # "entryPrice": "27.70000000",
10416 # "symbol": "ETH-230426-1850-C",
10417 # "side": "LONG",
10418 # "quantity": "0.50000000",
10419 # "reducibleQty": "0.50000000",
10420 # "markValue": "10.250000000",
10421 # "ror": "-0.2599",
10422 # "unrealizedPNL": "-3.600000000",
10423 # "markPrice": "20.5",
10424 # "strikePrice": "1850.00000000",
10425 # "positionCost": "13.85000000",
10426 # "expiryDate": 1682496000000,
10427 # "priceScale": 1,
10428 # "quantityScale": 2,
10429 # "optionSide": "CALL",
10430 # "quoteAsset": "USDT",
10431 # "time": 1682492427106
10432 # }
10433 # ]
10434 #
10435 result = []
10436 for i in range(0, len(response)):
10437 result.append(self.parse_option_position(response[i], market))
10438 return self.filter_by_array_positions(result, 'symbol', symbols, False)
10439
10440 def parse_option_position(self, position: dict, market: Market = None):
10441 #

Callers 1

fetch_positionsMethod · 0.95

Calls 10

marketMethod · 0.95
parse_option_positionMethod · 0.95
BadRequestClass · 0.90
market_symbolsMethod · 0.80
rangeFunction · 0.50
load_marketsMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected