Package com.opengamma.analytics.financial.model.finitedifference

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


    return new HyperbolicMeshing(0.0, maxSpace, heart, _nSpaceSteps, _spaceMeshBunching);
  }

  private BoundaryCondition getLowerBoundaryCondition(final EuropeanVanillaOption option, final double strike) {
    //call option with strike zero is worth the forward, while a put is worthless
    return option.isCall() ? new DirichletBoundaryCondition(0, 0) : new DirichletBoundaryCondition(strike, 0);
  }
View Full Code Here


    BoundaryCondition lower;
    BoundaryCondition upper;
    if (isCall) {
      //call option with low strike  is worth the forward - strike, while a put is worthless
      lower = new DirichletBoundaryCondition((1.0 - minMoneyness), minMoneyness);
      upper = new DirichletBoundaryCondition(0.0, maxMoneyness);
    } else {
      lower = new DirichletBoundaryCondition(0.0, minMoneyness);
      upper = new NeumannBoundaryCondition(1.0, maxMoneyness, false);
    }
    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);
View Full Code Here

    return new HyperbolicMeshing(minMoneyness, maxMoneyness, _centreMoneyness, _nSpaceSteps, _spaceMeshBunching);
  }

  private BoundaryCondition getLowerBoundaryCondition(final EuropeanVanillaOption option, final double minMoneyness) {
    //call option with strike zero is worth the forward, while a put is worthless
    return option.isCall() ? new DirichletBoundaryCondition(1.0 - minMoneyness, minMoneyness) : new DirichletBoundaryCondition(0.0, minMoneyness);
  }
View Full Code Here

    return option.isCall() ? new DirichletBoundaryCondition(1.0 - minMoneyness, minMoneyness) : new DirichletBoundaryCondition(0.0, minMoneyness);
  }

  private BoundaryCondition getUpperBoundaryCondition(final EuropeanVanillaOption option, final double maxMoneyness) {
    //call option with strike zero is worth the forward, while a put is worthless
    return option.isCall() ? new DirichletBoundaryCondition(0.0, maxMoneyness) : new NeumannBoundaryCondition(1.0, maxMoneyness, false);
  }
View Full Code Here

      public Double evaluate(final Double t) {
        return (1 - probState1(t)) * _forward.getSpot();
      }
    };

    final BoundaryCondition lower1 = new DirichletBoundaryCondition(strikeZeroPrice1, 0.0);
    final BoundaryCondition lower2 = new DirichletBoundaryCondition(strikeZeroPrice2, 0.0);

    final double kMax = grid.getSpaceNode(grid.getNumSpaceNodes() - 1);

    final BoundaryCondition upper = new NeumannBoundaryCondition(0, kMax, false);

View Full Code Here

  PDEFullResults1D[] solve(final PDEGrid1D grid) {

    final BoundaryCondition lower = new NeumannBoundaryCondition(0.0, grid.getSpaceNode(0), true);
    //BoundaryCondition lower = new DirichletBoundaryCondition(0.0, 0.0);//TODO for beta < 0.5 zero is accessible and thus there will be non-zero
    //density there
    final BoundaryCondition upper = new DirichletBoundaryCondition(0.0, grid.getSpaceNode(grid.getNumSpaceNodes() - 1));

    final ExtendedCoupledFiniteDifference solver = new ExtendedCoupledFiniteDifference(THETA);
    final PDEResults1D[] res = solver.solve(_data1, _data2, grid, lower, upper, lower, upper, null);
    //handle this with generics
    final PDEFullResults1D res1 = (PDEFullResults1D) res[0];
View Full Code Here

    BoundaryCondition upper;
    if (isUp) {
      sMin = 0.0;
      sMax = barrierLevel * Math.exp(-adj); //bring the barrier DOWN slightly to adjust for discrete monitoring
      if (isCall) {
        lower = new DirichletBoundaryCondition(0.0, sMin);
      } else {
        final Function1D<Double, Double> lowerValue = new Function1D<Double, Double>() {
          @Override
          public Double evaluate(final Double tau) {
            return Math.exp(-rate * tau) * strike;
          }
        };
        lower = new DirichletBoundaryCondition(lowerValue, sMin);
      }
      upper = new DirichletBoundaryCondition(rebate, sMax);
    } else {
      sMin = barrierLevel * Math.exp(adj); //bring the barrier UP slightly to adjust for discrete monitoring
      sMax = spot * Math.exp(_z * Math.sqrt(expiry));
      lower = new DirichletBoundaryCondition(rebate, sMin);

      if (isCall) {
        final Function1D<Double, Double> upperValue = new Function1D<Double, Double>() {
          @Override
          public Double evaluate(final Double tau) {
            return Math.exp(-rate * tau) * (spot * Math.exp(carry * tau) - strike);
          }
        };
        upper = new DirichletBoundaryCondition(upperValue, sMax);
      } else {
        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);
View Full Code Here

    BoundaryCondition upper;
    if (isUp) {
      sMin = 0.0;
      sMax = barrierLevel;
      if (isCall) {
        lower = new DirichletBoundaryCondition(0.0, sMin);
      } else {
        final Function1D<Double, Double> lowerValue = new Function1D<Double, Double>() {
          @Override
          public Double evaluate(final Double tau) {
            return Math.exp(-rate * tau) * strike;
          }
        };
        lower = new DirichletBoundaryCondition(lowerValue, sMin);
      }
      upper = new DirichletBoundaryCondition(rebateValue, sMax);
    } else {
      sMin = barrierLevel;
      sMax = spot * Math.exp(_z * Math.sqrt(expiry));
      lower = new DirichletBoundaryCondition(rebateValue, sMin);
      if (isCall) {
        final Function1D<Double, Double> upperValue = new Function1D<Double, Double>() {
          @Override
          public Double evaluate(final Double tau) {
            return Math.exp(-rate * tau) * (spot * Math.exp(carry * tau) - strike);
          }
        };
        upper = new DirichletBoundaryCondition(upperValue, sMax);
      } else {
        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);
View Full Code Here

    final double sMin = 0.0;
    final double sMax = spot * Math.exp(_z * Math.sqrt(expiry));
    BoundaryCondition lower;
    BoundaryCondition upper;
    if (isCall) {
      lower = new DirichletBoundaryCondition(0.0, sMin);
      final Function1D<Double, Double> upperValue = new Function1D<Double, Double>() {
        @Override
        public Double evaluate(final Double tau) {
          return Math.exp(-rate * tau) * (spot * Math.exp(carry * tau) - strike);
        }
      };
      upper = new DirichletBoundaryCondition(upperValue, sMax);
    } else {
      final Function1D<Double, Double> lowerValue = new Function1D<Double, Double>() {
        @Override
        public Double evaluate(final Double tau) {
          return Math.exp(-rate * tau) * strike;
        }
      };
      lower = new DirichletBoundaryCondition(lowerValue, sMin);
      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);
View Full Code Here

    //BoundaryCondition lower = new FixedSecondDerivativeBoundaryCondition(0, grid.getSpaceNode(0), true);
    final BoundaryCondition lower = new NeumannBoundaryCondition(0.0, grid.getSpaceNode(0), true);
    //BoundaryCondition lower = new DirichletBoundaryCondition(0.0, grid.getSpaceNode(0));//TODO for beta < 0.5 zero is accessible and thus there will be non-zero
    //density there
    final BoundaryCondition upper = new DirichletBoundaryCondition(0.0, grid.getSpaceNode(grid.getNumSpaceNodes() - 1));

    CoupledPDEDataBundle d1 = new CoupledPDEDataBundle(_data1, _initCon11, lower, upper, grid);
    CoupledPDEDataBundle d2 = new CoupledPDEDataBundle(_data2, _initCon12, lower, upper, grid);

    final CoupledFiniteDifference solver = new CoupledFiniteDifference(THETA, true);
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.finitedifference.DirichletBoundaryCondition

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.