public virtual void specifySource() { ObservableSource testSource = ObservableSource.of("test"); ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addValue(FxRateId.of(Currency.GBP, Currency.USD), FxRate.of(Currency.GBP, Currency.USD, 1.4d)).addValue(FxRateId.of(Currency.GBP, Currency.USD, testSource), FxRate.of(Currency.GBP, Currency.USD, 1.41d)).build(); ScenarioFxRateProvider defaultRateProvider = ScenarioFxRateProvider.of(marketData); ScenarioFxRateProvider sourceRateProvider = ScenarioFxRateProvider.of(marketData, testSource); assertThat(defaultRateProvider.fxRate(Currency.GBP, Currency.USD, 0)).isEqualTo(1.4d); assertThat(sourceRateProvider.fxRate(Currency.GBP, Currency.USD, 0)).isEqualTo(1.41d); }
/// <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))); }