Class IncrementalGreeks

java.lang.Object
com.quantfinlib.pricing.IncrementalGreeks

public final class IncrementalGreeks extends Object
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.
   price(S) ≈ price₀ + Δ₀·(S−S₀) + ½·Γ₀·(S−S₀)²
   delta(S) ≈ Δ₀ + Γ₀·(S−S₀)
 

This is how live options risk actually stays tick-fresh: the quadratic error term is O((S−S₀)³·speed), negligible for the sub-0.5% moves between anchor refreshes, and needsReprice(double) tells the slow path when the spot has drifted far enough to re-anchor (a pricing-thread job, not the tick thread's).

Single-threaded by design — one instance per position per risk thread. reprice(com.quantfinlib.pricing.BlackScholes.OptionType, double, double, double, double, double, double) allocates (it calls BlackScholes.greeks(com.quantfinlib.pricing.BlackScholes.OptionType, double, double, double, double, double, double)); it is the anchor operation. onTick(double) never allocates.

  • Constructor Details

    • IncrementalGreeks

      public IncrementalGreeks()
  • Method Details

    • reprice

      public void reprice(BlackScholes.OptionType type, double spot, double strike, double rate, double carry, double vol, double timeYears)
      Full reprice: re-anchors the expansion. Call from the pricing/slow thread — at start-up, on needsReprice(double), on vol or rate marks.
    • onTick

      public void onTick(double spot)
      The hot path: delta-gamma update from the anchor. No allocation, no transcendental math — two multiplies and three adds.
    • needsReprice

      public boolean needsReprice(double maxSpotDrift)
      Whether spot has drifted beyond maxSpotDrift from the anchor — the signal for the slow path to reprice(com.quantfinlib.pricing.BlackScholes.OptionType, double, double, double, double, double, double). The tick thread only reads a flag-style comparison; it never re-anchors itself.
    • estimatedPrice

      public double estimatedPrice()
      Tick-fresh price estimate (per unit; scale by position externally).
    • estimatedDelta

      public double estimatedDelta()
      Tick-fresh delta estimate.
    • gamma

      public double gamma()
      Anchor gamma (constant between reprices — second order is the anchor's).
    • vega

      public double vega()
      Anchor vega — vol risk only changes on reprice, not per tick.
    • theta

      public double theta()
      Anchor theta.
    • anchorSpot

      public double anchorSpot()
      The spot the expansion is anchored at (NaN before the first reprice).