Examples of PDEGrid1D


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

        timeMeshes[i] = new ExponentialMeshing(dividends.getTau(i - 1), dividends.getTau(i), steps[i], 0.0);
      }
      timeMeshes[nDivsBeforeExpiry] = new ExponentialMeshing(dividends.getTau(nDivsBeforeExpiry - 1), expiry, steps[nDivsBeforeExpiry], 0.0);
    }
    final PDETerminalResults1D[] res = new PDETerminalResults1D[nDivsBeforeExpiry + 1];
    grids[0] = new PDEGrid1D(timeMeshes[0], spaceMesh);
    PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> db = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, initialCond, lower, upper, grids[0]);
    res[0] = (PDETerminalResults1D) _solver.solve(db);
    for (int i = 1; i <= nDivsBeforeExpiry; i++) {
      grids[i] = new PDEGrid1D(timeMeshes[i], spaceMesh);
      db = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, res[i - 1].getTerminalResults(), lower, upper, grids[i]);
      res[i] = (PDETerminalResults1D) _solver.solve(db);
    }

    double corrDivAdj = 0;
View Full Code Here

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

    final BoundaryCondition upper = new NeumannBoundaryCondition(1.0, yMax, false);

    final MeshingFunction timeMesh = new ExponentialMeshing(0, expiry, _nTimeSteps, LAMBDA_T);
    final MeshingFunction spaceMesh = new ExponentialMeshing(yMin, yMax, _nSpaceSteps, LAMBDA_X);

    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> db = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, logPayoff, lower, upper, grid);
    final PDEResults1D res = _solver.solve(db);

    final int index = getLowerBoundIndex(res.getGrid().getSpaceNodes(), 0.0);
    final double x1 = res.getSpaceValue(index);
View Full Code Here

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

    final BoundaryCondition upper = new NeumannBoundaryCondition(0.0, yMax, false);

    final MeshingFunction timeMesh = new ExponentialMeshing(0, tau, _nTimeSteps, LAMBDA_T);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(yMin, yMax, 0.0, _nSpaceSteps, LAMBDA_X);

    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> db = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(pde, initalCond, lower, upper, grid);
    final PDEResults1D res = _solver.solve(db);

    final int gIndex = getLowerBoundIndex(res.getGrid().getSpaceNodes(), 0.0);
    final double x1 = res.getSpaceValue(gIndex);
View Full Code Here

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

    final int xNodes = nu * tNodes;
    final double sMin = S0 / 5.0;
    final double sMax = 5 * S0;
    final MeshingFunction xMesh = new ExponentialMeshing(sMin, sMax, xNodes, 0.0, new double[] {S0 });
    final MeshingFunction tMesh = new ExponentialMeshing(0, T, tNodes, 0.0);
    final PDEGrid1D grid = new PDEGrid1D(tMesh, xMesh);

    final BoundaryCondition lower = new NeumannBoundaryCondition(0.0, sMin, true);
    final BoundaryCondition upper = new NeumannBoundaryCondition(0.0, sMax, true);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> data = new PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients>(coef, payoff, lower, upper, grid);
    final ThetaMethodFiniteDifference solver = new ThetaMethodFiniteDifference();
    final PDEResults1D res = solver.solve(data);
    final int index = Arrays.binarySearch(grid.getSpaceNodes(), S0);
    final double pdePrice = res.getFunctionValue(index);

    //System.out.println(DF+"\t"+pdePrice);
    assertEquals(DF, pdePrice, DF * 5e-5);
  }
View Full Code Here

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

    final int xNodes = 100;
    final BoundaryCondition lower = new DirichletBoundaryCondition(0.0, 0.0);
    final BoundaryCondition upper = new DirichletBoundaryCondition(0.0, 10 * FORWARD_CURVE.getForward(T));
    final MeshingFunction timeMesh = new ExponentialMeshing(0, T, tNodes, 5.0);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(0.0, upper.getLevel(), SPOT, xNodes, 0.01);
    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);

    final ConvectionDiffusionPDE1DFullCoefficients pde1 = PDE_PROVIDER.getFokkerPlank(ConstantDoublesCurve.from(RATE), localVol);
    final ConvectionDiffusionPDE1DStandardCoefficients pde2 = PDE_PROVIDER.getFokkerPlankInStandardCoefficients(ConstantDoublesCurve.from(RATE), localVol);
    final Function1D<Double, Double> initalCondition = INITAL_CONDITION_PROVIDER.getLogNormalDensity(SPOT, 0.01, 0.2);

View Full Code Here

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

    @Override
    public PDEGrid1D buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final double[] timeNodes = deserializer.fieldValueToObject(double[].class, message.getByName(TIME_NODES_FIELD));
      final double[] spaceNodes = deserializer.fieldValueToObject(double[].class, message.getByName(SPACE_NODES_FIELD));
      return new PDEGrid1D(timeNodes, spaceNodes);
    }
View Full Code Here

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

    private static final String GRID_FIELD = "gridField";

    @Override
    public PDEFullResults1D buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final double[][] solverData = deserializer.fieldValueToObject(double[][].class, message.getByName(SOLVER_DATA_FIELD));
      final PDEGrid1D grid = deserializer.fieldValueToObject(PDEGrid1D.class, message.getByName(GRID_FIELD));
      return new PDEFullResults1D(grid, solverData);
    }
View Full Code Here

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

    }

    final MeshingFunction timeMesh = new ExponentialMeshing(0.0, maxT, nTimeSteps, timeMeshLambda);

    final MeshingFunction spaceMesh = new HyperbolicMeshing(minMoneyness, maxMoneyness, centreMoneyness, nStrikeSteps, strikeMeshBunching);
    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);
    final Function1D<Double, Double> intCond = (new InitialConditionsProvider()).getForwardCallPut(isCall);
    final PDEFullResults1D res = (PDEFullResults1D) solver.solve(new PDE1DDataBundle<>(pde, intCond, lower, upper, grid));
    return res;
  }
View Full Code Here

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

    // MeshingFunction timeMesh = new ExponentialMeshing(0.0, expiry, nTimeNodes, timeMeshLambda);
    final MeshingFunction timeMesh = new DoubleExponentialMeshing(0, expiry, expiry / 2, nTimeNodes, timeMeshLambda, -timeMeshLambda);
    //keep the grid the same regardless of spot (useful for finite-difference)
    final MeshingFunction spaceMesh = new HyperbolicMeshing(0.0, maxFwd, fwdNodeCentre, nFwdNodes, spotMeshBunching);
    final PDEGrid1D grid = new PDEGrid1D(timeMesh, spaceMesh);
    final PDE1DDataBundle<ConvectionDiffusionPDE1DCoefficients> db = new PDE1DDataBundle<>(pde, payoff, lower, upper, grid);
    final PDEResults1D res = solver.solve(db);
    return res;
  }
View Full Code Here

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

    final double xH = 4;
    final BoundaryCondition lower = new DirichletBoundaryCondition(1.0, xL);
    final BoundaryCondition upper = new NeumannBoundaryCondition(0.0, xH, false);
    final MeshingFunction spaceMesh = new HyperbolicMeshing(xL, xH, 1.0, 40, 0.05);
    final MeshingFunction timeMesh = new ExponentialMeshing(0, 2.0, 30, 0.2);
    final PDEGrid1D pdeGrid = new PDEGrid1D(timeMesh, spaceMesh);
    final Function1D<Double, Double> initialCond = INITIAL_COND_PROVIDER.getForwardCallPut(true);
    final double[] xa = new double[] {0, 0 };
    final double[] xb = new double[] {2.0, xH };
    final int[] nKnots = new int[] {3, 10 };
    final int[] degree = new int[] {3, 3 };
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.