Examples of VolatilityTermStructure


Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

    final Function1D<DoubleMatrix1D, DoubleMatrix1D> volDiffFunc = new Function1D<DoubleMatrix1D, DoubleMatrix1D>() {

      @SuppressWarnings("synthetic-access")
      @Override
      public DoubleMatrix1D evaluate(final DoubleMatrix1D x) {
        final VolatilityTermStructure vol = _volModel.evaluate(x);
        final double[] modelVols = pricer.impliedVols(vol);
        final double[] res = new double[nCaps];
        for (int i = 0; i < nCaps; i++) {
          res[i] = (modelVols[i] - capVols[i]);
        }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

      @SuppressWarnings("synthetic-access")
      @Override
      public DoubleMatrix1D evaluate(final DoubleMatrix1D x) {

        final VolatilityTermStructure vol = _volModel.evaluate(x);
        final double[] modelPrices = pricer.price(vol);

        final double[] res = new double[nCaps];
        for (int i = 0; i < nCaps; i++) {
          res[i] = (modelPrices[i] - capPrices[i]) * scale[i];
 
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

  }

  @Override
  public VolatilityTermStructure evaluate(DoubleMatrix1D data) {
    final Function1D<Double, Double> func = new BasisFunctionAggregation<>(_bSplines, data.getData());
    return new VolatilityTermStructure() {

      @Override
      public Double getVolatility(Double t) {
        return func.evaluate(t);
      }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

    final LeastSquareResults lsRes = solveForPrice(new DoubleMatrix1D(capPrices), new DoubleMatrix1D(vega), new DoubleMatrix1D(start));

    final double[] mPrices = pricer.priceFromCapletVols(lsRes.getFitParameters().getData());
    final double chiSqr = chiSqr(capPrices, mPrices);
    final VolatilityTermStructure vc = getVolCurve(lsRes.getFitParameters().getData());
    return new CapletStrippingSingleStrikeResult(chiSqr, lsRes.getFitParameters(), vc, new DoubleMatrix1D(mPrices));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

    Arrays.fill(start, capVols[capVols.length - 1]);
    final LeastSquareResults lsRes = solveForPrice(new DoubleMatrix1D(capPrices), sigma, new DoubleMatrix1D(start));

    final double[] mPrices = pricer.priceFromCapletVols(lsRes.getFitParameters().getData());
    final double chiSqr = chiSqr(capPrices, mPrices, errors);
    final VolatilityTermStructure vc = getVolCurve(lsRes.getFitParameters().getData());
    return new CapletStrippingSingleStrikeResult(chiSqr, lsRes.getFitParameters(), vc, new DoubleMatrix1D(mPrices));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

      lsRes = solveForVol(new DoubleMatrix1D(capVols), new DoubleMatrix1D(errors), new DoubleMatrix1D(start));
    }

    final double[] mVols = pricer.impliedVols(pricer.priceFromCapletVols(lsRes.getFitParameters().getData()));
    final double chiSqr = chiSqr(capVols, mVols, errors);
    final VolatilityTermStructure vc = getVolCurve(lsRes.getFitParameters().getData());
    return new CapletStrippingSingleStrikeResult(chiSqr, lsRes.getFitParameters(), vc, new DoubleMatrix1D(mVols));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

    final MultiCapFloorPricer pricer = getPricer();
    final double[] capVols = pricer.impliedVols(capPrices);
    final LeastSquareResults lsRes = solveForPrice(capPrices, capVols, errors, scaleByVega);

    final VolatilityTermStructure volCurve = getVolCurve(lsRes.getFitParameters());
    final double[] mPrices = pricer.price(volCurve);

    // least-squares gives chi2 including the penalty, and is calculated via the price differecne and vega w we just want the fit error
    // TODO maybe the solver should provide this?
    final double chi2 = chiSqr(capPrices, mPrices, errors); // ignore the vega weighting here
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

        }
      };
      lsRes = NLLSWP.solve(new DoubleMatrix1D(capVols), new DoubleMatrix1D(errors), modelVolFunc, new DoubleMatrix1D(_nWeights, capVols[capVols.length - 1]), _penalty);
    }

    final VolatilityTermStructure volCurve = getVolCurve(lsRes.getFitParameters());
    final double[] mVols = pricer.impliedVols(volCurve);

    // least-squares gives chi2 including the penalty, and is calculated via the price differecne and vega w we just want the fit error
    // TODO maybe the solver should provide this?
    final double chi2 = chiSqr(capVols, mVols, errors);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

  }

  @Override
  public VolatilityTermStructure evaluate(final DoubleMatrix1D data) {
    final InterpolatedDoublesCurve curve = new InterpolatedDoublesCurve(_knots, data.getData(), _interpolator, true);
    return new VolatilityTermStructure() {

      @Override
      public Double getVolatility(final Double t) {
        return curve.getYValue(t);
      }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.VolatilityTermStructure

      if (print) {
        System.out.println(i + " chiSqr: " + res.getChiSq() + " fit parameters: " + res.getFitParameters());
      }

      final double[] fitVols = res.getModelValues().getData();
      final VolatilityTermStructure volCurve = res.getVolatilityCurve();

      final int m = vols.length;
      assertEquals(fitVols.length, m);
      for (int j = 0; j < m; j++) {
        assertEquals(vols[j], fitVols[j], volTol);
      }

      if (print) {
        for (int j = 0; j < samples; j++) {
          final double t = j * 10.0 / (samples - 1);
          mVols[i][j] = volCurve.getVolatility(t);
        }
      }
    }

    if (print) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.