Fix KeyError for prefixed coins in historical candle fetch

Bypass SDK's name_to_coin lookup in candles_snapshot by calling
http_info.post directly with the raw coin name. This fixes
KeyError for symbols like xyz:GOLD, xyz:CL, mkts:USTECH that
aren't in the name_to_coin dictionary.

The WebSocket subscription already bypassed this lookup (line 154),
but the historical fetch path did not.
This commit is contained in:
DiTus
2026-08-05 09:20:07 +02:00
parent 21be9b40b7
commit 967c86e8e9
4 changed files with 27 additions and 10 deletions

View File

@ -162,7 +162,8 @@ class CandleFetcher:
max_retries = 3
for attempt in range(max_retries):
try:
return self.info.candles_snapshot(coin, self.interval, start_ms, end_ms)
req = {"coin": coin, "interval": self.interval, "startTime": start_ms, "endTime": end_ms}
return self.info.post("/info", {"type": "candleSnapshot", "req": req})
except ClientError as e:
if e.status_code == 429 and attempt < max_retries - 1:
logging.warning("Rate limited. Retrying in 2 seconds...")