ifieryarrows commited on
Commit
d07aa1d
·
verified ·
1 Parent(s): 99e7b4b

Sync from GitHub (tests passed)

Browse files
Files changed (3) hide show
  1. app/heatmap.py +12 -3
  2. pyproject.toml +1 -1
  3. requirements.txt +1 -1
app/heatmap.py CHANGED
@@ -228,12 +228,21 @@ def refresh_market_heatmap() -> None:
228
 
229
  import yfinance as yf
230
 
231
- # Batch fetch yfinance accepts space-separated tickers
232
- # Process in batches of 100 to avoid URL length issues
 
 
 
 
233
  all_data: list[dict] = []
234
- batch_size = 100
235
  for i in range(0, len(symbols_to_fetch), batch_size):
236
  batch = symbols_to_fetch[i : i + batch_size]
 
 
 
 
 
237
  try:
238
  tickers_obj = yf.Tickers(" ".join(batch))
239
  for sym in batch:
 
228
 
229
  import yfinance as yf
230
 
231
+ # Batch fetch with rate-limit protection
232
+ # Yahoo Finance aggressively blocks high-frequency scrapers.
233
+ # Process in batches of 50 (smaller than before) with inter-batch
234
+ # delays to stay under the radar.
235
+ import time
236
+
237
  all_data: list[dict] = []
238
+ batch_size = 50
239
  for i in range(0, len(symbols_to_fetch), batch_size):
240
  batch = symbols_to_fetch[i : i + batch_size]
241
+
242
+ # Inter-batch delay to avoid Yahoo crumb invalidation
243
+ if i > 0:
244
+ time.sleep(1.5)
245
+
246
  try:
247
  tickers_obj = yf.Tickers(" ".join(batch))
248
  for sym in batch:
pyproject.toml CHANGED
@@ -25,7 +25,7 @@ dependencies = [
25
  "psycopg2-binary>=2.9.9",
26
 
27
  # Data fetching
28
- "yfinance>=0.2.33",
29
  "requests>=2.31.0",
30
  "feedparser>=6.0.10",
31
 
 
25
  "psycopg2-binary>=2.9.9",
26
 
27
  # Data fetching
28
+ "yfinance>=1.3.0",
29
  "requests>=2.31.0",
30
  "feedparser>=6.0.10",
31
 
requirements.txt CHANGED
@@ -9,7 +9,7 @@ sqlalchemy>=2.0.23
9
  psycopg2-binary>=2.9.9
10
 
11
  # Data fetching
12
- yfinance>=0.2.33
13
  requests>=2.31.0
14
  httpx>=0.25.0
15
  websockets>=12.0
 
9
  psycopg2-binary>=2.9.9
10
 
11
  # Data fetching
12
+ yfinance>=1.3.0
13
  requests>=2.31.0
14
  httpx>=0.25.0
15
  websockets>=12.0