private RepoCurveDiscountFactors repoCurveDiscountFactors(RepoGroup repoGroup, Currency currency) { DiscountFactors discountFactors = repoCurves.get(Pair.of(repoGroup, currency)); if (discountFactors == null) { throw new IllegalArgumentException("Unable to find repo curve: " + repoGroup + ", " + currency); } return RepoCurveDiscountFactors.of(discountFactors, repoGroup); }
public void test_zeroRatePointSensitivity() { RepoCurveDiscountFactors base = RepoCurveDiscountFactors.of(DSC_FACTORS, GROUP); RepoCurveZeroRateSensitivity expected = RepoCurveZeroRateSensitivity.of(DSC_FACTORS.zeroRatePointSensitivity(DATE_AFTER), GROUP); RepoCurveZeroRateSensitivity computed = base.zeroRatePointSensitivity(DATE_AFTER); assertEquals(computed, expected); }
public void test_zeroRatePointSensitivity_USD() { RepoCurveDiscountFactors base = RepoCurveDiscountFactors.of(DSC_FACTORS, GROUP); RepoCurveZeroRateSensitivity expected = RepoCurveZeroRateSensitivity.of(DSC_FACTORS.zeroRatePointSensitivity(DATE_AFTER, USD), GROUP); RepoCurveZeroRateSensitivity computed = base.zeroRatePointSensitivity(DATE_AFTER, USD); assertEquals(computed, expected); }
public void test_of() { RepoCurveDiscountFactors test = RepoCurveDiscountFactors.of(DSC_FACTORS, GROUP); assertEquals(test.getRepoGroup(), GROUP); assertEquals(test.getCurrency(), GBP); assertEquals(test.getValuationDate(), DATE); assertEquals(test.discountFactor(DATE_AFTER), DSC_FACTORS.discountFactor(DATE_AFTER)); }
public void test_parameterSensitivity() { RepoCurveDiscountFactors base = RepoCurveDiscountFactors.of(DSC_FACTORS, GROUP); RepoCurveZeroRateSensitivity 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 void test_builder_noValuationDate() { 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)) .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_ISSUER)); assertEquals(test.repoCurveDiscountFactors(ID_ISSUER, GBP), RepoCurveDiscountFactors.of(DSC_FACTORS_REPO, GROUP_REPO_ISSUER)); assertEquals(test.getValuationDate(), DATE); }
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); }