strategy-backtest

A trading-strategy tester that uses past price and trading-volume data to simulate a simple moving-average crossover strategy.

In plain words
What is it for?
Use it to test CSV or JSON price data, compare different fast and slow moving-average periods, and review returns, risk, drawdowns, win rate, and the trade log.
Why use it?
It turns historical market data into consistent performance figures, so you can assess a strategy without calculating each trade by hand.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/leionion/clawforge/strategy_backtest
Any agent
npx skills add leionion/ClawForge --skill strategy_backtest
Clone the repo
git clone --depth 1 https://github.com/leionion/ClawForge

Made for: Claude Code, Codex.

Per session 92 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 708 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00092 $0.00708
Opus 5 $0.00046 $0.00354
Sonnet 5 $0.00018 $0.00142
Haiku 4.5 $0.00009 $0.00071

Measured 3d ago against content hash a0b51d994d81, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

strategy-backtest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (strategy_backtest.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/04-Process/strategy_backtest/SKILL.md · 75 lines

How it starts

The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on 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)
  • hhxg-top-hhxg-python: fetch A-share OHLCV data → feed into this skill
  • session-memory: store backtest metrics for later comparison

Read the full file on GitHub · 75 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 75 lines · 92 tokens per session scan A a0b51d994d81

Subscribe to this mod's changes

strategy-backtest is a skill published in the GitHub repository leionion/ClawForge (90 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 92 tokens to every session and 708 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

1m-trade

Integrated on-chain operations hub: integrates BlockBeats market intelligence, Hyperliquid DEX trading via hl1m, wallet creation and management at https://www.1m-trade.com, and supports local initialization using hl1m init-wallet (wallet address + proxy private key, never use the main wallet private key). Supports…

LeoYeAI/openclaw-master-skills · 79 tokens

1m-trade-dex

Hyperliquid DEX/Perps entrypoint via hl1m: market queries, order placement. Wallet creation/management at https://www.1m-trade.com; local hl1m init-wallet with address + proxy (API) private key — never the main wallet key. No in-skill private-key messaging.

LeoYeAI/openclaw-master-skills · 76 tokens

1m-trade-wallet

Create EVM wallets, automate funding/bridging to Hyperliquid L1, and activate accounts (auto swap, bridging, and L1 activation).

LeoYeAI/openclaw-master-skills · 37 tokens

earn-hunter

Automatically monitors OKX Flash Earn, Fixed Earn and Flexible Earn opportunities, sends push notifications, and guides subscription. 自动监控 OKX 闪赚、定期和活期赚币机会,推送通知并引导申购。Use when user says: 有闪赚通知我, 监控赚币, monitor earn, notify me about earn, 定时检查理财, 执行 earn-hunter 扫描, earn-hunter scan, 活期年化高了通知我, 监控活期.

okx/agent-trade-kit · 114 tokens

okx-cex-bot

Manage Grid bots (spot/contract/coin-margined) and DCA Martingale bots (Spot DCA 现货马丁 / Contract DCA 合约马丁) on OKX. Covers create, stop, amend, monitor P&L, TP/SL, margin/investment adjustment, and AI-recommended parameters. Requires API credentials. Not for regular orders (okx-cex-trade), market data (okx-cex-market)…

okx/agent-trade-kit · 112 tokens

okx-cex-trade

Use when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a position', 'close a position', 'set take profit', 'limit take profit', 'immediate TP', 'set stop loss', 'self-trade prevention', 'stpMode'…

okx/agent-trade-kit · 278 tokens