Exemple #1
0
        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);
        }
Exemple #2
0
        public static double PvCvaCapital_BII_SM(DateTime originDate, DateTime[] EADDates, IAssetFxModel[] models, Portfolio portfolio,
                                                 Currency reportingCurrency, IIrCurve discountCurve, double partyWeight, Dictionary <string, string> assetIdToHedgeMap,
                                                 Dictionary <string, double> hedgeGroupCCFs, ICurrencyProvider currencyProvider, double[] epeProfile, double[] eadProfile = null)
        {
            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 dfs  = Ms.Select(m => m == 0 ? 1.0 : (1.0 - Exp(-0.05 * m)) / (0.05 * m)).ToArray();
            var ks   = eads.Select((e, ix) => XVACalculator.Capital_BaselII_CVA_SM(e * dfs[ix], Ms[ix], partyWeight)).ToArray();

            var pvCapital = PvProfile(originDate, EADDates, ks, discountCurve);

            return(pvCapital);
        }
Exemple #3
0
 public static double PVCapital_BII_IMM(DateTime originDate, ICube expectedEAD, HazzardCurve hazzardCurve, IIrCurve discountCurve, double LGD, Portfolio portfolio)
 {
     (var eadDates, var eadValues) = XVACalculator.CubeToExposures(expectedEAD);
     return(PVCapital_BII_IMM(originDate, eadDates, eadValues, hazzardCurve, discountCurve, LGD, portfolio));
 }