public virtual void test_relative()
        {
            CurveParallelShifts test = CurveParallelShifts.relative(0.1d, 0.2d, 0.4d);

            Curve baseCurve = InterpolatedNodalCurve.of(Curves.zeroRates("curve", DayCounts.ACT_365F), DoubleArray.of(1, 2, 3), DoubleArray.of(5, 6, 7), CurveInterpolators.LOG_LINEAR);

            MarketDataBox <Curve> shiftedCurveBox = test.applyTo(MarketDataBox.ofSingleValue(baseCurve), REF_DATA);

            assertEquals(shiftedCurveBox.getValue(0), ParallelShiftedCurve.relative(baseCurve, 0.1d));
            assertEquals(shiftedCurveBox.getValue(1), ParallelShiftedCurve.relative(baseCurve, 0.2d));
            assertEquals(shiftedCurveBox.getValue(2), ParallelShiftedCurve.relative(baseCurve, 0.4d));
        }
Exemple #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);
        }
Exemple #3
0
        public virtual void test_pointShifts()
        {
            SabrParametersSwaptionVolatilities @base = SabrParametersSwaptionVolatilities.of(NAME, CONV, DATE_TIME, PARAM);
            PointShiftsBuilder builder = PointShifts.builder(ShiftType.ABSOLUTE);

            for (int i = 0; i < @base.ParameterCount; ++i)
            {
                builder.addShift(0, @base.getParameterMetadata(i).Identifier, 0.1d * (i + 1d));
                builder.addShift(1, @base.getParameterMetadata(i).Identifier, 10d * (i + 1d));
            }
            PointShifts shifts = builder.build();
            MarketDataBox <ParameterizedData>  resBox    = shifts.applyTo(MarketDataBox.ofSingleValue(@base), REF_DATA);
            SabrParametersSwaptionVolatilities computed0 = (SabrParametersSwaptionVolatilities)resBox.getValue(0);
            SabrParametersSwaptionVolatilities computed1 = (SabrParametersSwaptionVolatilities)resBox.getValue(1);

            for (int i = 0; i < @base.ParameterCount; ++i)
            {
                assertEquals(computed0.getParameter(i), @base.getParameter(i) + 0.1d * (i + 1d));
                assertEquals(computed1.getParameter(i), @base.getParameter(i) + 10d * (i + 1d));
            }
        }
        public virtual void test_toZonedDateTime_scenario_long()
        {
            ValuationZoneTimeDefinition   test     = ValuationZoneTimeDefinition.of(LOCAL_TIME_1, ZONE_ID, LOCAL_TIME_1, LOCAL_TIME_2);
            MarketDataBox <LocalDate>     dates    = MarketDataBox.ofScenarioValues(LocalDate.of(2016, 10, 21), LocalDate.of(2016, 10, 22), LocalDate.of(2016, 10, 23));
            MarketDataBox <ZonedDateTime> computed = test.toZonedDateTime(dates);
            MarketDataBox <ZonedDateTime> expected = MarketDataBox.ofScenarioValue(ScenarioArray.of(dates.getValue(0).atTime(LOCAL_TIME_1).atZone(ZONE_ID), dates.getValue(1).atTime(LOCAL_TIME_2).atZone(ZONE_ID), dates.getValue(2).atTime(LOCAL_TIME_1).atZone(ZONE_ID)));

            assertEquals(computed, expected);
        }