A structured workflow for AI-assisted quantitative strategy iteration. Instead of randomly tweaking code, this skill enforces a disciplined loop: read history, form hypothesis, write code, validate against past mistakes, backtest progressively, diagnose results, and record lessons.
This skill is an orchestrator — it coordinates two companion skills that must be installed separately:
SkillPurposeCommands providedbacktest-pollerBacktest submission, monitoring, early-stop, resultscli.py submit/status/results/logs``qc-deep-feature-forensicsDeep feature-level forensic analysisdeep_forensics.py
Install them first:
bash
clawhub install backtest-poller
clawhub install qc-deep-feature-forensics
All cli.py references below assume backtest-poller is installed as a sibling directory ( ../backtest-poller/cli.py). Adjust the path if your install location differs.
text
Step 1: Briefing ──> Read constitutional memory + history
Step 2: Hypothesis ──> Pick ONE mutation dimension, form testable hypothesis
Step 3: Code ──> Write strategy, scan for violations
Step 4: Submit ──> Progressive validation (smoke -> stress -> medium -> full)
Step 5: Diagnose ──> Run forensics on results
Step 6: Record ──> Update constitutional memory with new lessons
|
└──────────> Loop back to Step 1
bash
python3 orchestrator.py briefing
Returns:
Before writing code, answer these questions:
Mutation Dimensions:
DimensionDescriptionExamplessurvival_structureHow the strategy survives downturnsQQQ buy-and-hold, cash defense, SMA filterposition_sizingHow much capital per tradeKelly %, max trade value, total exposure capselectionWhat stocks to tradePremarket volume, RS breakout, HV lotteryprofit_managementWhat to do with winnersHold to expiry, take-profit at 200%, trailing stop
strategies/M{N}_{description}/main.pybash
python3 orchestrator.py scan --code strategies/M31_test/main.py
If violations are found, fix them before submitting.
Submit through increasingly demanding test windows. Only promote to the next stage after passing.
text
Stage 1: Smoke Test (3 months, ~15min) DD < 50% — Catch obvious bugs
Stage 2: Stress Test (5 months, ~30min) DD < 45% — Survive worst conditions
Stage 3: Medium (18 months, ~1hr) DD < 42% — Bull/bear transitions
Stage 4: Full (3 years, ~3hr) DD < 40% — Final acceptance
bash
# Check no active backtests (backtest-poller skill)
python3 ../backtest-poller/cli.py status
# Submit with early-stop protection
python3 ../backtest-poller/cli.py submit \
--backtest-id <id> \
--name "MyStrategy_smoke" \
--max-dd 50
# Monitor progress
python3 ../backtest-poller/cli.py status
# View results when done
python3 ../backtest-poller/cli.py results --name "MyStrategy_smoke" --full
Shortcut: If you only changed profit management (not entry logic), you can skip Smoke/Stress and start from Medium.
bash
python3 orchestrator.py diagnose \
--orders results/MyStrategy_smoke/xxx_orders.csv \
--result results/MyStrategy_smoke/xxx_result.json
For deeper analysis, run the feature forensics (requires qc-deep-feature-forensics skill):
bash
python3 ../qc-deep-feature-forensics/deep_forensics.py results/MyStrategy_smoke/xxx_orders.csv
bash
python3 orchestrator.py record \
--name "MyStrategy_v2" \
--blueprint "baseline" \
--dimension "position_sizing" \
--hypothesis "Reduce position size to 2% for better survival" \
--window "smoke_test" \
--status "completed" \
--sharpe 1.5 \
--drawdown 0.35 \
--net-profit 0.85
Decision Matrix:
OutcomeActionCurrent stage passedChange dates to next stage, resubmitDD exceeded but promisingAnalyze monthly cashflow, find bleeding point, targeted fixToo few tradesRed flag — loosen entry conditions or shorten cooldownSharpe < 1.0 but DD okAcceptable for now, optimize Sharpe laterFull period passedStrategy qualified!
bash
# This skill (orchestrator)
python3 orchestrator.py briefing # Decision context
python3 orchestrator.py status # System status
python3 orchestrator.py list # Available strategies
python3 orchestrator.py scan --code <path> # Code violation check
# backtest-poller skill
python3 ../backtest-poller/cli.py status # Backtest status
python3 ../backtest-poller/cli.py logs --lines 30 # Poller logs
python3 ../backtest-poller/cli.py results --name <name> --full # View results
# qc-deep-feature-forensics skill
python3 ../qc-deep-feature-forensics/deep_forensics.py <orders.csv> # Deep forensics
scan_strategy() before submitting. Constitutional violations must be resolved before backtest submission. Do not bypass the scanner.