Class PnlAttribution

java.lang.Object
com.quantfinlib.risk.PnlAttribution

public final class PnlAttribution extends Object
FRTB P&L attribution test (PLAT) — the exam a risk MODEL must pass to keep internal-model approval: does the risk engine's theoretical P&L (RTPL — what the model's factors and pricers say the desk made) actually track the desk's hypothetical P&L (HPL — what revaluing the real book on real prices says)? Two statistics, per MAR32:
  • Spearman correlation between daily HPL and RTPL — do they RANK days the same way;
  • Kolmogorov-Smirnov statistic between their empirical distributions — do they have the same SHAPE.
Zones per the regulation: GREEN (corr > 0.80 and KS < 0.09), RED (corr < 0.70 or KS > 0.12), AMBER between — amber adds a capital surcharge, red kicks the desk to the standardized approach. Failing PLAT usually means missing risk factors: the model prices with fewer factors than move the real book. Styled after BCBS MAR32, not certified (same stance as FrtbEs). Research lane.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    The PLAT verdict for one desk over one window.
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    ksStatistic(double[] a, double[] b)
    The two-sample KS statistic: max gap between the empirical CDFs, evaluated after BOTH samples have consumed each distinct value — ties must not register a transient gap (identical series score exactly 0).
    test(double[] hypotheticalPnl, double[] riskTheoreticalPnl)
    Runs the PLAT over aligned daily P&L series (250 days is the regulatory window; anything ≥ 20 computes).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • test

      public static PnlAttribution.Result test(double[] hypotheticalPnl, double[] riskTheoreticalPnl)
      Runs the PLAT over aligned daily P&L series (250 days is the regulatory window; anything ≥ 20 computes).
      Parameters:
      hypotheticalPnl - HPL — actual book, actual prices
      riskTheoreticalPnl - RTPL — the risk model's factors + pricers
    • ksStatistic

      public static double ksStatistic(double[] a, double[] b)
      The two-sample KS statistic: max gap between the empirical CDFs, evaluated after BOTH samples have consumed each distinct value — ties must not register a transient gap (identical series score exactly 0).