Skip to main content

Cloud Scheduler Integration - Quick Reference

What Changed?

Cortex Trader bot is now automatically scheduled to run every 5 minutes via GCP Cloud Scheduler instead of requiring manual startup.

Key Files

FileChangePurpose
apphosting.yaml➕ 8 linesAdded cortex-trader-execution job
src/app/api/cron/execute-cortex-trades/route.ts➕ NEWCloud Function endpoint to run Python bot
src/app/home/automate/page.tsx➕ 120 linesDashboard status display for scheduler
README.md➕ 3 linesDocumentation links

Deployment

npm run build
firebase deploy

Verification

  1. Cloud Scheduler (GCP Console)
    • Should show: cortex-trader-execution with status ACTIVE
  2. Trader Dashboard (/home/automate)
    • Should display Cloud Scheduler Status card with execution details
  3. First Execution
    • Happens within 5 minutes of deployment
    • Check status card for results

How It Works

Every 5 minutes →
  Cloud Scheduler calls →
    /api/cron/execute-cortex-trades →
      Spawns cortex_trader.py →
        Executes Genesis trades →
          Logs to Firestore →
            Dashboard displays status

Monitoring

Dashboard/home/automateCloud Scheduler Status card shows:
  • ✅ Status (completed/failed)
  • ✅ Trades executed
  • ✅ Last execution time
  • ✅ Next execution time
  • ❌ Errors (if any)

Troubleshooting

ProblemSolution
Job shows INACTIVECheck CRON_SECRET env var in App Hosting
Status stuck on “pending”Wait 5+ min for first execution
cortex_trader.py failsCheck cortex_trader.log for Python errors
Dashboard shows errorReview Firestore: _system/cortex_execution_log

Environment Variables Needed

CRON_SECRET=<your-secret-value>
# Set in Firebase App Hosting environment

Documentation

Build Status

Compiles successfully (13.1s)

Commits

  • 46e58f2 - Integrate Cortex Trader with Cloud Scheduler
  • baf2e10 - Add Cloud Scheduler documentation
  • 77887c7 - Add deployment checklist
  • c084521 - Add integration summary

Ready to deploy! 🚀