Class OptionsBook
java.lang.Object
com.quantfinlib.hedging.OptionsBook
An options book on one underlying: aggregate Greeks across positions,
spot×vol scenario grids, and delta-gamma-vega-theta P&L explain — the
risk view a desk runs, not a single option.
Positions carry their own implied vols (smile-aware if fed from
VolSurface); quantities are signed
(negative = short). The underlying hedge position is part of the book, so
net delta reflects the hedged residual.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAggregated book value and Greeks.static final recordOne option position;quantityin option units (contract multiplier applied by caller).static final recordTaylor attribution of a P&L move: delta, gamma, vega, vanna (∂²V/∂S∂σ · dS·dσ), volga (½·∂²V/∂σ² · dσ²) and theta, with the remainder inunexplained. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddOption(OptionsBook.OptionPosition position) addOption(String label, BlackScholes.OptionType type, double strike, double expiryYears, double quantity, double impliedVol) addUnderlying(double quantity) Adds (or hedges with) the underlying; negative = short.greeks()Aggregated Greeks: options plus the underlying (delta 1 per unit).pnlExplain(double newSpot, double volShift, double timeDecayYears) Second-order P&L explain versus full revaluation:double[][]scenarioGrid(double[] spotShiftsPct, double[] volShiftsAbs) Spot×vol scenario P&L grid (full revaluation, no time decay):grid[i][j]= P&L at spot shifted byspotShiftsPct[i](fraction, 0.05 = +5%) and vol shifted byvolShiftsAbs[j](absolute, 0.02 = +2 vol points).doublespot()doubledoublevalue()Book value at current market (options MTM + underlying).doublevalueAt(double newSpot, double volShift, double timeDecayYears) Full revaluation at a shifted market (parallel vol shift, time decay).
-
Constructor Details
-
OptionsBook
public OptionsBook(double spot, double rate, double carry)
-
-
Method Details
-
addOption
-
addOption
public OptionsBook addOption(String label, BlackScholes.OptionType type, double strike, double expiryYears, double quantity, double impliedVol) -
addUnderlying
Adds (or hedges with) the underlying; negative = short. -
spot
public double spot() -
positions
-
underlyingQuantity
public double underlyingQuantity() -
value
public double value()Book value at current market (options MTM + underlying). -
greeks
Aggregated Greeks: options plus the underlying (delta 1 per unit). -
valueAt
public double valueAt(double newSpot, double volShift, double timeDecayYears) Full revaluation at a shifted market (parallel vol shift, time decay). -
scenarioGrid
public double[][] scenarioGrid(double[] spotShiftsPct, double[] volShiftsAbs) Spot×vol scenario P&L grid (full revaluation, no time decay):grid[i][j]= P&L at spot shifted byspotShiftsPct[i](fraction, 0.05 = +5%) and vol shifted byvolShiftsAbs[j](absolute, 0.02 = +2 vol points). -
pnlExplain
Second-order P&L explain versus full revaluation:dV ≈ Δ·dS + ½Γ·dS² + ν·dσ + vanna·dS·dσ + ½volga·dσ² + Θ·dt
with Black-Scholes-Merton vanna−e^{−qT}·φ(d1)·d2/σand volgaν·d1·d2/σper position (Haug, The Complete Guide to Option Pricing Formulas, 2nd ed., 2.2).volShiftis a parallel absolute shift of every position's implied vol (no smile dynamics); theta is per year, sotimeDecayYearsmultiplies it directly. Rho and the time cross terms are left inunexplained.
-