/// <summary> /// Test that inputs are correctly built from market data. /// </summary> public virtual void build() { FraCurveNode node1x4 = fraNode(1, "a"); FraCurveNode node2x5 = fraNode(2, "b"); FraCurveNode node3x6 = fraNode(3, "c"); InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(CurveName.of("curve")).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(DayCounts.ACT_ACT_ISDA).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(curveDefn, Currency.USD).build(); MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupDefn.Name, groupDefn).build(); QuoteId idA = QuoteId.of(StandardId.of("test", "a")); QuoteId idB = QuoteId.of(StandardId.of("test", "b")); QuoteId idC = QuoteId.of(StandardId.of("test", "c")); ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(idA, 1d).addValue(idB, 2d).addValue(idC, 3d).build(); RatesCurveInputsMarketDataFunction marketDataFunction = new RatesCurveInputsMarketDataFunction(); RatesCurveInputsId curveInputsId = RatesCurveInputsId.of(groupDefn.Name, curveDefn.Name, ObservableSource.NONE); MarketDataBox <RatesCurveInputs> result = marketDataFunction.build(curveInputsId, marketDataConfig, marketData, REF_DATA); RatesCurveInputs curveInputs = result.SingleValue; assertThat(curveInputs.MarketData.get(idA)).isEqualTo(1d); assertThat(curveInputs.MarketData.get(idB)).isEqualTo(2d); assertThat(curveInputs.MarketData.get(idC)).isEqualTo(3d); IList <ParameterMetadata> expectedMetadata = ImmutableList.of(node1x4.metadata(VAL_DATE, REF_DATA), node2x5.metadata(VAL_DATE, REF_DATA), node3x6.metadata(VAL_DATE, REF_DATA)); assertThat(curveInputs.CurveMetadata.ParameterMetadata).hasValue(expectedMetadata); }
public static RatesCurveGroupDefinition config(Period[] dscOisTenors, string[] dscIdValues, Period[] fwd3FraTenors, Period[] fwd3IrsTenors, string[] fwd3IdValues, Period[] fwd6FraTenors, Period[] fwd6IrsTenors, string[] fwd6IdValues) { CurveNode[] dscNodes = new CurveNode[dscOisTenors.Length]; for (int i = 0; i < dscOisTenors.Length; i++) { dscNodes[i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(dscOisTenors[i]), EUR_FIXED_1Y_EONIA_OIS), QuoteId.of(StandardId.of(SCHEME, dscIdValues[i]))); } CurveNode[] fwd3Nodes = new CurveNode[fwd3IdValues.Length]; fwd3Nodes[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(EUR_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, fwd3IdValues[0]))); for (int i = 0; i < fwd3FraTenors.Length; i++) { fwd3Nodes[i + 1] = FraCurveNode.of(FraTemplate.of(fwd3FraTenors[i], EUR_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, fwd3IdValues[i + 1]))); } for (int i = 0; i < fwd3IrsTenors.Length; i++) { fwd3Nodes[i + 1 + fwd3FraTenors.Length] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(fwd3IrsTenors[i]), EUR_FIXED_1Y_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, fwd3IdValues[i + 1 + fwd3FraTenors.Length]))); } CurveNode[] fwd6Nodes = new CurveNode[fwd6IdValues.Length]; fwd6Nodes[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(EUR_EURIBOR_6M), QuoteId.of(StandardId.of(SCHEME, fwd6IdValues[0]))); for (int i = 0; i < fwd6FraTenors.Length; i++) { fwd6Nodes[i + 1] = FraCurveNode.of(FraTemplate.of(fwd6FraTenors[i], EUR_EURIBOR_6M), QuoteId.of(StandardId.of(SCHEME, fwd6IdValues[i + 1]))); } for (int i = 0; i < fwd6IrsTenors.Length; i++) { fwd6Nodes[i + 1 + fwd6FraTenors.Length] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(fwd6IrsTenors[i]), EUR_FIXED_1Y_EURIBOR_6M), QuoteId.of(StandardId.of(SCHEME, fwd6IdValues[i + 1 + fwd6FraTenors.Length]))); } InterpolatedNodalCurveDefinition DSC_CURVE_DEFN = 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(dscNodes).build(); InterpolatedNodalCurveDefinition FWD3_CURVE_DEFN = InterpolatedNodalCurveDefinition.builder().name(FWD3_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).interpolator(INTERPOLATOR_LINEAR).extrapolatorLeft(EXTRAPOLATOR_FLAT).extrapolatorRight(EXTRAPOLATOR_FLAT).nodes(fwd3Nodes).build(); InterpolatedNodalCurveDefinition FWD6_CURVE_DEFN = InterpolatedNodalCurveDefinition.builder().name(FWD6_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).interpolator(INTERPOLATOR_LINEAR).extrapolatorLeft(EXTRAPOLATOR_FLAT).extrapolatorRight(EXTRAPOLATOR_FLAT).nodes(fwd6Nodes).build(); return(RatesCurveGroupDefinition.builder().name(CURVE_GROUP_NAME).addCurve(DSC_CURVE_DEFN, EUR, EUR_EONIA).addForwardCurve(FWD3_CURVE_DEFN, EUR_EURIBOR_3M).addForwardCurve(FWD6_CURVE_DEFN, EUR_EURIBOR_6M).build()); }
/// <summary> /// End-to-end test for curve calibration and round-tripping that uses the <seealso cref="MarketDataFactory"/> /// to calibrate a curve and calculate PVs for the instruments at the curve nodes. /// /// This tests the full pipeline of market data functions: /// - Par rates /// - Curve group (including calibration) /// - Individual curves /// - Discount factors /// </summary> public virtual void roundTripFraAndFixedFloatSwap() { // Configuration and market data for the curve --------------------------------- string fra3x6 = "fra3x6"; string fra6x9 = "fra6x9"; string swap1y = "swap1y"; string swap2y = "swap2y"; string swap3y = "swap3y"; FraCurveNode fra3x6Node = fraNode(3, fra3x6); FraCurveNode fra6x9Node = fraNode(6, fra6x9); FixedIborSwapCurveNode swap1yNode = fixedIborSwapNode(Tenor.TENOR_1Y, swap1y); FixedIborSwapCurveNode swap2yNode = fixedIborSwapNode(Tenor.TENOR_2Y, swap2y); FixedIborSwapCurveNode swap3yNode = fixedIborSwapNode(Tenor.TENOR_3Y, swap3y); IDictionary <ObservableId, double> parRateData = ImmutableMap.builder <ObservableId, double>().put(id(fra3x6), 0.0037).put(id(fra6x9), 0.0054).put(id(swap1y), 0.005).put(id(swap2y), 0.0087).put(id(swap3y), 0.012).build(); LocalDate valuationDate = date(2011, 3, 8); // Build the trades from the node instruments MarketData quotes = ImmutableMarketData.of(valuationDate, parRateData); Trade fra3x6Trade = fra3x6Node.trade(1d, quotes, REF_DATA); Trade fra6x9Trade = fra6x9Node.trade(1d, quotes, REF_DATA); Trade swap1yTrade = swap1yNode.trade(1d, quotes, REF_DATA); Trade swap2yTrade = swap2yNode.trade(1d, quotes, REF_DATA); Trade swap3yTrade = swap3yNode.trade(1d, quotes, REF_DATA); IList <Trade> trades = ImmutableList.of(fra3x6Trade, fra6x9Trade, swap1yTrade, swap2yTrade, swap3yTrade); IList <CurveNode> nodes = ImmutableList.of(fra3x6Node, fra6x9Node, swap1yNode, swap2yNode, swap3yNode); CurveGroupName groupName = CurveGroupName.of("Curve Group"); CurveName curveName = CurveName.of("FRA and Fixed-Float Swap Curve"); InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(curveName).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(DayCounts.ACT_ACT_ISDA).nodes(nodes).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build(); RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(groupName).addCurve(curveDefn, Currency.USD, IborIndices.USD_LIBOR_3M).build(); MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupName, groupDefn).build(); // Rules for market data and calculations --------------------------------- RatesMarketDataLookup ratesLookup = RatesMarketDataLookup.of(groupDefn); CalculationRules calculationRules = CalculationRules.of(functions(), Currency.USD, ratesLookup); // Calculate the results and check the PVs for the node instruments are zero ---------------------- IList <Column> columns = ImmutableList.of(Column.of(Measures.PRESENT_VALUE)); MarketData knownMarketData = MarketData.of(date(2011, 3, 8), parRateData); // using the direct executor means there is no need to close/shutdown the runner CalculationTasks tasks = CalculationTasks.of(calculationRules, trades, columns, REF_DATA); MarketDataRequirements reqs = tasks.requirements(REF_DATA); MarketData enhancedMarketData = marketDataFactory().create(reqs, marketDataConfig, knownMarketData, REF_DATA); CalculationTaskRunner runner = CalculationTaskRunner.of(MoreExecutors.newDirectExecutorService()); Results results = runner.calculate(tasks, enhancedMarketData, REF_DATA); results.Cells.ForEach(this.checkPvIsZero); }
/* 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); }
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); }
/// <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"))); }
/// <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)); }
internal static InterpolatedNodalCurveDefinition fraSwapCurveDefinition() { string fra3x6 = "fra3x6"; string fra6x9 = "fra6x9"; string swap1y = "swap1y"; string swap2y = "swap2y"; string swap3y = "swap3y"; FraCurveNode fra3x6Node = CurveTestUtils.fraNode(3, fra3x6); FraCurveNode fra6x9Node = CurveTestUtils.fraNode(6, fra6x9); FixedIborSwapCurveNode swap1yNode = fixedIborSwapNode(Tenor.TENOR_1Y, swap1y); FixedIborSwapCurveNode swap2yNode = fixedIborSwapNode(Tenor.TENOR_2Y, swap2y); FixedIborSwapCurveNode swap3yNode = fixedIborSwapNode(Tenor.TENOR_3Y, swap3y); CurveName curveName = CurveName.of("FRA and Fixed-Float Swap Curve"); IList <CurveNode> nodes = ImmutableList.of(fra3x6Node, fra6x9Node, swap1yNode, swap2yNode, swap3yNode); return(InterpolatedNodalCurveDefinition.builder().name(curveName).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(DayCounts.ACT_ACT_ISDA).nodes(nodes).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build()); }
//------------------------------------------------------------------------- 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); }
/// <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))); }
internal static InterpolatedNodalCurveDefinition fraCurveDefinition() { string fra1x4 = "fra1x4"; string fra2x5 = "fra2x5"; string fra3x6 = "fra3x6"; string fra6x9 = "fra6x9"; string fra9x12 = "fra9x12"; string fra12x15 = "fra12x15"; string fra18x21 = "fra18x21"; FraCurveNode fra1x4Node = fraNode(1, fra1x4); FraCurveNode fra2x5Node = fraNode(2, fra2x5); FraCurveNode fra3x6Node = fraNode(3, fra3x6); FraCurveNode fra6x9Node = fraNode(6, fra6x9); FraCurveNode fra9x12Node = fraNode(9, fra9x12); FraCurveNode fra12x15Node = fraNode(12, fra12x15); FraCurveNode fra18x21Node = fraNode(18, fra18x21); CurveName curveName = CurveName.of("FRA Curve"); IList <CurveNode> nodes = ImmutableList.of(fra1x4Node, fra2x5Node, fra3x6Node, fra6x9Node, fra9x12Node, fra12x15Node, fra18x21Node); return(InterpolatedNodalCurveDefinition.builder().name(curveName).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(DayCounts.ACT_ACT_ISDA).nodes(nodes).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build()); }
// constructs an interpolated nodal curve definition internal InterpolatedNodalCurveDefinition createCurveDefinition(IList <CurveNode> nodes) { return(InterpolatedNodalCurveDefinition.builder().name(curveName).xValueType(xValueType).yValueType(yValueType).dayCount(dayCount).nodes(nodes).interpolator(interpolator).extrapolatorLeft(extrapolatorLeft).extrapolatorRight(extrapolatorRight).build()); }