//-------------------------------------------------------------------------
        // 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 test_builder()
        {
            BlackFxOptionSurfaceVolatilities test = BlackFxOptionSurfaceVolatilities.builder().currencyPair(CURRENCY_PAIR).surface(SURFACE).valuationDateTime(VAL_DATE_TIME).build();

            assertEquals(test.ValuationDateTime, VAL_DATE_TIME);
            assertEquals(test.CurrencyPair, CURRENCY_PAIR);
            assertEquals(test.Surface, SURFACE);
            assertEquals(VOLS, test);
        }
        //-------------------------------------------------------------------------
        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);
        }
Esempio n. 4
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         BlackFxOptionSurfaceVolatilities other = (BlackFxOptionSurfaceVolatilities)obj;
         return(JodaBeanUtils.equal(name, other.name) && JodaBeanUtils.equal(currencyPair, other.currencyPair) && JodaBeanUtils.equal(valuationDateTime, other.valuationDateTime) && JodaBeanUtils.equal(surface, other.surface));
     }
     return(false);
 }