quantskills/agent-quantspace/backtest

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

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.

Install

npx vskill@latest install quantskills/agent-quantspace/backtest

SKILL.md

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

ModulePurpose
skills.backtest.vectorVectorBacktester, BacktestResult, annual/activity/benchmark metrics
skills.backtest.weightingEqual weight, risk parity, inverse variance, EPO, WEIGHT_METHODS
skills.backtest.filtersMarket breadth, index trend, and volatility targeting overlays
skills.backtest.combinerBlend multiple strategy return streams
skills.backtest.cost_modelA-share trigger-time cost layers and single-trade PnL helpers
skills.backtest.exit_analysisBaseline vs filtered exit A/B evaluation
skills.backtest.overlay_metricsOverlay 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
OptionType / defaultDescription
--panelpath? / nullParquet/CSV panel, mutually exclusive with symbols or symbols-file.
--symbolslist[string] / factoryQuantSpace symbols such as SHSE.510300; repeat flag or comma-separate.
--symbols-filepath? / nullText lines or JSON list of QuantSpace symbols.
--frequencystring / 1dMarket store directory under data/market, for example 1d or 1d_adj.
--data-rootpath? / nullManaged data root; otherwise QUANTSPACE_DATA_ROOT or repository data/.
--startstring? / nullInclusive start date: YYYY-MM-DD or YYYYMMDD.
--endstring? / nullInclusive end date: YYYY-MM-DD or YYYYMMDD.
--fieldslist[string] / factoryOptional panel field subset.
OutputOptions
OptionType / defaultDescription
--outputpath? / nullExplicit output path outside managed store namespaces.
--overwriteboolean / falseAllow replacing an existing output artifact.
--data-rootpath? / nullManaged 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.

OptionType / defaultDescription
--startstring? / nullFirst result date (start_date); earlier bars still load. Pass a trimmed --panel from qs store read to limit history.
--endstring? / nullLast result date (end_date); later bars still load. Pass a trimmed --panel from qs store read to limit history.
--weightspath / requiredDate by symbol target weights table (eob index or column).
--commissionnumber / requiredOne-way commission rate, e.g. 0.0002.
--slippage-bpnumber / requiredOne-way slippage in basis points.
--trade-at`open\close / close`Execution price field.
--signal-laginteger / 1Bars between signal and execution.
--enforce-trade-constraintsboolean / falseApply suspension and limit masks; the panel needs is_suspended, is_limit_up and is_limit_down.
--out-dirpath? / nullOptional directory for result.parquet, executed_weights.parquet and metrics.json.
--overwriteboolean / falseAllow replacement of existing output files.

Output data fields: metrics, annual_returns, activity, rows, start, end.

Inspect schemas: uv run qs schema backtest.run (add --part input|output or --file-field FIELD).

uv run qs backtest weigh

Convert a vote matrix into portfolio weights.

Priority: P1. Side effects: writes-output.

Shared parameters: PanelSource, OutputOptions.

OptionType / defaultDescription
--outputpath / requiredDestination weights table.
--votespath / requiredDate by symbol vote matrix; nonzero means selected.
--returnspath? / nullDate by symbol asset returns; otherwise close-to-close returns of a panel source.
--method`equal\risk_parity\inverse_variance\epo / equal`WEIGHT_METHODS key.
--lookbackinteger? / nullTrailing return window; defaults to the method default (60, epo 1200).
--min-periodsinteger? / nullMinimum trailing observations; defaults to the method default (20, epo 60).
--lambdanumber / 10.0EPO risk aversion.
--shrink-wnumber / 0.2EPO correlation shrinkage.

Output data fields: method, rows, columns, start, end, preview.

Inspect schemas: uv run qs schema backtest.weigh (add --part input|output or --file-field FIELD).

uv run qs backtest overlay

Scale weights with market breadth, index trend, or volatility targeting.

Priority: P2. Side effects: writes-output.

Shared parameters: PanelSource, OutputOptions.

OptionType / defaultDescription
--outputpath / requiredDestination scaled weights table.
--weightspath / requiredDate by symbol weights to scale.
--index-closepath? / nullBenchmark close table with an eob index and one value column; required by index_trend.
--market-breadthobject? / nullapply_market_breadth_scale options, e.g. {"breadth_threshold": 0.3, "scale_below": 0.5, "ma_period": 20}.
--index-trendobject? / nullapply_index_trend_scale options, e.g. {"scale_downtrend": 0.5, "ma_period": 120}.
--vol-targetobject? / nullapply_portfolio_vol_targeting options, e.g. {"vol_target": 0.1, "lookback": 60}.

Output data fields: method, rows, columns, start, end, preview.

Inspect schemas: uv run qs schema backtest.overlay (add --part input|output or --file-field FIELD).

uv run qs backtest combine

Blend strategy return streams with StrategyCombiner.

Priority: P2. Side effects: writes-output.

Shared parameters: OutputOptions.

OptionType / defaultDescription
--returnspath / requiredStrategy daily returns: eob index or column plus one column per strategy.
--method`equal\risk_parity\custom / equal`StrategyCombiner method.
--weightsobject / factoryCustom strategy weights, normalized to sum to one.
--lookbackinteger / 60Risk parity volatility window.

Output data fields: strategies, weights, metrics, rows.

Inspect schemas: uv run qs schema backtest.combine (add --part input|output or --file-field FIELD).

uv run qs backtest cost

Look up the A-share trigger-time cost layer and single T PnL.

Priority: P2. Side effects: read-only.

OptionType / defaultDescription
--timestring / requiredA-share trigger timestamp, e.g. "2026-09-23 14:50".
--sell-pricenumber? / nullSell price of a single T trade; needs buyback_price.
--buyback-pricenumber? / nullBuyback price of a single T trade; needs sell_price.

Output data fields: time, layer, cost_bp, gross_bp, net_bp.

Inspect schemas: uv run qs schema backtest.cost (add --part input|output or --file-field FIELD).

<!-- END GENERATED: qs commands -->

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
57
Repository forks
11
7-day trend score
20

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/quantskills/agent-quantspace/backtest/badge)](https://verified-skill.com/skills/quantskills/agent-quantspace/backtest)

Something wrong with this skill or its page? Tell us.