Package com.opengamma.analytics.financial.model.interestrate.curve

Examples of com.opengamma.analytics.financial.model.interestrate.curve.ForwardCurve


  @Test
  public void testMixedLogNormalVolSurface() {

    final AffineDividends dividends = AffineDividends.noDividends();
    final ForwardCurve fwdCurve = new ForwardCurve(SPOT, DRIFT);
    final double sigma1 = 0.2;
    final double sigma2 = 1.0;
    final double w = 0.9;

    final Function<Double, Double> surf = new Function<Double, Double>() {
      @Override
      public Double evaluate(final Double... x) {
        final double t = x[0];
        final double k = x[1];
        @SuppressWarnings("synthetic-access")
        final double fwd = fwdCurve.getForward(t);
        final boolean isCall = k > fwd;
        final double price = w * BlackFormulaRepository.price(fwd, k, t, sigma1, isCall) + (1 - w) * BlackFormulaRepository.price(fwd, k, t, sigma2, isCall);
        return BlackFormulaRepository.impliedVolatility(price, fwd, k, t, isCall);
      }
    };
View Full Code Here


   * @param pImpVol The pure implied volatility surface
   * @param plv The pure local volatility surface
   */
  private void testNumerics(final AffineDividends dividends, final MultiHorizonMixedLogNormalModelData data, final double defaultTol) {

    final ForwardCurve fc = new ForwardCurve(1.0);
    final LocalVolatilitySurfaceStrike lv = MixedLogNormalVolatilitySurface.getLocalVolatilitySurface(fc, data);
    final PureLocalVolatilitySurface plv = new PureLocalVolatilitySurface(lv.getSurface());
    final BlackVolatilitySurfaceStrike iv = MixedLogNormalVolatilitySurface.getImpliedVolatilitySurface(fc, data);
    final PureImpliedVolatilitySurface piv = new PureImpliedVolatilitySurface(iv.getSurface());
    final double[] weights = data.getWeights();
View Full Code Here

          return 0.0;
        }
        return 0.4;
      }
    };
    final LocalVolatilitySurfaceMoneyness lv = new LocalVolatilitySurfaceMoneyness(FunctionalDoublesSurface.from(lvFunc), new ForwardCurve(1.0));

    final Function1D<Double, Double> initCon = new Function1D<Double, Double>() {
      @Override
      public Double evaluate(final Double x) {
        return Math.max(0, 1 - Math.exp(x));
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public LocalVolatilitySurfaceMoneyness buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final Object surface = deserializer.fieldValueToObject(message.getByName(SURFACE_FIELD_NAME));
      final ForwardCurve forwardCurve = deserializer.fieldValueToObject(ForwardCurve.class, message.getByName(FORWARD_CURVE_FIELD_NAME));
      if (surface instanceof Surface) {
        return new LocalVolatilitySurfaceMoneyness((Surface<Double, Double, Double>) surface, forwardCurve);
      }
      throw new OpenGammaRuntimeException("Expected Surface, got " + surface);
    }
View Full Code Here

    //2a Get forward curve
    final Object forwardCurveObject = inputs.getValue(ValueRequirementNames.FORWARD_CURVE);
    if (forwardCurveObject == null) {
      throw new OpenGammaRuntimeException("Could not get forward curve");
    }
    final ForwardCurve forwardCurve = (ForwardCurve) forwardCurveObject;

    // 3. Remove empties, convert expiries from number to years, and scale vols
    final Map<Pair<Double, Double>, Double> volValues = new HashMap<Pair<Double, Double>, Double>();
    final DoubleArrayList tList = new DoubleArrayList();
    final DoubleArrayList kList = new DoubleArrayList();
View Full Code Here

    //  System.out.println(bsPrice +"\t"+pdePrice+"\t"+resErr);

    assertEquals(bsPrice, pdePrice, bsPrice * 1e-4);

    //now price in terms of the forward - gives around 3 times improvement in accuracy
    final ForwardCurve fc = new ForwardCurve(FWD_CURVE.getForward(T));
    final ConstantDoublesCurve r = ConstantDoublesCurve.from(0.0);
    pdePrice = DF * PRICER.price(fc, r, option, LOCAL_VOL_SUR, false, xNodes, tNodes, 0.1, 0.0, 5.0);

    // resErr = Math.abs((pdePrice-bsPrice)/bsPrice);
    // System.out.println(bsPrice +"\t"+pdePrice+"\t"+resErr);
View Full Code Here

  public void fokkerPlankTest() {
    final DupireLocalVolatilityCalculator cal = new DupireLocalVolatilityCalculator(1e-4);

    final BlackVolatilitySurfaceStrike volSurface = new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(SABR_VOL_FUNCTION));

    final LocalVolatilitySurfaceStrike localVol = cal.getLocalVolatility(volSurface, new ForwardCurve(SPOT, RATE));

    //    final ZZConvectionDiffusionPDEDataBundle db1 = LocalVolDensity.getConvectionDiffusionPDEDataBundle(FORWARD_CURVE, localVol);
    //    final ExtendedConvectionDiffusionPDEDataBundle db2 = LocalVolDensity.getExtendedConvectionDiffusionPDEDataBundle(FORWARD_CURVE, localVol);

    final int tNodes = 50;
View Full Code Here

  @Test(enabled = false)
  public void localVolTest() {
    final DupireLocalVolatilityCalculator cal = new DupireLocalVolatilityCalculator();

    final BlackVolatilitySurfaceStrike volSurface = new BlackVolatilitySurfaceStrike(FunctionalDoublesSurface.from(SABR_VOL_FUNCTION));
    final LocalVolatilitySurfaceStrike localVol = cal.getLocalVolatility(volSurface, new ForwardCurve(SPOT, RATE));

    PDEUtilityTools.printSurface("localVolTest", localVol.getSurface(), 0, 5.0, SPOT / 4.0, SPOT * 4.0);
  }
View Full Code Here

  @Test
  public void testDegenerate() {
    //NOTE vols equal
    final TwoStateMarkovChainDataBundle mcData = new TwoStateMarkovChainDataBundle(VOL1, VOL1, LAMBDA12, LAMBDA21, PROB_STATE1);
    final CoupledFiniteDifference solver = new CoupledFiniteDifference(0.55, true);
    final ConvectionDiffusionPDE1DCoupledCoefficients[] pdeData = PDE_DATA_PROVIDER.getCoupledForwardPair(new ForwardCurve(SPOT, RATE), mcData);

    final int tNodes = 50;
    final int xNodes = 150;

    final MeshingFunction timeMesh = new ExponentialMeshing(0, T, tNodes, 7.5);
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public ForwardCurve buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final Object forwardCurve = deserializer.fieldValueToObject(message.getByName(FORWARD_CURVE_FIELD_NAME));
      final Object driftCurve = deserializer.fieldValueToObject(message.getByName(DRIFT_CURVE_FIELD_NAME));
      return new ForwardCurve((Curve<Double, Double>) forwardCurve, (Curve<Double, Double>) driftCurve);
    }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.interestrate.curve.ForwardCurve

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.