Skip to content

pricebook

A pricing-and-risk analytics library where every number is verified against the book or paper that defines it — not by a test that re-runs the code, but by an oracle that proves it against a known value.

The goal

Represent, value, and risk a position — price, greeks, calibration, scenario and P&L — for the asset classes a desk trades, ingesting any market provider through one representation contract. The point is to retire the expensive third-party black box, not to wrap it.

What it is

A functional core with an imperative shell: pricing is a pure price(product, model) → result; everything stateful is a thin shell around it. In scope are products, models, calibration, engines, risk, the market-data value types, and the representation of a position and a pricing request.

Out of scope — and built in other projects that consume the representation — are the GUI, the database, and broker and data feeds. The library is pluggable, not plugged in.

Why it is built this way

Its predecessor accreted references by inference: a provenance line naming a paper nobody had opened, a "this is probably Hull–White" in a comment. An unread citation is worse than none, because it looks like grounding. So the rule here is that nothing lands without a named, green oracle, and a source enters the register only when it is in hand and the claim has been read in it.

That has a cost and the cost is the point: the library grows by interest toward the goal above rather than by breadth, and a capability that cannot be oracled is not built — it is recorded as out of method until the discipline can reach it.

→ How every number is verified · Where it stands · What was built when

Inventory — derived from the tree, regenerated and drift-gated

  • Verification: 3645 tests (floored in CI), 13 verify.py gates plus ruff and pyright, mutation-swept; 11 whole-tree re-audits
  • Models: 40
  • Engines: 51, dispatching 37 (product, model) pairs
  • Products: 26

Greeks and book-level risk are DETECTED, not asserted — the columns below are derived from the risk layer, so they cannot drift. A hand-curated greeks cell said "Black MC only" and was wrong on this instrument's first run.

Asset class Engines Greek fns Book-level risk
commodity 4 — —
credit 8 — credit_valuation_adjustment, funding_valuation_adjustment, wrong_way_mc, wrong_way_risk
equity 7 4 equity_cva, sensitivities
inflation 5 — —
rates 12 — collateral, collateralised_capstone, mc_exposure
volatility 7 — —

Representation (R1) — 4 of 4 built. Detected by presence, so this column fills itself as the structural track proceeds.

Piece Built What it is
Trade yes a holding: product + units + direction (R1.1)
Position yes the trades held, across any number of products (R1.2)
PricingRequest yes what to value, as of when, against which market (R1.3)
MtMReport yes a book's mark, broken down by trade (R1.4)
Portfolio deferred a hierarchy of positions — deferred, because a flat multi-product Position is the book and nothing needs the hierarchy yet

Greeks (R2) — 17 of 17 built. The structural track's second column, detected by presence like R1's.

Piece Built What it is
bumped_equity_spot yes the bump primitive: a perturbed factor is a new snapshot (R2.1)
finite_difference_greek yes the generic FD greek over any priceable (R2.1)
equity_option_delta yes the first analytic greek, the FD's exact target (R2.1)
equity_option_gamma yes analytic gamma — the chain rule squared (R2.2)
equity_option_vega yes analytic vega, per unit of sigma (R2.2)
volatility_bump yes the model-level bump: vol is not in the snapshot (R2.2)
equity_option_theta yes analytic theta — the market-fixed decay (R2.2b)
equity_option_rho yes analytic rho — the total across three rate channels (R2.2b)
rolled_to yes the date roll: the market unchanged, seen from later (R2.2b)
paired_mc_spot_greek yes a greek of an MC estimate, banded by its paired paths (R2.3)
price_european_equity_option_mc yes the MC-priced equity vanilla the greek differences (R2.3)
book_greek yes a book's risk: one bump of the shared market, every trade repriced (R2.4)
bucketed_curve_greek yes the key-rate decomposition, one bucket per pillar (R2.4)
per_path_payoffs yes the engine's per-path protocol, so a book can band from its paths (R2.4)
spread_cross_gamma yes cross-gamma of the spread, Margrabe-exact (R2.5)
equity_option_vanna yes vanna and volga — the vol second order (R2.5)
book_risk yes the risk-a-book report: mark, every greek row, the buckets (R2.5)

Scenario / P&L (R3) — 3 of 3 built. The third structural column; a scenario is a finite reprice, so its oracle is an identity rather than a convergence rate.

Piece Built What it is
Scenario yes a composable FINITE market shock, not an infinitesimal one (R3.1)
scenario_value yes the book repriced under a shocked market — an exact identity (R3.1)
scenario_pnl yes the stress P&L: shocked minus base, the total R3.2 must attribute (R3.1)

Unclassified risk modules (7): analytic_greeks, book_greeks, book_risk, bumps, finite_difference, mc_greeks, scenario

Unclassified engines (4): equity_vanilla_mc, mtm, position, pricing_request — reported rather than dropped, so the table cannot look complete when it is not.