public static (double CVA, double CCR) PvCapital_Split(DateTime originDate, DateTime[] EADDates, IAssetFxModel[] models, Portfolio portfolio, HazzardCurve hazzardCurve, Currency reportingCurrency, IIrCurve discountCurve, double LGD, double partyCVAWeight, double riskWeight, Dictionary <string, string> assetIdToHedgeMap, Dictionary <string, double> hedgeGroupCCFs, ICurrencyProvider currencyProvider, double[] epeProfile, DateTime?B2B3ChangeDate = null, double[] eadProfile = null) { var pd = hazzardCurve.ConstantPD; if (!B2B3ChangeDate.HasValue) { B2B3ChangeDate = DateTime.MaxValue; } var eads = eadProfile ?? EAD_Split(originDate, EADDates, epeProfile, models, portfolio, reportingCurrency, assetIdToHedgeMap, hedgeGroupCCFs, B2B3ChangeDate.Value, currencyProvider); eads = eads.Select(e => e * riskWeight).ToArray(); var Ms = EADDates.Select(d => Max(1.0, portfolio.WeightedMaturity(d))).ToArray(); var dfs = Ms.Select(m => m == 0 ? 1.0 : (1.0 - Exp(-0.05 * m)) / (0.05 * m)).ToArray(); var ksCCR = eads.Select((e, ix) => BaselHelper.K(pd, LGD, Ms[ix]) * e).ToArray(); var ksCVA = eads.Select((e, ix) => XVACalculator.Capital_BaselII_CVA_SM(e * dfs[ix], Ms[ix], partyCVAWeight)).ToArray(); var pvCapitalCCR = PvProfile(originDate, EADDates, ksCCR, discountCurve); var pvCapitalCVA = PvProfile(originDate, EADDates, ksCVA, discountCurve); return(pvCapitalCVA, pvCapitalCCR); }
public static double PvCcrCapital_BII_SM(DateTime originDate, DateTime[] EADDates, IAssetFxModel[] models, Portfolio portfolio, HazzardCurve hazzardCurve, Currency reportingCurrency, IIrCurve discountCurve, double LGD, Dictionary <string, string> assetIdToHedgeMap, Dictionary <string, double> hedgeGroupCCFs, ICurrencyProvider currencyProvider, double[] epeProfile, double[] eadProfile = null) { var pd = hazzardCurve.ConstantPD; var eads = eadProfile ?? EAD_BII_SM(originDate, EADDates, epeProfile, models, portfolio, reportingCurrency, assetIdToHedgeMap, hedgeGroupCCFs, currencyProvider); var Ms = EADDates.Select(d => Max(1.0, portfolio.WeightedMaturity(d))).ToArray(); var ks = eads.Select((e, ix) => BaselHelper.K(pd, LGD, Ms[ix]) * e).ToArray(); var pvCapital = PvProfile(originDate, EADDates, ks, discountCurve); return(pvCapital); }
public static double PVCapital_BII_IMM(DateTime originDate, DateTime[] EADDates, double[] EADs, HazzardCurve hazzardCurve, IIrCurve discountCurve, double LGD, Portfolio portfolio) { if (EADDates.Length != EADs.Length) { throw new Exception("Number of EPE dates and EPE values must be equal"); } var pd = hazzardCurve.ConstantPD; var epees = EADs.Select((d, ix) => EADs.Skip(ix).Max()).ToArray(); var Ms = EADDates.Select(d => Max(1.0, portfolio.WeightedMaturity(d))).ToArray(); var ks = epees.Select((e, ix) => BaselHelper.K(pd, LGD, Ms[ix]) * e * 1.4).ToArray(); var pvCapital = PvProfile(originDate, EADDates, ks, discountCurve); return(pvCapital); }