Package com.quantfinlib.pricing
@NullMarked
package com.quantfinlib.pricing
Option and derivatives pricing models, implied volatility and volatility
surfaces. The main classes:
BlackScholes (Greeks with continuous
carry for equities and Garman-Kohlhagen FX),
ImpliedVolatility (Black implied
volatility by safeguarded Newton on the normalised Black function of
Jäckel, 2015), Bachelier (normal model),
QuantoOption (foreign-asset option paid
in domestic currency, with the foreign rate and quanto drift
adjustment),
BinomialTree (CRR American/European),
VolSurface (pillar smiles, total-variance
term interpolation), SabrModel (Hagan 2002
+ calibration), FairValueEngine
(microprice and latency-adjusted true mid),
TriangularArbitrage (executable FX
round-trip edge), ForwardCurve
(FX forwards with covered-interest-parity checks), the exotics
(DigitalOption,
TouchOption,
BarrierOption,
VannaVolga) and
Autocallable (the most common equity
structured product: memory coupons, autocall observations, European
knock-in; Monte Carlo with antithetic variates under documented GBM
simplifications; RFQ trading of it is in rfq). Market-risk pricing models
(docs/MARKET_RISK.md step 4):
Black76 (options on forwards and
futures, the quoting convention for caps, swaptions and futures
options),
Heston (stochastic volatility,
semi-analytic little-trap form, MC cross-checked) and
HigherOrderGreeks (vanna, volga and
exchange-option cross-gamma, checked against finite differences of the
first-order Greeks).-
ClassDescriptionAsian (average-price) options — the corporate hedger's option: paying off on the average of n fixings instead of one closing print kills both the expiry-day manipulation incentive and most of the vol (an average is smoother than its endpoints), which is why commodity and FX hedging programs default to them.Autocallable note pricer, the most common equity structured product: a note that pays a fat coupon and redeems early ("autocalls") the first observation date the underlier closes at or above the autocall barrier.Bachelier (normal) model for options on a forward: the forward follows dF = σ_N dW, so it can go negative and σ_N is quoted in absolute rate units (0.0080 = 80 basis points a year).Continuously monitored single-barrier options: all eight in/out, up/down, call/put combinations, regular and reverse, with a cash rebate.Barrier direction relative to spot.Whether the barrier activates or extinguishes the option.Cox-Ross-Rubinstein binomial tree for European and American options with a continuous carry yield (dividends / foreign rate).Black-76 — the Black-Scholes sibling for options on forwards and futures: rates caps/floors and swaptions, commodity futures options, bond futures options.Black-Scholes-Merton option pricing and Greeks with a continuous carry yield
q: setqto the dividend yield for equities or the foreign interest rate for FX (Garman-Kohlhagen).Full Greek set for one option.European digital (binary) options under Black-Scholes — the building blocks of the first-generation FX exotics book.Discrete (cash) dividends for equity derivatives — the forward-looking counterpart todata.CorporateActions' historical back-adjustment.European and American options on a stock paying discrete cash dividends, on a recombining Cox-Ross-Rubinstein tree, by the method of Vellekoop and Nieuwenhuis (2006, "Efficient pricing of derivatives on assets with discrete dividends", Applied Mathematical Finance 13(3), 265-284).Dupire (1994) local volatility from an implied total-variance surface, in Gatheral's form (Gatheral 2006, The Volatility Surface, equation 1.10):Two-asset closed forms: Margrabe's exchange option and Kirk's spread approximation — the workhorse formulas for relative-value option books (crack spreads, calendar spreads, stock-vs-index switches).Latency-adjusted fair value for rapidly updating order books.Implied FX forward curve from market outright forwards, with interpolation, implied rate differentials, and covered-interest-parity checks against deposit rates.Heston (1993) stochastic-volatility pricing — the canonical answer to Black-Scholes' one visible lie, the flat smile.Model parameters.Calibrates the fiveHeston.Paramsto a grid of Black-Scholes implied volatilities by Levenberg-Marquardt (Levenberg 1944; Marquardt 1963, with Marquardt's diagonal scaling).Calibration outcome.Heston European options by the COS method of Fang and Oosterlee (2008, "A novel pricing method for European options based on Fourier-cosine series expansions", SIAM J.The second-order Greeks a vol book actually hedges with — analytic Black-Scholes forms, the risk-side complement toBlackScholes.greeks(BlackScholes.OptionType, double, double, double, double, double, double): Vanna∂²V/∂S∂σ— how delta drifts when vol moves (equivalently, how vega drifts when spot moves).Black (lognormal) implied volatility by a safeguarded Newton iteration on the normalised Black function.Tick-frequency Greek estimation without tick-frequency repricing: a full Black-Scholes evaluation anchors the position, and every tick updates price/delta by the delta-gamma Taylor expansion (a handful of multiplies, zero allocation) while the anchor is refreshed off the hot path.Monte Carlo under Dupire local volatility, log-Euler scheme:Price and its Monte Carlo standard error.Finite-difference pricer for European options under Dupire local volatility.Quanto vanilla: a payoff on a foreign asset S (quoted in foreign currency) paid in domestic currency at a fixed conversion rate, for example a Nikkei call payingmax(S_T - K, 0)US dollars per index point.SABR stochastic volatility model: the Hagan, Kumar, Lesniewski and Woodward (2002) lognormal implied-vol expansion ("Managing smile risk", Wilmott, eq. 2.17a), and calibration of (α, ρ, ν) with β fixed.Calibrated SABR parameters.Surface SVI (Gatheral and Jacquier 2014, "Arbitrage-free SVI volatility surfaces", Quantitative Finance 14(1), definition 4.1):Structured notes — the retail shelf, priced by decomposition into the vanilla pieces this library already prices.One expiry of the raw SVI parametrisation (Gatheral 2004, "A parsimonious arbitrage-free implied volatility parameterization", Global Derivatives; Gatheral and Jacquier 2014, "Arbitrage-free SVI volatility surfaces", Quantitative Finance 14(1), equation 3.1):A surface of raw SVI slices (SviSlice), one per pillar expiry, interpolated linearly in total variance at fixed log-moneyness k = ln(K/F(t)).An implied volatility surface expressed as total implied variance w(T, k) = σ_BS(T, K)²·T against log-moneyness k = ln(K/F(T)), on a market with flat continuously compounded raterand carry (dividend or foreign) yieldq, so F(T) = S·e^{(r−q)T}.One-touch and no-touch options (pay-at-expiry) under continuously monitored geometric Brownian motion — with the barrier-hitting probability itself exposed, since desks quote one-touches as (roughly) discounted hit probabilities.Triangular arbitrage checks over three related FX pairs, using dealable bid/ask quotes (not mids), so a positive result is executable edge before fees.Vanna-volga pricing: the FX desk's standard smile-consistent adjustment built from exactly three market pillars (in practice the 25Δ put, ATM and 25Δ call thatfx.FxVolSurfacesolves from broker RR/BF quotes).Variance swap analytics: the cleanest pure-volatility trade there is.Implied volatility surface built from (expiry, strike, vol) pillar quotes — or directly from market option prices via implied-vol inversion.Total variance falls between two expiries at this log-moneyness.