stock-strategy-backtester-clean

Backtest stock trading strategies on historical OHLCV data and report win rate, return, CAGR, drawdown, Sharpe ratio, and trade logs. Use when evaluating or comparing strategy rules (SMA crossover, RSI mean reversion, breakout), quantifying transaction-cost impact, tuning parameters, or generating performance summaries from CSV data. Trigger for requests like "回测股票策略胜率", "测收益率", "compare two strategy backtests", and "build a strategy report from historical prices".

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 "stock-strategy-backtester-clean" with this command: npx skills add taylen/stock-strategy-backtester-clean

Stock Strategy Backtester Clean

Version Notice

  • Use this clean slug if your environment pins to stock-strategy-backtester-clean.

Overview

Run repeatable, long-only stock strategy backtests from daily OHLCV CSV files. Use bundled scripts to generate consistent metrics and trade-level output, then summarize with investor-friendly conclusions.

Quick Start

  1. Prepare a CSV with at least Date and Close columns.
  2. Run a baseline backtest:
python scripts/backtest_strategy.py \
  --csv /path/to/prices.csv \
  --strategy sma-crossover \
  --fast-window 20 \
  --slow-window 60
  1. Export artifacts for review:
python scripts/backtest_strategy.py \
  --csv /path/to/prices.csv \
  --strategy rsi-reversion \
  --rsi-period 14 \
  --rsi-entry 30 \
  --rsi-exit 55 \
  --commission-bps 5 \
  --slippage-bps 2

Workflow

  1. Validate data
  • Ensure Date is parseable and sorted ascending.
  • Ensure Open/High/Low/Close are numeric; missing Open/High/Low falls back to Close.
  1. Pick strategy logic
  • sma-crossover: trend-following with fast/slow moving averages.
  • rsi-reversion: buy oversold and exit on momentum recovery.
  • breakout: enter on highs breakout and exit on lows breakdown.
  1. Set realistic assumptions
  • Always set --commission-bps and --slippage-bps.
  • Avoid reporting cost-free backtests as production-ready.
  1. Compare variants
  • Change one parameter block at a time.
  • Compare on the same date range and same cost model.
  1. Produce final summary
  • Report: total_return_pct, cagr_pct, win_rate_pct, max_drawdown_pct, sharpe_ratio, profit_factor, and trade count.
  • Use trade CSV to explain where alpha is coming from.

Supported Commands

  • Baseline SMA strategy:
python scripts/backtest_strategy.py \
  --csv /path/to/prices.csv \
  --strategy sma-crossover \
  --fast-window 10 \
  --slow-window 50
  • Breakout strategy:
python scripts/backtest_strategy.py \
  --csv /path/to/prices.csv \
  --strategy breakout \
  --lookback 20
  • JSON-only output (for automation pipelines):
python scripts/backtest_strategy.py \
  --csv /path/to/prices.csv \
  --strategy rsi-reversion \
  --quiet

Output Contract

  • Script prints a JSON object to stdout with:
  • strategy
  • period
  • metrics
  • config
  • trades

Analysis Guardrails

  1. Use out-of-sample logic
  • Prefer walk-forward validation over one-shot tuning.
  1. Avoid leakage
  • Compute signals from bar t, execute at bar t+1 open.
  1. Report downside with upside
  • Never present return without drawdown and trade count.
  1. Treat results as research
  • Backtests are not guarantees and should not be framed as financial advice.

References

  • Metrics details: references/backtest-metrics.md

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

Stock Strategy Backtester

Backtest stock trading strategies on historical OHLCV data and report win rate, return, CAGR, drawdown, Sharpe ratio, and trade logs. Use when evaluating or...

Registry SourceRecently Updated
1.6K2Profile unavailable
General

Quant System 5steps

5-Step Quant Trading System with multi-source data, enhanced ML models, and 15+ strategy templates

Registry SourceRecently Updated
1300Profile unavailable
Coding

joinquant

聚宽量化交易平台 - 提供A股、期货、基金数据查询,事件驱动策略回测,支持在线研究与模拟实盘。

Registry SourceRecently Updated
630Profile unavailable
General

Superior Trade

Interact with the Superior Trade API to backtest and deploy trading strategies on Superior Trade's managed cloud — no coding required from the user. The agen...

Registry SourceRecently Updated
1280Profile unavailable