Class BachelierCalculator
- Namespace
- NanoQL.PricingEngines
- Assembly
- NanoQL.dll
The Bachelier calculator: the value and sensitivities of a striked payoff on a forward with a normal distribution of a given standard deviation (in price units), discounted. It supports plain vanilla, cash-or-nothing, asset-or-nothing and gap payoffs.
public sealed class BachelierCalculator
- Inheritance
-
BachelierCalculator
- Inherited Members
Remarks
Three of QuantLib's results are fixed, documented divergences:
- QuantLib tells a call from a put by
alpha >= 0(bacheliercalculator.cpp:102-114,:183-188), which a put's N(d) − 1 meets where N(d) rounds to 1, so a put far out of the money prices as the call; here the payoff's type decides (Divergences/BachelierPutBranchTests.cs). - QuantLib's visitor sets alpha, beta and x for cash-or-nothing, asset-or-nothing and gap payoffs,
which its value and Greeks never read, so each prices as the plain vanilla; here the value is
D·(F·α + x·β + σ·∂α/∂d) and the Greeks its derivatives, Bachelier's closed forms for each payoff
(
Divergences/BachelierPayoffTests.cs). The plain vanilla's are QuantLib's expressions. - QuantLib's theta reads the spot gamma where the time decay reads the forward gamma, missing
(S/F)²; its vanna, the sensitivity of the vega to the spot by its documentation, misses D·F/S; its volga divides by
σ√T where the derivative in σ divides by σ, missing √T. Each is here the derivative, the vanna taking the spot as
Vanna(double, double) does (
Divergences/BachelierGreeksTests.cs).
Immutable. At a standard deviation within QL_EPSILON the density terms are 0, as QuantLib's: the value is the discounted payoff at the forward, the gammas, vega, vanna and volga 0.
Constructors
BachelierCalculator(StrikedTypePayoff, double, double, double)
Initializes a new instance of the BachelierCalculator class for a striked payoff.
public BachelierCalculator(StrikedTypePayoff payoff, double forward, double stdDev, double discount = 1)
Parameters
payoffStrikedTypePayoffThe payoff.
forwarddoubleThe forward.
stdDevdoubleThe standard deviation of the underlying at expiry, in price units.
discountdoubleThe discount factor.
Exceptions
- ArgumentNullException
payoffis null.- ArgumentException
The standard deviation is negative, the discount isn't positive, or the payoff isn't a plain vanilla, cash-or-nothing, asset-or-nothing or gap payoff.
BachelierCalculator(OptionType, double, double, double, double)
Initializes a new instance of the BachelierCalculator class for a plain vanilla payoff.
public BachelierCalculator(OptionType optionType, double strike, double forward, double stdDev, double discount = 1)
Parameters
optionTypeOptionTypeThe option's type.
strikedoubleThe strike.
forwarddoubleThe forward.
stdDevdoubleThe standard deviation of the underlying at expiry, in price units.
discountdoubleThe discount factor.
Exceptions
- ArgumentOutOfRangeException
optionTypeisn't a member of its type.- ArgumentException
The standard deviation is negative, or the discount isn't positive.
Properties
Alpha
Gets alpha, the forward's coefficient in the value.
public double Alpha { get; }
Property Value
Beta
Gets beta, the strike's (or cash's) coefficient in the value.
public double Beta { get; }
Property Value
DeltaForward
Gets the sensitivity to the forward.
public double DeltaForward { get; }
Property Value
ElasticityForward
Gets the sensitivity in percent to a percent change in the forward.
public double ElasticityForward { get; }
Property Value
GammaForward
Gets the second-order sensitivity to the forward.
public double GammaForward { get; }
Property Value
ItmAssetProbability
Gets the probability of being in the money in the asset martingale measure: N(d), 1 − N(d) for a put.
public double ItmAssetProbability { get; }
Property Value
ItmCashProbability
Gets the probability of being in the money in the bond martingale measure: N(d), 1 − N(d) for a put.
public double ItmCashProbability { get; }
Property Value
StrikeGamma
Gets the second-order sensitivity to the strike.
public double StrikeGamma { get; }
Property Value
StrikeSensitivity
Gets the sensitivity to the strike.
public double StrikeSensitivity { get; }
Property Value
Value
Gets the value: the plain vanilla's Bachelier formula, otherwise D·(F·α + x·β + σ·∂α/∂d).
public double Value { get; }
Property Value
Methods
Delta(double)
The sensitivity to the spot.
public double Delta(double spot)
Parameters
spotdoubleThe spot.
Returns
- double
The delta, the forward delta times F/S.
DividendRho(double)
The sensitivity to the dividend yield.
public double DividendRho(double maturity)
Parameters
maturitydoubleThe time to maturity.
Returns
- double
The dividend rho.
Exceptions
- ArgumentException
The maturity is negative.
Elasticity(double)
The sensitivity in percent to a percent change in the spot.
public double Elasticity(double spot)
Parameters
spotdoubleThe spot.
Returns
- double
The elasticity.
Gamma(double)
The second-order sensitivity to the spot.
public double Gamma(double spot)
Parameters
spotdoubleThe spot.
Returns
- double
The gamma, the forward gamma times (F/S)².
Rho(double)
The sensitivity to the risk-free rate.
public double Rho(double maturity)
Parameters
maturitydoubleThe time to maturity.
Returns
- double
The rho.
Exceptions
- ArgumentException
The maturity is negative.
Theta(double, double)
The sensitivity to the time to maturity.
public double Theta(double spot, double maturity)
Parameters
Returns
- double
The theta; 0 at a maturity close to 0.
Exceptions
- ArgumentException
The maturity is negative.
ThetaPerDay(double, double)
The sensitivity to the time to maturity per day, assuming 365 days a year.
public double ThetaPerDay(double spot, double maturity)
Parameters
Returns
- double
The theta per day.
Exceptions
- ArgumentException
The maturity is negative.
Vanna(double, double)
The sensitivity of the vega to the spot (vanna): QuantLib's documented quantity, its forward form times D·F/S, which QuantLib's misses.
public double Vanna(double spot, double maturity)
Parameters
Returns
- double
The vanna.
Vega(double)
The sensitivity to the volatility σ, the standard deviation being σ√T.
public double Vega(double maturity)
Parameters
maturitydoubleThe time to maturity.
Returns
- double
The vega.
Exceptions
- ArgumentException
The maturity is negative.
Volga(double)
The sensitivity of the vega to the volatility (volga): QuantLib's times √T, which QuantLib's misses.
public double Volga(double maturity)
Parameters
maturitydoubleThe time to maturity.
Returns
- double
The volga.