backtest
Use when tasks need vectorized strategy execution, portfolio weighting, portfolio-level filters, transaction cost helpers, exit A/B analysis, overlay metrics…
Skill by quantskills
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/quantskills-backtest
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 2
codeload.github.com· found in install commandjoinquant.com· found in code
Files it touches
~/.claude/skills/backtest
What's inside
- Skill name
backtest- Description
- Use when tasks need vectorized strategy execution, portfolio weighting, portfolio-level filters, transaction cost helpers, exit A/B analysis, overlay metrics, or multi-strategy return blending.
- License
- GPL-3.0
- Instructions
- 74 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (10)
- SKILL.md
- __init__.py
- combiner.py
- cost_model.py
- exit_analysis.py
- filters.py
- overlay_metrics.py
- protocols.py
- vector.py
- weighting.py
SKILL.md (first lines)
# Backtest
Backtest is the shared portfolio execution and construction boundary. Strategy
domains should produce date x symbol weights; this skill turns those weights
into executed weights, returns, costs, diagnostics, and report-ready metrics.
## Public API
```python
from skills.backtest import VectorBacktester, annual_return_metrics
from skills.backtest.weighting import WEIGHT_METHODS, risk_parity
from skills.backtest.filters import apply_portfolio_filters
from skills.backtest.cost_model import cost_bp_for_trigger_time
from skills.backtest.exit_analysis import evaluate_exit_factor
from skills.backtest.overlay_metrics import overlay_alpha
```
## Components
| Module | Purpose |
|--------|---------|
| `skills.backtest.vector` | `VectorBacktester`, `BacktestResult`, annual/activity/benchmark metrics |
| `skills.backtest.weighting` | Equal weight, risk parity, inverse variance, EPO, `WEIGHT_METHODS` |
| `skills.backtest.filters` | Market breadth, index trend, and volatility targeting overlays |
| `skills.backtest.combiner` | Blend multiple strategy return streams |
| `skills.backtest.cost_model` | A-share trigger-time cost layers and single-trade PnL helpers |
| `skills.backtest.exit_analysis` | Baseline vs filtered exit A/B evaluation |
| `skills.backtest.overlay_metrics` | Overlay alpha, win rate, drawdown, Sharpe, and regime metrics |
`VectorBacktester` requires explicit `commission` and `slippage_bp` (a missing
value raises `ValueError`). Each date's executed weight always earns the
next bar's return, which is the safe convention for close-derived signals.
## Recipes
**Run weights through the shared vectorized backtester**
```python
from skills.backtest import VectorBacktester
result = VectorBacktester(
data=panel,
trade_at="close",
signal_lag=1,
commission=0.0002,
slippage_bp=2.0,
).run(weights_df)
```
**Convert votes to risk-aware weights**
```python
from skills.backtest.weighting import risk_parity
weights = risk_parity(votes_df, returns_df=returns_df, lookback=60, min_periods=20)
```
**Evaluate an exit filter**
```python
from skills.backtest.exit_analysis import evaluate_exit_factor
from skills.strategy.cross_sectional import ModularBacktester
result = evaluate_exit_factor(
data,
factor_configs,
exit_filter,
backtester_cls=ModularBacktester,
commission=0.0002,
slippage_bp=2.0,
)
```
## CLI command reference
<!-- BEGIN GENERATED: qs commands -->
Transport: `--input-json FILE|-`, `--preview N`, and `--log-level LEVEL`; flags override JSON. Use `--print-template [FIELD]` for fillable templates.
### Shared parameter groups
#### `PanelSource`
| Option | Type / default | Description |
|---|---|---|
| `--panel` | `path?` / `null` | Parquet/CSV panel, mutually exclusive with symbols or symbols-file. |
| `--symbols` | `list[string]` / `factory` | QuantSpace symbols such as SHSE.510300; repeat flag or comma-separate. |
| `--symbols-file` | `path?` / `null` | Text lines or JSON list of QuantSpace symbols. |
| `--frequency` | `string` / `1d` | Market store directory under data/market, for example 1d or 1d_adj. |
| `--data-root` | `path?` / `null` | Managed data root; otherwise QUANTSPACE_DATA_ROOT or repository data/. |
| `--start` | `string?` / `null` | Inclusive start date: YYYY-MM-DD or YYYYMMDD. |
| `--end` | `string?` / `null` | Inclusive end date: YYYY-MM-DD or YYYYMMDD. |
| `--fields` | `list[string]` / `factory` | Optional panel field subset. |
#### `OutputOptions`
| Option | Type / default | Description |
|---|---|---|
| `--output` | `path?` / `null` | Explicit output path outside managed store namespaces. |
| `--overwrite` | `boolean` / `false` | Allow replacing an existing output artifact. |
| `--data-root` | `path?` / `null` | Managed data root; otherwise QUANTSPACE_DATA_ROOT or repository data/. |
### `uv run qs backtest run`
Execute target weights through VectorBacktester with costs and metrics.
Priority: P0. Side effects: writes-output.
Shared parameters: `PanelSource`.
| Option | Type / default | Description |
|---|---|---|
| `--start` | `string?` / `null` | First result date (start_date); earlier bars still load. Pass a trimmed --panel from `qs store read` to limit history. |
| `--end` | `string?` / `null` | Last result date (end_date); later bars still load. Pass a trimmed --panel from `qs store read` to limit history. |
| `--weights` | `path` / `required` | Date by symbol target weights table (eob index or column). |
| `--commission` | `number` / `required` | One-way commission rate, e.g. 0.0002. |
| `--slippage-bp` | `number` / `required` | One-way slippage in basis points. |
| `--trade-at` | `open\|close` / `close` | Execution price field. |
| `--signal-lag` | `integer` / `1` | Bars between signal and execution. |From quantskills/agent-quantspace, GPL-3.0.
More from quantskills/agent-quantspace
- 0.667score
analyze
quantskills
Use when tasks need factor diagnostics, IC/grouped return analysis, attribution, robustness checks, deterministic factor-mining evaluation, or time-series…
SkillAFreshness: A★ 64Claude Code +9 - 0.632score
ingest
quantskills
Use when tasks need PandaData/PandaAI stock, fund, ETF, index, or futures data, reference data, adjustment factors, futures tick downloads, or symbol…
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
ml
quantskills
Use when tasks need optional PyCaret model training, ML factor generation, inference wrappers, feature importance, or sparse LASSO weight generation.
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
report
quantskills
Use when tasks need complete HTML research reports, HTML dashboards, PNG chart helpers, or files under the research reports directory.
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
strategy
quantskills
Use when tasks need reusable strategy contracts, cross-sectional selection types, or time-series signal-to-weight helpers.
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
compute
quantskills
Use when tasks need strategy-agnostic OHLCV indicators, math utilities, generic factor examples, regime slicing, resampling, or label makers.
SkillBFreshness: B★ 64Claude Code +9 - 0.626score
store
quantskills
Use when tasks need local market Parquet data, factor artifacts, backtest data, or model files through DataManager.
SkillBFreshness: B★ 64Claude Code +9 - 0.623score
factor_mining
quantskills
Use when tasks need AI multi-agent factor mining research boundaries, versioned ResearchBrief/FactorSpec contracts, evaluation/review/decision objects, or…
SkillBFreshness: B★ 64Claude Code +9 - 0.621score
research
quantskills
Use when tasks need reusable research pipeline templates, factor screening, or parameter sensitivity sweeps.
SkillBFreshness: B★ 64Claude Code +9
Signals
- Stars
- 64
- Forks
- 14
- Open issues
- 2
- Last commit (this folder)
- Aug 7, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- GPL-3.0
- Repository
- github.com/quantskills/agent-quantspace
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from quantskills
- 0.667score
analyze
quantskills
Use when tasks need factor diagnostics, IC/grouped return analysis, attribution, robustness checks, deterministic factor-mining evaluation, or time-series…
SkillAFreshness: A★ 64Claude Code +9 - 0.632score
ingest
quantskills
Use when tasks need PandaData/PandaAI stock, fund, ETF, index, or futures data, reference data, adjustment factors, futures tick downloads, or symbol…
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
ml
quantskills
Use when tasks need optional PyCaret model training, ML factor generation, inference wrappers, feature importance, or sparse LASSO weight generation.
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
report
quantskills
Use when tasks need complete HTML research reports, HTML dashboards, PNG chart helpers, or files under the research reports directory.
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
strategy
quantskills
Use when tasks need reusable strategy contracts, cross-sectional selection types, or time-series signal-to-weight helpers.
SkillBFreshness: B★ 64Claude Code +9 - 0.627score
compute
quantskills
Use when tasks need strategy-agnostic OHLCV indicators, math utilities, generic factor examples, regime slicing, resampling, or label makers.
SkillBFreshness: B★ 64Claude Code +9
Cite this page
backtest skill. Agent Mart. https://agentmart.dev/skills/quantskills-backtest (last updated 2026-10-24)