Class BlackScholes

java.lang.Object
io.deephaven.numerics.derivatives.BlackScholes

public class BlackScholes extends Object
A generalized Black-Scholes model for European options.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    carryRho(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes carryRho (first order partial derivative of option price with respect to cost-of-carry).
    static double
    charm(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes charm (first order partial derivative of Delta with respect to time to expiry).
    static double
    delta(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes delta (first order partial derivative of option price with respect to stock price).
    static double
    driftlessTheta(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes driftlessTheta (theta assuing the risk free rate and the cost of carry are zero).
    static double
    gamma(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes gamma (second order partial derivative of option price with respect to stock price).
    static double
    gammaP(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes percentage gamma (first order partial derivative of delta with respect to ln(stock price)).
    static double
    impliedVolBisect(double P, Boolean isCall, double S, double X, double T, double r, double b)
    Generalized Black-Scholes implied vol fitter using a bisection algorithm.
    static double
    impliedVolBisect(double P, Boolean isCall, double S, double X, double T, double r, double b, double eps, int maxIters)
    Generalized Black-Scholes implied vol fitter using a bisection algorithm.
    static double
    impliedVolNewton(double P, Boolean isCall, double S, double X, double T, double r, double b)
    Generalized Black-Scholes implied vol fitter using a newton algorithm.
    static double
    impliedVolNewton(double P, Boolean isCall, double S, double X, double T, double r, double b, double eps, int maxIters)
    Generalized Black-Scholes implied vol fitter using a newton algorithm.
    static double
    impliedVolNewtonP(double P, Boolean isCall, double S, double X, double T, double r, double b)
    Generalized Black-Scholes implied vol fitter using a newton algorithm based on log(vol).
    static double
    impliedVolNewtonP(double P, Boolean isCall, double S, double X, double T, double r, double b, double eps, int maxIters)
    Generalized Black-Scholes implied vol fitter using a newton algorithm based on log(vol).
    static double
    price(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes option price.
    static double
    rho(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes rho (first order partial derivative of option price with respect to risk-free rate).
    static double
    strikeDelta(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes strikeDelta (first order partial derivative of option price with respect to strike price).
    static double
    strikeFromDeltaBisect(double delta, Boolean isCall, double S, double T, double r, double b, double v)
    Finds the Generalized Black-Scholes strike from the delta.
    static double
    strikeFromDeltaBisect(double delta, Boolean isCall, double S, double T, double r, double b, double v, double eps, int maxIters)
    Finds the Generalized Black-Scholes strike from the delta.
    static double
    theta(boolean isCall, double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes theta (first order partial derivative of option price with respect to time to expiry).
    static double
    vega(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes vega (first order partial derivative of option price with respect to volatility).
    static double
    vegaBleed(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes vegaBleed (first order partial derivative of Vega with respect to time to expiry).
    static double
    vegaP(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes percentage vega (first order partial derivative of vega with respect to ln(volatility)).
    static double
    vomma(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes vomma (second order partial derivative of option price with respect to volatility).
    static double
    vommaP(double S, double X, double T, double r, double b, double v)
    Computes the generalized Black-Scholes percentage vomma (first order partial derivative of Vega with respect to ln(volatility)).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • price

      public static double price(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes option price.
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • delta

      public static double delta(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes delta (first order partial derivative of option price with respect to stock price).
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option delta
    • gamma

      public static double gamma(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes gamma (second order partial derivative of option price with respect to stock price).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • gammaP

      public static double gammaP(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes percentage gamma (first order partial derivative of delta with respect to ln(stock price)).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • vega

      public static double vega(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes vega (first order partial derivative of option price with respect to volatility).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • vegaP

      public static double vegaP(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes percentage vega (first order partial derivative of vega with respect to ln(volatility)).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • vomma

      public static double vomma(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes vomma (second order partial derivative of option price with respect to volatility).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • vommaP

      public static double vommaP(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes percentage vomma (first order partial derivative of Vega with respect to ln(volatility)).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • vegaBleed

      public static double vegaBleed(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes vegaBleed (first order partial derivative of Vega with respect to time to expiry).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • charm

      public static double charm(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes charm (first order partial derivative of Delta with respect to time to expiry).
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • theta

      public static double theta(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes theta (first order partial derivative of option price with respect to time to expiry).
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • driftlessTheta

      public static double driftlessTheta(double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes driftlessTheta (theta assuing the risk free rate and the cost of carry are zero).
      Parameters:
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • rho

      public static double rho(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes rho (first order partial derivative of option price with respect to risk-free rate).
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • carryRho

      public static double carryRho(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes carryRho (first order partial derivative of option price with respect to cost-of-carry).
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • strikeDelta

      public static double strikeDelta(boolean isCall, double S, double X, double T, double r, double b, double v)
      Computes the generalized Black-Scholes strikeDelta (first order partial derivative of option price with respect to strike price).
      Parameters:
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      theoretical option price
    • impliedVolBisect

      public static double impliedVolBisect(double P, Boolean isCall, double S, double X, double T, double r, double b)
      Generalized Black-Scholes implied vol fitter using a bisection algorithm.
      Parameters:
      P - option price
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      Returns:
      implied volatility
    • impliedVolBisect

      public static double impliedVolBisect(double P, Boolean isCall, double S, double X, double T, double r, double b, double eps, int maxIters)
      Generalized Black-Scholes implied vol fitter using a bisection algorithm.
      Parameters:
      P - option price
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      eps - volatility convergence tolerance
      maxIters - maximum number of optimization iterations
      Returns:
      implied volatility
    • impliedVolNewton

      public static double impliedVolNewton(double P, Boolean isCall, double S, double X, double T, double r, double b)
      Generalized Black-Scholes implied vol fitter using a newton algorithm.
      Parameters:
      P - option price
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      Returns:
      implied volatility
    • impliedVolNewton

      public static double impliedVolNewton(double P, Boolean isCall, double S, double X, double T, double r, double b, double eps, int maxIters)
      Generalized Black-Scholes implied vol fitter using a newton algorithm.
      Parameters:
      P - option price
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      eps - volatility convergence tolerance
      maxIters - maximum number of optimization iterations
      Returns:
      implied volatility
    • impliedVolNewtonP

      public static double impliedVolNewtonP(double P, Boolean isCall, double S, double X, double T, double r, double b)
      Generalized Black-Scholes implied vol fitter using a newton algorithm based on log(vol).
      Parameters:
      P - option price
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      Returns:
      implied volatility
    • impliedVolNewtonP

      public static double impliedVolNewtonP(double P, Boolean isCall, double S, double X, double T, double r, double b, double eps, int maxIters)
      Generalized Black-Scholes implied vol fitter using a newton algorithm based on log(vol).
      Parameters:
      P - option price
      isCall - true for call; false for put.
      S - underlying stock price
      X - strike price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      eps - volatility convergence tolerance
      maxIters - maximum number of optimization iterations
      Returns:
      implied volatility
    • strikeFromDeltaBisect

      public static double strikeFromDeltaBisect(double delta, Boolean isCall, double S, double T, double r, double b, double v)
      Finds the Generalized Black-Scholes strike from the delta.
      Parameters:
      delta - delta
      isCall - true for call; false for put.
      S - underlying stock price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      Returns:
      strike associated with the delta
    • strikeFromDeltaBisect

      public static double strikeFromDeltaBisect(double delta, Boolean isCall, double S, double T, double r, double b, double v, double eps, int maxIters)
      Finds the Generalized Black-Scholes strike from the delta.
      Parameters:
      delta - delta
      isCall - true for call; false for put.
      S - underlying stock price
      T - years to expiry
      r - risk-free rate
      b - cost-of-carry
      v - volatility
      eps - volatility convergence tolerance
      maxIters - maximum number of optimization iterations
      Returns:
      strike associated with the delta