//------------------------------------------------------------------------- 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)); }
//------------------------------------------------------------------------- public virtual void coverage() { IssuerCurveZeroRateSensitivity test1 = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); coverImmutableBean(test1); IssuerCurveZeroRateSensitivity test2 = IssuerCurveZeroRateSensitivity.of(GBP, YEARFRAC2, LegalEntityGroup.of("ISSUER1"), 12d); coverBeanEquals(test1, test2); }
public virtual void test_compareKey() { IssuerCurveZeroRateSensitivity a1 = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); IssuerCurveZeroRateSensitivity a2 = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE); IssuerCurveZeroRateSensitivity b = IssuerCurveZeroRateSensitivity.of(GBP, YEARFRAC, GROUP, VALUE); IssuerCurveZeroRateSensitivity c = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC2, GROUP, VALUE); IssuerCurveZeroRateSensitivity d = IssuerCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, LegalEntityGroup.of("ISSUER2"), VALUE); IborRateSensitivity other = IborRateSensitivity.of(IborIndexObservation.of(GBP_LIBOR_3M, date(2015, 8, 27), REF_DATA), 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) > 0, true); assertEquals(b.compareKey(a1) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) > 0, true); assertEquals(other.compareKey(a1) < 0, true); }
//------------------------------------------------------------------------- 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_builder_fail() { // no relevant map for repo curve assertThrowsIllegalArg(() => 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, RepoGroup.of("ISSUER2 BND 5Y"))).build()); // no relevant map for issuer curve assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, LegalEntityGroup.of("ISSUER2"))).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_ISSUER, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_REPO_ISSUER)).build()); // issuer curve and valuation date are missing assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().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)).build()); // issuer curve date is different from valuation date DiscountFactors dscFactorIssuer = ZeroRateDiscountFactors.of(GBP, date(2015, 6, 14), CURVE_ISSUER); assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), dscFactorIssuer)).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()); // repo curve rate is different from valuation date DiscountFactors dscFactorRepo = ZeroRateDiscountFactors.of(GBP, date(2015, 6, 14), CURVE_REPO); assertThrowsIllegalArg(() => 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), dscFactorRepo)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build()); }