Package com.opengamma.analytics.financial.model.volatility.smile.function

Examples of com.opengamma.analytics.financial.model.volatility.smile.function.SABRFormulaData


        double alpha = mp.getEntry(0);
        final double beta = mp.getEntry(1);
        final double rho = mp.getEntry(2);
        final double nu = mp.getEntry(3);

        final SABRFormulaData sabrFormulaData;
        if (recoverATMVol) {
          alpha = _atmCalculator.calculate(new SABRFormulaData(alpha, beta, rho, nu), atmOption, forward, atmVol);
          sabrFormulaData = new SABRFormulaData(alpha, beta, rho, nu);
        } else {
          sabrFormulaData = new SABRFormulaData(alpha, beta, rho, nu);
        }
        final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, maturity, true);
        return _formula.getVolatilityFunction(option, forward).evaluate(sabrFormulaData);
      }
    };

    final DoubleMatrix1D fp = transforms.transform(new DoubleMatrix1D(initialFitParameters));
    LeastSquareResults lsRes = errors == null ? SOLVER.solve(new DoubleMatrix1D(strikes), new DoubleMatrix1D(blackVols), function, fp)
        : SOLVER.solve(new DoubleMatrix1D(strikes), new DoubleMatrix1D(blackVols), new DoubleMatrix1D(errors), function, fp);
    final double[] mp = transforms.inverseTransform(lsRes.getFitParameters()).toArray();
    if (recoverATMVol) {
      final double beta = mp[1];
      final double nu = mp[2];
      final double rho = mp[3];
      final EuropeanVanillaOption option = new EuropeanVanillaOption(forward, maturity, true);
      final SABRFormulaData sabrFormulaData = new SABRFormulaData(mp[0], beta, rho, nu);
      final double value = _atmCalculator.calculate(sabrFormulaData, option, forward, atmVol);
      mp[0] = value;
      lsRes = new LeastSquareResults(lsRes.getChiSq(), new DoubleMatrix1D(mp), lsRes.getCovariance());
    }
    return new LeastSquareResultsWithTransform(lsRes, transforms);
View Full Code Here


    final DoublesPair expiryMaturity = new DoublesPair(CAP_LONG.getFixingTime(), maturity);
    final double alpha = SABR_PARAMETERS.getAlpha(expiryMaturity);
    final double beta = SABR_PARAMETERS.getBeta(expiryMaturity);
    final double rho = SABR_PARAMETERS.getRho(expiryMaturity);
    final double nu = SABR_PARAMETERS.getNu(expiryMaturity);
    final SABRFormulaData sabrParam = new SABRFormulaData(alpha, beta, rho, nu);
    final SABRExtrapolationRightFunction sabrExtrapolation = new SABRExtrapolationRightFunction(forward, sabrParam, CUT_OFF_STRIKE, CAP_LONG.getFixingTime(), MU);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(CAP_LONG.getStrike(), CAP_LONG.getFixingTime(), CAP_LONG.isCap());
    final double expectedPrice = sabrExtrapolation.price(option) * CAP_LONG.getNotional() * CAP_LONG.getPaymentYearFraction() * df;
    assertEquals("Cap/floor: SABR with extrapolation pricing", expectedPrice, methodPrice.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

    final DoublesPair expiryMaturity = new DoublesPair(CAP_HIGH_LONG.getFixingTime(), maturity);
    final double alpha = SABR_PARAMETERS.getAlpha(expiryMaturity);
    final double beta = SABR_PARAMETERS.getBeta(expiryMaturity);
    final double rho = SABR_PARAMETERS.getRho(expiryMaturity);
    final double nu = SABR_PARAMETERS.getNu(expiryMaturity);
    final SABRFormulaData sabrParam = new SABRFormulaData(alpha, beta, rho, nu);
    final SABRExtrapolationRightFunction sabrExtrapolation = new SABRExtrapolationRightFunction(forward, sabrParam, CUT_OFF_STRIKE, CAP_HIGH_LONG.getFixingTime(), MU);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(CAP_HIGH_LONG.getStrike(), CAP_HIGH_LONG.getFixingTime(), CAP_HIGH_LONG.isCap());
    final double expectedPrice = sabrExtrapolation.price(option) * CAP_HIGH_LONG.getNotional() * CAP_HIGH_LONG.getPaymentYearFraction() * df;
    assertEquals("Cap/floor: SABR with extrapolation pricing", expectedPrice, methodPrice.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

    return new SABRHaganVolatilityFunction();
  }

  @Override
  SABRFormulaData getModelData() {
    return new SABRFormulaData(ALPHA, BETA, RHO, NU);
  }
View Full Code Here

    final DoublesPair expiryMaturity = new DoublesPair(CAP_LONG.getFixingTime(), maturity);
    final double alpha = SABR_PARAMETERS.getAlpha(expiryMaturity);
    final double beta = SABR_PARAMETERS.getBeta(expiryMaturity);
    final double rho = SABR_PARAMETERS.getRho(expiryMaturity);
    final double nu = SABR_PARAMETERS.getNu(expiryMaturity);
    final SABRFormulaData sabrParam = new SABRFormulaData(alpha, beta, rho, nu);
    final SABRExtrapolationRightFunction sabrExtrapolation = new SABRExtrapolationRightFunction(forward, sabrParam, CUT_OFF_STRIKE, CAP_LONG.getFixingTime(), MU);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(CAP_LONG.getStrike(), CAP_LONG.getFixingTime(), CAP_LONG.isCap());
    final double expectedPrice = sabrExtrapolation.price(option) * CAP_LONG.getNotional() * CAP_LONG.getPaymentYearFraction() * df;
    assertEquals("Cap/floor: SABR with extrapolation pricing", expectedPrice, methodPrice.getAmount(), 1E-2);
  }
View Full Code Here

    final DoublesPair expiryMaturity = new DoublesPair(CAP_HIGH_LONG.getFixingTime(), maturity);
    final double alpha = SABR_PARAMETERS.getAlpha(expiryMaturity);
    final double beta = SABR_PARAMETERS.getBeta(expiryMaturity);
    final double rho = SABR_PARAMETERS.getRho(expiryMaturity);
    final double nu = SABR_PARAMETERS.getNu(expiryMaturity);
    final SABRFormulaData sabrParam = new SABRFormulaData(alpha, beta, rho, nu);
    final SABRExtrapolationRightFunction sabrExtrapolation = new SABRExtrapolationRightFunction(forward, sabrParam, CUT_OFF_STRIKE, CAP_HIGH_LONG.getFixingTime(), MU);
    final EuropeanVanillaOption option = new EuropeanVanillaOption(CAP_HIGH_LONG.getStrike(), CAP_HIGH_LONG.getFixingTime(), CAP_HIGH_LONG.isCap());
    final double expectedPrice = sabrExtrapolation.price(option) * CAP_HIGH_LONG.getNotional() * CAP_HIGH_LONG.getPaymentYearFraction() * df;
    assertEquals("Cap/floor: SABR with extrapolation pricing", expectedPrice, methodPrice.getAmount(), 1E-2);
    methodPrice = METHOD.presentValue(CAP_HIGH_LONG, SABR_BUNDLE);
View Full Code Here

    final int tNodes = 50;
    final int xNodes = 101;

    final double forward = FORWARD_CURVE.getForward(T);
    final double maxMoneyness = 5.0;
    final SABRFormulaData sabrData = new SABRFormulaData(ATM_VOL.evaluate(T), 1.0, RHO, NU.evaluate(T));
    final LocalVolatilitySurfaceStrike locVol = getSABRLocalVolSurface(1.0, FORWARD_CURVE);

    // final ZZConvectionDiffusionPDEDataBundle pdeDataFwd = PDE_DATA_PROVIDER.getForwardLocalVol(locVol, FORWARD_CURVE, true);
    final ConvectionDiffusionPDE1DCoefficients pde = PDE_PROVIDER.getForwardLocalVol(FORWARD_CURVE, locVol);
    final Function1D<Double, Double> initialCond = INITIAL_CONDITIONS_PROVIDER.getForwardCallPut(true);
View Full Code Here

        final double t = x[0];
        final double k = x[1];
        final double fwd = forwardCurve.getForward(t);
        final double alpha = ATM_VOL.evaluate(T) * Math.pow(fwd, 1 - beta);
        final double nu = NU.evaluate(t);
        final SABRFormulaData data = new SABRFormulaData(alpha, beta, RHO, nu);
        final EuropeanVanillaOption option = new EuropeanVanillaOption(k, t, true);
        return SABR.getVolatility(option, fwd, data);
      }
    };

View Full Code Here

      final double sigma = atmVol * Math.pow(f, 1 - beta);
      final EuropeanVanillaOption option = new EuropeanVanillaOption(k, t, true);
      final CEVFunctionData cevData = new CEVFunctionData(f, 1.0, sigma, beta);
      final double price = CEV.getPriceFunction(option).evaluate(cevData);
      final double vol = BLACK_IMPLIED_VOL.getImpliedVolatility(new BlackFunctionData(f, 1.0, sigma), option, price);
      final SABRFormulaData sabrData = new SABRFormulaData(sigma, beta, 0.0, 0.0);
      final double sabrVol = SABR.getVolatilityFunction(option, f).evaluate(sabrData);
      assertEquals(sabrVol, vol, 1e-4);//TODO this used to work with 1e-5????
    }
  }
View Full Code Here

      k = 1.0 + i / 2.5;
      final EuropeanVanillaOption option = new EuropeanVanillaOption(k, t, true);
      final CEVFunctionData cevData = new CEVFunctionData(f, 1.0, sigma, beta);
      final double price = CEV.getPriceFunction(option).evaluate(cevData);
      final double vol = BLACK_IMPLIED_VOL.getImpliedVolatility(new BlackFunctionData(f, 1.0, sigma), option, price);
      final SABRFormulaData sabrData = new SABRFormulaData(sigma, beta, 0.0, 0.0);
      final double sabrVol = SABR.getVolatilityFunction(option, f).evaluate(sabrData);
      assertEquals(sabrVol, vol, 1e-4);
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.volatility.smile.function.SABRFormulaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.