//------------------------------------------------------------------------- public virtual void coverage() { ParallelShiftedCurve test = ParallelShiftedCurve.absolute(CONSTANT_CURVE, 1); coverImmutableBean(test); ParallelShiftedCurve test2 = ParallelShiftedCurve.relative(CONSTANT_CURVE2, 0.2); coverBeanEquals(test, test2); }
public virtual void test_firstDerivative() { 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); assertThat(curve.firstDerivative(0.1)).isEqualTo(0.5); assertThat(absoluteShiftedCurve.firstDerivative(0.1)).isEqualTo(0.5); assertThat(relativeShiftedCurve.firstDerivative(0.1)).isEqualTo(0.5 * 1.2); }
//------------------------------------------------------------------------- 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); }
public virtual void test_absolute() { CurveParallelShifts test = CurveParallelShifts.absolute(1d, 2d, 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.absolute(baseCurve, 1d)); assertEquals(shiftedCurveBox.getValue(1), ParallelShiftedCurve.absolute(baseCurve, 2d)); assertEquals(shiftedCurveBox.getValue(2), ParallelShiftedCurve.absolute(baseCurve, 4d)); }
//------------------------------------------------------------------------- public virtual void absolute() { ParallelShiftedCurve test = ParallelShiftedCurve.absolute(CONSTANT_CURVE, 1d); assertThat(test.UnderlyingCurve).isEqualTo(CONSTANT_CURVE); assertThat(test.ShiftType).isEqualTo(ShiftType.ABSOLUTE); assertThat(test.ShiftAmount).isEqualTo(1d); assertThat(test.Metadata).isEqualTo(METADATA); assertThat(test.Name).isEqualTo(METADATA.CurveName); assertThat(test.ParameterCount).isEqualTo(2); assertThat(test.getParameter(0)).isEqualTo(3d); assertThat(test.getParameter(1)).isEqualTo(1d); assertThat(test.getParameterMetadata(0)).isEqualTo(ParameterMetadata.empty()); assertThat(test.getParameterMetadata(1)).isEqualTo(LabelParameterMetadata.of("AbsoluteShift")); assertThat(test.withParameter(0, 5d)).isEqualTo(ParallelShiftedCurve.absolute(CONSTANT_CURVE2, 1d)); assertThat(test.withParameter(1, 0.5d)).isEqualTo(ParallelShiftedCurve.absolute(CONSTANT_CURVE, 0.5d)); assertThat(test.withPerturbation((i, v, m) => v + 2d)).isEqualTo(ParallelShiftedCurve.absolute(CONSTANT_CURVE2, 3d)); assertThat(test.yValue(0)).isEqualTo(4d); assertThat(test.yValue(1)).isEqualTo(4d); }
public virtual void test_serialization() { ParallelShiftedCurve test = ParallelShiftedCurve.absolute(CONSTANT_CURVE, 1); assertSerialization(test); }