Class CentralRiskBook
Factor naming and units (query via exposure(String)):
EQ:<sym>— equity delta in book-currency notional (cash shares contribute qty·price; options contribute Δ·spot·contracts·multiplier);EQGAMMA:<sym>/EQVEGA:<sym>— dollar gamma per 1% move (Γ·S²/100 per contract-adjusted unit) and vega per vol POINT;CCY:<ccy>— currency exposure in NATIVE units of that currency (an EURUSD buy of 10M books CCY:EUR +10M euros and CCY:USD −10M·rate dollars) — this is what lets spot, swaps, NDFs and option deltas net at the CURRENCY level;FXPOINTS:<pair>— forward-points risk of swaps: P&L in quote units per 1.0 move in the far−near differential;FXGAMMA:<pair>/FXVEGA:<pair>— dollar gamma per 1% and vega per vol point, in quote-currency units.
Sign convention: positive quantity/notional = the BOOK is long.
Book what the book absorbs (a client sell hits the book as a buy).
NDFs carry currency delta until fixing; the pending non-deliverable
notional is tracked per pair in pendingFixing(String) and
released via settleFixing(java.lang.String, double) once fixings occur. This is a
RISK ledger, not a cash ledger: premium and settlement cash legs are
deliberately untracked (the same delta-only stance for cash equities
— no settlement cash — and options — no premium), and lifecycle
events (expiry, exercise, settlement) re-book as offsetting flows.
Deterministic, single-threaded, research/warm lane — pair it with
InternalizationEngine for flow decisions and
CrbAutoHedger for the hedging loop.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbookCashEquity(String desk, String symbol, double qty, double price) Cash equity:qtyshares (signed) atprice.voidbookEquityOption(String desk, String symbol, BlackScholes.OptionType type, double contracts, double multiplier, double spot, double strike, double rate, double carry, double vol, double timeYears) Listed equity option:contractssigned,multipliershares per contract (100 for US listed).voidbookFxOption(String desk, String pair, BlackScholes.OptionType type, double baseNotional, double spotRate, double strike, double domesticRate, double foreignRate, double vol, double timeYears) FX option via Garman-Kohlhagen (BlackScholeswith carry = foreign rate):baseNotionalsigned (long calls on base).voidbookFxSpot(String desk, String pair, double baseNotional, double rate) FX spot onpair("EURUSD"): buybaseNotionalof the base currency (signed) atrate.voidbookFxSwap(String desk, String pair, double baseNotional, double nearRate, double farRate) FX swap (buy-sell base for positive notional): near leg atnearRate, far leg back atfarRate.voidNDF: buybaseNotionalof base forward atfwdRate.doubledeskExposure(String desk, String factor) One desk's net contribution to a factor.desks()doubleNet exposure on a factor (0 for a factor never booked).factors()longdoublegrossExposure(String factor) Gross (sum of |flow|) on a factor — what the desks did severally.double[]Net exposures over all factors, indexed by registry id.doubleHow much risk the netting destroyed before anyone hedged:1 − Σ|net| / Σgross— 0 when every flow is one-way, → 1 when the desks' flows offset each other entirely.doublependingFixing(String pair) Non-deliverable notional still awaiting its fixing, per pair.voidRestores state written bywriteState(java.io.DataOutput)into THIS (fresh) book.report(double[][] covariance, double confidence) The book-level risk report.voidsettleFixing(String pair, double notional) Releasesnotional(positive, gross) of pending fixing after the fixing occurs — without this the pending number only ever grows and goes stale the day after the first fixing.voidwriteState(DataOutput out) Serializes the whole netted book — factor names, net/gross, per-desk attribution, pending fixings, flow count — for apersist.Checkpointsection.
-
Constructor Details
-
CentralRiskBook
public CentralRiskBook()
-
-
Method Details
-
bookCashEquity
-
bookEquityOption
public void bookEquityOption(String desk, String symbol, BlackScholes.OptionType type, double contracts, double multiplier, double spot, double strike, double rate, double carry, double vol, double timeYears) Listed equity option:contractssigned,multipliershares per contract (100 for US listed). Greeks come fromBlackScholeswith the house q-convention (carry= dividend yield). -
bookFxSpot
-
bookFxSwap
public void bookFxSwap(String desk, String pair, double baseNotional, double nearRate, double farRate) FX swap (buy-sell base for positive notional): near leg atnearRate, far leg back atfarRate. The base-currency legs cancel EXACTLY (that is what a swap is); what remains is the quote-currency cash-flow imbalance and the forward-POINTS risk. The FXPOINTS factor is the SENSITIVITY: a buy-sell locked in at today's (far − near) must close out at tomorrow's, so its P&L per +1.0 move in the market's far−near differential is−baseNotional— points widening HURTS the buy-sell. -
bookNdf
NDF: buybaseNotionalof base forward atfwdRate. Economically a forward until the fixing — full currency delta on both legs — with the non-deliverable notional tracked per pair (settlement is cash in the deliverable currency; what fixes at the fixing is the RATE, and until then the book is exposed). -
bookFxOption
public void bookFxOption(String desk, String pair, BlackScholes.OptionType type, double baseNotional, double spotRate, double strike, double domesticRate, double foreignRate, double vol, double timeYears) FX option via Garman-Kohlhagen (BlackScholeswith carry = foreign rate):baseNotionalsigned (long calls on base). Delta decomposes into the two currency legs; gamma/vega stay pair-keyed in quote-currency units. -
exposure
Net exposure on a factor (0 for a factor never booked). -
grossExposure
Gross (sum of |flow|) on a factor — what the desks did severally. -
deskExposure
-
netExposures
public double[] netExposures()Net exposures over all factors, indexed by registry id. -
nettingEfficiency
public double nettingEfficiency()How much risk the netting destroyed before anyone hedged:1 − Σ|net| / Σgross— 0 when every flow is one-way, → 1 when the desks' flows offset each other entirely. -
pendingFixing
Non-deliverable notional still awaiting its fixing, per pair. -
settleFixing
Releasesnotional(positive, gross) of pending fixing after the fixing occurs — without this the pending number only ever grows and goes stale the day after the first fixing. The fixed NDF's currency delta must be re-booked separately as the offsetting flow when it cash-settles (position decomposition, not lifecycle — see class doc). Over-settling throws: releasing more than is pending means the caller's fixing ledger disagrees with the book's, which is a reconciliation problem, not a rounding one. -
flowsBooked
public long flowsBooked() -
factors
-
desks
-
report
The book-level risk report.covarianceis over the factor space in REGISTRY ORDER (factors().name(i)) with entries in (factor-return)² units matching each factor's exposure units — the same contract asVarEngine. The headline number is the diversification benefit: standalone desk VaRs minus the netted book's VaR, i.e. what running the risk CENTRALLY is worth. -
writeState
Serializes the whole netted book — factor names, net/gross, per-desk attribution, pending fixings, flow count — for apersist.Checkpointsection. Restore into a FRESH instance viareadState(java.io.DataInput): a book that relearns its positions every morning is not a book.- Throws:
IOException
-
readState
Restores state written bywriteState(java.io.DataOutput)into THIS (fresh) book.- Throws:
IOException
-