Class SaCcr

java.lang.Object
com.quantfinlib.risk.SaCcr

public final class SaCcr extends Object
Standardised approach for counterparty credit risk, SA-CCR (Basel Committee, "The standardised approach for measuring counterparty credit risk exposures", BCBS 279, March 2014, Annex 4). Exposure at default of one netting set:
  EAD = alpha * (RC + PFE),  alpha = 1.4                      (para 128)
  RC  = max(V - C, 0)                          unmargined     (para 136)
  RC  = max(V - C, TH + MTA - NICA, 0)         margined       (para 144)
  PFE = multiplier * AddOn_aggregate,  AddOn_aggregate = sum over classes  (paras 146, 150)
  multiplier = min(1, F + (1 - F) * exp((V - C) / (2 (1 - F) AddOn_aggregate))),  F = 5%  (para 149)

Trade level (paras 155-159): adjusted notional d_i is the notional times the supervisory duration SD = (exp(-0.05 S) - exp(-0.05 E)) / 0.05 for rates and credit, the foreign leg for FX, price times units for equity and commodity. The maturity factor is MF = sqrt(min(max(M, 10/250), 1)) unmargined and MF = 1.5 sqrt(MPOR / 250) margined (MPOR in business days, a 250-day year as in the Annex 4a examples). Each trade contributes delta * d * MF.

Asset-class add-ons (paras 165-182), supervisory factors from Table 2:

  • Interest rates: hedging set per currency, three maturity buckets by E (under 1y, 1y-5y, over 5y), effective notional sqrt(D1^2 + D2^2 + D3^2 + 1.4 D1 D2 + 1.4 D2 D3 + 0.6 D1 D3), SF 0.5%, add-on is the sum over currencies.
  • FX: hedging set per currency pair, SF 4% times the absolute net effective notional, summed over pairs.
  • Credit and equity: entity-level add-on SF times net effective notional; then sqrt((sum rho_k A_k)^2 + sum (1 - rho_k^2) A_k^2) with rho 50% single name, 80% index.
  • Commodity: commodity-type add-on SF times net effective notional (40% electricity, 18% other types), the same systematic plus idiosyncratic formula with rho 40% inside each of the four hedging sets, summed over sets.

Basis and volatility transactions (paras 162-163) form their own hedging sets inside their asset class, with the supervisory factor times 0.5 (basis) or 5 (volatility); mark a trade with SaCcrTrade.asBasis() or SaCcrTrade.asVolatility(). For example a USD 3m/OIS basis swap with adjusted notional 78,694 in the over-5y bucket adds 0.5 * 0.5% * 78,694 = 196.7 on its own, where the same trade as an ordinary swap would add 393.5 and net against the other USD swaps.

Margin agreements and netting sets (paras 185-187, checked against the March 2014 text): oneMarginAgreementManyNettingSets(List, double) for one agreement covering several netting sets, subNettingSets(List) for one netting set under several agreements (or partly unmargined). Collateral C is passed already haircut; SaCcrHaircuts gives the supervisory haircuts. Times are year fractions the caller computes; the S and E floor of ten business days is applied as 10/250 years. The tests reproduce Annex 4a Examples 1 to 5. Research lane, deterministic.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The five SA-CCR asset classes.
    static enum 
    The four commodity hedging sets (para 161).
    static enum 
    Credit rating buckets and their supervisory factors (Table 2).
    static enum 
    Hedging-set kind of a trade (paras 162-163) and its multiplier on the supervisory factor.
    static final record 
    Margin agreement terms for a margined netting set.
    static final record 
    SA-CCR outputs for one netting set.
    static final record 
    One part of a netting set for subNettingSets(List): the trades under one margin agreement (or the unmargined trades when margin is null) and the haircut collateral that belongs to them.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Alpha, para 128.
    static final double
    Multiplier floor, para 149.
    static final double
    Supervisory option volatility, other commodities (Table 2).
    static final double
    Supervisory option volatility, credit index (Table 2).
    static final double
    Supervisory option volatility, single-name credit (Table 2).
    static final double
    Supervisory option volatility, electricity (Table 2).
    static final double
    Supervisory option volatility, equity index (Table 2).
    static final double
    Supervisory option volatility, single-name equity (Table 2).
    static final double
    Supervisory option volatility, FX (Table 2).
    static final double
    Supervisory option volatility, interest rates (Table 2).
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    cdoTrancheDelta(double attachment, double detachment, boolean purchased)
    Supervisory delta of a CDO tranche, para 159: 15 / ((1 + 14 A)(1 + 14 D)), positive for purchased protection.
    margined(List<SaCcrTrade> trades, double collateralHeld, SaCcr.Margin margin)
    EAD of a margined netting set.
    static double
    maturityFactor(double maturityYears, SaCcr.Margin margin)
    Maturity factor of paras 164 and 171.
    static double
    multiplier(double vMinusC, double aggregate)
    The PFE multiplier of para 149.
    oneMarginAgreementManyNettingSets(List<List<SaCcrTrade>> nettingSets, double collateralHeld)
    One margin agreement covering several netting sets (RC from BCBS 279 para 186, PFE from para 187, both checked against the March 2014 text).
    static double
    optionDelta(boolean call, boolean bought, double underlying, double strike, double expiryYears, double vol)
    Supervisory option delta of para 159 (Black-Scholes delta with the supervisory volatility, zero rates).
    One netting set under several margin agreements, or mixing margined and unmargined trades (BCBS 279 para 185).
    static double
    supervisoryDuration(double startYears, double endYears)
    Supervisory duration of para 157, with S and E in years.
    unmargined(List<SaCcrTrade> trades, double collateralHeld)
    EAD of an unmargined netting set.

    Methods inherited from class Object

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

    • ALPHA

      public static final double ALPHA
      Alpha, para 128.
      See Also:
    • MULTIPLIER_FLOOR

      public static final double MULTIPLIER_FLOOR
      Multiplier floor, para 149.
      See Also:
    • OPTION_VOL_INTEREST_RATE

      public static final double OPTION_VOL_INTEREST_RATE
      Supervisory option volatility, interest rates (Table 2).
      See Also:
    • OPTION_VOL_FX

      public static final double OPTION_VOL_FX
      Supervisory option volatility, FX (Table 2).
      See Also:
    • OPTION_VOL_CREDIT_SINGLE

      public static final double OPTION_VOL_CREDIT_SINGLE
      Supervisory option volatility, single-name credit (Table 2).
      See Also:
    • OPTION_VOL_CREDIT_INDEX

      public static final double OPTION_VOL_CREDIT_INDEX
      Supervisory option volatility, credit index (Table 2).
      See Also:
    • OPTION_VOL_EQUITY_SINGLE

      public static final double OPTION_VOL_EQUITY_SINGLE
      Supervisory option volatility, single-name equity (Table 2).
      See Also:
    • OPTION_VOL_EQUITY_INDEX

      public static final double OPTION_VOL_EQUITY_INDEX
      Supervisory option volatility, equity index (Table 2).
      See Also:
    • OPTION_VOL_ELECTRICITY

      public static final double OPTION_VOL_ELECTRICITY
      Supervisory option volatility, electricity (Table 2).
      See Also:
    • OPTION_VOL_COMMODITY_OTHER

      public static final double OPTION_VOL_COMMODITY_OTHER
      Supervisory option volatility, other commodities (Table 2).
      See Also:
  • Method Details

    • unmargined

      public static SaCcr.Result unmargined(List<SaCcrTrade> trades, double collateralHeld)
      EAD of an unmargined netting set.
      Parameters:
      trades - the trades of the netting set
      collateralHeld - C, haircut value of net collateral held (negative when posted)
      Returns:
      the result
    • margined

      public static SaCcr.Result margined(List<SaCcrTrade> trades, double collateralHeld, SaCcr.Margin margin)
      EAD of a margined netting set.
      Parameters:
      trades - the trades of the netting set
      collateralHeld - C, haircut value of net collateral held, variation margin plus NICA
      margin - margin agreement terms
      Returns:
      the result
    • oneMarginAgreementManyNettingSets

      public static SaCcr.Result oneMarginAgreementManyNettingSets(List<List<SaCcrTrade>> nettingSets, double collateralHeld)
      One margin agreement covering several netting sets (RC from BCBS 279 para 186, PFE from para 187, both checked against the March 2014 text). The agreement's collateral cannot be split between the netting sets, so RC_MA = max(sum_NS max(V_NS, 0) - C_MA, 0), and PFE_MA = sum_NS PFE_NS with each netting set's PFE computed as if unmargined. Each multiplier uses that set's own V_NS with no collateral, since C_MA belongs to no single set; para 187 says only that each PFE follows the unmargined methodology, so the choice of V_NS for the multiplier is this library's reading.

      Example (own hand computation): netting sets with V of 100 and -40 under one agreement holding C = 30 give RC = max(100 + 0 - 30, 0) = 70. Netting the two sets first would give 30, which the rule does not allow.

      Parameters:
      nettingSets - the netting sets, each non-empty
      collateralHeld - C_MA, haircut net collateral under the agreement
      Returns:
      a result whose add-on fields are sums over the netting sets and whose multiplier is PFE divided by the aggregate add-on
    • subNettingSets

      public static SaCcr.Result subNettingSets(List<SaCcr.SubNettingSet> parts)
      One netting set under several margin agreements, or mixing margined and unmargined trades (BCBS 279 para 185). The netting set is divided into sub-netting sets aligned with their agreements, and para 185 states that this applies to both RC and PFE. So each part gets its own RC_k (margined: max(V_k - C_k, TH_k + MTA_k - NICA_k, 0); unmargined: max(V_k - C_k, 0)) and its own PFE with its own maturity factors and multiplier from V_k - C_k, and both are summed over the parts. Until 2.3 the RC was taken for the netting set as a whole with summed floors; that reading did not match para 185 and was corrected.

      Example (own hand computation): a margined part with V = -30, C = 0, TH + MTA - NICA = 5 and an unmargined part with V = 50 give RC = 5 + 50 = 55, where netting the parts first would give 20.

      Parameters:
      parts - the sub-netting sets
      Returns:
      a result whose add-on fields are sums over the parts and whose multiplier is PFE divided by the aggregate add-on
    • multiplier

      public static double multiplier(double vMinusC, double aggregate)
      The PFE multiplier of para 149.
      Parameters:
      vMinusC - V - C
      aggregate - aggregate add-on (≥ 0); zero gives 1
      Returns:
      the multiplier in [0.05, 1]
    • supervisoryDuration

      public static double supervisoryDuration(double startYears, double endYears)
      Supervisory duration of para 157, with S and E in years.
      Parameters:
      startYears - S (0 when started; a positive S is floored at ten business days)
      endYears - E (floored at ten business days)
      Returns:
      SD in years
    • optionDelta

      public static double optionDelta(boolean call, boolean bought, double underlying, double strike, double expiryYears, double vol)
      Supervisory option delta of para 159 (Black-Scholes delta with the supervisory volatility, zero rates).
      Parameters:
      call - true for a call, false for a put
      bought - true when the bank bought the option
      underlying - P, the underlying price (forward, spot, swap rate), > 0
      strike - K, > 0
      expiryYears - T, latest exercise date, > 0
      vol - supervisory volatility, > 0
      Returns:
      the signed delta
    • cdoTrancheDelta

      public static double cdoTrancheDelta(double attachment, double detachment, boolean purchased)
      Supervisory delta of a CDO tranche, para 159: 15 / ((1 + 14 A)(1 + 14 D)), positive for purchased protection.
      Parameters:
      attachment - A in [0, 1)
      detachment - D in (A, 1]
      purchased - true for long protection
      Returns:
      the signed delta
    • maturityFactor

      public static double maturityFactor(double maturityYears, SaCcr.Margin margin)
      Maturity factor of paras 164 and 171.
      Parameters:
      maturityYears - M
      margin - null for unmargined
      Returns:
      MF