Agent skill

Backtesting

by gauss314 in gauss314/skills

Academic backtesting framework for quantitative research. An agent skill from gauss314/skills.

MITAuto-check passedBusiness, Finance & HR

Install Backtesting

skills CLI
$ npx skills add gauss314/skills --skill backtesting -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install gauss314/skills backtesting --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/gauss314/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/backtesting .claude/skills/backtesting && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
backtesting
GitHub stars
245
Token cost
~2.4k tokens
SKILL.md length
412 words
Files
34 (incl. scripts, references, assets)
Skills in repo
32
Repo updated
First seen
Licence
MIT

At a glance

Academic backtesting framework for quantitative research. An agent skill from gauss314/skills.

  • Tasks that involve Trading and backtesting
  • SKILL.md covers File Map, Quick Start, Using Ratios as a Library and Using the Engine, plus 2 more sections
  • Tasks that involve Event-driven systems

What it does

Backtesting is an agent skill from gauss314/skills. Academic backtesting framework for quantitative research. ~30 risk and performance ratios, 10 classes of indicators, event-driven engine with 6+ strategies, MPT optimizer, forward-looking simulation with Johnson SU + t-Copula, walk-forward CV, stress testing, fundamental analysis (Altman Z, Piotroski, DuPont). All flat Python + numpy.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 35 other files, including scripts, reference files and assets (for example `assets/defaults.json`, `assets/sample_portfolios.json` and `assets/validation_cases.json`).

It sits in Business, Finance & HR, covering Trading and backtesting and Event-driven systems. It works with NumPy and Python. The repository describes itself as: Financial market data consumption skills for claude code and AI agents. The licence is MIT.

When your agent uses it

  • Tasks that involve Trading and backtesting
  • Tasks that involve Event-driven systems

Example prompts

  • “/backtesting”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 5156f81. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/, which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Backtesting loads about 2.4k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 87 tokens; SKILL.md has 412 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~87
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~13k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from gauss314/skills at commit 5156f81, republished under its MIT licence (© gauss314). 412 words, ~2,357 tokens.

Download SKILL.mdSave it as .claude/skills/backtesting/SKILL.md (or your agent's skills folder). This skill also uses 33 other files; get the full folder from GitHub.
name
backtesting
description
Academic backtesting framework for quantitative research. ~30 risk and performance ratios, 10 classes of indicators, event-driven engine with 6+ strategies, MPT optimizer, forward-looking simulation with Johnson SU + t-Copula, walk-forward CV, stress testing, fundamental analysis (Altman Z, Piotroski, DuPont). All flat Python + numpy.
license
MIT

Backtesting — Full Backtesting Skill

This skill implements the full 5-stage backtesting methodology from the course material: Data → Research → Metrics → Parameterisation → Validation. It provides:

  • 30+ risk/performance ratios (flat, numpy-vectorized, no classes)
  • 10 classes of indicators following the course taxonomy (trend-following, oscillators, contrarians, flow, combined, discrete counts, seasonality, statistical, referential, fundamental)
  • Event-driven backtesting engine with 8 built-in strategies
  • Forward-looking simulation (Johnson SU marginals + t/Gaussian copula)
  • Portfolio theory (Markowitz efficient frontier, portfolio-of-portfolios)
  • Walk-forward cross-validation with IS/OOS split + gap
  • Stress testing with parametric scenario shocks
  • Fundamental analysis (Altman Z, Piotroski F, DuPont)

All scripts use only numpy, pandas, and scipy. No heavy dependencies.

Part of the Gauss314 Skills Repository.


File Map

skills/backtesting/
├── SKILL.md                         ← This file
├── references/
│   ├── BACKTESTING_THEORY.md        ← Marco conceptual: GIGO, trilema, 5 etapas (ES)
│   ├── RATIOS.md                    ← Fórmulas, convención de retornos, advertencias (ES)
│   ├── FEATURES.md                  ← Taxonomía de 10 clases de indicadores con edges (ES)
│   ├── SIMULATIONS.md               ← Pipeline Johnson SU + cópula (ES)
│   ├── VALIDATION.md                ← Suite de validación de 4 niveles (ES)
│   └── OTHER_FEATURES.md            ← Fundamental, Sentimiento, Exógenos (ES)
├── assets/
│   ├── sp500_returns.csv            ← SPY benchmark daily returns (lin + log), 1980-today
│   ├── momentum_sma50_200_returns.csv ← SMA(50)/SMA(200) crossover strategy returns
│   ├── contrarian_bbands_returns.csv  ← Bollinger Band contrarian strategy returns
│   ├── sample_portfolios.json       ← Real investor portfolios (Buffett, Dalio, Ackman, 60/40)
│   ├── defaults.json                ← Default parameters (VaR alpha, windows, etc.)
│   └── validation_cases.json        ← 6 known cases for ratio validation
├── scripts/
│   ├── __init__.py
│   ├── ratios.py                    ← 30+ flat numpy functions for all risk/performance ratios
│   ├── indicators.py                ← 10 classes of technical/statistical/fundamental indicators
│   ├── engine.py                    ← Event-driven BacktestEngine with 8 built-in strategies
│   ├── backtesting.py               ← CLI: run, sweep, walkforward, montecarlo, optmpt, event, validate
│   ├── simulations.py               ← CLI: marginal, copula, run, portfolio, scenarios
│   ├── forward.py                   ← CLI: project, risk, stress, summary
│   ├── distributions.py             ← Fit + KS test for Normal/t/NCt/Laplace/JohnsonSU
│   ├── copulas.py                   ← t/Gaussian/Clayton/Gumbel/Frank copulas + sampling
│   ├── fundamental_ratios.py        ← Income/balance/cashflow metrics, DuPont, Altman Z, Piotroski
│   └── validate.py                  ← 4-level validation: CLI modes, math consistency, edge cases, regression
└── tests/
    └── test_ratios.py               ← 18 pytest tests for core ratios
What each file does
FileRoleKey Functions / Modes
ratios.pyThe core library. Every ratio is a flat function accepting 1-D arrays.sharpe_ratio, max_drawdown, var_all, cvar_all, kelly_fraction, payoff_ratio, profit_factor, rachev_a/b/c, common_sense_ratio, ruin_curve, compute_all
indicators.py10 classes of indicators, covering all types from the course taxonomy.rsi, adx, bbands, macd, atr, cross_indicator, range_bound, zscore_norm, poisson_rate, binomial_ratio, fourier_terms, best_fit_dist
engine.pyBacktestEngine class and 8 strategy functions.BacktestEngine, strategy_sma_crossover, strategy_rsi_cross, strategy_bbands_contrarian, strategy_growth_momentum_combo
backtesting.pyMain CLI. Run full backtests, walks, sweeps, optimization.run, sweep, walkforward, montecarlo, optmpt, event, validate, bench
simulations.pyForward-looking simulation with Johnson SU + copula.marginal, copula, run, portfolio, scenarios
forward.pyRisk projection and stress testing.project, risk, stress, summary
distributions.pyDistribution fitting and comparison.fit, best_fit, compare_distributions, sample
copulas.pyCopula fitting and sampling.fit_t, fit_gaussian, sample_t, sample_gaussian, validate_copula
fundamental_ratios.pyFundamental analysis ratios.income_metrics, valuation_metrics, dupont, altman_z, piotroski
validate.py4-level integration testing suite.33 checks across CLI, math, edge cases, regression

Show full SKILL.md (156 more words)Show less

Quick Start

Basic Ratios
bash
# Compute all 30+ ratios on a CSV of prices
py scripts/backtesting.py run --prices assets/sp500_returns.csv

# Compute with benchmark comparison
py scripts/backtesting.py run --prices assets/momentum_sma50_200_returns.csv --benchmark assets/sp500_returns.csv
Validate (4-level suite)
bash
# Full validation (33 checks across 4 levels)
py scripts/validate.py

# Single level
py scripts/validate.py --nivel 1

Validates CLI modes, mathematical consistency of all ratios, edge case resilience, and post-fix regression. See references/VALIDATION.md for the detailed breakdown of all 33 checks.

Event-Driven Backtest
bash
# Load a CSV with OHLCV data and run SMA crossover
py scripts/backtesting.py event --data my_stock.csv --strategy sma_crossover --fast 50 --slow 200 --commission 0.001
Parameter Sweep
bash
# 2D sweep over fast/slow MA windows
py scripts/backtesting.py sweep --prices assets/sp500_returns.csv --p1-min 10 --p1-max 100 --p1-step 10
# 2D over 2 parameters
py scripts/backtesting.py sweep --prices assets/sp500_returns.csv --p1-min 10 --p1-max 50 --p1-step 5 --p2-min 25 --p2-max 200 --p2-step 25
Walk-Forward
bash
py scripts/backtesting.py walkforward --prices assets/sp500_returns.csv --splits 5 --gap 21
Markowitz Optimization
bash
py scripts/backtesting.py optmpt --assets assets/sp500_returns.csv --iterations 5000
Forward Simulation
bash
py scripts/simulations.py marginal --returns assets/sp500_returns.csv
py scripts/simulations.py copula --returns assets/sp500_returns.csv --df 4
py scripts/forward.py project --returns assets/sp500_returns.csv --horizon 252 --paths 10000 --drift 0.08
py scripts/forward.py risk --returns assets/sp500_returns.csv --horizon 252 --paths 10000
Portfolio Simulation
bash
py scripts/simulations.py portfolio --name warren_buffett
py scripts/simulations.py scenarios --name warren_buffett --cagr -0.3,-0.15,0,0.2,0.35,0.5

Using Ratios as a Library

python
from scripts.ratios import *

prices = np.array([100, 105, 102, 110, 108, 115])
r = linear_returns(prices)    # [0.05, -0.0286, 0.0784, -0.0182, 0.0648]
lr = log_returns(prices)      # [0.0488, -0.0290, 0.0755, -0.0183, 0.0628]

sharpe_ratio(r)               # 0.847
max_drawdown(prices)          # -0.0370
kelly_fraction(lr)            # 0.0793
var_all(r, alpha=0.05)        # {'empirical': ..., 'normal': ..., 'johnsonsu': ...}
profit_factor(lr)             # 2.314
payoff_ratio(lr)              # 1.578
rachev_c(lr, alpha=0.05)      # 1.234
common_sense_ratio(lr)        # 2.856

Using the Engine

python
from scripts.engine import BacktestEngine

eng = BacktestEngine(initial_capital=1.0, commission=0.001, slippage=0.0005)
eng.load_data(df_ohlcv)
result = eng.run(strategy='sma_crossover', strategy_params={'fast': 50, 'slow': 200})

print(result['metrics']['sharpe_ratio'])     # 0.847
print(result['trades'])
print(result['metrics'])

Dependencies

LibraryRequiredUsed for
numpy✅Vectorised computation, arrays, cumprod
pandas✅CSV I/O, rolling operations, DataFrames
scipy.stats✅Distribution fitting, KS test, copulas
statsmodelsOptionalSTL decomposition in indicators.py (Class 5)

To run the full validation suite (py scripts/validate.py) you also need pytest for the Level 4 regression check.

No arch, quantlib, sklearn required.


See Also

  • Gauss314 Skills Repository — other skills for financial data
  • references/BACKTESTING_THEORY.md — marco conceptual del backtesting (ES)
  • references/RATIOS.md — fórmulas, convención de retornos, advertencias (ES)
  • references/FEATURES.md — taxonomía de 10 clases de indicadores con edges (ES)
  • references/SIMULATIONS.md — pipeline de Johnson SU + cópula (ES)
  • references/VALIDATION.md — suite de validación de 4 niveles (ES)
  • references/OTHER_FEATURES.md — fundamental, sentimiento, exógenos (ES)

© gauss314, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 33 other files (scripts, references, assets) in skills/backtesting of gauss314/skills.

  • SKILL.md
  • assets/contrarian_bbands_returns.csv
  • assets/defaults.json
  • assets/frontier.csv
  • assets/momentum_sma50_200_returns.csv
  • assets/multi_asset_prices.csv
  • assets/multi_ma_3_5_8_13_returns.csv
  • assets/sample_portfolios.json
  • assets/sp500_close.csv
  • assets/sp500_prices.csv
  • assets/sp500_returns.csv
  • assets/trend_bbands_combo_returns.csv
  • assets/validation_cases.json
  • references/BACKTESTING_THEORY.md
  • references/FEATURES.md
  • references/OTHER_FEATURES.md
  • references/RATIOS.md
  • references/SIMULATIONS.md
  • references/VALIDATION.md
  • … and 15 more

Open the folder on GitHubat commit 5156f81

Compare with similar skills

Backtesting next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Backtesting compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Backtesting this skillgauss314/skills245—~2.4kAutomated safety check: PassMIT
Tushare Datazillionare/zillionare3182 repos~2.3kAutomated safety check: PassNone
Quant Blog Writingzillionare/zillionare318—~895Automated safety check: PassNone
Elliott Wave Signal EngineHKUDS/Vibe-Trading35k—~482Automated safety check: PassMIT
Candlestick Pattern SignalsHKUDS/Vibe-Trading35k—~468Automated safety check: PassMIT
Event-Driven Sentiment SignalsHKUDS/Vibe-Trading35k—~2.1kAutomated safety check: PassMIT

Similar skills

  • Tushare Data

    zillionare/zillionare

    面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。

    318 GitHub starsUsed in 2 repos~2.3k tokens
    Business, Finance & HRAuto-check passed
  • Quant Blog Writing

    zillionare/zillionare

    撰写文笔精炼、富有深度的量化交易博文,论点清晰、证据确凿、叙事层次更加丰富。适用于量化交易博文、因子研究、回测复盘、数据源排查、市场微观结构、策略原理、风险控制、职业观察、量化人物故事等选题。文章将聚焦具体角度,提供详实的大纲、证据规划及成稿,力求内容兼具思想深度与诚实性,而非单纯口号式宣传;同时,通过人物经历、引言、贡献及行业背景的融入,让文章更具可读性和吸引力。

    318 GitHub stars~895 tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Elliott Wave Signal Engine

    HKUDS/Vibe-Trading

    Detects Elliott Wave structures in price data with a Zigzag swing finder and Fibonacci checks, and turns completed waves into long, short or flat signals.

    35k GitHub stars~482 tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Candlestick Pattern Signals

    HKUDS/Vibe-Trading

    Detects 15 classic candlestick patterns with vectorized pandas code and combines bullish and bearish scores into a long, short or flat trading signal.

    35k GitHub stars~468 tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Scores news, announcements and macro events with the LLM, stores them in an event CSV and blends the decaying event signal with technical signals in signal_engine.py.

    35k GitHub stars~2.1k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Ichimoku Kinko Hyo Signals

    HKUDS/Vibe-Trading

    Generates trading signals from the Ichimoku five-line system using Tenkan and Kijun crossovers, cloud position and cloud direction, implemented in pandas.

    35k GitHub stars~417 tokensUpdated yesterday
    Business, Finance & HRAuto-check passed

More from gauss314/skills

All 32 skills in this repo
  • Google Finance

    gauss314/skills

    Datos de Google Finance via batchexecute (API RPC interna sin auth ni API key).

    245 GitHub stars~3.1k tokensUpdated 3 mo ago
    Auto-check passed
  • Historyofmarket

    gauss314/skills

    History of Market (historyofmarket.com) — API publica con 88 datasets historicos de indices US desde 1871.

    245 GitHub stars~1.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Indec

    gauss314/skills

    Datos macro y sociales de Argentina via la API oficial Series de Tiempo del Estado (apis.datos.gob.ar/series).

    245 GitHub stars~3k tokensUpdated 3 mo ago
    Auto-check passed
  • Morningstar

    gauss314/skills

    Morningstar Screener via API JSON publica: descarga masiva de 53 universes (102K+ listings, 39 paises, NYSE/Nasdaq/BCBA/etc) con 33 campos (precio, market cap, ratios, retornos…

    245 GitHub stars~2.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Option Pricing

    gauss314/skills

    Pricing completo de opciones europeas y americanas. An agent skill from gauss314/skills.

    245 GitHub stars~4.7k tokensUpdated 3 mo ago
    Auto-check passed
  • Portfolio

    gauss314/skills

    Construcción y optimización cuantitativa de portafolios: Markowitz (scipy.optimize + Monte Carlo), Black-Litterman (prior CAPM, views absolutas/relativas, posterior bayesiano), HRP/HERC/NCO…

    245 GitHub stars~2.4k tokensUpdated 3 mo ago
    Auto-check passed

Works with

Questions about Backtesting

What does Backtesting do?

Academic backtesting framework for quantitative research. An agent skill from gauss314/skills. Backtesting is an agent skill from gauss314/skills. Academic backtesting framework for quantitative research.

When should I use Backtesting?

Backtesting fits situations like: tasks that involve Trading and backtesting; tasks that involve Event-driven systems.

How do I install Backtesting in Claude Code?

Run `npx skills add gauss314/skills --skill backtesting -a claude-code`. Or copy the skill folder (skills/backtesting in gauss314/skills) into .claude/skills/backtesting in your project. Claude Code loads it when a task matches its description.

How do I install Backtesting in Codex?

Run `npx skills add gauss314/skills --skill backtesting -a codex`. Or copy the skill folder (skills/backtesting in gauss314/skills) into .agents/skills/backtesting in your project. Codex loads it when a task matches its description.

Can I use Backtesting in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add gauss314/skills --skill backtesting -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/backtesting, .gemini/skills/backtesting, .github/skills/backtesting and .opencode/skills/backtesting in your project.

What does Backtesting need to run?

SKILL.md names no scripts, command-line tools or credentials: Backtesting is instructions for the agent only. Our summary lists: Python 3.

Does Backtesting access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Backtesting safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Backtesting use?

Backtesting is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Backtesting use?

About 2.4k tokens (SKILL.md is roughly 9.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 10k tokens, read only when the agent opens those files.

What are the alternatives to Backtesting?

Skills that share tags, products or a category with Backtesting: Tushare Data (zillionare/zillionare, 318 stars), Quant Blog Writing (zillionare/zillionare, 318 stars), Elliott Wave Signal Engine (HKUDS/Vibe-Trading, 35k stars) and Candlestick Pattern Signals (HKUDS/Vibe-Trading, 35k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Backtesting?

gauss314 (a GitHub user) maintains it in gauss314/skills, which has 245 GitHub stars. The repository holds 32 skills in this directory. The repository was last updated on June 14, 2026.

Source: gauss314/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.