frank0957 commited on
Commit
9ed8242
Β·
verified Β·
1 Parent(s): dba62f9

Update external_data_daemon.py

Browse files
Files changed (1) hide show
  1. external_data_daemon.py +4 -2
external_data_daemon.py CHANGED
@@ -5,7 +5,7 @@
5
  # This daemon does NOT attempt any live fetch.
6
  # 2. Resolves open flags:
7
  # a. Polymarket‑based – using /app/flag_mappings.json
8
- # b. Price‑based – using yfinance
9
  # All comments in English.
10
 
11
  import os, json, time, re, urllib.request, urllib.parse
@@ -44,7 +44,7 @@ def write_json(path, data):
44
  with open(path, "w") as f:
45
  json.dump(data, f, indent=2)
46
 
47
- # ── Flag resolution (unchanged) ──────────────────────────────────
48
  POLYMARKET_API = "https://data-api.polymarket.com/markets"
49
 
50
  def resolve_polymarket_flags(flags, mappings):
@@ -184,6 +184,8 @@ def resolve_price_flags(flags):
184
  try:
185
  start_date = datetime.fromisoformat(flag.get("opened_at", now_iso)) - timedelta(days=2)
186
  end_date = deadline + timedelta(days=1)
 
 
187
  df = yf.download(symbol, start=start_date.strftime("%Y-%m-%d"),
188
  end=end_date.strftime("%Y-%m-%d"), progress=False)
189
  if df.empty:
 
5
  # This daemon does NOT attempt any live fetch.
6
  # 2. Resolves open flags:
7
  # a. Polymarket‑based – using /app/flag_mappings.json
8
+ # b. Price‑based – using yfinance (with a small delay to avoid rate limits)
9
  # All comments in English.
10
 
11
  import os, json, time, re, urllib.request, urllib.parse
 
44
  with open(path, "w") as f:
45
  json.dump(data, f, indent=2)
46
 
47
+ # ── Flag resolution ──────────────────────────────────────────────
48
  POLYMARKET_API = "https://data-api.polymarket.com/markets"
49
 
50
  def resolve_polymarket_flags(flags, mappings):
 
184
  try:
185
  start_date = datetime.fromisoformat(flag.get("opened_at", now_iso)) - timedelta(days=2)
186
  end_date = deadline + timedelta(days=1)
187
+ # ── small delay to avoid yfinance rate limits ──
188
+ time.sleep(2)
189
  df = yf.download(symbol, start=start_date.strftime("%Y-%m-%d"),
190
  end=end_date.strftime("%Y-%m-%d"), progress=False)
191
  if df.empty: