//------------------------------------------------------------------------- // proper end-to-end FD tests are in pricer test public virtual void test_parameterSensitivity() { LegalEntitySurvivalProbabilities test = LegalEntitySurvivalProbabilities.of(LEGAL_ENTITY, DFS); CreditCurveZeroRateSensitivity point = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, ZeroRateSensitivity.of(USD, 1d, 1d)); assertEquals(test.parameterSensitivity(point).size(), 1); }
//------------------------------------------------------------------------- public virtual void test_unitParameterSensitivity() { LegalEntitySurvivalProbabilities test = LegalEntitySurvivalProbabilities.of(LEGAL_ENTITY, DFS); CreditCurveZeroRateSensitivity sens = test.zeroRatePointSensitivity(DATE_AFTER); CurrencyParameterSensitivities expected = DFS.parameterSensitivity(DFS.zeroRatePointSensitivity(DATE_AFTER)); assertEquals(test.parameterSensitivity(sens), expected); }
public CurrencyParameterSensitivity singleCreditCurveParameterSensitivity(PointSensitivities pointSensitivities, StandardId legalEntityId, Currency currency) { CurrencyParameterSensitivities sens = CurrencyParameterSensitivities.empty(); foreach (PointSensitivity point in pointSensitivities.Sensitivities) { if (point is CreditCurveZeroRateSensitivity) { CreditCurveZeroRateSensitivity pt = (CreditCurveZeroRateSensitivity)point; if (pt.LegalEntityId.Equals(legalEntityId) && pt.Currency.Equals(currency)) { LegalEntitySurvivalProbabilities factors = survivalProbabilities(pt.LegalEntityId, pt.CurveCurrency); sens = sens.combinedWith(factors.parameterSensitivity(pt)); } } } ArgChecker.isTrue(sens.size() == 1, "sensitivity must be unique"); return(sens.Sensitivities.get(0)); }
//------------------------------------------------------------------------- public CurrencyParameterSensitivities parameterSensitivity(PointSensitivities pointSensitivities) { CurrencyParameterSensitivities sens = CurrencyParameterSensitivities.empty(); foreach (PointSensitivity point in pointSensitivities.Sensitivities) { if (point is CreditCurveZeroRateSensitivity) { CreditCurveZeroRateSensitivity pt = (CreditCurveZeroRateSensitivity)point; LegalEntitySurvivalProbabilities factors = survivalProbabilities(pt.LegalEntityId, pt.CurveCurrency); sens = sens.combinedWith(factors.parameterSensitivity(pt)); } else if (point is ZeroRateSensitivity) { ZeroRateSensitivity pt = (ZeroRateSensitivity)point; CreditDiscountFactors factors = discountFactors(pt.CurveCurrency); sens = sens.combinedWith(factors.parameterSensitivity(pt)); } } return(sens); }