strategy-backtest
Skill92 starsChanged 8 months agoApache-2.0View on GitHub
Runs SMA crossover backtests on historical OHLCV/candlestick data, calculating total return, Sharpe ratio, max drawdown, win rate, and trade log. Supports CSV files and JSON input with automatic AKShare/hhxg column normalization. Use when the user asks to backtest a trading strategy, evaluate strategy performance on historical price data, run quantitative analysis, or mentions OHLCV, candlestick data, or equity curves.
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- INo-xious/stockbit-mcptheir own version, first seen Aug 24, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- INo-xious/stockbit-mcp★ 51same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository32 other files it gives its agents.
- metaskillbaseSkill
- mac-brightnessSkill
- mac_ejectSkill
- mac_ipSkill
- mac_screenshotSkill
- mac-volumeSkill
- memory-backupSkill
- mac-activateSkill
- mac_calculatorSkill
- mac_calendarSkill
- mac-clipboardSkill
- mac_close_appSkill
- mac-dark-modeSkill
- mac_dictionarySkill
- mac_empty_trashSkill
- mac_file_copySkill
- mac_file_deleteSkill
- mac_file_moveSkill
- mac-finderSkill
- mac_input_sourceSkill
- mac_lockSkill
- mac-mailSkill
- mac_mkdirSkill
- mac_musicSkill
- mac_notifySkill
- mac_open_appSkill
- mac_preferencesSkill
- mac_printSkill
- mac_restartSkill
- mac_shutdownSkill
- mac_spotlightSkill
- mac-terminalSkill
The file
Files
strategy-backtest — Quantitative Strategy Backtesting
Runs strategy backtests on historical OHLCV data and returns performance metrics as JSON. Supports SMA crossover strategy with configurable fast/slow periods.
Usage
# Demo mode — uses built-in sample_ohlcv.csv
python3 strategy_backtest.py
# Backtest with custom CSV data
python3 strategy_backtest.py --data path/to/ohlcv.csv
# Backtest with JSON string input
python3 strategy_backtest.py --data '[{"open":10,"high":11,"low":9,"close":10.5,"volume":100}]'
# Custom SMA periods
python3 strategy_backtest.py --data prices.csv --fast 10 --slow 30
# Human-readable output
python3 strategy_backtest.py --data prices.csv --output printParameters
| Flag | Default | Description |
--data | sample_ohlcv.csv | CSV path or JSON string (OHLCV) |
--strategy | sma_crossover | Strategy type |
--fast | 5 | Fast SMA period |
--slow | 20 | Slow SMA period |
--output | json | Output format (json or print) |
Supports column names in English (open/high/low/close/volume) or Chinese AKShare format (开盘/收盘/最高/最低/成交量/日期).
Example output
{
"total_return": 0.0523,
"sharpe_ratio": 1.2345,
"max_drawdown": -0.0812,
"win_rate": 0.6,
"trade_count": 10,
"trades": [
{"date": "2024-01-15", "action": "buy", "price": 150.25},
{"date": "2024-02-01", "action": "sell", "price": 158.50, "pnl": 0.0549}
]
}Error handling
- Missing pandas: prints
{"error": "pandas required: pip install pandas"} - Missing columns: reports which OHLCV columns are absent
- Insufficient data: returns error if fewer rows than the slow SMA window
- Unknown strategy: reports the unrecognized strategy name
Programmatic API
from strategy_backtest import run_backtest
metrics = run_backtest("prices.csv", strategy="sma_crossover", fast=5, slow=20)Related skills
- hhxg-top-hhxg-python: fetch A-share OHLCV data → feed into this skill
- session-memory: store backtest metrics for later comparison
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

