Exemple #1
0
 public virtual void test_map()
 {
     assertEquals(LOOKUP.queryType(), typeof(CreditRatesMarketDataLookup));
     assertEquals(LOOKUP_WITH_SOURCE.requirements(ISSUER_A, USD), FunctionRequirements.builder().observableSource(OBS_SOURCE).valueRequirements(CC_A_USD, DC_USD, RC_A).outputCurrencies(USD).build());
     assertEquals(LOOKUP_WITH_SOURCE.requirements(ISSUER_A, GBP), FunctionRequirements.builder().observableSource(OBS_SOURCE).valueRequirements(CC_A_GBP, DC_GBP, RC_A).outputCurrencies(GBP).build());
     assertEquals(LOOKUP_WITH_SOURCE.requirements(ISSUER_B, GBP), FunctionRequirements.builder().observableSource(OBS_SOURCE).valueRequirements(CC_B_GBP, DC_GBP, RC_B).outputCurrencies(GBP).build());
     assertEquals(LOOKUP.requirements(ISSUER_A, USD), FunctionRequirements.builder().valueRequirements(CC_A_USD, DC_USD, RC_A).outputCurrencies(USD).build());
     assertEquals(LOOKUP.requirements(ISSUER_A, GBP), FunctionRequirements.builder().valueRequirements(CC_A_GBP, DC_GBP, RC_A).outputCurrencies(GBP).build());
     assertEquals(LOOKUP.requirements(ISSUER_B, GBP), FunctionRequirements.builder().valueRequirements(CC_B_GBP, DC_GBP, RC_B).outputCurrencies(GBP).build());
     assertThrowsIllegalArg(() => LOOKUP.requirements(ISSUER_A, EUR));
     assertThrowsIllegalArg(() => LOOKUP.requirements(ISSUER_C, USD));
     assertEquals(LOOKUP.creditRatesProvider(MOCK_MARKET_DATA), DefaultLookupCreditRatesProvider.of((DefaultCreditRatesMarketDataLookup)LOOKUP, MOCK_MARKET_DATA));
 }
Exemple #2
0
        public virtual void test_bondDiscountingProvider()
        {
            LocalDate valDate = LocalDate.of(2015, 6, 30);
            Curve     ccAUsd  = ConstantNodalCurve.of(Curves.zeroRates(CC_A_USD.CurveName, ACT_365F), 0.5d, 1.5d);
            Curve     ccBGbp  = ConstantNodalCurve.of(Curves.zeroRates(CC_B_GBP.CurveName, ACT_365F), 0.5d, 2d);
            Curve     ccAGbp  = ConstantNodalCurve.of(Curves.zeroRates(CC_A_GBP.CurveName, ACT_365F), 0.5d, 3d);
            Curve     dcGbp   = ConstantNodalCurve.of(Curves.zeroRates(DC_GBP.CurveName, ACT_365F), 0.5d, 0.1d);
            Curve     dcUsd   = ConstantNodalCurve.of(Curves.zeroRates(DC_USD.CurveName, ACT_365F), 0.5d, 0.05d);
            Curve     rcA     = ConstantCurve.of(Curves.recoveryRates(RC_A.CurveName, ACT_365F), 0.5d);
            Curve     rcB     = ConstantCurve.of(Curves.recoveryRates(RC_B.CurveName, ACT_365F), 0.4234d);
            IDictionary <CurveId, Curve> curveMap = new Dictionary <CurveId, Curve>();

            curveMap[CC_A_USD] = ccAUsd;
            curveMap[CC_B_GBP] = ccBGbp;
            curveMap[CC_A_GBP] = ccAGbp;
            curveMap[DC_USD]   = dcUsd;
            curveMap[DC_GBP]   = dcGbp;
            curveMap[RC_A]     = rcA;
            curveMap[RC_B]     = rcB;
            MarketData          md       = ImmutableMarketData.of(valDate, ImmutableMap.copyOf(curveMap));
            CreditRatesProvider provider = LOOKUP_WITH_SOURCE.creditRatesProvider(md);

            assertEquals(provider.ValuationDate, valDate);
            assertEquals(provider.findData(CC_A_USD.CurveName), ccAUsd);
            assertEquals(provider.findData(DC_USD.CurveName), dcUsd);
            assertEquals(provider.findData(RC_B.CurveName), rcB);
            assertEquals(provider.findData(CurveName.of("Rubbish")), null);
            // check credit curve
            LegalEntitySurvivalProbabilities cc      = provider.survivalProbabilities(ISSUER_A, GBP);
            IsdaCreditDiscountFactors        ccUnder = (IsdaCreditDiscountFactors)cc.SurvivalProbabilities;

            assertEquals(ccUnder.Curve.Name, ccAGbp.Name);
            assertThrowsRuntime(() => provider.survivalProbabilities(ISSUER_B, USD));
            assertThrowsRuntime(() => provider.survivalProbabilities(ISSUER_C, USD));
            // check discount curve
            IsdaCreditDiscountFactors dc = (IsdaCreditDiscountFactors)provider.discountFactors(USD);

            assertEquals(dc.Curve.Name, dcUsd.Name);
            assertThrowsRuntime(() => provider.discountFactors(EUR));
            // check recovery rate curve
            ConstantRecoveryRates rc = (ConstantRecoveryRates)provider.recoveryRates(ISSUER_B);

            assertEquals(rc.RecoveryRate, rcB.getParameter(0));
            assertThrowsRuntime(() => provider.recoveryRates(ISSUER_C));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private DefaultCreditRatesMarketData(CreditRatesMarketDataLookup lookup, com.opengamma.strata.data.MarketData marketData)
        private DefaultCreditRatesMarketData(CreditRatesMarketDataLookup lookup, MarketData marketData)
        {
            this.lookup     = ArgChecker.notNull(lookup, "lookup");
            this.marketData = ArgChecker.notNull(marketData, "marketData");
            this.creditRatesProvider_Renamed = lookup.creditRatesProvider(marketData);
        }