/// <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));
        }
        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);
        }
        //-------------------------------------------------------------------------
        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);
        }