예제 #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));
        }
예제 #2
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));
        }