@Override public double discountFactorTimeDerivative(double yearFraction) { return curve.firstDerivative(yearFraction); }
@Override public double firstDerivative(double x) { return baseCurve.firstDerivative(x) + spreadCurve.firstDerivative(x); }
@Override public double firstDerivative(double x) { return fixedCurve.firstDerivative(x) + spreadCurve.firstDerivative(x); }
@Override public double discountFactorTimeDerivative(double yearFraction) { double zr = curve.yValue(yearFraction); double periodIF = 1d + zr / frequency; double df = Math.pow(periodIF, -yearFraction * frequency); return -frequency * df * (Math.log(periodIF) + yearFraction / periodIF * curve.firstDerivative(yearFraction) / frequency); }
@Override public double firstDerivative(double x) { double firstDerivative = underlyingCurve.firstDerivative(x); switch (shiftType) { case ABSOLUTE: // If all Y values have been shifted the same amount the derivative is unaffected return firstDerivative; case RELATIVE: // If all Y values have been scaled by the same factor the first derivative is scaled in the same way return shiftType.applyShift(firstDerivative, shiftAmount); default: throw new IllegalArgumentException("Unsupported shift type " + shiftType); } }
@Override public double discountFactorTimeDerivative(double yearFraction) { double zr = curve.yValue(yearFraction); return -Math.exp(-yearFraction * curve.yValue(yearFraction)) * (zr + curve.firstDerivative(yearFraction) * yearFraction); }
public 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); }