Skip to content

Commit 417a081

Browse files
committed
Fix IndexError in fetch_positions for Hyperliquid when no pair specified
## Summary Fix IndexError crash in fetch_positions() when initializing wallets on Hyperliquid exchange. ## Quick changelog - Changed fetch_positions to pass None instead of empty list when no specific pair is requested - Fixes compatibility with Hyperliquid CCXT implementation that expects None for all positions ## What's new? When fetch_positions() is called without a specific pair parameter, the code was passing an empty list [] to the CCXT API. For Hyperliquid exchange, this causes an IndexError because the exchange's implementation attempts to access symbols[0] without checking if the list is empty. The CCXT standard is to pass None (not an empty list) when requesting all positions. This change aligns the code with the CCXT API convention and prevents the crash on Hyperliquid during wallet initialization. Error that was occurring: ``` IndexError: list index out of range at /root/freqtrade/.venv/lib/python3.11/site-packages/ccxt/hyperliquid.py:3051 market = self.market(symbols[0]) ``` This change does not use AI-generated code.
1 parent 262f4ff commit 417a081

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

freqtrade/exchange/exchange.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,9 +1834,9 @@ def fetch_positions(self, pair: str | None = None) -> list[CcxtPosition]:
18341834
if self._config["dry_run"] or self.trading_mode != TradingMode.FUTURES:
18351835
return []
18361836
try:
1837-
symbols = []
1837+
symbols = None
18381838
if pair:
1839-
symbols.append(pair)
1839+
symbols = [pair]
18401840
positions: list[CcxtPosition] = self._api.fetch_positions(symbols)
18411841
self._log_exchange_response("fetch_positions", positions)
18421842
return positions

0 commit comments

Comments
 (0)