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

Method fetch_positions

python/ccxt/pacifica.py:2293–2335  ·  view source on GitHub ↗

fetch all open positions https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-positions :param str[] [symbols]: list of unified market symbols :param dict [params]: extra parameters specific to the exchange API endpoint :param str [params.acc

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

Source from the content-addressed store, hash-verified

2291 return self.safe_dict(positions, 0, {})
2292
2293 def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2294 """
2295 fetch all open positions
2296
2297 https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-positions
2298
2299 :param str[] [symbols]: list of unified market symbols
2300 :param dict [params]: extra parameters specific to the exchange API endpoint
2301 :param str [params.account]: will default to walletAddress if not provided
2302 :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>`
2303 """
2304 self.load_markets()
2305 userAddress = None
2306 userAddress, params = self.handle_origin_and_single_address('fetchPositions', params)
2307 symbols = self.market_symbols(symbols)
2308 request = {
2309 'account': userAddress,
2310 }
2311 response = self.publicGetPositions(self.extend(request, params))
2312 # {
2313 # "success": True,
2314 # "data": [
2315 # {
2316 # "symbol": "AAVE",
2317 # "side": "ask",
2318 # "amount": "223.72",
2319 # "entry_price": "279.283134",
2320 # "margin": "0", # only shown for isolated margin
2321 # "funding": "13.159593",
2322 # "isolated": False,
2323 # "created_at": 1754928414996,
2324 # "updated_at": 1759223365538
2325 # }
2326 # ],
2327 # "error": null,
2328 # "code": null,
2329 # "last_order_id": 1557431179
2330 # }
2331 data = self.safe_list(response, 'data', [])
2332 result = []
2333 for i in range(0, len(data)):
2334 result.append(self.parse_position(data[i], None))
2335 return self.filter_by_array_positions(result, 'symbol', symbols, False)
2336
2337 def parse_position(self, position: dict, market: Market = None):
2338 #

Callers 1

fetch_positionMethod · 0.95

Calls 10

parse_positionMethod · 0.95
market_symbolsMethod · 0.80
safe_listMethod · 0.80
publicGetPositionsMethod · 0.65
rangeFunction · 0.50
load_marketsMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected