Class AntiGamingJitter

java.lang.Object
com.quantfinlib.execution.AntiGamingJitter

public final class AntiGamingJitter extends Object
Anti-gaming randomization for schedule-driven algos — a TWAP that fires identical children on a metronome is a gift to anyone watching the tape: predators detect the clock in a handful of intervals and lean on every child. The counter-measure is controlled jitter that keeps the SCHEDULE honest while killing the pattern:
  • Size jitter — each child ±sizeFraction, with the differences redistributed so the TOTAL is preserved exactly (the parent must complete; anti-gaming never changes what gets done, only how recognizable it looks);
  • Time jitter — each firing time ±timeFraction of its own interval, monotonicity preserved (children never reorder) and end time never exceeded.

Deterministic per seed — replayable in backtests, auditable in production (compliance can reconstruct exactly why each child fired when it did). Research/warm lane. Relationship to TwapScheduler.scheduleRandomized(long, long, int, double, long): that method jitters TWAP slice SIZES at construction; this class is the generic overlay — it jitters any existing child plan (VWAP, benchmark-executor, hand-built) and adds the TIME dimension the schedulers do not randomize.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AntiGamingJitter(long seed, double sizeFraction, double timeFraction)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long[]
    jitterSizes(long[] childQty)
    Jitters child sizes ±sizeFraction, preserving the total EXACTLY and never producing a negative child.
    long[]
    jitterTimes(long[] timesNanos, long startNanos)
    Jitters firing times within their intervals: each time moves ±timeFraction of the gap to its neighbors, strict monotonicity preserved, first/last never escape [startNanos, original end].

    Methods inherited from class java.lang.Object

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

    • AntiGamingJitter

      public AntiGamingJitter(long seed, double sizeFraction, double timeFraction)
      Parameters:
      seed - deterministic seed (replayable, auditable)
      sizeFraction - max relative size perturbation, in [0, 0.5]
      timeFraction - max relative time perturbation within each interval, in [0, 0.5]
  • Method Details

    • jitterSizes

      public long[] jitterSizes(long[] childQty)
      Jitters child sizes ±sizeFraction, preserving the total EXACTLY and never producing a negative child. Perturbations are paired (child i gives what child i+1 takes), so the completion curve wanders inside a one-child envelope of the original.
    • jitterTimes

      public long[] jitterTimes(long[] timesNanos, long startNanos)
      Jitters firing times within their intervals: each time moves ±timeFraction of the gap to its neighbors, strict monotonicity preserved, first/last never escape [startNanos, original end].