Пример #1
0
        public virtual void test_builder_noRepoRate()
        {
            ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder().issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).build();

            assertEquals(test.issuerCurveDiscountFactors(ID_ISSUER, GBP), IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER));
            assertEquals(test.ValuationDate, DATE);
        }
        public virtual void test_zeroRatePointSensitivity_USD()
        {
            IssuerCurveDiscountFactors     @base    = IssuerCurveDiscountFactors.of(DSC_FACTORS, GROUP);
            IssuerCurveZeroRateSensitivity expected = IssuerCurveZeroRateSensitivity.of(DSC_FACTORS.zeroRatePointSensitivity(DATE_AFTER, USD), GROUP);
            IssuerCurveZeroRateSensitivity computed = @base.zeroRatePointSensitivity(DATE_AFTER, USD);

            assertEquals(computed, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IssuerCurveDiscountFactors test1 = IssuerCurveDiscountFactors.of(DSC_FACTORS, GROUP);

            coverImmutableBean(test1);
            IssuerCurveDiscountFactors test2 = IssuerCurveDiscountFactors.of(ZeroRateDiscountFactors.of(USD, DATE, CURVE), LegalEntityGroup.of("ISSUER2"));

            coverBeanEquals(test1, test2);
        }
        public virtual void test_parameterSensitivity()
        {
            IssuerCurveDiscountFactors     @base    = IssuerCurveDiscountFactors.of(DSC_FACTORS, GROUP);
            IssuerCurveZeroRateSensitivity sensi    = @base.zeroRatePointSensitivity(DATE_AFTER, USD);
            CurrencyParameterSensitivities computed = @base.parameterSensitivity(sensi);
            CurrencyParameterSensitivities expected = DSC_FACTORS.parameterSensitivity(DSC_FACTORS.zeroRatePointSensitivity(DATE_AFTER, USD));

            assertEquals(computed, expected);
        }
        public virtual void test_of()
        {
            IssuerCurveDiscountFactors test = IssuerCurveDiscountFactors.of(DSC_FACTORS, GROUP);

            assertEquals(test.LegalEntityGroup, GROUP);
            assertEquals(test.Currency, GBP);
            assertEquals(test.ValuationDate, DATE);
            assertEquals(test.discountFactor(DATE_AFTER), DSC_FACTORS.discountFactor(DATE_AFTER));
        }
Пример #6
0
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), DSC_FACTORS_REPO)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build();

            assertEquals(test.issuerCurveDiscountFactors(ID_ISSUER, GBP), IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER));
            assertEquals(test.repoCurveDiscountFactors(ID_SECURITY, ID_ISSUER, GBP), RepoCurveDiscountFactors.of(DSC_FACTORS_REPO, GROUP_REPO_SECURITY));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(ID_ISSUER, GBP));
            assertEquals(test.ValuationDate, DATE);
        }
        // lookup the discount factors for the legal entity group
        private IssuerCurveDiscountFactors issuerCurveDiscountFactors(LegalEntityGroup legalEntityGroup, Currency currency)
        {
            DiscountFactors discountFactors = issuerCurves.get(Pair.of(legalEntityGroup, currency));

            if (discountFactors == null)
            {
                throw new System.ArgumentException("Unable to find issuer curve: " + legalEntityGroup + ", " + currency);
            }
            return(IssuerCurveDiscountFactors.of(discountFactors, legalEntityGroup));
        }
Пример #8
0
        //-------------------------------------------------------------------------
        public virtual void presentValueSensitivity()
        {
            PointSensitivities sensiComputed = PRICER.presentValueSensitivity(BILL, PROVIDER);
            PointSensitivities sensiExpected = IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER).zeroRatePointSensitivity(MATURITY_DATE).multipliedBy(NOTIONAL.Amount).build();

            assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PV));
            CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(sensiComputed);
            CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity(PROVIDER, p => PRICER.presentValue(BILL, p));

            assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT));
        }
        public virtual void test_presentValueWithZSpread_periodic_noExcoupon()
        {
            CurrencyAmount computed = PRICER.presentValueWithZSpread(PRODUCT_NO_EXCOUPON, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
            CurrencyAmount expected = PRICER_NOMINAL.presentValueWithSpread(PRODUCT.NominalPayment, DSC_FACTORS_ISSUER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
            int            size     = PRODUCT.PeriodicPayments.size();
            double         pvcCupon = 0d;

            for (int i = 2; i < size; ++i)
            {
                FixedCouponBondPaymentPeriod payment = PRODUCT.PeriodicPayments.get(i);
                pvcCupon += PRICER_COUPON.presentValueWithSpread(payment, IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER), Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
            }
            expected = expected.plus(pvcCupon);
            assertEquals(computed.Currency, EUR);
            assertEquals(computed.Amount, expected.Amount, NOTIONAL * TOL);
        }
        /// <summary>
        /// Obtains issuer curve discount factors form valuation date.
        /// </summary>
        /// <param name="valuationDate">  the valuation date </param>
        /// <returns> the discount factors </returns>
        public static IssuerCurveDiscountFactors getIssuerCurveDiscountFactors(LocalDate valuationDate)
        {
            DiscountFactors dscIssuer = ZeroRateDiscountFactors.of(USD, valuationDate, ISSUER_CURVE);

            return(IssuerCurveDiscountFactors.of(dscIssuer, GROUP_ISSUER));
        }