Class BarrierAlignedSpotGridFactory

java.lang.Object
net.finmath.finitedifference.grids.BarrierAlignedSpotGridFactory

public final class BarrierAlignedSpotGridFactory extends Object
Utility factory for spot grids used in barrier option PDE problems.

Main features:

  • forces the barrier to be an exact grid node,
  • can build either a uniform or a clustered grid,
  • clustered grid puts more points near the barrier.

The clustered grid is piecewise-defined: on each side of the barrier, nodes are generated with a power transform. For clusteringExponent > 1.0, points concentrate near the barrier. For clusteringExponent = 1.0, the grid is piecewise uniform.

This class is intended especially for direct barrier pricing under Heston/SABR, where barrier alignment can materially improve knock-in accuracy.

Author:
Alessandro Gnoatto
  • Method Details

    • createBarrierAlignedUniformGrid

      public static Grid createBarrierAlignedUniformGrid(int numberOfSteps, double sMin, double sMax, double barrier)
      Creates a uniform grid with the barrier exactly on a node.

      The spacing is chosen so that:

      • the barrier lies exactly on a node,
      • the lower/upper bounds are preserved,
      • the number of intervals is exactly numberOfSteps.

      This method requires the barrier to lie strictly inside the interval.

      Parameters:
      numberOfSteps - Number of grid intervals.
      sMin - Lower grid boundary.
      sMax - Upper grid boundary.
      barrier - Barrier level.
      Returns:
      A grid with the barrier exactly on a node.
    • createBarrierAlignedClusteredGrid

      public static Grid createBarrierAlignedClusteredGrid(int numberOfSteps, double sMin, double sMax, double barrier, double clusteringExponent)
      Creates a barrier-aligned clustered grid.

      The barrier is exactly on a node. Points are concentrated near the barrier using a power transform on each side:

      x = barrier - (barrier - sMin) * (1 - u)^p    on the left side
      x = barrier + (sMax - barrier) * u^p          on the right side
      

      where p = clusteringExponent.

      • clusteringExponent = 1.0: piecewise uniform
      • clusteringExponent > 1.0: points cluster near the barrier
      Parameters:
      numberOfSteps - Number of grid intervals.
      sMin - Lower grid boundary.
      sMax - Upper grid boundary.
      barrier - Barrier level.
      clusteringExponent - Clustering strength, must be >= 1.0.
      Returns:
      A clustered grid with the barrier exactly on a node.
    • findBarrierIndex

      public static int findBarrierIndex(double[] grid, double barrier)
      Returns the index of the barrier node in a grid previously built by this factory.
      Parameters:
      grid - The grid array.
      barrier - The barrier level.
      Returns:
      The barrier node index.
    • findBarrierIndex

      public static int findBarrierIndex(Grid grid, double barrier)
      Convenience overload.
      Parameters:
      grid - The grid.
      barrier - The barrier level.
      Returns:
      The barrier node index.