Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_discountFactor_notFound()
        {
            LegalEntityId    issuerId    = LegalEntityId.of("OG-Ticker", "Issuer-2");
            LegalEntityGroup issuerGroup = LegalEntityGroup.of("ISSUER2");
            RepoGroup        repoGroup   = RepoGroup.of("ISSUER2 BND 5Y");
            SecurityId       securityId  = SecurityId.of("OG-Ticker", "Issuer-2-bond-5Y");
            ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER, issuerId, issuerGroup)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(issuerId, repoGroup)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build();

            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(ID_ISSUER, USD));
            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(LegalEntityId.of("OG-Ticker", "foo"), GBP));
            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(issuerId, GBP));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(ID_SECURITY, ID_ISSUER, USD));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(SecurityId.of("OG-Ticker", "foo-bond"), LegalEntityId.of("OG-Ticker", "foo"), GBP));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(securityId, issuerId, GBP));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public virtual void test_curveParameterSensitivity()
        {
            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_ISSUER, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_REPO_ISSUER)).valuationDate(DATE).build();
            LocalDate refDate = date(2018, 11, 24);
            IssuerCurveZeroRateSensitivity sensi1   = test.issuerCurveDiscountFactors(ID_ISSUER, GBP).zeroRatePointSensitivity(refDate, GBP);
            RepoCurveZeroRateSensitivity   sensi2   = test.repoCurveDiscountFactors(ID_SECURITY, ID_ISSUER, GBP).zeroRatePointSensitivity(refDate, GBP);
            PointSensitivities             sensi    = PointSensitivities.of(sensi1, sensi2);
            CurrencyParameterSensitivities computed = test.parameterSensitivity(sensi);
            CurrencyParameterSensitivities expected = DSC_FACTORS_ISSUER.parameterSensitivity(sensi1.createZeroRateSensitivity()).combinedWith(DSC_FACTORS_REPO.parameterSensitivity(sensi2.createZeroRateSensitivity()));

            assertTrue(computed.equalWithTolerance(expected, 1.0e-12));
        }