Class AntiGamingJitter
java.lang.Object
com.quantfinlib.execution.AntiGamingJitter
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 on track while removing 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 ±
timeFractionof 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 -
Method Summary
Modifier and TypeMethodDescriptionlong[]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.
-
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 back by at mosttimeFractionof the gap to its original predecessor (or tostartNanos) and forward by at mosttimeFractionof the gap to its original successor; the last time never moves forward. Both bounds come from the original schedule only, and each is also held below half its gap, so two neighbours can never meet: consecutive outputs stay at leastg (1 - 2 timeFraction) - 1nanoseconds apart, wheregis their original gap. Strictly increasing, first time not beforestartNanos, last not after the original end.
-