Update external_data_daemon.py
Browse files- 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
|
| 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:
|