Class BlackScholesFormulaRepository


  • public final class BlackScholesFormulaRepository
    extends Object
    The primary repository for Black-Scholes formulas, including the price and greeks.

    When the formula involves ambiguous quantities, a reference value (rather than NaN) is returned Note that the formulas are expressed in terms of interest rate (r) and cost of carry (b), then d_1 and d_2 are d_{1,2} = \frac{\ln(S/X) + (b \pm \sigma^2 ) T}{\sigma \sqrt{T}}.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double carryRho​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the carry rho.
      static double charm​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the charm.
      static double crossGamma​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the cross gamma.
      static double delta​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the spot delta.
      static double dualCharm​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the dual charm.
      static double dualDelta​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the dual delta.
      static double dualGamma​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the dual gamma.
      static double dualVanna​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the dual vanna.
      static double gamma​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the spot gamma.
      static double price​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the spot price.
      static double rho​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the rho.
      static double strikeForDelta​(double spot, double spotDelta, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the strike for the delta.
      static double theta​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry, boolean isCall)
      Computes the theta.
      static double vanna​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the vanna.
      static double vega​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the spot vega.
      static double vegaBleed​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the vega bleed.
      static double vomma​(double spot, double strike, double timeToExpiry, double lognormalVol, double interestRate, double costOfCarry)
      Computes the vomma (aka volga).
    • Method Detail

      • price

        public static double price​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry,
                                   boolean isCall)
        Computes the spot price.
        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        isCall - true for call, false for put
        Returns:
        the spot price
      • delta

        public static double delta​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry,
                                   boolean isCall)
        Computes the spot delta.
        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        isCall - true for call, false for put
        Returns:
        the spot delta
      • strikeForDelta

        public static double strikeForDelta​(double spot,
                                            double spotDelta,
                                            double timeToExpiry,
                                            double lognormalVol,
                                            double interestRate,
                                            double costOfCarry,
                                            boolean isCall)
        Computes the strike for the delta.

        Note that the parameter range is more restricted for this method because the strike is undetermined for infinite/zero valued parameters.

        Parameters:
        spot - the spot value of the underlying
        spotDelta - The spot delta
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        isCall - true for call, false for put
        Returns:
        the strike
      • dualDelta

        public static double dualDelta​(double spot,
                                       double strike,
                                       double timeToExpiry,
                                       double lognormalVol,
                                       double interestRate,
                                       double costOfCarry,
                                       boolean isCall)
        Computes the dual delta.

        This is the first derivative of option price with respect to strike.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        isCall - true for call, false for put
        Returns:
        the dual delta
      • gamma

        public static double gamma​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry)
        Computes the spot gamma.

        This is the second order sensitivity of the spot option value to the spot.

        $\frac{\partial^2 FV}{\partial^2 f}$.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the spot gamma
      • dualGamma

        public static double dualGamma​(double spot,
                                       double strike,
                                       double timeToExpiry,
                                       double lognormalVol,
                                       double interestRate,
                                       double costOfCarry)
        Computes the dual gamma.
        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the dual gamma
      • crossGamma

        public static double crossGamma​(double spot,
                                        double strike,
                                        double timeToExpiry,
                                        double lognormalVol,
                                        double interestRate,
                                        double costOfCarry)
        Computes the cross gamma.

        This is the sensitivity of the delta to the strike.

        $\frac{\partial^2 V}{\partial f \partial K}$.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the cross gamma
      • theta

        public static double theta​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry,
                                   boolean isCall)
        Computes the theta.

        This is the sensitivity of the present value to a change in time to maturity.

        $\-frac{\partial V}{\partial T}$.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        isCall - true for call, false for put
        Returns:
        theta
      • charm

        public static double charm​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry,
                                   boolean isCall)
        Computes the charm.

        This is the minus of second order derivative of option value, once spot and once time to maturity.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - The interest rate
        costOfCarry - The cost of carry
        isCall - true for call, false for put
        Returns:
        the charm
      • dualCharm

        public static double dualCharm​(double spot,
                                       double strike,
                                       double timeToExpiry,
                                       double lognormalVol,
                                       double interestRate,
                                       double costOfCarry,
                                       boolean isCall)
        Computes the dual charm.

        This is the minus of second order derivative of option value, once strike and once time to maturity.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost of carry
        isCall - true for call, false for put
        Returns:
        the dual charm
      • vega

        public static double vega​(double spot,
                                  double strike,
                                  double timeToExpiry,
                                  double lognormalVol,
                                  double interestRate,
                                  double costOfCarry)
        Computes the spot vega.

        This is the sensitivity of the option's spot price wrt the implied volatility (which is just the spot vega divided by the numeraire).

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the spot vega
      • vanna

        public static double vanna​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry)
        Computes the vanna.

        This is the second order derivative of the option value, once to the underlying spot and once to volatility.

        $\frac{\partial^2 FV}{\partial f \partial \sigma}$.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the spot vanna
      • dualVanna

        public static double dualVanna​(double spot,
                                       double strike,
                                       double timeToExpiry,
                                       double lognormalVol,
                                       double interestRate,
                                       double costOfCarry)
        Computes the dual vanna.

        This is the second order derivative of the option value, once to the strike and once to volatility.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the spot dual vanna
      • vomma

        public static double vomma​(double spot,
                                   double strike,
                                   double timeToExpiry,
                                   double lognormalVol,
                                   double interestRate,
                                   double costOfCarry)
        Computes the vomma (aka volga).

        This is the second order derivative of the option spot price with respect to the implied volatility.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the spot vomma
      • vegaBleed

        public static double vegaBleed​(double spot,
                                       double strike,
                                       double timeToExpiry,
                                       double lognormalVol,
                                       double interestRate,
                                       double costOfCarry)
        Computes the vega bleed.

        This is the second order derivative of the option spot price, once to the volatility and once to the time.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - the interest rate
        costOfCarry - the cost-of-carry rate
        Returns:
        the spot vomma
      • rho

        public static double rho​(double spot,
                                 double strike,
                                 double timeToExpiry,
                                 double lognormalVol,
                                 double interestRate,
                                 double costOfCarry,
                                 boolean isCall)
        Computes the rho.

        This is the derivative of the option value with respect to the risk free interest rate . Note that costOfCarry = interestRate - dividend, which the derivative also acts on.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - The interest rate
        costOfCarry - the cost of carry
        isCall - true for call, false for put
        Returns:
        the rho
      • carryRho

        public static double carryRho​(double spot,
                                      double strike,
                                      double timeToExpiry,
                                      double lognormalVol,
                                      double interestRate,
                                      double costOfCarry,
                                      boolean isCall)
        Computes the carry rho.

        This is the derivative of the option value with respect to the cost of carry . Note that costOfCarry = interestRate - dividend, which the derivative also acts on.

        Parameters:
        spot - the spot value of the underlying
        strike - the strike
        timeToExpiry - the time to expiry
        lognormalVol - the log-normal volatility
        interestRate - The interest rate
        costOfCarry - The cost of carry
        isCall - true for call, false for put
        Returns:
        the carry rho