/** * Obtains an instance of {@code LogMoneyness} from the strike and forward. * <p> * The log-moneyness is defined as {@code ln(strike/forward)}. * * @param strike the strike, not negative * @param forward the forward, not negative * @return the instance */ public static LogMoneynessStrike ofStrikeAndForward(double strike, double forward) { return of(Math.log(ArgChecker.notNegative(strike, "strike") / ArgChecker.notNegative(forward, "forward"))); }
public void test_ofStrikeAndForward() { LogMoneynessStrike test = LogMoneynessStrike.ofStrikeAndForward(0.6d, 1.2d); assertEquals(test.getType(), StrikeType.LOG_MONEYNESS); assertEquals(test.getValue(), Math.log(0.5d), 0d); assertEquals(test.getLabel(), "LogMoneyness=" + Math.log(0.5d)); assertEquals(test.withValue(0.2d), LogMoneynessStrike.of(0.2d)); }
public void test_serialization() { LogMoneynessStrike test = LogMoneynessStrike.of(0.6d); assertSerialization(test); }