strategy-backtest
БесплатноЗапускает вложенные скриптыНе проверенRuns SMA crossover backtests on historical OHLCV/candlestick data, calculating total return, Sharpe ratio, max drawdown, win rate, and trade log. Supports CSV…
от leionion★ 88 звёзд на GitHubОб этом скилле
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 print
Parameters
| 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
Установить strategy-backtest в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл strategy-backtest?
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.
Как установить скилл strategy-backtest?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл strategy-backtest запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic