Class AnalyticFormulas


  • public class AnalyticFormulas
    extends Object
    This class implements some functions as static class methods. It provides functions like
    • the Black-Scholes formula,
    • the inverse of the Back-Scholes formula with respect to (implied) volatility,
    • the Bachelier formula,
    • the inverse of the Bachelier formula with respect to (implied) volatility,
    • the corresponding functions (versions) for caplets and swaptions,
    • analytic approximation for European options under the SABR model,
    • some convexity adjustments.
    Version:
    1.10
    Author:
    Christian Fries
    Date:
    27.04.2012
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double bachelierGeneralizedOptionVega​(double forward, double volatility, double optionMaturity, double optionStrike, double payoffUnit)
      Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma \mathrm{d}W(t) \]
      static double bachelierOptionDelta​(double forward, double volatility, double optionMaturity, double optionStrike, double payoffUnit)
      Calculates the option delta dV(0)/dS(0) of a call option, i.e., the payoff V(T)=max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
      static double bachelierOptionImpliedVolatility​(double forward, double optionMaturity, double optionStrike, double payoffUnit, double optionValue)
      Calculates the Bachelier option implied volatility of a call, i.e., the payoff max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
      static double bachelierOptionValue​(double forward, double volatility, double optionMaturity, double optionStrike, double payoffUnit)
      Calculates the option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
      static RandomVariable bachelierOptionValue​(RandomVariable forward, RandomVariable volatility, double optionMaturity, double optionStrike, RandomVariable payoffUnit)
      Calculates the option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
      static double blackModelCapletValue​(double forward, double volatility, double optionMaturity, double optionStrike, double periodLength, double discountFactor)
      Calculate the value of a caplet assuming the Black'76 model.
      static double blackModelDgitialCapletValue​(double forward, double volatility, double periodLength, double discountFactor, double optionMaturity, double optionStrike)
      Calculate the value of a digital caplet assuming the Black'76 model.
      static double blackModelSwaptionValue​(double forwardSwaprate, double volatility, double optionMaturity, double optionStrike, double swapAnnuity)
      Calculate the value of a swaption assuming the Black'76 model.
      static double blackScholesATMOptionValue​(double volatility, double optionMaturity, double forward, double payoffUnit)
      Calculates the Black-Scholes option value of an atm call option.
      static double blackScholesDigitalOptionDelta​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the delta of a digital option under a Black-Scholes model
      static double blackScholesDigitalOptionRho​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the rho of a digital option under a Black-Scholes model
      static double blackScholesDigitalOptionValue​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the Black-Scholes option value of a digital call option.
      static double blackScholesDigitalOptionVega​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the vega of a digital option under a Black-Scholes model
      static double blackScholesGeneralizedOptionValue​(double forward, double volatility, double optionMaturity, double optionStrike, double payoffUnit)
      Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a log-normal process with constant log-volatility.
      static RandomVariable blackScholesGeneralizedOptionValue​(RandomVariable forward, RandomVariable volatility, double optionMaturity, double optionStrike, RandomVariable payoffUnit)
      Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a log-normal process with constant log-volatility.
      static double blackScholesGeneralizedOptionVega​(double forward, double volatility, double optionMaturity, double optionStrike, double payoffUnit)
      Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
      static double blackScholesOptionDelta​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero.
      static RandomVariable blackScholesOptionDelta​(RandomVariable initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero.
      static RandomVariable blackScholesOptionDelta​(RandomVariable initialStockValue, RandomVariable riskFreeRate, RandomVariable volatility, double optionMaturity, double optionStrike)
      Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero.
      static RandomVariable blackScholesOptionDelta​(RandomVariable initialStockValue, RandomVariable riskFreeRate, RandomVariable volatility, double optionMaturity, RandomVariable optionStrike)
      Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero.
      static double blackScholesOptionGamma​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      This static method calculated the gamma of a call option under a Black-Scholes model
      static RandomVariable blackScholesOptionGamma​(RandomVariable initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      This static method calculated the gamma of a call option under a Black-Scholes model
      static RandomVariable blackScholesOptionGamma​(RandomVariable initialStockValue, RandomVariable riskFreeRate, RandomVariable volatility, double optionMaturity, double optionStrike)
      This static method calculated the gamma of a call option under a Black-Scholes model
      static double blackScholesOptionImpliedVolatility​(double forward, double optionMaturity, double optionStrike, double payoffUnit, double optionValue)
      Calculates the Black-Scholes option implied volatility of a call, i.e., the payoff
      static double blackScholesOptionRho​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      This static method calculated the rho of a call option under a Black-Scholes model
      static double blackScholesOptionTheta​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      This static method calculated the vega of a call option under a Black-Scholes model
      static double blackScholesOptionValue​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a log-normal process with constant log-volatility.
      static double blackScholesOptionValue​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike, boolean isCall)
      Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), or a put, i.e., the payoff max(K-S(T),0), where S follows a log-normal process with constant log-volatility.
      static RandomVariable blackScholesOptionValue​(RandomVariable initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a log-normal process with constant log-volatility.
      static RandomVariable blackScholesOptionValue​(RandomVariable initialStockValue, RandomVariable riskFreeRate, RandomVariable volatility, double optionMaturity, double optionStrike)
      Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a log-normal process with constant log-volatility.
      static double blackScholesOptionVega​(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
      static RandomVariable blackScholesOptionVega​(RandomVariable initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)
      Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
      static RandomVariable blackScholesOptionVega​(RandomVariable initialStockValue, RandomVariable riskFreeRate, RandomVariable volatility, double optionMaturity, double optionStrike)
      Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
      static double constantElasticityOfVarianceOptionValue​(double initialStockValue, double riskFreeRate, double volatility, double exponent, double optionMaturity, double optionStrike, boolean isCall)
      Calculates the CEV option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a CEV process.
      static double huntKennedyCMSAdjustedRate​(double forwardSwaprate, double volatility, double swapAnnuity, double optionMaturity, double swapMaturity, double payoffUnit)
      Calculate the adjusted forward swaprate corresponding to a change of payoff unit from the given swapAnnuity to the given payoffUnit using the Black-Scholes model for the swap rate together with the Hunt-Kennedy convexity adjustment.
      static double huntKennedyCMSFloorValue​(double forwardSwaprate, double volatility, double swapAnnuity, double optionMaturity, double swapMaturity, double payoffUnit, double optionStrike)
      Calculate the value of a CMS strike using the Black-Scholes model for the swap rate together with the Hunt-Kennedy convexity adjustment.
      static double huntKennedyCMSOptionValue​(double forwardSwaprate, double volatility, double swapAnnuity, double optionMaturity, double swapMaturity, double payoffUnit, double optionStrike)
      Calculate the value of a CMS option using the Black-Scholes model for the swap rate together with the Hunt-Kennedy convexity adjustment.
      static double margrabeExchangeOptionValue​(double spot1, double spot2, double volatility1, double volatility2, double correlation, double optionMaturity)
      Calculates the value of an Exchange option under a generalized Black-Scholes model, i.e., the payoff \( max(S_{1}(T)-S_{2}(T),0) \), where \( S_{1} \) and \( S_{2} \) follow a log-normal process with constant log-volatility and constant instantaneous correlation.
      static double price​(double timeToMaturity, double coupon, double yield, double redemption, int frequency)
      Re-implementation of the Excel PRICE function (a rather primitive bond price formula).
      static double price​(Date settlementDate, Date maturityDate, double coupon, double yield, double redemption, int frequency)
      Re-implementation of the Excel PRICE function (a rather primitive bond price formula).
      static double sabrAlphaApproximation​(double normalVolatility, double beta, double rho, double nu, double displacement, double underlying, double maturity)
      Return the parameter alpha (initial value of the stochastic vol process) of a SABR model using the to match the given at-the-money volatility.
      static double sabrBerestyckiNormalVolatilityApproximation​(double alpha, double beta, double rho, double nu, double displacement, double underlying, double strike, double maturity)
      Return the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Berestycki.
      static double sabrHaganLognormalBlackVolatilityApproximation​(double alpha, double beta, double rho, double nu, double underlying, double strike, double maturity)
      Calculated the approximation to the lognormal Black volatility using the standard SABR model and the standard Hagan approximation.
      static double sabrHaganLognormalBlackVolatilityApproximation​(double alpha, double beta, double rho, double nu, double displacement, double underlying, double strike, double maturity)
      Calculated the approximation to the lognormal Black volatility using the standard SABR model and the standard Hagan approximation.
      static double sabrNormalVolatilityApproximation​(double alpha, double beta, double rho, double nu, double displacement, double underlying, double strike, double maturity)
      Return the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Hagan.
      static double sabrNormalVolatilityCurvatureApproximation​(double alpha, double beta, double rho, double nu, double displacement, double underlying, double maturity)
      Return the curvature of the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Berestycki.
      static double sabrNormalVolatilitySkewApproximation​(double alpha, double beta, double rho, double nu, double displacement, double underlying, double maturity)
      Return the skew of the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Berestycki.
      static double volatilityConversionLognormalATMtoNormalATM​(double forward, double displacement, double optionMaturity, double lognormalVolatility)
      Exact conversion of displaced lognormal ATM volatility to normal ATM volatility.
      static double volatilityConversionLognormalToNormal​(double forward, double displacement, double optionMaturity, double optionStrike, double lognormalVolatility)
      Numerical conversion of displaced lognormal volatility to normal volatility.
    • Method Detail

      • blackScholesGeneralizedOptionValue

        public static double blackScholesGeneralizedOptionValue​(double forward,
                                                                double volatility,
                                                                double optionMaturity,
                                                                double optionStrike,
                                                                double payoffUnit)
        Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a log-normal process with constant log-volatility. The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward and/or the option strike is zero.
        Parameters:
        forward - The forward of the underlying.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        payoffUnit - The payoff unit (e.g., the discount factor)
        Returns:
        Returns the value of a European call option under the Black-Scholes model.
      • blackScholesGeneralizedOptionValue

        public static RandomVariable blackScholesGeneralizedOptionValue​(RandomVariable forward,
                                                                        RandomVariable volatility,
                                                                        double optionMaturity,
                                                                        double optionStrike,
                                                                        RandomVariable payoffUnit)
        Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a log-normal process with constant log-volatility. The model specific quantities are considered to be random variable, i.e., the function may calculate an per-path valuation in a single call.
        Parameters:
        forward - The forward of the underlying.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        payoffUnit - The payoff unit (e.g., the discount factor)
        Returns:
        Returns the value of a European call option under the Black-Scholes model.
      • blackScholesOptionValue

        public static double blackScholesOptionValue​(double initialStockValue,
                                                     double riskFreeRate,
                                                     double volatility,
                                                     double optionMaturity,
                                                     double optionStrike)
        Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a log-normal process with constant log-volatility.
        Parameters:
        initialStockValue - The spot value of the underlying.
        riskFreeRate - The risk free rate r (df = exp(-r T)).
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        Returns:
        Returns the value of a European call option under the Black-Scholes model.
      • blackScholesOptionValue

        public static RandomVariable blackScholesOptionValue​(RandomVariable initialStockValue,
                                                             RandomVariable riskFreeRate,
                                                             RandomVariable volatility,
                                                             double optionMaturity,
                                                             double optionStrike)
        Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a log-normal process with constant log-volatility.
        Parameters:
        initialStockValue - The spot value of the underlying.
        riskFreeRate - The risk free rate r (df = exp(-r T)).
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        Returns:
        Returns the value of a European call option under the Black-Scholes model.
      • blackScholesOptionValue

        public static RandomVariable blackScholesOptionValue​(RandomVariable initialStockValue,
                                                             double riskFreeRate,
                                                             double volatility,
                                                             double optionMaturity,
                                                             double optionStrike)
        Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a log-normal process with constant log-volatility.
        Parameters:
        initialStockValue - The spot value of the underlying.
        riskFreeRate - The risk free rate r (df = exp(-r T)).
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        Returns:
        Returns the value of a European call option under the Black-Scholes model.
      • blackScholesOptionValue

        public static double blackScholesOptionValue​(double initialStockValue,
                                                     double riskFreeRate,
                                                     double volatility,
                                                     double optionMaturity,
                                                     double optionStrike,
                                                     boolean isCall)
        Calculates the Black-Scholes option value of a call, i.e., the payoff max(S(T)-K,0), or a put, i.e., the payoff max(K-S(T),0), where S follows a log-normal process with constant log-volatility.
        Parameters:
        initialStockValue - The spot value of the underlying.
        riskFreeRate - The risk free rate r (df = exp(-r T)).
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T for the call and zero for the put.
        isCall - If true, the value of a call is calculated, if false, the value of a put is calculated.
        Returns:
        Returns the value of a European call/put option under the Black-Scholes model.
      • blackScholesATMOptionValue

        public static double blackScholesATMOptionValue​(double volatility,
                                                        double optionMaturity,
                                                        double forward,
                                                        double payoffUnit)
        Calculates the Black-Scholes option value of an atm call option.
        Parameters:
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        forward - The forward, i.e., the expectation of the index under the measure associated with payoff unit.
        payoffUnit - The payoff unit, i.e., the discount factor or the anuity associated with the payoff.
        Returns:
        Returns the value of a European at-the-money call option under the Black-Scholes model
      • blackScholesOptionDelta

        public static double blackScholesOptionDelta​(double initialStockValue,
                                                     double riskFreeRate,
                                                     double volatility,
                                                     double optionMaturity,
                                                     double optionStrike)
        Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero. In the case forward = option strike = 0 the method returns 1.0.
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The delta of the option
      • blackScholesOptionDelta

        public static RandomVariable blackScholesOptionDelta​(RandomVariable initialStockValue,
                                                             RandomVariable riskFreeRate,
                                                             RandomVariable volatility,
                                                             double optionMaturity,
                                                             double optionStrike)
        Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero. In the case forward = option strike = 0 the method returns 1.0.
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The delta of the option
      • blackScholesOptionDelta

        public static RandomVariable blackScholesOptionDelta​(RandomVariable initialStockValue,
                                                             double riskFreeRate,
                                                             double volatility,
                                                             double optionMaturity,
                                                             double optionStrike)
        Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero. In the case forward = option strike = 0 the method returns 1.0.
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The delta of the option
      • blackScholesOptionDelta

        public static RandomVariable blackScholesOptionDelta​(RandomVariable initialStockValue,
                                                             RandomVariable riskFreeRate,
                                                             RandomVariable volatility,
                                                             double optionMaturity,
                                                             RandomVariable optionStrike)
        Calculates the delta of a call option under a Black-Scholes model The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward or the option strike is zero. In the case forward = option strike = 0 the method returns 1.0.
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The delta of the option
      • blackScholesOptionGamma

        public static double blackScholesOptionGamma​(double initialStockValue,
                                                     double riskFreeRate,
                                                     double volatility,
                                                     double optionMaturity,
                                                     double optionStrike)
        This static method calculated the gamma of a call option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The gamma of the option
      • blackScholesOptionGamma

        public static RandomVariable blackScholesOptionGamma​(RandomVariable initialStockValue,
                                                             RandomVariable riskFreeRate,
                                                             RandomVariable volatility,
                                                             double optionMaturity,
                                                             double optionStrike)
        This static method calculated the gamma of a call option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The gamma of the option
      • blackScholesOptionGamma

        public static RandomVariable blackScholesOptionGamma​(RandomVariable initialStockValue,
                                                             double riskFreeRate,
                                                             double volatility,
                                                             double optionMaturity,
                                                             double optionStrike)
        This static method calculated the gamma of a call option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The gamma of the option
      • blackScholesOptionVega

        public static double blackScholesOptionVega​(double initialStockValue,
                                                    double riskFreeRate,
                                                    double volatility,
                                                    double optionMaturity,
                                                    double optionStrike)
        Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The vega of the option
      • blackScholesOptionVega

        public static RandomVariable blackScholesOptionVega​(RandomVariable initialStockValue,
                                                            RandomVariable riskFreeRate,
                                                            RandomVariable volatility,
                                                            double optionMaturity,
                                                            double optionStrike)
        Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The vega of the option
      • blackScholesOptionVega

        public static RandomVariable blackScholesOptionVega​(RandomVariable initialStockValue,
                                                            double riskFreeRate,
                                                            double volatility,
                                                            double optionMaturity,
                                                            double optionStrike)
        Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The vega of the option
      • blackScholesOptionTheta

        public static double blackScholesOptionTheta​(double initialStockValue,
                                                     double riskFreeRate,
                                                     double volatility,
                                                     double optionMaturity,
                                                     double optionStrike)
        This static method calculated the vega of a call option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The vega of the option
      • blackScholesOptionRho

        public static double blackScholesOptionRho​(double initialStockValue,
                                                   double riskFreeRate,
                                                   double volatility,
                                                   double optionMaturity,
                                                   double optionStrike)
        This static method calculated the rho of a call option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The rho of the option
      • blackScholesOptionImpliedVolatility

        public static double blackScholesOptionImpliedVolatility​(double forward,
                                                                 double optionMaturity,
                                                                 double optionStrike,
                                                                 double payoffUnit,
                                                                 double optionValue)
        Calculates the Black-Scholes option implied volatility of a call, i.e., the payoff

        max(S(T)-K,0)

        , where S follows a log-normal process with constant log-volatility. The admissible values for optionValue are between forward * payoffUnit - optionStrike (the inner value) and forward * payoffUnit.
        Parameters:
        forward - The forward of the underlying (which is equal to S(0) / payoffUnit, given the spot value S(0)).
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        payoffUnit - The payoff unit (e.g., the discount factor), (which is equal to exp(-maturity * r), given the interest rate r).
        optionValue - The option value. The admissible values for optionValue are between forward * payoffUnit - optionStrike (the inner value) and forward * payoffUnit.
        Returns:
        Returns the implied volatility of a European call option under the Black-Scholes model.
      • blackScholesDigitalOptionValue

        public static double blackScholesDigitalOptionValue​(double initialStockValue,
                                                            double riskFreeRate,
                                                            double volatility,
                                                            double optionMaturity,
                                                            double optionStrike)
        Calculates the Black-Scholes option value of a digital call option.
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        Returns the value of a European call option under the Black-Scholes model
      • blackScholesDigitalOptionDelta

        public static double blackScholesDigitalOptionDelta​(double initialStockValue,
                                                            double riskFreeRate,
                                                            double volatility,
                                                            double optionMaturity,
                                                            double optionStrike)
        Calculates the delta of a digital option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The delta of the digital option
      • blackScholesDigitalOptionVega

        public static double blackScholesDigitalOptionVega​(double initialStockValue,
                                                           double riskFreeRate,
                                                           double volatility,
                                                           double optionMaturity,
                                                           double optionStrike)
        Calculates the vega of a digital option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The vega of the digital option
      • blackScholesDigitalOptionRho

        public static double blackScholesDigitalOptionRho​(double initialStockValue,
                                                          double riskFreeRate,
                                                          double volatility,
                                                          double optionMaturity,
                                                          double optionStrike)
        Calculates the rho of a digital option under a Black-Scholes model
        Parameters:
        initialStockValue - The initial value of the underlying, i.e., the spot.
        riskFreeRate - The risk free rate of the bank account numerarie.
        volatility - The Black-Scholes volatility.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        Returns:
        The rho of the digital option
      • blackModelCapletValue

        public static double blackModelCapletValue​(double forward,
                                                   double volatility,
                                                   double optionMaturity,
                                                   double optionStrike,
                                                   double periodLength,
                                                   double discountFactor)
        Calculate the value of a caplet assuming the Black'76 model.
        Parameters:
        forward - The forward (spot).
        volatility - The Black'76 volatility.
        optionMaturity - The option maturity
        optionStrike - The option strike.
        periodLength - The period length of the underlying forward rate.
        discountFactor - The discount factor corresponding to the payment date (option maturity + period length).
        Returns:
        Returns the value of a caplet under the Black'76 model
      • blackModelDgitialCapletValue

        public static double blackModelDgitialCapletValue​(double forward,
                                                          double volatility,
                                                          double periodLength,
                                                          double discountFactor,
                                                          double optionMaturity,
                                                          double optionStrike)
        Calculate the value of a digital caplet assuming the Black'76 model.
        Parameters:
        forward - The forward (spot).
        volatility - The Black'76 volatility.
        periodLength - The period length of the underlying forward rate.
        discountFactor - The discount factor corresponding to the payment date (option maturity + period length).
        optionMaturity - The option maturity
        optionStrike - The option strike.
        Returns:
        Returns the price of a digital caplet under the Black'76 model
      • blackModelSwaptionValue

        public static double blackModelSwaptionValue​(double forwardSwaprate,
                                                     double volatility,
                                                     double optionMaturity,
                                                     double optionStrike,
                                                     double swapAnnuity)
        Calculate the value of a swaption assuming the Black'76 model.
        Parameters:
        forwardSwaprate - The forward (spot)
        volatility - The Black'76 volatility.
        optionMaturity - The option maturity.
        optionStrike - The option strike.
        swapAnnuity - The swap annuity corresponding to the underlying swap.
        Returns:
        Returns the value of a Swaption under the Black'76 model
      • margrabeExchangeOptionValue

        public static double margrabeExchangeOptionValue​(double spot1,
                                                         double spot2,
                                                         double volatility1,
                                                         double volatility2,
                                                         double correlation,
                                                         double optionMaturity)
        Calculates the value of an Exchange option under a generalized Black-Scholes model, i.e., the payoff \( max(S_{1}(T)-S_{2}(T),0) \), where \( S_{1} \) and \( S_{2} \) follow a log-normal process with constant log-volatility and constant instantaneous correlation. The method also handles cases where the forward and/or option strike is negative and some limit cases where the forward and/or the option strike is zero.
        Parameters:
        spot1 - Value of \( S_{1}(0) \)
        spot2 - Value of \( S_{2}(0) \)
        volatility1 - Volatility of \( \log(S_{1}(t)) \)
        volatility2 - Volatility of \( \log(S_{2}(t)) \)
        correlation - Instantaneous correlation of \( \log(S_{1}(t)) \) and \( \log(S_{2}(t)) \)
        optionMaturity - The option maturity \( T \).
        Returns:
        Returns the value of a European exchange option under the Black-Scholes model.
      • bachelierOptionValue

        public static double bachelierOptionValue​(double forward,
                                                  double volatility,
                                                  double optionMaturity,
                                                  double optionStrike,
                                                  double payoffUnit)
        Calculates the option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
        Parameters:
        forward - The forward of the underlying \( F(0) = S(0)/N(0) = S(0) \exp(r T) \).
        volatility - The Bachelier volatility \( \sigma \) of the forward process.
        optionMaturity - The option maturity T.
        optionStrike - The option strike K.
        payoffUnit - The payoff unit (e.g., the discount factor \( N(0)/N(T) = exp(-r T) \))
        Returns:
        Returns the value of a European call option under the Bachelier model.
      • bachelierOptionValue

        public static RandomVariable bachelierOptionValue​(RandomVariable forward,
                                                          RandomVariable volatility,
                                                          double optionMaturity,
                                                          double optionStrike,
                                                          RandomVariable payoffUnit)
        Calculates the option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
        Parameters:
        forward - The forward of the underlying \( F(0) = S(0)/N(0) = S(0) \exp(r T) \).
        volatility - The Bachelier volatility \( \sigma \) of the forward process.
        optionMaturity - The option maturity T.
        optionStrike - The option strike K.
        payoffUnit - The payoff unit (e.g., the discount factor \( N(0)/N(T) = exp(-r T) \))
        Returns:
        Returns the value of a European call option under the Bachelier model.
      • bachelierOptionImpliedVolatility

        public static double bachelierOptionImpliedVolatility​(double forward,
                                                              double optionMaturity,
                                                              double optionStrike,
                                                              double payoffUnit,
                                                              double optionValue)
        Calculates the Bachelier option implied volatility of a call, i.e., the payoff max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
        Parameters:
        forward - The forward of the underlying.
        optionMaturity - The option maturity T.
        optionStrike - The option strike. If the option strike is ≤ 0.0 the method returns the value of the forward contract paying S(T)-K in T.
        payoffUnit - The payoff unit (e.g., the discount factor)
        optionValue - The option value.
        Returns:
        Returns the implied volatility of a European call option under the Bachelier model.
      • bachelierOptionDelta

        public static double bachelierOptionDelta​(double forward,
                                                  double volatility,
                                                  double optionMaturity,
                                                  double optionStrike,
                                                  double payoffUnit)
        Calculates the option delta dV(0)/dS(0) of a call option, i.e., the payoff V(T)=max(S(T)-K,0), where S follows a normal process with numeraire scaled volatility, i.e., a homogeneous Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma exp(-r (T-t)) \mathrm{d}W(t) \] Considering the numeraire \( N(t) = exp(-r (T-t)) \), this implies that \( F(t) = S(t)/N(t) \) follows \[ \mathrm{d} F(t) = \sigma \mathrm{d}W(t) \text{.} \]
        Parameters:
        forward - The forward of the underlying \( F(0) = S(0)/N(0) = S(0) \exp(r T) \).
        volatility - The Bachelier volatility \( \sigma \) of the forward process.
        optionMaturity - The option maturity T.
        optionStrike - The option strike K.
        payoffUnit - The payoff unit (e.g., the discount factor \( N(0)/N(T) = exp(-r T) \))
        Returns:
        Returns the value of the option delta (dV/dS(0)) of a European call option under the Bachelier model.
      • huntKennedyCMSOptionValue

        public static double huntKennedyCMSOptionValue​(double forwardSwaprate,
                                                       double volatility,
                                                       double swapAnnuity,
                                                       double optionMaturity,
                                                       double swapMaturity,
                                                       double payoffUnit,
                                                       double optionStrike)
        Calculate the value of a CMS option using the Black-Scholes model for the swap rate together with the Hunt-Kennedy convexity adjustment.
        Parameters:
        forwardSwaprate - The forward swap rate
        volatility - Volatility of the log of the swap rate
        swapAnnuity - The swap annuity
        optionMaturity - The option maturity
        swapMaturity - The swap maturity
        payoffUnit - The payoff unit, e.g., the discount factor corresponding to the payment date
        optionStrike - The option strike
        Returns:
        Value of the CMS option
      • huntKennedyCMSFloorValue

        public static double huntKennedyCMSFloorValue​(double forwardSwaprate,
                                                      double volatility,
                                                      double swapAnnuity,
                                                      double optionMaturity,
                                                      double swapMaturity,
                                                      double payoffUnit,
                                                      double optionStrike)
        Calculate the value of a CMS strike using the Black-Scholes model for the swap rate together with the Hunt-Kennedy convexity adjustment.
        Parameters:
        forwardSwaprate - The forward swap rate
        volatility - Volatility of the log of the swap rate
        swapAnnuity - The swap annuity
        optionMaturity - The option maturity
        swapMaturity - The swap maturity
        payoffUnit - The payoff unit, e.g., the discount factor corresponding to the payment date
        optionStrike - The option strike
        Returns:
        Value of the CMS strike
      • huntKennedyCMSAdjustedRate

        public static double huntKennedyCMSAdjustedRate​(double forwardSwaprate,
                                                        double volatility,
                                                        double swapAnnuity,
                                                        double optionMaturity,
                                                        double swapMaturity,
                                                        double payoffUnit)
        Calculate the adjusted forward swaprate corresponding to a change of payoff unit from the given swapAnnuity to the given payoffUnit using the Black-Scholes model for the swap rate together with the Hunt-Kennedy convexity adjustment.
        Parameters:
        forwardSwaprate - The forward swap rate
        volatility - Volatility of the log of the swap rate
        swapAnnuity - The swap annuity
        optionMaturity - The option maturity
        swapMaturity - The swap maturity
        payoffUnit - The payoff unit, e.g., the discount factor corresponding to the payment date
        Returns:
        Convexity adjusted forward rate
      • sabrHaganLognormalBlackVolatilityApproximation

        public static double sabrHaganLognormalBlackVolatilityApproximation​(double alpha,
                                                                            double beta,
                                                                            double rho,
                                                                            double nu,
                                                                            double underlying,
                                                                            double strike,
                                                                            double maturity)
        Calculated the approximation to the lognormal Black volatility using the standard SABR model and the standard Hagan approximation.
        Parameters:
        alpha - initial value of the stochastic volatility process of the SABR model.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        underlying - Underlying (spot) value.
        strike - Strike.
        maturity - Maturity.
        Returns:
        Implied lognormal Black volatility.
      • sabrHaganLognormalBlackVolatilityApproximation

        public static double sabrHaganLognormalBlackVolatilityApproximation​(double alpha,
                                                                            double beta,
                                                                            double rho,
                                                                            double nu,
                                                                            double displacement,
                                                                            double underlying,
                                                                            double strike,
                                                                            double maturity)
        Calculated the approximation to the lognormal Black volatility using the standard SABR model and the standard Hagan approximation.
        Parameters:
        alpha - initial value of the stochastic volatility process of the SABR model.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        displacement - The displacement parameter d.
        underlying - Underlying (spot) value.
        strike - Strike.
        maturity - Maturity.
        Returns:
        Implied lognormal Black volatility.
      • sabrBerestyckiNormalVolatilityApproximation

        public static double sabrBerestyckiNormalVolatilityApproximation​(double alpha,
                                                                         double beta,
                                                                         double rho,
                                                                         double nu,
                                                                         double displacement,
                                                                         double underlying,
                                                                         double strike,
                                                                         double maturity)
        Return the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Berestycki.
        Parameters:
        alpha - initial value of the stochastic volatility process of the SABR model.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        displacement - The displacement parameter d.
        underlying - Underlying (spot) value.
        strike - Strike.
        maturity - Maturity.
        Returns:
        The implied normal volatility (Bachelier volatility)
      • sabrNormalVolatilityApproximation

        public static double sabrNormalVolatilityApproximation​(double alpha,
                                                               double beta,
                                                               double rho,
                                                               double nu,
                                                               double displacement,
                                                               double underlying,
                                                               double strike,
                                                               double maturity)
        Return the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Hagan.
        Parameters:
        alpha - initial value of the stochastic volatility process of the SABR model.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        displacement - The displacement parameter d.
        underlying - Underlying (spot) value.
        strike - Strike.
        maturity - Maturity.
        Returns:
        The implied normal volatility (Bachelier volatility)
      • sabrAlphaApproximation

        public static double sabrAlphaApproximation​(double normalVolatility,
                                                    double beta,
                                                    double rho,
                                                    double nu,
                                                    double displacement,
                                                    double underlying,
                                                    double maturity)
        Return the parameter alpha (initial value of the stochastic vol process) of a SABR model using the to match the given at-the-money volatility.
        Parameters:
        normalVolatility - ATM volatility to match.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        displacement - The displacement parameter d.
        underlying - Underlying (spot) value.
        maturity - Maturity.
        Returns:
        The implied normal volatility (Bachelier volatility)
      • sabrNormalVolatilitySkewApproximation

        public static double sabrNormalVolatilitySkewApproximation​(double alpha,
                                                                   double beta,
                                                                   double rho,
                                                                   double nu,
                                                                   double displacement,
                                                                   double underlying,
                                                                   double maturity)
        Return the skew of the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Berestycki. The skew is the first derivative of the implied vol w.r.t. the strike, evaluated at the money.
        Parameters:
        alpha - initial value of the stochastic volatility process of the SABR model.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        displacement - The displacement parameter d.
        underlying - Underlying (spot) value.
        maturity - Maturity.
        Returns:
        The skew of the implied normal volatility (Bachelier volatility)
      • sabrNormalVolatilityCurvatureApproximation

        public static double sabrNormalVolatilityCurvatureApproximation​(double alpha,
                                                                        double beta,
                                                                        double rho,
                                                                        double nu,
                                                                        double displacement,
                                                                        double underlying,
                                                                        double maturity)
        Return the curvature of the implied normal volatility (Bachelier volatility) under a SABR model using the approximation of Berestycki. The curvatures is the second derivative of the implied vol w.r.t. the strike, evaluated at the money.
        Parameters:
        alpha - initial value of the stochastic volatility process of the SABR model.
        beta - CEV parameter of the SABR model.
        rho - Correlation (leverages) of the stochastic volatility.
        nu - Volatility of the stochastic volatility (vol-of-vol).
        displacement - The displacement parameter d.
        underlying - Underlying (spot) value.
        maturity - Maturity.
        Returns:
        The curvature of the implied normal volatility (Bachelier volatility)
      • volatilityConversionLognormalATMtoNormalATM

        public static double volatilityConversionLognormalATMtoNormalATM​(double forward,
                                                                         double displacement,
                                                                         double optionMaturity,
                                                                         double lognormalVolatility)
        Exact conversion of displaced lognormal ATM volatility to normal ATM volatility.
        Parameters:
        forward - The forward
        displacement - The displacement (considering a displaced lognormal model, otherwise 0.
        optionMaturity - The maturity
        lognormalVolatility - The (implied) lognormal volatility.
        Returns:
        The (implied) normal volatility.
        See Also:
        Dimitroff, Fries, Lichtner and Rodi: Lognormal vs Normal Volatilities and Sensitivities in Practice
      • volatilityConversionLognormalToNormal

        public static double volatilityConversionLognormalToNormal​(double forward,
                                                                   double displacement,
                                                                   double optionMaturity,
                                                                   double optionStrike,
                                                                   double lognormalVolatility)
        Numerical conversion of displaced lognormal volatility to normal volatility.
        Parameters:
        forward - The forward.
        displacement - The displacement (considering a displaced lognormal model, otherwise 0.
        optionMaturity - The maturity.
        optionStrike - The strike.
        lognormalVolatility - The (implied) lognormal volatility.
        Returns:
        The (implied) normal volatility.
      • price

        public static double price​(Date settlementDate,
                                   Date maturityDate,
                                   double coupon,
                                   double yield,
                                   double redemption,
                                   int frequency)
        Re-implementation of the Excel PRICE function (a rather primitive bond price formula). The re-implementation is not exact, because this function does not consider daycount conventions.
        Parameters:
        settlementDate - Valuation date.
        maturityDate - Maturity date of the bond.
        coupon - Coupon payment.
        yield - Yield (discount factor, using frequency: 1/(1 + yield/frequency).
        redemption - Redemption (notional repayment).
        frequency - Frequency (1,2,4).
        Returns:
        price Clean price.
      • price

        public static double price​(double timeToMaturity,
                                   double coupon,
                                   double yield,
                                   double redemption,
                                   int frequency)
        Re-implementation of the Excel PRICE function (a rather primitive bond price formula). The re-implementation is not exact, because this function does not consider daycount conventions. We assume we have (int)timeToMaturity/frequency future periods and the running period has an accrual period of timeToMaturity - frequency * ((int)timeToMaturity/frequency).
        Parameters:
        timeToMaturity - The time to maturity.
        coupon - Coupon payment.
        yield - Yield (discount factor, using frequency: 1/(1 + yield/frequency).
        redemption - Redemption (notional repayment).
        frequency - Frequency (1,2,4).
        Returns:
        price Clean price.
      • bachelierGeneralizedOptionVega

        public static double bachelierGeneralizedOptionVega​(double forward,
                                                            double volatility,
                                                            double optionMaturity,
                                                            double optionStrike,
                                                            double payoffUnit)
        Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Bachelier model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma \mathrm{d}W(t) \]
        Parameters:
        forward - The forward of the underlying \( F = S(0) \exp(r T) \).
        volatility - The Bachelier volatility \( \sigma \).
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        payoffUnit - The payoff unit (e.g., the discount factor)
        Returns:
        Returns the vega of a European call option under the Bachelier model.
      • blackScholesGeneralizedOptionVega

        public static double blackScholesGeneralizedOptionVega​(double forward,
                                                               double volatility,
                                                               double optionMaturity,
                                                               double optionStrike,
                                                               double payoffUnit)
        Calculates the vega of a call, i.e., the payoff max(S(T)-K,0) P, where S follows a normal process with constant volatility, i.e., a Black-Scholes model \[ \mathrm{d} S(t) = r S(t) \mathrm{d} t + \sigma S(t)\mathrm{d}W(t) \]
        Parameters:
        forward - The forward of the underlying \( F = S(0) \exp(r T) \).
        volatility - The Black-Scholes volatility \( \sigma \).
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        payoffUnit - The payoff unit (e.g., the discount factor)
        Returns:
        Returns the vega of a European call option under the Black-Scholes model.
      • constantElasticityOfVarianceOptionValue

        public static double constantElasticityOfVarianceOptionValue​(double initialStockValue,
                                                                     double riskFreeRate,
                                                                     double volatility,
                                                                     double exponent,
                                                                     double optionMaturity,
                                                                     double optionStrike,
                                                                     boolean isCall)
        Calculates the CEV option value of a call, i.e., the payoff max(S(T)-K,0), where S follows a CEV process. Formula is from 2007 - Hsu Lin Lee - 'Constant Elasticity of Variance Option Pricing Model'. CEV exponent must be between 0 and 1.
        Parameters:
        initialStockValue - The spot value of the underlying.
        riskFreeRate - The risk free rate r (df = exp(-r T)).
        volatility - The CEV volatility (NOT the log-normal volatility).
        exponent - The exponent of S in the diffusion term.
        optionMaturity - The option maturity T.
        optionStrike - The option strike.
        isCall - If true, the value of a call is calculated, if false, the value of a put is calculated.
        Returns:
        Returns the value of a European call option under the CEV model.