Ejemplo n.º 1
0
        public virtual void test_multipleCurves()
        {
            Curve              curve1     = ConstantCurve.of(CURVE_NAME1, (double)1);
            Curve              curve2     = ConstantCurve.of(CURVE_NAME2, (double)2);
            CurveId            curveId1   = CurveId.of(GROUP_NAME, CURVE_NAME1);
            CurveId            curveId2   = CurveId.of(GROUP_NAME, CURVE_NAME2);
            RatesCurveGroupId  groupId    = RatesCurveGroupId.of(GROUP_NAME);
            RatesCurveGroup    curveGroup = RatesCurveGroup.of(GROUP_NAME, ImmutableMap.of(Currency.AUD, curve1, Currency.GBP, curve2), ImmutableMap.of());
            ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(groupId, curveGroup).build();
            MarketDataConfig   config     = MarketDataConfig.builder().add(GROUP_NAME, RatesCurveGroupDefinition.builder().name(GROUP_NAME).build()).build();

            CurveMarketDataFunction test    = new CurveMarketDataFunction();
            MarketDataBox <Curve>   result1 = test.build(curveId1, config, marketData, REF_DATA);

            assertEquals(result1, MarketDataBox.ofSingleValue(curve1));
            MarketDataBox <Curve> result2 = test.build(curveId2, config, marketData, REF_DATA);

            assertEquals(result2, MarketDataBox.ofSingleValue(curve2));
        }
Ejemplo n.º 2
0
        public virtual void absoluteScenarios()
        {
            CurveName      curveName                  = CurveName.of("curveName");
            CurveGroupName curveGroupName             = CurveGroupName.of("curveGroupName");
            Curve          curve                      = ConstantCurve.of(curveName, 2);
            PerturbationMapping <Curve> mapping       = PerturbationMapping.of(MarketDataFilter.ofName(curveName), CurveParallelShifts.absolute(0.1, 0.2, 0.3));
            CurveId                curveId            = CurveId.of(curveGroupName, curveName);
            ScenarioMarketData     marketData         = ImmutableScenarioMarketData.builder(TestHelper.date(2011, 3, 8)).addValue(curveId, curve).build();
            ScenarioDefinition     scenarioDefinition = ScenarioDefinition.ofMappings(mapping);
            MarketDataFactory      marketDataFactory  = MarketDataFactory.of(mock(typeof(ObservableDataProvider)), mock(typeof(TimeSeriesProvider)));
            MarketDataRequirements requirements       = MarketDataRequirements.builder().addValues(curveId).build();
            ScenarioMarketData     scenarioData       = marketDataFactory.createMultiScenario(requirements, MarketDataConfig.empty(), marketData, REF_DATA, scenarioDefinition);
            MarketDataBox <Curve>  curves             = scenarioData.getValue(curveId);

            assertThat(curves.ScenarioCount).isEqualTo(3);
            checkCurveValues(curves.getValue(0), 2.1);
            checkCurveValues(curves.getValue(1), 2.2);
            checkCurveValues(curves.getValue(2), 2.3);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void test_singleCurve()
        {
            Curve              curve      = ConstantCurve.of(CURVE_NAME1, (double)1);
            CurveId            curveId1   = CurveId.of(GROUP_NAME, CURVE_NAME1, OBS_SOURCE);
            CurveId            curveId2   = CurveId.of(GROUP_NAME, CURVE_NAME2, OBS_SOURCE);
            CurveId            curveId3   = CurveId.of(GROUP_NAME2, CURVE_NAME1, OBS_SOURCE);
            RatesCurveGroupId  groupId    = RatesCurveGroupId.of(GROUP_NAME, OBS_SOURCE);
            RatesCurveGroup    curveGroup = RatesCurveGroup.of(GROUP_NAME, ImmutableMap.of(Currency.AUD, curve), ImmutableMap.of());
            ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(groupId, curveGroup).build();
            MarketDataConfig   config     = MarketDataConfig.builder().add(GROUP_NAME, RatesCurveGroupDefinition.builder().name(GROUP_NAME).build()).build();

            CurveMarketDataFunction test = new CurveMarketDataFunction();
            MarketDataRequirements  reqs = test.requirements(curveId1, config);

            assertEquals(reqs.NonObservables, ImmutableSet.of(groupId));
            MarketDataBox <Curve> result = test.build(curveId1, config, marketData, REF_DATA);

            assertEquals(result, MarketDataBox.ofSingleValue(curve));
            assertThrowsIllegalArg(() => test.build(curveId2, config, marketData, REF_DATA));
            assertThrowsIllegalArg(() => test.build(curveId3, config, marketData, REF_DATA));
        }