Skip to content

Commit edb58f0

Browse files
enarjordclaude
andcommitted
Use denormalized exchange names for all cache directory paths
- HLCVManager, OHLCVManager, fetch_markets_ccxt, and coin_to_symbol now use denormalized names (e.g., "binance" not "binanceusdm") - Ensures only caches/binance/ is created instead of both caches/binance/ and caches/binanceusdm/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 905834b commit edb58f0

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/downloader.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,12 @@ def __init__(
520520
self.start_ts = date_to_ts(self.start_date)
521521
self.end_ts = date_to_ts(self.end_date)
522522
self.cc = cc
523+
# Use denormalized exchange name for cache paths (e.g., "binance" not "binanceusdm")
524+
cache_exchange = denormalize_exchange_name(self.exchange)
523525
self.cache_filepaths = {
524-
"markets": os.path.join("caches", self.exchange, "markets.json"),
525-
"ohlcvs": os.path.join("historical_data", f"ohlcvs_{self.exchange}"),
526-
"first_timestamps": os.path.join("caches", self.exchange, "first_timestamps.json"),
526+
"markets": os.path.join("caches", cache_exchange, "markets.json"),
527+
"ohlcvs": os.path.join("historical_data", f"ohlcvs_{cache_exchange}"),
528+
"first_timestamps": os.path.join("caches", cache_exchange, "first_timestamps.json"),
527529
}
528530
self.markets = None
529531
self.verbose = verbose

src/hlcv_preparation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ def __init__(
107107
self.start_ts = int(date_to_ts(self.start_date))
108108
self.end_ts = int(date_to_ts(self.end_date))
109109
self.cc = cc
110+
# Use denormalized exchange name for cache paths (e.g., "binance" not "binanceusdm")
111+
cache_exchange = denormalize_exchange_name(self.exchange)
110112
self.cache_filepaths = {
111-
"markets": os.path.join("caches", self.exchange, "markets.json"),
112-
"first_timestamps": os.path.join("caches", self.exchange, "first_timestamps.json"),
113+
"markets": os.path.join("caches", cache_exchange, "markets.json"),
114+
"first_timestamps": os.path.join("caches", cache_exchange, "first_timestamps.json"),
113115
}
114116
self.markets = None
115117
self.verbose = bool(verbose)

src/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ async def load_markets(
492492
consistency with other cache paths (pnls, ohlcv, fill_events).
493493
"""
494494
# Prefer cc.id when a ccxt instance is supplied, otherwise use the provided exchange string.
495-
ex = (getattr(cc, "id", None) or exchange or "").lower()
495+
# Denormalize to use canonical form for cache paths (e.g., "binance" not "binanceusdm")
496+
ex = denormalize_exchange_name(getattr(cc, "id", None) or exchange or "")
496497
markets_path = os.path.join("caches", ex, "markets.json")
497498

498499
# Try cache first
@@ -914,7 +915,8 @@ def coin_to_symbol(coin, exchange, quote=None):
914915
# caches coin_to_symbol_map in memory and reloads if file changes
915916
if coin == "":
916917
return ""
917-
ex = (exchange or "").lower()
918+
# Denormalize to use canonical form for cache paths (e.g., "binance" not "binanceusdm")
919+
ex = denormalize_exchange_name(exchange or "")
918920
quote = get_quote(ex, quote)
919921
coin_sanitized = symbol_to_coin(coin)
920922
fallback = f"{coin_sanitized}/{quote}:{quote}"

0 commit comments

Comments
 (0)