-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron_runner.py
More file actions
63 lines (51 loc) · 1.86 KB
/
Copy pathcron_runner.py
File metadata and controls
63 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Cron runner for Railway.
Deploy this as a separate Railway cron service that runs on a schedule.
Railway cron setup:
1. Create a second service in your Railway project
2. Set it as a "Cron" type
3. Schedule: 0 18 * * 1-5 (weekdays at 6pm ET / market close)
4. Command: python cron_runner.py
5. Same env vars as the main service
What it does:
- Loads transcripts from HuggingFace dataset
- Analyzes new transcripts with Claude
- Refreshes incomplete price data
- Re-runs the backtest
- Generates updated summary
"""
import os
import sys
import subprocess
from datetime import datetime
def main():
print(f"[{datetime.now().isoformat()}] Earnings Signal Lab — Cron Run Starting")
print("=" * 60)
# Check env vars
if not os.environ.get("ANTHROPIC_API_KEY"):
print("ERROR: ANTHROPIC_API_KEY not set")
sys.exit(1)
# Step 1: Pull new transcripts
print("\n[1/4] Pulling new transcripts...")
result = subprocess.run(
["python", "earnings_signal_pipeline.py", "--step", "pull"],
capture_output=False
)
# Step 2: Analyze new transcripts
print("\n[2/4] Analyzing new transcripts with Claude...")
result = subprocess.run(
["python", "earnings_signal_pipeline.py", "--step", "analyze", "--no-confirm"],
capture_output=False
)
# Step 3: Refresh price data + re-backtest
print("\n[3/4] Refreshing price data and running backtest...")
result = subprocess.run(
["python", "earnings_signal_pipeline.py", "--refresh", "--no-confirm"],
capture_output=False
)
# Step 4: Notify (optional — you could add a webhook here)
print(f"\n[{datetime.now().isoformat()}] Cron run complete")
# If the web server is running, it will pick up the new results
# automatically on next /api/results request (file mtime check)
if __name__ == "__main__":
main()