Package com.quantfinlib.crb


@NullMarked package com.quantfinlib.crb
The central risk book: one netted view of the firm's risk across desks and products, with internalization, routing and hedging.

Netting centrally avoids two desks each paying the market to shed opposite risks. Every instrument (cash equities, listed equity options, FX spot, FX swaps, NDFs, FX options) decomposes into a common factor space at booking (CentralRiskBook: equity deltas per symbol, currency-level FX deltas so spot/swap/NDF/option legs net, dollar gamma and vega per underlying, forward-points risk). Incoming flow is priced with an inventory skew (SkewedQuoter) and either internalized or routed (InternalizationEngine: risk-reducing flow earns price improvement, risk-adding flow is warehoused only inside the limit). The residual is watched by CrbAutoHedger (on a band breach it hedges only the excess) through HedgeOptimizer (minimum variance with an L1 cost term — expensive instruments get exactly zero) over a CrbHedgeUniverse (the loadings-matrix builder), and hedge orders route through CrbRouter: internal cross first, adverse-selection-priced dark venues second, lit last. CrbPnlLedger records whether the captured spread paid for the hedging.

Everything is deterministic, single-threaded, research/warm lane (interval cadence; the low-latency lanes are in trading and marketdata). CentralRiskBook.report hands the netted book to VarEngine for VaR/ES and prices the diversification benefit of running risk centrally.

  • Class
    Description
    The central risk book — one netted view of the firm's market risk across desks and products.
    Snapshot of the book's exposures.
    The central risk book's hedging loop: per-factor exposure bands, a cost-aware hedge when breached, and a cooldown so the book does not chase its own hedges.
    One instrument's hedge instruction.
    The hedge-instrument universe, aligned to a book's factor registry — because hand-assembling loadings[factor][instrument] is the most error-prone step in the whole hedging workflow (one transposed index and the optimizer confidently hedges the wrong thing).
    The central risk book's economics ledger — the number the desk head actually asks for at the close: did the spread we captured by internalizing pay for the hedging we did?
    The central risk book's order router — internal cross first, dark pools second, lit last, each leg priced at its expected all-in cost: Internal — crossing against the book's own offsetting inventory costs zero bps and leaks nothing: the CRB itself is the firm's first and best dark pool.
    Where the notional went.
    A dark venue as the router sees it.
    Dense integer ids for risk-factor names — the SymbolRegistry pattern applied to the central risk book's factor space, so exposure arithmetic runs over primitive arrays while the factor names stay readable (EQ:AAPL, CCY:EUR, FXVEGA:EURUSD).
    Cost-aware minimum-variance hedging of the central risk book's residual — the question is never "how do we flatten this" (sell everything) but "what is the cheapest basket of liquid instruments that takes the risk below the limit".
    The internalize-or-route decision — the economics that justify a central risk book's existence.
    Where one flow went, and what the client got for it.
    Inventory-skewed two-way pricing — the central risk book's quoting face.
    A shaded two-way price.