public virtual void test_addVolatility_notAscendingTime() { HullWhiteOneFactorPiecewiseConstantParameters @base = HullWhiteOneFactorPiecewiseConstantParameters.of(MEAN_REVERSION, VOLATILITY, VOLATILITY_TIME); double time = 3.0; double vol = 0.015; assertThrowsIllegalArg(() => @base.withVolatilityAdded(vol, time)); }
public virtual void test_addVolatility() { HullWhiteOneFactorPiecewiseConstantParameters @base = HullWhiteOneFactorPiecewiseConstantParameters.of(MEAN_REVERSION, VOLATILITY, VOLATILITY_TIME); double time = 7.0; double vol = 0.015; HullWhiteOneFactorPiecewiseConstantParameters test = @base.withVolatilityAdded(vol, time); assertEquals(test.LastVolatility, vol); assertEquals(test.MeanReversion, MEAN_REVERSION); assertEquals(test.Volatility, DoubleArray.of(0.01, 0.011, 0.012, 0.013, 0.014, vol)); assertEquals(test.VolatilityTime, DoubleArray.of(0.0, 0.5, 1.0, 2.0, 5.0, 7.0, 1000d)); }