//------------------------------------------------------------------------- // bumping a node point at nodeExpiry private double nodeSensitivity(BlackFxOptionFlatVolatilities provider, CurrencyPair pair, ZonedDateTime expiry, double strike, double forward, double nodeExpiry) { NodalCurve curve = (NodalCurve)provider.Curve; DoubleArray xValues = curve.XValues; DoubleArray yValues = curve.YValues; int nData = xValues.size(); int index = -1; for (int i = 0; i < nData; ++i) { if (Math.Abs(xValues.get(i) - nodeExpiry) < TOLERANCE) { index = i; } } NodalCurve curveUp = curve.withYValues(yValues.with(index, yValues.get(index) + EPS)); NodalCurve curveDw = curve.withYValues(yValues.with(index, yValues.get(index) - EPS)); BlackFxOptionFlatVolatilities provUp = BlackFxOptionFlatVolatilities.of(CURRENCY_PAIR, VAL_DATE_TIME, curveUp); BlackFxOptionFlatVolatilities provDw = BlackFxOptionFlatVolatilities.of(CURRENCY_PAIR, VAL_DATE_TIME, curveDw); 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() { BlackFxOptionFlatVolatilities test1 = BlackFxOptionFlatVolatilities.of(CURRENCY_PAIR, VAL_DATE_TIME, CURVE); coverImmutableBean(test1); BlackFxOptionFlatVolatilities test2 = BlackFxOptionFlatVolatilities.of(CURRENCY_PAIR.inverse(), ZonedDateTime.of(2015, 12, 21, 11, 15, 0, 0, ZoneId.of("Z")), CURVE); coverBeanEquals(test1, test2); }