//------------------------------------------------------------------------- // bumping a node point at (nodeExpiry, nodeStrike) private double nodeSensitivity(BlackFxOptionSurfaceVolatilities provider, CurrencyPair pair, ZonedDateTime expiry, double strike, double forward, double nodeExpiry, double nodeStrike) { NodalSurface surface = (NodalSurface)provider.Surface; DoubleArray xValues = surface.XValues; DoubleArray yValues = surface.YValues; DoubleArray zValues = surface.ZValues; int nData = xValues.size(); int index = -1; for (int i = 0; i < nData; ++i) { if (Math.Abs(xValues.get(i) - nodeExpiry) < TOLERANCE && Math.Abs(yValues.get(i) - nodeStrike) < TOLERANCE) { index = i; } } Surface surfaceUp = surface.withZValues(zValues.with(index, zValues.get(index) + EPS)); Surface surfaceDw = surface.withZValues(zValues.with(index, zValues.get(index) - EPS)); BlackFxOptionSurfaceVolatilities provUp = BlackFxOptionSurfaceVolatilities.of(CURRENCY_PAIR, VAL_DATE_TIME, surfaceUp); BlackFxOptionSurfaceVolatilities provDw = BlackFxOptionSurfaceVolatilities.of(CURRENCY_PAIR, VAL_DATE_TIME, surfaceDw); double volUp = provUp.volatility(pair, expiry, strike, forward); double volDw = provDw.volatility(pair, expiry, strike, forward); return(0.5 * (volUp - volDw) / EPS); }
//------------------------------------------------------------------------- public virtual void coverage() { BlackFxOptionSurfaceVolatilities test1 = BlackFxOptionSurfaceVolatilities.of(CURRENCY_PAIR, VAL_DATE_TIME, SURFACE); coverImmutableBean(test1); BlackFxOptionSurfaceVolatilities test2 = BlackFxOptionSurfaceVolatilities.of(CURRENCY_PAIR.inverse(), ZonedDateTime.of(2015, 12, 21, 11, 15, 0, 0, ZoneId.of("Z")), SURFACE); coverBeanEquals(test1, test2); }