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, t) ≈ price₀ + Δ₀·(S−S₀) + ½·Γ₀·(S−S₀)² + Θ₀·(t − t₀)
  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(BlackScholes.OptionType, double, double, double, double, double, double) allocates (it calls BlackScholes.greeks(BlackScholes.OptionType, double, double, double, double, double, double)); it is the anchor operation. onTick(double) never allocates.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance; the explicit form of the default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    The spot the expansion is anchored at (NaN before the first reprice).
    double
    Tick-fresh delta estimate.
    double
    Tick-fresh price estimate (per unit; scale by position externally).
    double
    Anchor gamma (constant between reprices — second order is the anchor's).
    boolean
    needsReprice(double maxSpotDrift)
    Whether spot has drifted beyond maxSpotDrift from the anchor — the signal for the slow path to reprice(BlackScholes.OptionType, double, double, double, double, double, double).
    void
    onTick(double spot)
    The hot path with no time elapsed since the anchor: delta-gamma update only.
    void
    onTick(double spot, double yearsSinceAnchor)
    The hot path: delta-gamma-theta update from the anchor,
    void
    reprice(BlackScholes.OptionType type, double spot, double strike, double rate, double carry, double vol, double timeYears)
    Full reprice: re-anchors the expansion.
    double
    Anchor theta.
    double
    Anchor vega — vol risk only changes on reprice, not per tick.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IncrementalGreeks

      public IncrementalGreeks()
      Creates an instance; the explicit form of the default constructor.
  • 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 with no time elapsed since the anchor: delta-gamma update only. Use onTick(double, double) when ticks arrive over a meaningful fraction of a day, or the estimate misses the time decay.
    • onTick

      public void onTick(double spot, double yearsSinceAnchor)
      The hot path: delta-gamma-theta update from the anchor,
        price ≈ price₀ + Δ₀·dS + ½Γ₀·dS² + Θ₀·dt

      with dt = yearsSinceAnchor and Θ₀ = ∂V/∂t per year as BlackScholes.theta(BlackScholes.OptionType, double, double, double, double, double, double) defines it (negative for a long vanilla). Delta is updated by gamma only; its time drift (charm) is not included. No allocation, no transcendental math.

    • needsReprice

      public boolean needsReprice(double maxSpotDrift)
      Whether spot has drifted beyond maxSpotDrift from the anchor — the signal for the slow path to reprice(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).