public final class BlackFormulaRepository extends Object
Other classes that have higher level abstractions (e.g. option data bundles) should call these functions. As the numeraire (e.g. the zero bond p(0,T) in the T-forward measure) in the Black formula is just a multiplication factor, all prices, input/output, are forward prices, i.e. (spot price)/numeraire. Note that a "reference value" is returned if computation comes across an ambiguous expression.
| Modifier and Type | Method and Description |
|---|---|
static double |
crossGamma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the driftless cross gamma.
|
static double |
delta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the forward driftless delta.
|
static double |
driftlessTheta(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the forward driftless theta.
|
static double |
dualDelta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the driftless dual delta.
|
static double |
dualGamma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the driftless dual gamma.
|
static double |
dualVanna(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the driftless dual vanna.
|
static double |
gamma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the forward driftless gamma.
|
static double |
impliedStrike(double delta,
boolean isCall,
double forward,
double time,
double volatility)
Computes the implied strike from delta and volatility in the Black formula.
|
static double |
impliedStrike(double delta,
boolean isCall,
double forward,
double time,
double volatility,
double[] derivatives)
Computes the implied strike and its derivatives from delta and volatility in the Black formula.
|
static double |
impliedVolatility(double price,
double forward,
double strike,
double timeToExpiry,
boolean isCall)
Computes the log-normal implied volatility.
|
static double |
impliedVolatility(double otmPrice,
double forward,
double strike,
double timeToExpiry,
double volGuess)
Computes the log-normal (Black) implied volatility of an out-the-money
European option starting from an initial guess.
|
static ValueDerivatives |
impliedVolatilityAdjoint(double price,
double forward,
double strike,
double timeToExpiry,
boolean isCall)
Computes the log-normal implied volatility and its derivative with respect to price.
|
static ValueDerivatives |
impliedVolatilityAdjoint(double otmPrice,
double forward,
double strike,
double timeToExpiry,
double volGuess)
Computes the log-normal (Black) implied volatility of an out-the-money European option starting
from an initial guess and the derivative of the volatility w.r.t.
|
static double |
impliedVolatilityFromNormalApproximated(double forward,
double strike,
double timeToExpiry,
double normalVolatility)
Compute the log-normal implied volatility from a normal volatility using an approximate initial guess and a root-finder.
|
static double |
impliedVolatilityFromNormalApproximated2(double forward,
double strike,
double timeToExpiry,
double normalVolatility)
Compute the normal implied volatility from a normal volatility using an approximate explicit formula.
|
static ValueDerivatives |
impliedVolatilityFromNormalApproximatedAdjoint(double forward,
double strike,
double timeToExpiry,
double normalVolatility)
Compute the log-normal implied volatility from a normal volatility using an approximate initial guess and a
root-finder and compute the derivative of the log-normal volatility with respect to the input normal volatility.
|
static double |
price(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the forward price.
|
static ValueDerivatives |
priceAdjoint(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the price without numeraire and its derivatives.
|
static Pair<ValueDerivatives,double[][]> |
priceAdjoint2(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the price without numeraire and its derivatives of the first and second order.
|
static double |
simpleDelta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the simple delta.
|
static double |
strikeForDelta(double forward,
double forwardDelta,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Computes the strike for the delta.
|
static double |
theta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall,
double interestRate)
Computes the theta (non-forward).
|
static double |
thetaMod(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall,
double interestRate)
Computes the theta (non-forward).
|
static double |
vanna(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the driftless vanna.
|
static double |
vega(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the forward vega.
|
static double |
volga(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the driftless volga (aka vomma).
|
static double |
vomma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
Computes the driftless vomma (aka volga).
|
public static double price(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static ValueDerivatives priceAdjoint(double forward, double strike, double timeToExpiry, double lognormalVol, boolean isCall)
The derivatives are in the following order:
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static Pair<ValueDerivatives,double[][]> priceAdjoint2(double forward, double strike, double timeToExpiry, double lognormalVol, boolean isCall)
The first order derivatives are in the following order:
The second order derivatives are in the following order:
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static double delta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static double strikeForDelta(double forward,
double forwardDelta,
double timeToExpiry,
double lognormalVol,
boolean isCall)
forward - the forward value of the underlyingforwardDelta - the forward deltatimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static double dualDelta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
This is the first derivative of option price with respect to strike.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static double simpleDelta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall)
Note that this is not the standard delta one is accustomed to.
The argument of the cumulative normal is simply d = Math.log(forward / strike) / sigmaRootT.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putpublic static double gamma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the second order sensitivity of the forward option value to the forward.
$\frac{\partial^2 FV}{\partial^2 f}$
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double dualGamma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double crossGamma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the sensitity of the delta to the strike.
$\frac{\partial^2 V}{\partial f \partial K}$.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double theta(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall,
double interestRate)
This is the sensitivity of the present value to a change in time to maturity.
$\-frac{\partial * V}{\partial T}$.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putinterestRate - the interest ratepublic static double thetaMod(double forward,
double strike,
double timeToExpiry,
double lognormalVol,
boolean isCall,
double interestRate)
This is the sensitivity of the present value to a change in time to maturity
$\-frac{\partial * V}{\partial T}$.
This is consistent with BlackScholesFormulaRepository.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilityisCall - true for call, false for putinterestRate - the interest ratepublic static double driftlessTheta(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double vega(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the sensitivity of the option's forward price wrt the implied volatility (which is just the spot vega divided by the numeraire).
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double vanna(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the second order derivative of the option value, once to the underlying forward and once to volatility.
$\frac{\partial^2 FV}{\partial f \partial \sigma}$.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double dualVanna(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the second order derivative of the option value, once to the strike and once to volatility.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double vomma(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the second order derivative of the option forward price with respect to the implied volatility.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double volga(double forward,
double strike,
double timeToExpiry,
double lognormalVol)
This is the second order derivative of the option forward price with respect to the implied volatility.
forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expirylognormalVol - the log-normal volatilitypublic static double impliedVolatility(double price,
double forward,
double strike,
double timeToExpiry,
boolean isCall)
price - The forward price, which is the market price divided by the numeraire,
for example the zero bond p(0,T) for the T-forward measureforward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expiryisCall - true for call, false for putpublic static ValueDerivatives impliedVolatilityAdjoint(double price, double forward, double strike, double timeToExpiry, boolean isCall)
price - The forward price, which is the market price divided by the numeraire,
for example the zero bond p(0,T) for the T-forward measureforward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expiryisCall - true for call, false for putpublic static double impliedVolatility(double otmPrice,
double forward,
double strike,
double timeToExpiry,
double volGuess)
otmPrice - The forward price, which is the market price divided by the numeraire,
for example the zero bond p(0,T) for the T-forward measure
This MUST be an OTM price, i.e. a call price for strike >= forward and a put price otherwise.forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expiryvolGuess - a guess of the implied volatilitypublic static ValueDerivatives impliedVolatilityAdjoint(double otmPrice, double forward, double strike, double timeToExpiry, double volGuess)
otmPrice - The forward price, which is the market price divided by the numeraire,
for example the zero bond p(0,T) for the T-forward measure
This MUST be an OTM price, i.e. a call price for strike >= forward and a put price otherwise.forward - the forward value of the underlyingstrike - the striketimeToExpiry - the time to expiryvolGuess - a guess of the implied volatilitypublic static double impliedStrike(double delta,
boolean isCall,
double forward,
double time,
double volatility)
delta - The option deltaisCall - true for call, false for putforward - The forward.time - The time to expiry.volatility - The volatility.public static double impliedStrike(double delta,
boolean isCall,
double forward,
double time,
double volatility,
double[] derivatives)
delta - The option deltaisCall - true for call, false for putforward - the forwardtime - the time to expiryvolatility - the volatilityderivatives - the mutated array of derivatives of the implied strike with respect to the input
Derivatives with respect to: [0] delta, [1] forward, [2] time, [3] volatility.public static double impliedVolatilityFromNormalApproximated(double forward,
double strike,
double timeToExpiry,
double normalVolatility)
The forward and the strike must be positive.
Reference: Hagan, P. S. Volatility conversion calculator. Technical report, Bloomberg.
forward - the forward rate/pricestrike - the option striketimeToExpiry - the option time to expirationnormalVolatility - the normal implied volatilitypublic static ValueDerivatives impliedVolatilityFromNormalApproximatedAdjoint(double forward, double strike, double timeToExpiry, double normalVolatility)
The forward and the strike must be positive.
Reference: Hagan, P. S. Volatility conversion calculator. Technical report, Bloomberg.
forward - the forward rate/pricestrike - the option striketimeToExpiry - the option time to expirationnormalVolatility - the normal implied volatilitypublic static double impliedVolatilityFromNormalApproximated2(double forward,
double strike,
double timeToExpiry,
double normalVolatility)
The formula is usually not good enough to be used as such, but provide a good initial guess for a
root-finding procedure. Use impliedVolatilityFromNormalApproximated(double, double, double, double) for
more precision.
The forward and the strike must be positive.
Reference: Hagan, P. S. Volatility conversion calculator. Technical report, Bloomberg.
forward - the forward rate/pricestrike - the option striketimeToExpiry - the option time to expirationnormalVolatility - the normal implied volatilityCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.