| 36 | # vendor daily update lands ~23:30–03:00 ET → poll from 02:00 every 30 min (incremental skips when vendor unchanged) |
36 | # vendor daily update lands ~23:30–03:00 ET → poll from 02:00 every 30 min (incremental skips when vendor unchanged) |
| 37 | if now.weekday() < 6 and (now.hour >= 2 or now.hour < 1): |
37 | if now.weekday() < 6 and (now.hour >= 2 or now.hour < 1): |
| 38 | queue.enqueue("incremental", "market_bars.stock.1m.raw", {"type": "stock", "period": "day"}, priority=20, |
38 | queue.enqueue("incremental", "market_bars.stock.1m.raw", {"type": "stock", "period": "day"}, priority=20, |
| 39 | − dedupe_key=f"incremental:stock:day:{day}:{now.hour}:{now.minute // 30}") |
39 | + dedupe_key=f"incremental:stock:day:{day}:{now.hour}:{now.minute // 30}", rerun_succeeded=False) |
| 40 | if now.weekday() == 5 and now.hour == 6: # Saturday 06:00 ET — week archive repairs any missed day |
40 | if now.weekday() == 5 and now.hour == 6: # Saturday 06:00 ET — week archive repairs any missed day |
| 41 | queue.enqueue("incremental", "market_bars.stock.1m.raw", {"type": "stock", "period": "week", "force": True}, priority=25, |
41 | queue.enqueue("incremental", "market_bars.stock.1m.raw", {"type": "stock", "period": "week", "force": True}, priority=25, |
| 42 | − dedupe_key=f"incremental:stock:week:{day}") |
42 | + dedupe_key=f"incremental:stock:week:{day}", rerun_succeeded=False) |
| 43 | if now.weekday() == 6 and now.hour == 7: |
43 | if now.weekday() == 6 and now.hour == 7: |
| 44 | − queue.enqueue("metadata", None, {"types": ["stock", "etf"]}, priority=30, dedupe_key=f"metadata:{day}") |
44 | + queue.enqueue("metadata", None, {"types": ["stock", "etf"]}, priority=30, dedupe_key=f"metadata:{day}", rerun_succeeded=False) |
| 45 | − queue.enqueue("compaction", "market_bars.stock.1m.raw", {}, priority=60, dedupe_key=f"compaction:1m:{day}") |
45 | + queue.enqueue("compaction", "market_bars.stock.1m.raw", {}, priority=60, dedupe_key=f"compaction:1m:{day}", rerun_succeeded=False) |
| 46 | − queue.enqueue("compaction", "market_bars.stock.5m.raw", {}, priority=61, dedupe_key=f"compaction:5m:{day}") |
46 | + queue.enqueue("compaction", "market_bars.stock.5m.raw", {}, priority=61, dedupe_key=f"compaction:5m:{day}", rerun_succeeded=False) |
| 47 | # other raw 1-minute feeds and daily bars (vendor publishes daily; crypto 7/7) |
47 | # other raw 1-minute feeds and daily bars (vendor publishes daily; crypto 7/7) |
| 48 | if now.hour >= 2 or now.hour < 1: |
48 | if now.hour >= 2 or now.hour < 1: |
| 49 | for t in ("index", "fx", "crypto"): |
49 | for t in ("index", "fx", "crypto"): |
| 50 | if now.weekday() < 6 or t == "crypto": |
50 | if now.weekday() < 6 or t == "crypto": |
| 51 | queue.enqueue("incremental", f"market_bars.{t}.1m.raw", {"type": t, "period": "day", "timeframe": "1min"}, priority=26, |
51 | queue.enqueue("incremental", f"market_bars.{t}.1m.raw", {"type": t, "period": "day", "timeframe": "1min"}, priority=26, |
| 52 | − dedupe_key=f"incremental:{t}:day:{day}:{now.hour}:{now.minute // 30}") |
52 | + dedupe_key=f"incremental:{t}:day:{day}:{now.hour}:{now.minute // 30}", rerun_succeeded=False) |
| 53 | if now.weekday() < 6: |
53 | if now.weekday() < 6: |
| 54 | for t in ("stock", "etf"): |
54 | for t in ("stock", "etf"): |
| 55 | queue.enqueue("incremental", f"market_bars.{t}.1d.raw", {"type": t, "period": "day", "timeframe": "1day", "adjustment": "UNADJUSTED"}, priority=27, |
55 | queue.enqueue("incremental", f"market_bars.{t}.1d.raw", {"type": t, "period": "day", "timeframe": "1day", "adjustment": "UNADJUSTED"}, priority=27, |
| 56 | − dedupe_key=f"incremental:{t}:1day:{day}:{now.hour}:{now.minute // 30}") |
56 | + dedupe_key=f"incremental:{t}:1day:{day}:{now.hour}:{now.minute // 30}", rerun_succeeded=False) |
| 57 | queue.enqueue("incremental", "market_bars.etf.1m.raw", {"type": "etf", "period": "day"}, priority=21, |
57 | queue.enqueue("incremental", "market_bars.etf.1m.raw", {"type": "etf", "period": "day"}, priority=21, |
| 58 | − dedupe_key=f"incremental:etf:day:{day}:{now.hour}:{now.minute // 30}") |
58 | + dedupe_key=f"incremental:etf:day:{day}:{now.hour}:{now.minute // 30}", rerun_succeeded=False) |
| 59 | if now.weekday() == 5 and now.hour == 6: |
59 | if now.weekday() == 5 and now.hour == 6: |
| 60 | # weekly: futures continuous (week), individual contracts update, adjusted stock/etf histories (full_update) |
60 | # weekly: futures continuous (week), individual contracts update, adjusted stock/etf histories (full_update) |
| 61 | for tf in ("1min", "1day", "5min", "30min", "1hour"): |
61 | for tf in ("1min", "1day", "5min", "30min", "1hour"): |
| 62 | for adj in ("contin_UNadj", "contin_adj_ratio", "contin_adj_absolute"): |
62 | for adj in ("contin_UNadj", "contin_adj_ratio", "contin_adj_absolute"): |
| 63 | queue.enqueue("incremental", None, {"type": "futures", "period": "week", "timeframe": tf, "adjustment": adj}, priority=36, |
63 | queue.enqueue("incremental", None, {"type": "futures", "period": "week", "timeframe": tf, "adjustment": adj}, priority=36, |
| 64 | − dedupe_key=f"incremental:futures:week:{tf}:{adj}:{day}") |
64 | + dedupe_key=f"incremental:futures:week:{tf}:{adj}:{day}", rerun_succeeded=False) |
| 65 | queue.enqueue("backfill", None, {"type": "futures", "endpoint": "futures_contract", "contract_files": "update", "timeframe": tf, "contracts": True}, |
65 | queue.enqueue("backfill", None, {"type": "futures", "endpoint": "futures_contract", "contract_files": "update", "timeframe": tf, "contracts": True}, |
| 66 | − priority=37, dedupe_key=f"contracts:update:{tf}:{day}") |
66 | + priority=37, dedupe_key=f"contracts:update:{tf}:{day}", rerun_succeeded=False) |
| 67 | for t in ("stock", "etf"): |
67 | for t in ("stock", "etf"): |
| 68 | for adj in ("adj_split", "adj_splitdiv"): |
68 | for adj in ("adj_split", "adj_splitdiv"): |
| 69 | queue.enqueue("backfill", None, {"type": t, "endpoint": "full_update", "period": "week", "timeframe": tf, "adjustment": adj}, |
69 | queue.enqueue("backfill", None, {"type": t, "endpoint": "full_update", "period": "week", "timeframe": tf, "adjustment": adj}, |
| 70 | − priority=38, dedupe_key=f"full_update:{t}:{tf}:{adj}:{day}") |
70 | + priority=38, dedupe_key=f"full_update:{t}:{tf}:{adj}:{day}", rerun_succeeded=False) |
| 71 | for t in ("index", "fx", "crypto"): |
71 | for t in ("index", "fx", "crypto"): |
| 72 | if tf != "1min": |
72 | if tf != "1min": |
| 73 | − queue.enqueue("incremental", None, {"type": t, "period": "week", "timeframe": tf}, priority=39, dedupe_key=f"incremental:{t}:week:{tf}:{day}") |
73 | + queue.enqueue("incremental", None, {"type": t, "period": "week", "timeframe": tf}, priority=39, dedupe_key=f"incremental:{t}:week:{tf}:{day}", rerun_succeeded=False) |
| 74 | queue.enqueue("backfill", "market_bars.stock.1m.raw", {"type": "stock", "endpoint": "delisted_data_file", "update": "week", "timeframe": "1min", "adjustment": "UNADJUSTED"}, |
74 | queue.enqueue("backfill", "market_bars.stock.1m.raw", {"type": "stock", "endpoint": "delisted_data_file", "update": "week", "timeframe": "1min", "adjustment": "UNADJUSTED"}, |
| 75 | − priority=38, dedupe_key=f"delisted:week:{day}") |
75 | + priority=38, dedupe_key=f"delisted:week:{day}", rerun_succeeded=False) |
| 76 | if now.day == 2 and now.hour == 8: |
76 | if now.day == 2 and now.hour == 8: |
| 77 | − queue.enqueue("options", "options.eod", {"period": "month"}, priority=55, dedupe_key=f"options:month:{now.year}-{now.month:02d}") |
77 | + queue.enqueue("options", "options.eod", {"period": "month"}, priority=55, dedupe_key=f"options:month:{now.year}-{now.month:02d}", rerun_succeeded=False) |
| 78 | if now.hour == 5 and now.minute < 30: |
78 | if now.hour == 5 and now.minute < 30: |
| 79 | − queue.enqueue("fundamentals", "fundamentals.financials", {"tracked": True}, priority=50, dedupe_key=f"fundamentals:{day}") |
79 | + queue.enqueue("fundamentals", "fundamentals.financials", {"tracked": True}, priority=50, dedupe_key=f"fundamentals:{day}", rerun_succeeded=False) |
| 80 | if now.hour == 4 and now.minute < 30 and get_settings().backup_target: |
80 | if now.hour == 4 and now.minute < 30 and get_settings().backup_target: |
| 81 | − queue.enqueue("backup", None, {}, priority=70, dedupe_key=f"backup:{day}") |
81 | + queue.enqueue("backup", None, {}, priority=70, dedupe_key=f"backup:{day}", rerun_succeeded=False) |
| 82 | if now.hour == 6 and now.minute < 30: |
82 | if now.hour == 6 and now.minute < 30: |
| 83 | − queue.enqueue("quality", "market_bars.stock.1m.raw", {}, priority=80, dedupe_key=f"quality:{day}") |
83 | + queue.enqueue("quality", "market_bars.stock.1m.raw", {}, priority=80, dedupe_key=f"quality:{day}", rerun_succeeded=False) |
| 84 | − queue.enqueue("gc", None, {}, priority=90, dedupe_key=f"gc:{day}") |
84 | + queue.enqueue("gc", None, {}, priority=90, dedupe_key=f"gc:{day}", rerun_succeeded=False) |
| 85 | |
85 | |
| 86 | |
86 | |
| 87 | def main(once: bool = False, kinds: list[str] | None = None, with_scheduler: bool = True, role: str = "primary") -> None: |
87 | def main(once: bool = False, kinds: list[str] | None = None, with_scheduler: bool = True, role: str = "primary") -> None: |
| 88 | |
88 | |