net.finmath.functions
Class AnalyticFormulas
- java.lang.Object
-
- net.finmath.functions.AnalyticFormulas
-
public class AnalyticFormulas extends java.lang.ObjectThis 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 corresponding functions (versions) for caplets and swaptions,
- some convexity adjustments.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doublebachelierOptionImpliedVolatility(double forward, double optionMaturity, double optionStrike, double payoffUnit, double optionValue)Calculates the Bachelier option implied volatility of a call, i.e., the payoffstatic doublebachelierOptionValue(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) P, where S follows a normal process with constant volatility, i.e., a Bachelier model.static RandomVariableInterfacebachelierOptionValue(RandomVariableInterface forward, RandomVariableInterface volatility, double optionMaturity, double optionStrike, RandomVariableInterface payoffUnit)Calculates the option value 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.static doubleblackModelCapletValue(double forward, double volatility, double optionMaturity, double optionStrike, double periodLength, double discountFactor)Calculate the value of a caplet assuming the Black'76 model.static doubleblackModelDgitialCapletValue(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 doubleblackModelSwaptionValue(double forwardSwaprate, double volatility, double optionMaturity, double optionStrike, double swapAnnuity)Calculate the value of a swaption assuming the Black'76 model.static doubleblackScholesATMOptionValue(double volatility, double optionMaturity, double forward, double payoffUnit)Calculates the Black-Scholes option value of an atm call option.static doubleblackScholesDigitalOptionDelta(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)Calculates the delta of a digital option under a Black-Scholes modelstatic doubleblackScholesDigitalOptionValue(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)Calculates the Black-Scholes option value of a digital call option.static doubleblackScholesGeneralizedOptionValue(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 RandomVariableInterfaceblackScholesGeneralizedOptionValue(RandomVariableInterface forward, RandomVariableInterface volatility, double optionMaturity, double optionStrike, RandomVariableInterface 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 doubleblackScholesOptionDelta(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 RandomVariableInterfaceblackScholesOptionDelta(RandomVariableInterface initialStockValue, RandomVariableInterface riskFreeRate, RandomVariableInterface 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 doubleblackScholesOptionGamma(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)This static method calculated the gamma of a call option under a Black-Scholes modelstatic RandomVariableInterfaceblackScholesOptionGamma(RandomVariableInterface initialStockValue, RandomVariableInterface riskFreeRate, RandomVariableInterface volatility, double optionMaturity, double optionStrike)This static method calculated the gamma of a call option under a Black-Scholes modelstatic doubleblackScholesOptionImpliedVolatility(double forward, double optionMaturity, double optionStrike, double payoffUnit, double optionValue)Calculates the Black-Scholes option implied volatility of a call, i.e., the payoffstatic doubleblackScholesOptionRho(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)This static method calculated the rho of a call option under a Black-Scholes modelstatic doubleblackScholesOptionValue(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 doubleblackScholesOptionVega(double initialStockValue, double riskFreeRate, double volatility, double optionMaturity, double optionStrike)This static method calculated the vega of a call option under a Black-Scholes modelstatic doublehuntKennedyCMSAdjustedRate(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 doublehuntKennedyCMSFloorValue(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 doublehuntKennedyCMSOptionValue(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 doublemargrabeExchangeOptionValue(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 doubleprice(java.util.Date settlementDate, java.util.Date maturityDate, double coupon, double yield, double redemption, int frequency)Re-implementation of the Excel PRICE function (a rather primitive bond price formula).static doubleprice(double timeToMaturity, double coupon, double yield, double redemption, int frequency)Re-implementation of the Excel PRICE function (a rather primitive bond price formula).
-
-
-
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 RandomVariableInterface blackScholesGeneralizedOptionValue(RandomVariableInterface forward, RandomVariableInterface volatility, double optionMaturity, double optionStrike, RandomVariableInterface 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.
-
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 RandomVariableInterface blackScholesOptionDelta(RandomVariableInterface initialStockValue, RandomVariableInterface riskFreeRate, RandomVariableInterface 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
-
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 RandomVariableInterface blackScholesOptionGamma(RandomVariableInterface initialStockValue, RandomVariableInterface riskFreeRate, RandomVariableInterface 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)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 payoffmax(S(T)-K,0)
, where S follows a log-normal process with constant log-volatility.- 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 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
-
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 maturityoptionStrike- 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 maturityoptionStrike- 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) P, where S follows a normal process with constant volatility, i.e., a Bachelier model.- Parameters:
forward- The forward of the underlying.volatility- The Bachelier volatility.optionMaturity- The option maturity T.optionStrike- The option strike.payoffUnit- The payoff unit (e.g., the discount factor)- Returns:
- Returns the value of a European call option under the Bachelier model.
-
bachelierOptionValue
public static RandomVariableInterface bachelierOptionValue(RandomVariableInterface forward, RandomVariableInterface volatility, double optionMaturity, double optionStrike, RandomVariableInterface payoffUnit)
Calculates the option value 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.- Parameters:
forward- The forward of the underlying.volatility- The Bachelier volatility.optionMaturity- The option maturity T.optionStrike- The option strike.payoffUnit- The payoff unit (e.g., the discount factor)- 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 payoffmax(S(T)-K,0)
, where S follows a normal process with constant volatility.- 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.
-
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 ratevolatility- Volatility of the log of the swap rateswapAnnuity- The swap annuityoptionMaturity- The option maturityswapMaturity- The swap maturitypayoffUnit- The payoff unit, e.g., the discount factor corresponding to the payment dateoptionStrike- 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 ratevolatility- Volatility of the log of the swap rateswapAnnuity- The swap annuityoptionMaturity- The option maturityswapMaturity- The swap maturitypayoffUnit- The payoff unit, e.g., the discount factor corresponding to the payment dateoptionStrike- 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 ratevolatility- Volatility of the log of the swap rateswapAnnuity- The swap annuityoptionMaturity- The option maturityswapMaturity- The swap maturitypayoffUnit- The payoff unit, e.g., the discount factor corresponding to the payment date- Returns:
- Convexity adjusted forward rate
-
price
public static double price(java.util.Date settlementDate, java.util.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.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG