Class PiecewiseConstantVolatility

java.lang.Object
net.finmath.marketdata.model.volatilities.PiecewiseConstantVolatility
All Implemented Interfaces:
LocalVolatility

public class PiecewiseConstantVolatility extends Object implements LocalVolatility
Piecewise constant local volatility function.

The volatility is a deterministic function of running time only. It does not depend on the asset value. Hence it represents a time-dependent Black-Scholes-type volatility as a LocalVolatility.

The time discretization represents running times t, not time to maturity. The convention is:

  • volatilities[i] applies from timeDiscretization.getTime(i) inclusive to timeDiscretization.getTime(i+1) exclusive;
  • the last volatility applies from the last discretization time onward;
  • before the first discretization time, the first volatility is used.

The number of volatility values must equal timeDiscretization.getNumberOfTimes().

Author:
Alessandro Gnoatto
  • Constructor Details

    • PiecewiseConstantVolatility

      public PiecewiseConstantVolatility(TimeDiscretization timeDiscretization, double[] volatilities)
      Creates a piecewise constant volatility from a time discretization and an array of volatility values.
      Parameters:
      timeDiscretization - The running-time discretization at which the volatility values become active.
      volatilities - The volatility values.
  • Method Details

    • getValue

      public double getValue(double time, double assetValue)
      Returns the local volatility sigma(t,S).

      Since this implementation is piecewise constant in time and independent of the asset value, the argument assetValue is ignored.

      Specified by:
      getValue in interface LocalVolatility
      Parameters:
      time - The running time.
      assetValue - The asset value.
      Returns:
      The piecewise constant volatility at the given time.
    • getVolatility

      public double getVolatility(int timeIndex)
      Returns the volatility value associated with a time index.
      Parameters:
      timeIndex - The time index.
      Returns:
      The volatility value.
    • getVolatility

      public double getVolatility(double time)
      Returns the volatility value active at the given running time.
      Parameters:
      time - The running time.
      Returns:
      The volatility value.
    • getTimeDiscretization

      public TimeDiscretization getTimeDiscretization()
      Returns the running-time discretization.
      Returns:
      The running-time discretization.
    • getVolatilities

      public double[] getVolatilities()
      Returns a defensive copy of the volatility array.
      Returns:
      The volatility array.
    • getNumberOfVolatilities

      public int getNumberOfVolatilities()
      Returns the number of volatility values.
      Returns:
      The number of volatility values.
    • getCloneForModifiedVolatilities

      public PiecewiseConstantVolatility getCloneForModifiedVolatilities(double[] newVolatilities)
      Creates a clone with modified volatility values and the same time discretization.
      Parameters:
      newVolatilities - The new volatility values.
      Returns:
      The modified volatility function.
    • getCloneForModifiedTimeDiscretization

      public PiecewiseConstantVolatility getCloneForModifiedTimeDiscretization(TimeDiscretization newTimeDiscretization)
      Creates a clone with a modified time discretization and the same volatility values.
      Parameters:
      newTimeDiscretization - The new time discretization.
      Returns:
      The modified volatility function.
    • toString

      public String toString()
      Overrides:
      toString in class Object