private static LegalEntityDiscountingProvider createRatesProvider(LocalDate valuationDate) { DiscountFactors dscRepo = ZeroRateDiscountFactors.of(EUR, valuationDate, CURVE_REPO); DiscountFactors dscIssuer = ZeroRateDiscountFactors.of(EUR, valuationDate, CURVE_ISSUER); LegalEntityDiscountingProvider provider = ImmutableLegalEntityDiscountingProvider.builder() .issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, EUR), dscIssuer)) .issuerCurveGroups(ImmutableMap.of(ISSUER_ID, GROUP_ISSUER)) .repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO, EUR), dscRepo)) .repoCurveSecurityGroups(ImmutableMap.of(SECURITY_ID, GROUP_REPO)) .valuationDate(valuationDate) .build(); return provider; }
public 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.getValuationDate(), DATE); }
public void coverage() { ImmutableLegalEntityDiscountingProvider test1 = 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)) .build(); coverImmutableBean(test1); LocalDate val = date(2015, 6, 14); DiscountFactors dscFactorIssuer = ZeroRateDiscountFactors.of(GBP, val, CURVE_ISSUER); DiscountFactors dscFactorRepo = ZeroRateDiscountFactors.of(GBP, val, CURVE_REPO); ImmutableLegalEntityDiscountingProvider test2 = ImmutableLegalEntityDiscountingProvider.builder() .issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), dscFactorIssuer)) .issuerCurveGroups(ImmutableMap.of(LegalEntityId.of("OG-Ticker", "foo"), GROUP_ISSUER)) .repoCurves(ImmutableMap.of(Pair.of(RepoGroup.of("ISSUER2 BND 5Y"), GBP), dscFactorRepo)) .repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, RepoGroup.of("ISSUER2 BND 5Y"))) .build(); coverBeanEquals(test1, test2); }
.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()); .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()); .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());
public 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)); }