0017 · More measurement, two more kernel rules, and a Beancount ledger
Status: accepted, 2026-09-27. The code is in src/measure/metrics.ts, src/risk/covariance.ts,
src/measure/ic.ts, src/measure/spa.ts, src/measure/screen-evidence.ts, src/measure/crps.ts,
src/kernel/kernel.ts and src/integrations/beancount.ts. The tests are test/metrics.test.ts,
test/covariance.test.ts, test/screen-evidence.test.ts, test/crps.test.ts, test/kernel-count-cost.test.ts
and test/beancount.test.ts. Reference: docs/measurement.md and
docs/integrations.md.
Context
The factsheet stopped at the Sharpe and its relatives, and said little about the shape of the losses. Risk had one
view of the book, the factor model. The screens sourced candidates, but nothing measured whether their rankings
predicted anything, or whether the best of them beat a null book once the picking was allowed for. Two mandate keys,
max_positions and cost_warn_pct, were set at setup, but no rule read them. The book could not be opened in a
double-entry tool.
Decision
- Distribution metrics on Analytics: Omega, the Ulcer index, historical CVaR, the tail ratio, up and down capture, and PSR. They follow empyrical's definitions, so each can be checked against it.
- Ledoit–Wolf covariance on Risk, with each position's share of volatility. Graded LOG: it is shown, and nothing is sized from it.
- Per-screen rank IC at 1, 5 and 20 sessions, and Hansen's SPA test against each null book, written weekly as
evidence.icandevidence.spa. Graded LOG: the kernel never reads them. The SPA bootstrap seed is taken from the Record head, so a replay reproduces the result. The walk yields to the event loop between screens, so a day run does not stall the server. - CRPS for the seats is the Brier score, and says so. The seats state only yes/no probabilities. For those the CRPS equals the Brier score exactly, so no separate column is shown. The general forms are tested and wait for a seat that states a distribution.
- Two kernel rules.
L-CONC-COUNTis HARD and readsmax_positions(default 12).L-COST-WARNis SOFT and readscost_warn_pct(default 3). Existing rules are unchanged. - A Beancount export, written from the Record rather than booked, so its balances are the book's. It comes from
npm run export:beancount,GET /api/export/beancountand/api/v1/export/ledger.beancount. Fava runs separately and unmodified.
Consequences
- The kernel has 26 rules. A proposal that would open a thirteenth name is blocked until the owner signs an
override, or raises
max_positionsby a signed mandate row. - A day run on a measurement day does about a second more CPU work.
- Paper returns in the SPA test are gross of costs, so a screen that passes has shown a signal, not a profit.
- Realized P&L in the ledger is the fund's average-cost figure. Beancount's own lot matching would give a different one, so holdings carry no cost lots.
- Beancount is not a dependency. The tests check the ledger with their own parser, not with
bean-check.