Class CrbPnlLedger

java.lang.Object
com.quantfinlib.crb.CrbPnlLedger

public final class CrbPnlLedger extends Object
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? A CRB that nets beautifully but hedges expensively is a cost center with good graphics.

Accounting model (realized flow economics, deliberately simple and stated): internalized client flow captures the street half spread minus whatever improvement was given back (notional·(halfSpread − improvement)/1e4); routed flow captures nothing (it went to the street); hedge executions cost their all-in bps; router allocations cost their blended expected bps. Inventory MARK-TO-MARKET P&L is deliberately out of scope — that is the risk report's domain (CentralRiskBook.report), and mixing realized spread economics with unrealized inventory marks is how desks fool themselves. All notionals positive, all bps non-negative, book-currency units. Persistable via writeState/readState (persist.Checkpoint section); deterministic, single-threaded, research/warm lane.

  • Constructor Details

    • CrbPnlLedger

      public CrbPnlLedger()
  • Method Details

    • onInternalized

      public void onInternalized(double internalizedNotional, double halfSpreadBps, double improvementBps)
      Records one internalization decision's economics.
      Parameters:
      internalizedNotional - |notional| kept on the book, ≥ 0
      halfSpreadBps - the street half spread saved, > 0
      improvementBps - improvement given to the client, ≥ 0 and ≤ halfSpreadBps
    • onDecision

      public void onDecision(InternalizationEngine.Decision decision, double halfSpreadBps)
      Convenience: books a whole InternalizationEngine.Decision.
    • onHedge

      public void onHedge(double notional, double costBps)
      Records a hedge execution's all-in cost.
    • onRoute

      public void onRoute(double notional, CrbRouter.Allocation allocation)
      Records a router allocation's blended expected cost.
    • spreadCaptured

      public double spreadCaptured()
      Spread captured by internalizing, net of improvement given back.
    • improvementPaid

      public double improvementPaid()
      Improvement handed to clients — the cost of being worth trading with.
    • hedgeCost

      public double hedgeCost()
    • routerCost

      public double routerCost()
    • netEconomics

      public double netEconomics()
      The desk's realized economics: captured spread minus hedging and routing costs. POSITIVE means the netting engine paid for its own risk management — the CRB's entire commercial argument.
    • internalizations

      public long internalizations()
    • hedges

      public long hedges()
    • writeState

      public void writeState(DataOutput out) throws IOException
      Throws:
      IOException
    • readState

      public void readState(DataInput in) throws IOException
      Throws:
      IOException