예제 #1
0
        //-------------------------------------------------------------------------
        // 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);
        }
예제 #2
0
        //-------------------------------------------------------------------------
        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);
        }
예제 #3
0
        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));
        }
예제 #4
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);
        }