Examples of PDEGrid1D


Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

            + minFrac);
      }
      final MeshingFunction tBurnMesh = new ExponentialMeshing(0.0, tBurn, tBurnNodes, 0.0);
      final MeshingFunction tMesh = new ExponentialMeshing(tBurn, t, timeNodes - tBurnNodes, 0.0);
      grid = new PDEGrid1D[2];
      grid[0] = new PDEGrid1D(tBurnMesh, xMesh);
      grid[1] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_burninTheta, _mainRunTheta};
    } else {
      grid = new PDEGrid1D[1];
      final MeshingFunction tMesh = new ExponentialMeshing(0, t, timeNodes, 0.0);
      grid[0] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_mainRunTheta};
    }

    return price(s0, k, r, b, t, sigma, isCall, isAmerican, grid, theta);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

      final double dt = tMesh.evaluate(1) - tMesh.evaluate(0);
      final double tBurn = tBurnNodes * dt * dt;
      final MeshingFunction tBurnMesh = new ExponentialMeshing(0, tBurn, tBurnNodes, 0.0);
      tMesh = new ExponentialMeshing(tBurn, t, timeNodes - tBurnNodes, lambda);
      grid = new PDEGrid1D[2];
      grid[0] = new PDEGrid1D(tBurnMesh, xMesh);
      grid[1] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_burninTheta, _mainRunTheta};
    } else {
      grid = new PDEGrid1D[1];
      grid[0] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_mainRunTheta};
    }

    return price(s0, k, r, b, t, sigma, isCall, isAmerican, grid, theta);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

      }
    }

    final MeshingFunction tMesh = new ExponentialMeshing(0, expiry, _nTNodes, _lambda);
    final MeshingFunction xMesh = new HyperbolicMeshing(sMin, sMax, spot, _nXNodes, _bunching);
    final PDEGrid1D grid = new PDEGrid1D(tMesh, xMesh);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> pdeData = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, intCon, lower, upper, grid);

    final PDEResults1D res = SOLVER.solve(pdeData);
    //for now just do linear interpolation on price. TODO replace this with something more robust
    final double[] xNodes = grid.getSpaceNodes();
    final int index = SurfaceArrayUtils.getLowerBoundIndex(xNodes, spot);
    final double w = (xNodes[index + 1] - spot) / (xNodes[index + 1] - xNodes[index]);
    return w * res.getFunctionValue(index) + (1 - w) * res.getFunctionValue(index + 1);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

      upper = new DirichletBoundaryCondition(0.0, sMax);
    }

    final MeshingFunction tMesh = new ExponentialMeshing(0, expiry, _nTNodes, _lambda);
    final MeshingFunction xMesh = new HyperbolicMeshing(sMin, sMax, spot, _nXNodes, _bunching);
    final PDEGrid1D grid = new PDEGrid1D(tMesh, xMesh);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> pdeData = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, intCon, lower, upper, grid);

    final PDEResults1D res = SOLVER.solve(pdeData);
    //for now just do linear interpolation on price. TODO replace this with something more robust
    final double[] xNodes = grid.getSpaceNodes();
    final int index = SurfaceArrayUtils.getLowerBoundIndex(xNodes, spot);
    final double w = (xNodes[index + 1] - spot) / (xNodes[index + 1] - xNodes[index]);
    return w * res.getFunctionValue(index) + (1 - w) * res.getFunctionValue(index + 1);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

    //get the local vol of basic Markov chain model

    final MeshingFunction timeMesh = new ExponentialMeshing(0, tmaxT, tNodes, 2.0);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(0, 6.0 * forward.getForward(tmaxT), forward.getForward(0), xNodes, 0.01);
    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);

    final TwoStateMarkovChainWithLocalVolDensity densityCal = new TwoStateMarkovChainWithLocalVolDensity(forward, chainData, new AbsoluteLocalVolatilitySurface(ConstantDoublesSurface.from(1.0)));
    PDEFullResults1D[] denRes = densityCal.solve(grid);

    if (_print) {
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

    final int xNodes = 100;

    //TODO remove hard coded grid
    final MeshingFunction timeMesh = new ExponentialMeshing(0, tmaxT, tNodes, 5.0);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(0, 10.0 * forward.getForward(maxT), forward.getSpot(), xNodes, 0.01);
    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);

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

      @SuppressWarnings("synthetic-access")
      @Override
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

      }
    }

    final MeshingFunction tMesh = new ExponentialMeshing(0, expiry, _nTNodes, _lambda);
    final MeshingFunction xMesh = new HyperbolicMeshing(sMin, sMax, spot, _nXNodes, _bunching);
    final PDEGrid1D grid = new PDEGrid1D(tMesh, xMesh);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> pdeData = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, intCon, lower, upper, grid);

    final PDEResults1D res = SOLVER.solve(pdeData);
    //for now just do linear interpolation on price. TODO replace this with something more robust
    final double[] xNodes = grid.getSpaceNodes();

    final int index = SurfaceArrayUtils.getLowerBoundIndex(xNodes, spot);
    final double w = (xNodes[index + 1] - spot) / (xNodes[index + 1] - xNodes[index]);
    return w * res.getFunctionValue(index) + (1 - w) * res.getFunctionValue(index + 1);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

    // set up a near-uniform mesh that includes spot and strike
    MeshingFunction xMesh = new ExponentialMeshing(sMin, sMax, spaceNodes, 0.0, new double[] {s0, k});
    MeshingFunction tMeshBurn = USE_BURNIN ? new ExponentialMeshing(0.0, tBurn, tBurnNodes, 0.0) : null;
    MeshingFunction tMesh = new ExponentialMeshing(tBurn, t, timeNodes - tBurnNodes, 0.0);
    PDEGrid1D gridBurn = USE_BURNIN ? new PDEGrid1D(tMeshBurn, xMesh) : null;
    PDEGrid1D grid = new PDEGrid1D(tMesh, xMesh);
    final int index = Arrays.binarySearch(grid.getSpaceNodes(), s0);
    ArgumentChecker.isTrue(index >= 0, "cannot find spot on grid");

    ConvectionDiffusionPDE1DStandardCoefficients coef = PDE.getBackwardsLocalVol(r, q, t, locVol);
    Function1D<Double, Double> payoff = ICP.getEuropeanPayoff(k, isCall);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

        throw new IllegalArgumentException("burn in period greater than total time. Either increase timeNodes to above " + minNodes + ", or reduce burninFrac to below " + minFrac);
      }
      final MeshingFunction tBurnMesh = new ExponentialMeshing(0.0, tBurn, tBurnNodes, 0.0);
      final MeshingFunction tMesh = new ExponentialMeshing(tBurn, t, timeNodes - tBurnNodes, 0.0);
      grid = new PDEGrid1D[2];
      grid[0] = new PDEGrid1D(tBurnMesh, xMesh);
      grid[1] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_burninTheta, _mainRunTheta};
    } else {
      grid = new PDEGrid1D[1];
      final MeshingFunction tMesh = new ExponentialMeshing(0, t, timeNodes, 0.0);
      grid[0] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_mainRunTheta};
    }

    return price(fwd, riskFreeRate, option, localVol, isAmerican, grid, theta);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.finitedifference.PDEGrid1D

      final double dt = tMesh.evaluate(1) - tMesh.evaluate(0);
      final double tBurn = tBurnNodes * dt * dt;
      final MeshingFunction tBurnMesh = new ExponentialMeshing(0, tBurn, tBurnNodes, 0.0);
      tMesh = new ExponentialMeshing(tBurn, t, timeNodes - tBurnNodes, lambda);
      grid = new PDEGrid1D[2];
      grid[0] = new PDEGrid1D(tBurnMesh, xMesh);
      grid[1] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_burninTheta, _mainRunTheta};
    } else {
      grid = new PDEGrid1D[1];
      grid[0] = new PDEGrid1D(tMesh, xMesh);
      theta = new double[] {_mainRunTheta};
    }

    return price(fwd, riskFreeRate, option, localVol, isAmerican, grid, theta);
  }
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.