Example #1
0
        //-------------------------------------------------------------------------
        public virtual void test_filtered()
        {
            DummyFraCurveNode node1 = DummyFraCurveNode.of(Period.ofDays(5), GBP_LIBOR_1M, GBP_LIBOR_1M_ID);
            DummyFraCurveNode node2 = DummyFraCurveNode.of(Period.ofDays(10), GBP_LIBOR_1M, GBP_LIBOR_1M_ID);
            DummyFraCurveNode node3 = DummyFraCurveNode.of(Period.ofDays(11), GBP_LIBOR_1M, GBP_LIBOR_1M_ID, DROP_THIS_2D);
            ImmutableList <DummyFraCurveNode> nodes = ImmutableList.of(node1, node2, node3);
            LocalDate valuationDate = date(2015, 6, 30);

            InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(CURVE_NAME1).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).nodes(nodes).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
            RatesCurveGroupDefinition        test      = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(curveDefn, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();
            RatesCurveGroupDefinition        expected  = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(curveDefn.filtered(valuationDate, REF_DATA), GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            assertEquals(test.filtered(valuationDate, REF_DATA), expected);
        }
        /* Check calibration for forward curve directly interpolated on forward rates. */
        public virtual void calibration_present_value_simple_forward()
        {
            InterpolatedNodalCurveDefinition dsc    = InterpolatedNodalCurveDefinition.builder().name(DSCON_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).interpolator(INTERPOLATOR_LINEAR).extrapolatorLeft(EXTRAPOLATOR_FLAT).extrapolatorRight(EXTRAPOLATOR_FLAT).nodes(DSC_NODES).build();
            InterpolatedNodalCurveDefinition fwd    = InterpolatedNodalCurveDefinition.builder().name(FWD3_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.FORWARD_RATE).dayCount(CURVE_DC).interpolator(INTERPOLATOR_LINEAR).extrapolatorLeft(EXTRAPOLATOR_FLAT).extrapolatorRight(EXTRAPOLATOR_FLAT).nodes(FWD3_NODES).build();
            RatesCurveGroupDefinition        config = RatesCurveGroupDefinition.builder().name(CURVE_GROUP_NAME).addCurve(dsc, USD, USD_FED_FUND).addForwardCurve(fwd, USD_LIBOR_3M).build();
            RatesProvider result = CALIBRATOR.calibrate(config, ALL_QUOTES_BD, REF_DATA);

            assertResult(result, ALL_QUOTES_BD);
            IborIndexRates ibor3M = result.iborIndexRates(USD_LIBOR_3M);

            assertTrue(ibor3M is SimpleIborIndexRates, "USD-LIBOR-3M curve should be simple interpolation on forward rates");
            double shift = 1.0E-6;

            System.Func <MarketData, RatesProvider> f = marketData => CALIBRATOR.calibrate(config, marketData, REF_DATA);
            calibration_market_quote_sensitivity_check(f, config, shift, TS_EMPTY);
        }
Example #3
0
        public virtual void test_builder_seasonality()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build();

            assertEquals(test.Name, CurveGroupName.of("Test"));
            assertEquals(test.Entries, ImmutableList.of(ENTRY3));
            assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3);
            assertEquals(test.findEntry(CurveName.of("Test2")), null);
            assertEquals(test.findEntry(CurveName.of("Rubbish")), null);
            assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1);
            assertEquals(test.findCurveDefinition(CurveName.of("Test2")), null);
            assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null);
            ImmutableMap <CurveName, SeasonalityDefinition> seasonMap = test.SeasonalityDefinitions;

            assertTrue(seasonMap.size() == 1);
            assertEquals(seasonMap.get(CURVE_NAME_I), SEASONALITY_ADDITIVE_DEF);
        }
        public virtual void calibration_present_value_discountCurve_clamped()
        {
            CurveInterpolator interp                = CurveInterpolators.LOG_NATURAL_SPLINE_DISCOUNT_FACTOR;
            CurveExtrapolator extrapRight           = CurveExtrapolators.LOG_LINEAR;
            CurveExtrapolator extrapLeft            = CurveExtrapolators.INTERPOLATOR;
            InterpolatedNodalCurveDefinition dsc    = InterpolatedNodalCurveDefinition.builder().name(DSCON_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).dayCount(CURVE_DC).interpolator(interp).extrapolatorLeft(extrapLeft).extrapolatorRight(extrapRight).nodes(DSC_NODES).build();
            InterpolatedNodalCurveDefinition fwd    = InterpolatedNodalCurveDefinition.builder().name(FWD3_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).dayCount(CURVE_DC).interpolator(interp).extrapolatorLeft(extrapLeft).extrapolatorRight(extrapRight).nodes(FWD3_NODES).build();
            RatesCurveGroupDefinition        config = RatesCurveGroupDefinition.builder().name(CURVE_GROUP_NAME).addCurve(dsc, USD, USD_FED_FUND).addForwardCurve(fwd, USD_LIBOR_3M).build();
            RatesProvider result = CALIBRATOR.calibrate(config, ALL_QUOTES_BD, REF_DATA);

            assertResult(result, ALL_QUOTES_BD);

            double shift = 1.0E-6;

            System.Func <MarketData, RatesProvider> f = marketData => CALIBRATOR.calibrate(config, marketData, REF_DATA);
            calibration_market_quote_sensitivity_check(f, config, shift, TS_EMPTY);
        }
Example #5
0
        /// <summary>
        /// Test that the curve node requirements are extracted and returned.
        /// </summary>
        public virtual void requirements()
        {
            FraCurveNode node1x4 = fraNode(1, "a");
            FraCurveNode node2x5 = fraNode(2, "b");
            FraCurveNode node3x6 = fraNode(3, "c");

            InterpolatedNodalCurveDefinition curve = InterpolatedNodalCurveDefinition.builder().name(CurveName.of("curve")).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).nodes(node1x4, node2x5, node3x6).build();

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("curve group")).addDiscountCurve(curve, Currency.USD).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupDefn.Name, groupDefn).build();

            RatesCurveInputsMarketDataFunction marketDataFunction = new RatesCurveInputsMarketDataFunction();
            RatesCurveInputsId     curveInputsId = RatesCurveInputsId.of(groupDefn.Name, curve.Name, ObservableSource.NONE);
            MarketDataRequirements requirements  = marketDataFunction.requirements(curveInputsId, marketDataConfig);

            assertThat(requirements.Observables).contains(QuoteId.of(StandardId.of("test", "a"))).contains(QuoteId.of(StandardId.of("test", "b"))).contains(QuoteId.of(StandardId.of("test", "c")));
        }
Example #6
0
        /// <summary>
        /// Test that a failure is returned if the observable data isn't available.
        /// </summary>
        public virtual void buildMissingMarketData()
        {
            FraCurveNode node1x4 = fraNode(1, "a");
            FraCurveNode node2x5 = fraNode(2, "b");
            FraCurveNode node3x6 = fraNode(3, "c");

            InterpolatedNodalCurveDefinition curve = InterpolatedNodalCurveDefinition.builder().name(CurveName.of("curve")).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).nodes(node1x4, node2x5, node3x6).build();

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("curve group")).addDiscountCurve(curve, Currency.USD).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupDefn.Name, groupDefn).build();

            ScenarioMarketData emptyData = ScenarioMarketData.of(1, date(2016, 6, 30), ImmutableMap.of(), ImmutableMap.of());

            RatesCurveInputsMarketDataFunction marketDataFunction = new RatesCurveInputsMarketDataFunction();
            RatesCurveInputsId curveInputsId = RatesCurveInputsId.of(groupDefn.Name, curve.Name, ObservableSource.NONE);

            assertThrows(() => marketDataFunction.build(curveInputsId, marketDataConfig, emptyData, REF_DATA), typeof(MarketDataNotFoundException));
        }
Example #7
0
        public virtual void test_builder1()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_DEFN1, GBP).addForwardCurve(CURVE_DEFN1, GBP_SONIA).addForwardCurve(CURVE_DEFN1, GBP_LIBOR_1W).addForwardCurve(CURVE_DEFN2, GBP_LIBOR_1M, GBP_LIBOR_3M).build();

            assertEquals(test.Name, CurveGroupName.of("Test"));
            assertEquals(test.Entries, ImmutableList.of(ENTRY1, ENTRY2));
            assertEquals(test.findDiscountCurveName(GBP), CURVE_NAME1);
            assertEquals(test.findDiscountCurveName(USD), null);
            assertEquals(test.findForwardCurveName(GBP_LIBOR_1W), CURVE_NAME1);
            assertEquals(test.findForwardCurveName(GBP_LIBOR_1M), CURVE_NAME2);
            assertEquals(test.findForwardCurveName(GBP_LIBOR_6M), null);
            assertEquals(test.findForwardCurveNames(GBP_LIBOR), ImmutableSet.of(CURVE_NAME1, CURVE_NAME2));
            assertEquals(test.findEntry(CurveName.of("Test")), ENTRY1);
            assertEquals(test.findEntry(CurveName.of("Test2")), ENTRY2);
            assertEquals(test.findEntry(CurveName.of("Rubbish")), null);
            assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1);
            assertEquals(test.findCurveDefinition(CurveName.of("Test2")), CURVE_DEFN2);
            assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null);
        }
        //-------------------------------------------------------------------------
        public virtual void duplicateInputDataKeys()
        {
            FxSwapTemplate  template1               = FxSwapTemplate.of(Period.ofMonths(1), FxSwapConventions.EUR_USD);
            FxSwapTemplate  template2               = FxSwapTemplate.of(Period.ofMonths(2), FxSwapConventions.EUR_USD);
            QuoteId         pointsKey1a             = QuoteId.of(StandardId.of("test", "1a"));
            QuoteId         pointsKey1b             = QuoteId.of(StandardId.of("test", "1b"));
            QuoteId         pointsKey2a             = QuoteId.of(StandardId.of("test", "2a"));
            QuoteId         pointsKey2b             = QuoteId.of(StandardId.of("test", "2b"));
            FxSwapCurveNode node1a                  = FxSwapCurveNode.of(template1, pointsKey1a);
            FxSwapCurveNode node1b                  = FxSwapCurveNode.of(template2, pointsKey1b);
            FxSwapCurveNode node2                   = FxSwapCurveNode.of(template1, pointsKey2a);
            FxSwapCurveNode node2b                  = FxSwapCurveNode.of(template2, pointsKey2b);
            CurveName       curveName1              = CurveName.of("curve1");
            InterpolatedNodalCurveDefinition curve1 = InterpolatedNodalCurveDefinition.builder().name(curveName1).nodes(node1a, node1b).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_360).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.LINEAR).extrapolatorRight(CurveExtrapolators.LINEAR).build();
            CurveName curveName2 = CurveName.of("curve2");
            InterpolatedNodalCurveDefinition curve2   = InterpolatedNodalCurveDefinition.builder().name(curveName2).nodes(node2, node2b).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_360).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.LINEAR).extrapolatorRight(CurveExtrapolators.LINEAR).build();
            CurveGroupName            curveGroupName  = CurveGroupName.of("group");
            RatesCurveGroupDefinition groupDefinition = RatesCurveGroupDefinition.builder().name(curveGroupName).addDiscountCurve(curve1, Currency.EUR).addDiscountCurve(curve2, Currency.USD).build();

            RatesCurveGroupMarketDataFunction fn = new RatesCurveGroupMarketDataFunction();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> marketDataMap1 = com.google.common.collect.ImmutableMap.of(com.opengamma.strata.data.FxRateId.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD), com.opengamma.strata.basics.currency.FxRate.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD, 1.01), pointsKey1a, 0.1d, pointsKey1b, 0.2d);
            IDictionary <MarketDataId <object>, object> marketDataMap1 = ImmutableMap.of(FxRateId.of(Currency.EUR, Currency.USD), FxRate.of(Currency.EUR, Currency.USD, 1.01), pointsKey1a, 0.1d, pointsKey1b, 0.2d);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> marketDataMap2 = com.google.common.collect.ImmutableMap.of(com.opengamma.strata.data.FxRateId.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD), com.opengamma.strata.basics.currency.FxRate.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD, 1.01), pointsKey2a, 0.1d, pointsKey2b, 0.2d);
            IDictionary <MarketDataId <object>, object> marketDataMap2 = ImmutableMap.of(FxRateId.of(Currency.EUR, Currency.USD), FxRate.of(Currency.EUR, Currency.USD, 1.01), pointsKey2a, 0.1d, pointsKey2b, 0.2d);
            RatesCurveInputs            curveInputs1 = RatesCurveInputs.of(marketDataMap1, DefaultCurveMetadata.of("curve1"));
            RatesCurveInputs            curveInputs2 = RatesCurveInputs.of(marketDataMap2, DefaultCurveMetadata.of("curve2"));
            ImmutableScenarioMarketData marketData   = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addValue(RatesCurveInputsId.of(curveGroupName, curveName1, ObservableSource.NONE), curveInputs1).addValue(RatesCurveInputsId.of(curveGroupName, curveName2, ObservableSource.NONE), curveInputs2).build();

            fn.buildCurveGroup(groupDefinition, CALIBRATOR, marketData, REF_DATA, ObservableSource.NONE);

            // This has a duplicate key with a different value which should fail
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> badMarketDataMap = com.google.common.collect.ImmutableMap.of(com.opengamma.strata.data.FxRateId.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD), com.opengamma.strata.basics.currency.FxRate.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD, 1.02), pointsKey2a, 0.2d);
            IDictionary <MarketDataId <object>, object> badMarketDataMap = ImmutableMap.of(FxRateId.of(Currency.EUR, Currency.USD), FxRate.of(Currency.EUR, Currency.USD, 1.02), pointsKey2a, 0.2d);
            RatesCurveInputs   badCurveInputs = RatesCurveInputs.of(badMarketDataMap, DefaultCurveMetadata.of("curve2"));
            ScenarioMarketData badMarketData  = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addValue(RatesCurveInputsId.of(curveGroupName, curveName1, ObservableSource.NONE), curveInputs1).addValue(RatesCurveInputsId.of(curveGroupName, curveName2, ObservableSource.NONE), badCurveInputs).build();
            string             msg            = "Multiple unequal values found for identifier .*\\. Values: .* and .*";

            assertThrowsIllegalArg(() => fn.buildCurveGroup(groupDefinition, CALIBRATOR, badMarketData, REF_DATA, ObservableSource.NONE), msg);
        }
        public virtual void metadata()
        {
            CurveGroupName groupName = CurveGroupName.of("Curve Group");

            InterpolatedNodalCurveDefinition fraCurveDefn = CurveTestUtils.fraCurveDefinition();
            IList <CurveNode> fraNodes = fraCurveDefn.Nodes;

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(groupName).addForwardCurve(fraCurveDefn, IborIndices.USD_LIBOR_3M).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupName, groupDefn).build();

            RatesCurveGroupId curveGroupId = RatesCurveGroupId.of(groupName);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, double> fraInputData = com.google.common.collect.ImmutableMap.builder<com.opengamma.strata.data.MarketDataId<?>, double>().put(CurveTestUtils.key(fraNodes.get(0)), 0.003).put(CurveTestUtils.key(fraNodes.get(1)), 0.0033).put(CurveTestUtils.key(fraNodes.get(2)), 0.0037).put(CurveTestUtils.key(fraNodes.get(3)), 0.0054).put(CurveTestUtils.key(fraNodes.get(4)), 0.007).put(CurveTestUtils.key(fraNodes.get(5)), 0.0091).put(CurveTestUtils.key(fraNodes.get(6)), 0.0134).build();
            IDictionary <MarketDataId <object>, double> fraInputData = ImmutableMap.builder <MarketDataId <object>, double>().put(CurveTestUtils.key(fraNodes[0]), 0.003).put(CurveTestUtils.key(fraNodes[1]), 0.0033).put(CurveTestUtils.key(fraNodes[2]), 0.0037).put(CurveTestUtils.key(fraNodes[3]), 0.0054).put(CurveTestUtils.key(fraNodes[4]), 0.007).put(CurveTestUtils.key(fraNodes[5]), 0.0091).put(CurveTestUtils.key(fraNodes[6]), 0.0134).build();

            LocalDate          valuationDate  = date(2011, 3, 8);
            RatesCurveInputs   fraCurveInputs = RatesCurveInputs.of(fraInputData, fraCurveDefn.metadata(valuationDate, REF_DATA));
            ScenarioMarketData marketData     = ImmutableScenarioMarketData.builder(valuationDate).addValue(RatesCurveInputsId.of(groupName, fraCurveDefn.Name, ObservableSource.NONE), fraCurveInputs).build();

            RatesCurveGroupMarketDataFunction function   = new RatesCurveGroupMarketDataFunction();
            MarketDataBox <RatesCurveGroup>   curveGroup = function.build(curveGroupId, marketDataConfig, marketData, REF_DATA);

            // Check the FRA curve identifiers are the expected tenors
            Curve forwardCurve = curveGroup.SingleValue.findForwardCurve(IborIndices.USD_LIBOR_3M).get();
            IList <ParameterMetadata> forwardMetadata = forwardCurve.Metadata.ParameterMetadata.get();

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IList <object> forwardTenors = forwardMetadata.Select(ParameterMetadata::getIdentifier).collect(toImmutableList());

            IList <Tenor> expectedForwardTenors = ImmutableList.of(Tenor.TENOR_4M, Tenor.TENOR_5M, Tenor.TENOR_6M, Tenor.TENOR_9M, Tenor.TENOR_12M, Tenor.ofMonths(15), Tenor.ofMonths(21));

            assertThat(forwardTenors).isEqualTo(expectedForwardTenors);

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IList <ParameterMetadata> expectedForwardMetadata = fraNodes.Select(node => node.metadata(valuationDate, REF_DATA)).collect(toImmutableList());

            assertThat(forwardMetadata).isEqualTo(expectedForwardMetadata);
        }
        /// <summary>
        /// Tests calibration a curve containing FRAs and pricing the curve instruments using the curve.
        /// </summary>
        public virtual void roundTripFra()
        {
            InterpolatedNodalCurveDefinition curveDefn = CurveTestUtils.fraCurveDefinition();

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IList <FraCurveNode> nodes = curveDefn.Nodes.Select(typeof(FraCurveNode).cast).collect(toImmutableList());

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.data.MarketDataId<?>> keys = nodes.stream().map(CurveTestUtils::key).collect(toImmutableList());
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IList <MarketDataId <object> > keys = nodes.Select(CurveTestUtils.key).collect(toImmutableList());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, double> inputData = com.google.common.collect.ImmutableMap.builder<com.opengamma.strata.data.MarketDataId<?>, double>().put(keys.get(0), 0.003).put(keys.get(1), 0.0033).put(keys.get(2), 0.0037).put(keys.get(3), 0.0054).put(keys.get(4), 0.007).put(keys.get(5), 0.0091).put(keys.get(6), 0.0134).build();
            IDictionary <MarketDataId <object>, double> inputData = ImmutableMap.builder <MarketDataId <object>, double>().put(keys[0], 0.003).put(keys[1], 0.0033).put(keys[2], 0.0037).put(keys[3], 0.0054).put(keys[4], 0.007).put(keys[5], 0.0091).put(keys[6], 0.0134).build();

            CurveGroupName   groupName   = CurveGroupName.of("Curve Group");
            CurveName        curveName   = CurveName.of("FRA Curve");
            RatesCurveInputs curveInputs = RatesCurveInputs.of(inputData, DefaultCurveMetadata.of(curveName));

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(groupName).addCurve(curveDefn, Currency.USD, IborIndices.USD_LIBOR_3M).build();

            RatesCurveGroupMarketDataFunction function = new RatesCurveGroupMarketDataFunction();
            LocalDate          valuationDate           = date(2011, 3, 8);
            ScenarioMarketData inputMarketData         = ImmutableScenarioMarketData.builder(valuationDate).addValue(RatesCurveInputsId.of(groupName, curveName, ObservableSource.NONE), curveInputs).build();
            MarketDataBox <RatesCurveGroup> curveGroup = function.buildCurveGroup(groupDefn, CALIBRATOR, inputMarketData, REF_DATA, ObservableSource.NONE);

            Curve curve = curveGroup.SingleValue.findDiscountCurve(Currency.USD).get();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> marketDataMap = com.google.common.collect.ImmutableMap.builder<com.opengamma.strata.data.MarketDataId<?>, Object>().putAll(inputData).put(com.opengamma.strata.market.curve.CurveId.of(groupName, curveName), curve).build();
            IDictionary <MarketDataId <object>, object> marketDataMap = ImmutableMap.builder <MarketDataId <object>, object>().putAll(inputData).put(CurveId.of(groupName, curveName), curve).build();

            MarketData            marketData         = ImmutableMarketData.of(valuationDate, marketDataMap);
            TestMarketDataMap     scenarioMarketData = new TestMarketDataMap(valuationDate, marketDataMap, ImmutableMap.of());
            RatesMarketDataLookup lookup             = RatesMarketDataLookup.of(groupDefn);
            RatesProvider         ratesProvider      = lookup.ratesProvider(scenarioMarketData.scenario(0));

            // The PV should be zero for an instrument used to build the curve
            nodes.ForEach(node => checkFraPvIsZero(node, ratesProvider, marketData));
        }
        /// <summary>
        /// Tests that par rates and ibor index are required for curves.
        /// </summary>
        public virtual void requirements()
        {
            FraCurveNode      node1x4   = CurveTestUtils.fraNode(1, "foo");
            FraCurveNode      node2x5   = CurveTestUtils.fraNode(2, "foo");
            IList <CurveNode> nodes     = ImmutableList.of(node1x4, node2x5);
            CurveGroupName    groupName = CurveGroupName.of("Curve Group");
            CurveName         curveName = CurveName.of("FRA Curve");
            ObservableSource  obsSource = ObservableSource.of("Vendor");

            InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(curveName).nodes(nodes).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();

            RateIndex ibor = IborIndices.USD_LIBOR_3M;
            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(groupName).addCurve(curveDefn, Currency.USD, ibor).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupName, groupDefn).build();

            RatesCurveGroupMarketDataFunction function = new RatesCurveGroupMarketDataFunction();
            RatesCurveGroupId      curveGroupId        = RatesCurveGroupId.of(groupName, obsSource);
            MarketDataRequirements requirements        = function.requirements(curveGroupId, marketDataConfig);

            assertThat(requirements.NonObservables).contains(RatesCurveInputsId.of(groupName, curveName, obsSource));
            assertThat(requirements.TimeSeries.contains(IndexQuoteId.of(ibor)));
        }
Example #12
0
        //-------------------------------------------------------------------------
        public virtual void test_bind()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build();
            LocalDate valuationDate        = LocalDate.of(2015, 11, 10);
            LocalDate lastFixingDate       = LocalDate.of(2015, 10, 31);
            LocalDate otherFixingDate      = LocalDate.of(2015, 9, 30);
            double    lastFixingValue      = 234.56;
            IDictionary <Index, LocalDateDoubleTimeSeries> map = ImmutableMap.of(GB_RPI, LocalDateDoubleTimeSeries.builder().put(lastFixingDate, 234.56).put(otherFixingDate, lastFixingValue - 1).build());
            RatesCurveGroupDefinition testBound = test.bindTimeSeries(valuationDate, map);
            IList <CurveDefinition>   list      = testBound.CurveDefinitions;

            assertEquals(list.Count, 2);
            assertTrue(list[0] is InterpolatedNodalCurveDefinition);
            assertTrue(list[1] is InflationNodalCurveDefinition);
            InflationNodalCurveDefinition seasonDef = (InflationNodalCurveDefinition)list[1];

            assertEquals(seasonDef.CurveWithoutFixingDefinition, CURVE_DEFN_I);
            assertEquals(seasonDef.LastFixingMonth, YearMonth.from(lastFixingDate));
            assertEquals(seasonDef.LastFixingValue, lastFixingValue);
            assertEquals(seasonDef.Name, CURVE_NAME_I);
            assertEquals(seasonDef.SeasonalityDefinition, SEASONALITY_ADDITIVE_DEF);
            assertEquals(seasonDef.YValueType, ValueType.PRICE_INDEX);
        }
        public virtual void roundTripFraAndFixedFloatSwap()
        {
            CurveGroupName groupName = CurveGroupName.of("Curve Group");
            InterpolatedNodalCurveDefinition curveDefn = CurveTestUtils.fraSwapCurveDefinition();
            CurveName         curveName = curveDefn.Name;
            IList <CurveNode> nodes     = curveDefn.Nodes;

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(groupName).addCurve(curveDefn, Currency.USD, IborIndices.USD_LIBOR_3M).build();

            RatesCurveGroupMarketDataFunction function = new RatesCurveGroupMarketDataFunction();
            LocalDate valuationDate = date(2011, 3, 8);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, double> inputData = com.google.common.collect.ImmutableMap.builder<com.opengamma.strata.data.MarketDataId<?>, double>().put(CurveTestUtils.key(nodes.get(0)), 0.0037).put(CurveTestUtils.key(nodes.get(1)), 0.0054).put(CurveTestUtils.key(nodes.get(2)), 0.005).put(CurveTestUtils.key(nodes.get(3)), 0.0087).put(CurveTestUtils.key(nodes.get(4)), 0.012).build();
            IDictionary <MarketDataId <object>, double> inputData = ImmutableMap.builder <MarketDataId <object>, double>().put(CurveTestUtils.key(nodes[0]), 0.0037).put(CurveTestUtils.key(nodes[1]), 0.0054).put(CurveTestUtils.key(nodes[2]), 0.005).put(CurveTestUtils.key(nodes[3]), 0.0087).put(CurveTestUtils.key(nodes[4]), 0.012).build();

            RatesCurveInputs   curveInputs     = RatesCurveInputs.of(inputData, DefaultCurveMetadata.of(curveName));
            ScenarioMarketData inputMarketData = ImmutableScenarioMarketData.builder(valuationDate).addValue(RatesCurveInputsId.of(groupName, curveName, ObservableSource.NONE), curveInputs).build();

            MarketDataBox <RatesCurveGroup> curveGroup = function.buildCurveGroup(groupDefn, CALIBRATOR, inputMarketData, REF_DATA, ObservableSource.NONE);
            Curve curve = curveGroup.SingleValue.findDiscountCurve(Currency.USD).get();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> marketDataMap = com.google.common.collect.ImmutableMap.builder<com.opengamma.strata.data.MarketDataId<?>, Object>().putAll(inputData).put(com.opengamma.strata.market.curve.CurveId.of(groupName, curveName), curve).build();
            IDictionary <MarketDataId <object>, object> marketDataMap = ImmutableMap.builder <MarketDataId <object>, object>().putAll(inputData).put(CurveId.of(groupName, curveName), curve).build();
            MarketData            marketData         = ImmutableMarketData.of(valuationDate, marketDataMap);
            TestMarketDataMap     scenarioMarketData = new TestMarketDataMap(valuationDate, marketDataMap, ImmutableMap.of());
            RatesMarketDataLookup lookup             = RatesMarketDataLookup.of(groupDefn);
            RatesProvider         ratesProvider      = lookup.ratesProvider(scenarioMarketData.scenario(0));

            checkFraPvIsZero((FraCurveNode)nodes[0], ratesProvider, marketData);
            checkFraPvIsZero((FraCurveNode)nodes[1], ratesProvider, marketData);
            checkSwapPvIsZero((FixedIborSwapCurveNode)nodes[2], ratesProvider, marketData);
            checkSwapPvIsZero((FixedIborSwapCurveNode)nodes[3], ratesProvider, marketData);
            checkSwapPvIsZero((FixedIborSwapCurveNode)nodes[4], ratesProvider, marketData);
        }
Example #14
0
        public virtual void test_serialization()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_DEFN1, GBP).build();

            assertSerialization(test);
        }