Automate QuantConnect cloud backtesting workflow with GitHub integration. Push strategies to QuantConnect cloud, execute backtests, wait for completion, and retrieve performance metrics. This skill should be used when running backtests on QuantConnect cloud or testing trading strategies.
This skill automates the complete workflow for running backtests on QuantConnect cloud:
Auto-activate when user requests:
LEAN CLI installed:
pip install lean
lean login
Environment variables in .env:
QC_PROJECT_NAME="Your Project Name"
GitHub repo configured:
--project: QuantConnect project name (default: from QC_PROJECT_NAME env var)--commit: Commit and push to GitHub before backtest--commit-message: Custom git commit message--open: Open results in browser after starting backtest--wait: Wait for backtest to complete (polls every 10s)--save: Download and save results locally to results/qc/--timeout: Wait timeout in seconds (default: 300)--no-push: Skip pushing to QC cloud (use existing code)The skill includes a bundled script scripts/qc_cloud_backtest.py that automates the entire backtest workflow.
Execute the bundled script to start a backtest and open results in browser:
venv/bin/python .claude/skills/qc-backtest-runner/scripts/qc_cloud_backtest.py --open
Execute with wait and save flags to retrieve complete results:
venv/bin/python .claude/skills/qc-backtest-runner/scripts/qc_cloud_backtest.py --wait --save
Commit and push changes before running backtest:
venv/bin/python .claude/skills/qc-backtest-runner/scripts/qc_cloud_backtest.py --commit --wait --save
Specify a different QuantConnect project:
venv/bin/python .claude/skills/qc-backtest-runner/scripts/qc_cloud_backtest.py --project "My Custom Strategy" --open
============================================================
BACKTEST RESULTS
============================================================
Total Return : 392.23%
Sharpe Ratio : 0.829
Total Orders : 2
Win Rate : 0%
Loss Rate : 0%
Average Win : 0%
Average Loss : 0%
Max Drawdown : 59.000%
Sortino Ratio : 0.856
Net Profit : $3922.28
Annual Return : 37.501%
============================================================
results/qc/backtest_YYYYMMDD_HHMMSS.jsonLEAN CLI not installed:
Error: LEAN CLI not installed
Install with: pip install lean
Then login with: lean login
Missing credentials:
Error: QC_PROJECT_NAME not set in .env
Add to .env file:
QC_PROJECT_NAME="Your Project Name"
Backtest timeout:
⚠ Backtest timed out after 300 seconds
Check status at: https://www.quantconnect.com/terminal
Automatically activate this skill when detecting:
strategies/*.py or lean_projects/*/main.pyStrategy Development:
Result Analysis:
--wait --save flags to retrieve complete resultsIterative Testing:
Backtest Started: Exit code 0, "Backtest started" message Backtest Completed: Results JSON downloaded, metrics displayed Git Integration: Changes committed and pushed successfully Error Handling: Clear error messages with actionable steps
data-manager: Download historical data before backtestingbacktest-runner: Run local Backtrader backtestsparameter-optimizer: Optimize strategy parameters before cloud testingSolution: Check QC_PROJECT_NAME matches exact project name in QuantConnect terminal
Solution: Run lean login and re-enter credentials from https://www.quantconnect.com/account
Solution: Backtest may still be running. Increase --timeout or check web UI manually
Solution: Ensure SSH key is configured for [email protected]:vinamra2013/QuantConnectAlgoTradingStratigies.git