Skip to content

Commit d3be772

Browse files
committed
Improving LOGGING for failing coin download.
1 parent 2be9de5 commit d3be772

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

src/main.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,15 +1718,60 @@ def cmd_fetch_prices(args: argparse.Namespace) -> int:
17181718
logger.info("-" * 60)
17191719
logger.info("RESULTS")
17201720
logger.info("-" * 60)
1721-
logger.info(
1722-
" Prices fetched: %d coins × %d currencies", len(results), len(currencies_to_fetch)
1723-
)
1721+
1722+
# Count actually fetched (non-empty results)
1723+
# Note: BTC-BTC returns empty (skipped), BTC uses USD pair instead
1724+
successful_coins = []
1725+
failed_coins = []
1726+
skipped_coins_list = []
1727+
1728+
for coin in coins:
1729+
coin_id = coin["id"]
1730+
coin_data = results.get(coin_id, {})
1731+
has_data = any(not df.empty for df in coin_data.values())
1732+
1733+
if has_data:
1734+
successful_coins.append(coin_id)
1735+
elif coin_id.lower() == "btc" and "BTC" in currencies_to_fetch:
1736+
# BTC with BTC quote is intentionally skipped (uses USD instead)
1737+
skipped_coins_list.append((coin_id, "BTC/BTC skipped, uses USD pair"))
1738+
else:
1739+
# Coin failed to fetch or returned empty data
1740+
failed_coins.append(coin_id)
1741+
1742+
logger.info(" Coins processed: %d (attempted: %d)", len(successful_coins), len(coins))
1743+
1744+
# Log failed coins if any (excluding intentionally skipped ones)
1745+
if failed_coins:
1746+
logger.warning(" Failed/empty: %d coins", len(failed_coins))
1747+
for coin_id in failed_coins[:10]: # Show first 10
1748+
logger.warning(" - %s (no data returned)", coin_id)
1749+
if len(failed_coins) > 10:
1750+
logger.warning(" ... and %d more", len(failed_coins) - 10)
1751+
1752+
# Log skipped coins
1753+
if skipped_coins_list:
1754+
logger.info(" Skipped: %d coins", len(skipped_coins_list))
1755+
for coin_id, reason in skipped_coins_list:
1756+
logger.info(" - %s (%s)", coin_id, reason)
17241757

17251758
# Show cache stats per currency
17261759
price_cache = PriceDataCache()
17271760
for currency in currencies_to_fetch:
17281761
cached_coins = price_cache.list_cached_coins(currency)
1729-
logger.info(" Cached (%s): %d coins", currency, len(cached_coins))
1762+
logger.info(
1763+
" Cached (%s): %d coins (altcoin/%s pairs)", currency, len(cached_coins), currency
1764+
)
1765+
1766+
# Also show BTC-USD if we're in default mode (BTC pairs only)
1767+
total_cached = 0
1768+
if not args.all_pairs:
1769+
btc_cached = price_cache.list_cached_coins("BTC")
1770+
btc_usd_cached = price_cache.has_prices("btc", "USD")
1771+
total_cached = len(btc_cached) + (1 if btc_usd_cached else 0)
1772+
if btc_usd_cached:
1773+
logger.info(" Cached (USD): 1 coin (BTC/USD, since BTC/BTC doesn't exist)")
1774+
logger.info(" Total cached: %d coins", total_cached)
17301775

17311776
logger.info("Price data saved to: %s", fetcher.price_cache.prices_dir)
17321777

0 commit comments

Comments
 (0)