Files
hk-weather-mkt/scheduled_runner.py
ramseshk c93af97059 HK Weather Prediction Market Pipeline: WeatherNext + HKO + Polymarket
- Open-Meteo WeatherNext API client for HK forecasts
- HKO public data client (current conditions, 9-day forecast, typhoon warnings)
- HK-specific weather extraction and calibration
- Polymarket market scanning, price discovery, and market creation proposals
- Trading strategy engine: edge detection, Kelly criterion sizing, probability calibration
- End-to-end pipeline with dry-run mode and scheduled runner
- Interactive dashboard with live HK weather + forecasts + trading signals

Dependencies: Python 3.10+, openmeteo-requests, pandas
No API keys needed for dry-run mode.
Polymarket trading requires private key in .env.
2026-08-10 12:48:05 +08:00

61 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""Scheduled runner that executes the pipeline hourly and logs results."""
import time
import signal
import sys
from datetime import datetime
from pathlib import Path
from pipeline import Pipeline
LOG_DIR = Path(__file__).parent / "logs"
LOG_DIR.mkdir(exist_ok=True)
running = True
def signal_handler(sig, frame):
global running
print("\nShutting down scheduled runner...")
running = False
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
def main():
pipeline = Pipeline(live=False, bankroll=1000.0)
print(f"Scheduled runner started at {datetime.now():%Y-%m-%d %H:%M:%S}")
print(f"Running every hour. Logs in {LOG_DIR}/")
print()
while running:
try:
log_file = LOG_DIR / f"run_{datetime.now():%Y%m%d_%H%M}.txt"
with open(log_file, "w") as f:
old_stdout = sys.stdout
sys.stdout = f
pipeline.run()
sys.stdout = old_stdout
print(f"[{datetime.now():%H:%M}] Run complete -> {log_file}")
except Exception as e:
print(f"[{datetime.now():%H:%M}] Error: {e}")
# Sleep until next hour
for _ in range(3600):
if not running:
break
time.sleep(1)
print("Runner stopped.")
if __name__ == "__main__":
main()