Class VolSurface
java.lang.Object
com.quantfinlib.pricing.VolSurface
Implied volatility surface built from (expiry, strike, vol) pillar quotes —
or directly from market option prices via implied-vol inversion.
Interpolation:
- Within a smile — linear in vol across strikes, flat extrapolation beyond the quoted wings.
- Across expiries — linear in total variance w = σ²T. When a
forward is supplied for every expiry (
VolSurface.Builder.forward(double, double)), the interpolation is at fixed log-moneyness ln(K/F(t)), with F(t) log-linear in t; this is the convention under which a smile that rolls with the forward stays calendar-arbitrage-free (Gatheral 2006, The Volatility Surface, chapter 3). Without forwards it falls back to fixed strike. Flat vol outside the quoted expiry range.
Nothing in the construction enforces absence of arbitrage. Two checks
are provided: calendarViolations(int) (total variance must not fall
with expiry at fixed moneyness) and minimumDensity(double, double, int) (the
butterfly condition ∂²C/∂K² >= 0 on one smile). Linear interpolation
with flat wings puts a concave kink at the outermost pillar of any skewed
smile, and the density check reports it there; a smooth parametric smile
(SABR, SabrModel) avoids that. For an arbitrage-free parametric
surface use SsviSurface or SviSurface; Dupire local vol
is DupireLocalVol.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final recordTotal variance falls between two expiries at this log-moneyness. -
Method Summary
Modifier and TypeMethodDescriptiondoubleatmVol(double expiryYears, double forward) ATM vol, taking the forward (or spot) as the at-the-money strike.static VolSurface.Builderbuilder()calendarViolations(int gridPoints) Calendar-arbitrage scan: for each pair of consecutive quoted expiries, total variance atgridPointslog-moneyness values spanning both smiles' quoted range must not decrease.expiries()doubleforwardAt(double expiryYears) Forward at an expiry, log-linear between pillars and flat outside.doubleminimumDensity(double expiryYears, double forward, int n) Smallest butterfly density ∂²C/∂K² (undiscounted Black call on the interpolated smile, central second difference) overnstrikes across the quoted range of pillar expiryexpiryYears.doubleprice(BlackScholes.OptionType type, double spot, double strike, double rate, double carry, double expiryYears) Option price using the surface vol at (expiry, strike).doubleskew(double expiryYears, double strikeLow, double strikeHigh) Chord slope of the smile between two strikes, in decimal vol per unit of strike.strikes(double expiryYears) doublevol(double expiryYears, double strike) Interpolated implied volatility at any (expiry, strike).
-
Method Details
-
builder
-
vol
public double vol(double expiryYears, double strike) Interpolated implied volatility at any (expiry, strike). -
forwardAt
public double forwardAt(double expiryYears) Forward at an expiry, log-linear between pillars and flat outside.- Throws:
IllegalStateException- if the surface was built without forwards
-
calendarViolations
Calendar-arbitrage scan: for each pair of consecutive quoted expiries, total variance atgridPointslog-moneyness values spanning both smiles' quoted range must not decrease. Returns every violation found (empty when clean). Without forwards, moneyness is ln(K) at fixed strike. -
minimumDensity
public double minimumDensity(double expiryYears, double forward, int n) Smallest butterfly density ∂²C/∂K² (undiscounted Black call on the interpolated smile, central second difference) overnstrikes across the quoted range of pillar expiryexpiryYears. Negative means the smile admits a butterfly arbitrage. Kinks of the linear interpolation show up as spikes, not as negative density, unless the slope change itself is arbitrageable. -
atmVol
public double atmVol(double expiryYears, double forward) ATM vol, taking the forward (or spot) as the at-the-money strike. -
price
public double price(BlackScholes.OptionType type, double spot, double strike, double rate, double carry, double expiryYears) Option price using the surface vol at (expiry, strike). -
skew
public double skew(double expiryYears, double strikeLow, double strikeHigh) Chord slope of the smile between two strikes, in decimal vol per unit of strike. -
expiries
-
strikes
-