risk-backtest
Backtest a supplied VaR forecast series, and optionally an Expected Shortfall series, against realised P&L. Reports exceptions, the Kupiec proportion-of-failures test, the Christoffersen independence and conditional coverage tests, the Basel MAR99 traffic-light zone for one-day 99% VaR, and the Acerbi-Szekely Z2 ES test with a seeded simulated p-value. Use to judge a forecast record, not to compute VaR (use risk-tail).
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- risk-backtest
- description
- Backtest a supplied VaR forecast series, and optionally an Expected Shortfall series, against realised P&L. Reports exceptions, the Kupiec proportion-of-failures test, the Christoffersen independence and conditional coverage tests, the Basel MAR99 traffic-light zone for one-day 99% VaR, and the Acerbi-Szekely Z2 ES test with a seeded simulated p-value. Use to judge a forecast record, not to compute VaR (use risk-tail).
02 资源文件 3
- 参考文档reference.md4.7 KB
- 脚本scripts/check_artifact.py2.1 KB
- 参考文档workflows/backtest-a-var-series.md1010 B
03 SKILL.md 正文
Risk Backtest
Tool risk_backtest, CLI riskdesk backtest --input PATH.
Contract (BacktestRequest)
Provenance fields as in input contracts: as_of, currency,
source, data_mode. Then:
pnl: realised P&L per period, positive is profit, time order, 2 to 10,000 rows.var: the VaR forecast for each row, positive is loss, made before that row's P&L was known.confidence(0 to 1, exclusive),horizon_days(positive integer).- Optional ES test:
expected_shortfall(same length, each positive and above its VaR), andes_null:normalorstudent-twithes_null_dof(above 1).seed(default 0).
Unknown fields, non-finite numbers and mismatched lengths are refused.
Report first
degradedanddegraded_reason.- Exceptions against expected exceptions (
exceptions,expected_exceptions). - The Basel zone if present, or
basel_traffic_light_unavailableif not. - Kupiec, Christoffersen independence, conditional coverage: statistic and p-value each.
- The ES test, with its null family, simulations, seed and Monte Carlo standard error.
Sign conventions
An exception is a realised loss strictly greater than VaR: -pnl > var. Z2 is zero in expectation when the forecasts are right; negative values mean risk was understated, and the p-value is the left tail.
What not to claim
- A test that does not reject has not validated the model. Backtests with few expected exceptions have little power: say how many were expected.
- The Basel zone is the MAR99 supervisory classification for one-day 99% VaR. It is not a capital calculation, and this tool does not report a multiplier.
- The ES p-value is under the stated location-scale null implied by each day's VaR and ES, not under the forecaster's own model distribution. Say which null was used.
- Kupiec and Christoffersen p-values are asymptotic chi-square.
- Research output, not a regulatory submission and not investment advice.
Going deeper
reference.md: formulas, sources with paragraph, and what each check proves.workflows/backtest-a-var-series.md: step by step.scripts/check_artifact.py: one line verdict on a saved result.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.