CoolFace
Apppublic

BluefxPraise/The_Oracle

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
scheduler.py89 linesDownload Raw Back to utils
1"""APScheduler setup: scans, news refresh, weekly export+calibration, monthly deep tune."""2 3import logging4from datetime import datetime, timezone5 6from apscheduler.schedulers.background import BackgroundScheduler7 8import memory9from config import PAIRS10 11log = logging.getLogger("oracle.sched")12 13scheduler = BackgroundScheduler(timezone="UTC")14 15 16def in_quiet_hours() -> bool:17    h = datetime.now(timezone.utc).hour18    return h >= 21 or h < 119 20 21def setup(brain):22    """brain is an instance of brain.Brain — wires its callbacks to schedule."""23 24    # 15-minute scan25    scheduler.add_job(26        brain.scan_all,27        "cron",28        minute="0,15,30,45",29        id="scan_all",30        replace_existing=True,31    )32    # tick to check open trades vs current price (every 5 minutes)33    scheduler.add_job(34        brain.check_open_trades,35        "cron",36        minute="*/5",37        id="check_trades",38        replace_existing=True,39    )40    # news refresh hourly41    scheduler.add_job(42        brain.refresh_news,43        "cron",44        minute="5",45        id="news_refresh",46        replace_existing=True,47    )48    # daily report 22:00 UTC49    scheduler.add_job(50        brain.send_daily_report,51        "cron",52        hour=22,53        minute=0,54        id="daily_report",55        replace_existing=True,56    )57    # phase check daily at 00:0558    scheduler.add_job(59        brain.check_phase_transition,60        "cron",61        hour=0,62        minute=5,63        id="phase_check",64        replace_existing=True,65    )66    # weekly: Sunday 00:00 UTC -> exports + weekly calibration + ML retrain67    scheduler.add_job(68        brain.weekly_routine,69        "cron",70        day_of_week="sun",71        hour=0,72        minute=0,73        id="weekly",74        replace_existing=True,75    )76    # monthly: 1st of month, 00:30 UTC -> deep optimization77    scheduler.add_job(78        brain.monthly_deep_optimization,79        "cron",80        day=1,81        hour=0,82        minute=30,83        id="monthly_opt",84        replace_existing=True,85    )86 87    scheduler.start()88    log.info("scheduler started")89