backtest-poller

Background daemon that monitors QuantConnect backtests with adaptive polling, real-time equity tracking, drawdown early-stop, auto-download, and auto-diagnosis — survives terminal disconnection.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "backtest-poller" with this command: npx skills add tltby12341/backtest-poller

Backtest Poller

Never babysit a 3-hour backtest again. This skill runs a background daemon that monitors your QuantConnect backtests, auto-stops on excessive drawdown, downloads results when done, runs forensic diagnosis, and sends you a system notification.

When to use

  • After submitting a backtest: "Monitor this backtest in the background"
  • "Start the poller daemon"
  • "Check backtest status"
  • "Show me the poller logs"

Architecture

The poller runs as a nohup background process that survives terminal disconnection. All state is persisted to state.json with file-locking to prevent CLI/poller race conditions.

User submits backtest
        |
        v
  [Poller Daemon] (nohup, runs independently)
        |
        |-- Every 30-180s: check QC API
        |-- Track equity & peak equity
        |-- Calculate live drawdown
        |
        |-- If DD > threshold at 20%+ progress:
        |     |-- Delete backtest (early stop)
        |     |-- Record result
        |     \-- Send notification
        |
        |-- If completed:
        |     |-- Download orders.csv + result.json
        |     |-- Run OrderForensics diagnosis
        |     |-- Generate diagnosis.txt
        |     |-- Update state.json
        |     \-- Send macOS notification
        |
        \-- If no active backtests: exit gracefully

Adaptive Polling Intervals

Instead of a fixed 30s interval (360 API calls for a 3-hour backtest), the poller adapts based on progress:

PhaseProgressIntervalRationale
Startup0%, < 2min elapsed30sConfirm backtest actually started
Normal0-30%120sSteady tracking
Midgame30-80%180sLow frequency, save API quota
Endgame> 80%60sNearly done, check frequently

Result: ~50 API calls instead of ~360 for a 3-hour backtest.

CLI Commands

Submit a backtest (auto-starts poller)

python3 cli.py submit \
  --main-file strategy.py \
  --name "MyStrategy_v1" \
  --max-dd 40

Check status of all backtests

python3 cli.py status

Shows a table with: name, status, progress %, current equity, live drawdown, elapsed time.

View poller logs

python3 cli.py logs --lines 30

View completed results

python3 cli.py results --name "MyStrategy_v1" --full

Manually start/stop the poller

python3 cli.py start-poller
python3 cli.py stop-poller

Clean up completed records

python3 cli.py clear

State Management

All state is stored in state.json:

{
  "poller_pid": 12345,
  "poller_running": true,
  "poller_started": "2026-03-17T10:00:00",
  "backtests": [
    {
      "backtest_id": "abc123",
      "name": "MyStrategy_v1",
      "status": "running",
      "progress": 0.45,
      "peak_equity": 12500,
      "current_equity": 11200,
      "live_drawdown": 0.104,
      "max_dd_threshold": 0.40,
      "auto_download": true,
      "auto_diagnose": true
    }
  ]
}

File-locking (fcntl.flock) prevents race conditions between the CLI and the poller daemon writing to the same file.

Auto-Diagnosis

When a backtest completes, the poller automatically:

  1. Downloads orders.csv and result.json to results/<name>/
  2. Runs OrderForensics.full_diagnosis() to generate diagnosis.txt
  3. Extracts a summary: order count, option ROI, zero rate, windfall count

Notifications

On macOS, the poller sends a system notification via osascript when a backtest finishes.

Graceful Shutdown

The daemon handles SIGTERM and SIGINT for clean exit. It clears its PID from state.json only if the PID still matches (prevents stale cleanup from a different process).

Rules

  • Never submit more than one backtest at a time. QuantConnect free tier only allows one concurrent backtest per project. Submitting a second will silently queue or fail.
  • Never manually edit state.json while the poller is running. Use the CLI commands (submit, clear) to modify state. The file uses fcntl.flock locking — manual edits bypass the lock and can corrupt state.
  • Never run multiple poller instances simultaneously. The CLI checks for an existing PID before starting. If you force-start a second poller, both will race on state.json writes.
  • Do not delete files in results/ while the poller is actively downloading. Wait for the "completed" status.
  • Early-stop deletes the backtest permanently from QuantConnect. There is no "pause" API — early-stopped backtests cannot be resumed or recovered.
  • Environment variables QC_USER_ID, QC_API_TOKEN, and QC_PROJECT_ID must be set before running any command. The skill will fail with a clear error if they are missing.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

GigaChat (Sber AI) Proxy

Integrate GigaChat (Sber AI) with OpenClaw via gpt2giga proxy

Registry SourceRecently Updated
3600smvlx
General

TencentCloud Video Face Fusion

通过提取两张人脸核心特征并实现自然融合,支持多种风格适配,提升创意互动性和内容传播力,广泛应用于创意营销、娱乐互动和社交分享场景。

Registry SourceRecently Updated
General

TencentCloud Image Face Fusion

图片人脸融合(专业版)为同步接口,支持自定义美颜、人脸增强、牙齿增强、拉脸等参数,最高支持8K分辨率,有多个模型类型供选择。

Registry SourceRecently Updated
General

YoudaoNote News

有道云笔记资讯推送:基于收藏笔记分析关注话题,推送最新相关资讯。支持对话触发与每日定时推送(如早上9点)。触发词:资讯推送、设置资讯推送、生成资讯推送。

Registry SourceRecently Updated
1.5K1lephix