Esempio n. 1
0
        //-------------------------------------------------------------------------
        public virtual void test_lookup()
        {
            InterpolatedNodalCurve test   = InterpolatedNodalCurve.of(METADATA, XVALUES, YVALUES, INTERPOLATOR);
            BoundCurveInterpolator interp = INTERPOLATOR.bind(XVALUES, YVALUES, FLAT_EXTRAPOLATOR, FLAT_EXTRAPOLATOR);

            assertThat(test.yValue(XVALUES.get(0))).isEqualTo(YVALUES.get(0));
            assertThat(test.yValue(XVALUES.get(1))).isEqualTo(YVALUES.get(1));
            assertThat(test.yValue(XVALUES.get(2))).isEqualTo(YVALUES.get(2));
            assertThat(test.yValue(10d)).isEqualTo(interp.interpolate(10d));

            assertThat(test.yValueParameterSensitivity(10d).MarketDataName).isEqualTo(CURVE_NAME);
            assertThat(test.yValueParameterSensitivity(10d).Sensitivity).isEqualTo(interp.parameterSensitivity(10d));
            assertThat(test.firstDerivative(10d)).isEqualTo(interp.firstDerivative(10d));
        }
Esempio n. 2
0
 public virtual void test_yValueParameterSensitivity()
 {
     for (int i = 0; i < NUM_SAMPLES; ++i)
     {
         UnitParameterSensitivity computed   = COMBINED_CURVE.yValueParameterSensitivity(X_SAMPLES.get(i));
         UnitParameterSensitivity baseSens   = BASE_CURVE.yValueParameterSensitivity(X_SAMPLES.get(i));
         UnitParameterSensitivity spreadSens = SPREAD_CURVE.yValueParameterSensitivity(X_SAMPLES.get(i));
         assertEquals(computed.split(), ImmutableList.of(baseSens, spreadSens));
     }
 }
 public virtual void yParameterSensitivity()
 {
     for (int i = 0; i < X_SAMPLE.Length; i++)
     {
         UnitParameterSensitivity dComputed = ADD_FIXED_CURVE.yValueParameterSensitivity(X_SAMPLE[i]);
         UnitParameterSensitivity dExpected = SPREAD_CURVE.yValueParameterSensitivity(X_SAMPLE[i]);
         assertTrue(dComputed.compareKey(dExpected) == 0);
         assertTrue(dComputed.Sensitivity.equalWithTolerance(dExpected.Sensitivity, TOLERANCE_Y));
     }
 }
        //-------------------------------------------------------------------------
        public virtual void test_yValueParameterSensitivity()
        {
            InterpolatedNodalCurve curve = InterpolatedNodalCurve.of(METADATA, DoubleArray.of(0, 1), DoubleArray.of(2, 2.5), CurveInterpolators.LINEAR);

            Curve absoluteShiftedCurve = ParallelShiftedCurve.absolute(curve, 1);
            Curve relativeShiftedCurve = ParallelShiftedCurve.relative(curve, 0.2);

            UnitParameterSensitivity expected = curve.yValueParameterSensitivity(0.1);

            assertThat(absoluteShiftedCurve.yValueParameterSensitivity(0.1)).isEqualTo(expected);
            assertThat(relativeShiftedCurve.yValueParameterSensitivity(0.1)).isEqualTo(expected);
        }