Skip to main content

Module patterns

Module patterns 

Source
Expand description

Bot-pattern signals in a venue’s recent trades and order book, for the market summary’s health advisory.

Market making is legitimate, so a signal never fails a summary: it warns, with the evidence, where the tape or the book looks machine-made. The signals:

  • Repeated sizes: one exact trade size makes up a large share of the tape, or a few sizes make up half of it.
  • Metronome timing: trades come at an almost fixed interval.
  • Cadence: most gaps between trades are one interval, even when a bot trades in bursts with pauses between them (so the gaps as a whole are not a metronome).
  • Jittered timer: the gaps are not one interval but stay in a band (30–60 s, say), never much shorter: a timer with random jitter. Real order flow has many near-zero gaps.
  • Ping-pong: a buy and a sell of the same size at nearly the same price, seconds apart (the shape of wash trading).
  • Ladder quotes: consecutive book levels at even price steps whose sizes are equal, or rise or fall level by level (a quoting curve).
  • Round notionals: most of a side’s levels are whole quote amounts (560.00 USDT) though their sizes are not whole: a bot sizes its quotes by value; people size orders by quantity.

Across the runs of a repeating summary, one more: a depth cycle, a side of the book refilled on a timer and drained between the refills (depth_cycle). One run cannot see it.

The functions are pure: they read trades and levels and fetch nothing.

Structs§

BotPatterns
The bot-pattern result of one summary.
DepthCycle
A side of the book refilled at a near-fixed period and drained between the refills: a bot quoting on a timer.

Enums§

Finding
One signal that was found, with its evidence.
LadderShape
How a ladder’s sizes run, from the best level out.

Constants§

CADENCE_MIN_GAP_MS
Shortest interval the cadence signal judges: some venues print whole seconds, which would put many short random gaps on one value.
CADENCE_SHARE
Gaps at one interval, as a share of all gaps, at or above this are a cadence. Random arrivals put at most about 1.5% of gaps in any ±2% band.
CADENCE_TOLERANCE
Gaps within this share of an interval count as that interval.
CYCLE_FALLING_SHARE
Between refills, at least this share of the run-to-run steps must be flat or down: the depth drains, it does not grow.
CYCLE_JUMP
A run-to-run rise of at least this share of the depth is a refill.
CYCLE_MAX_CV
Periods between refills whose standard deviation is under this share of their mean are a timer.
CYCLE_MIN
Fewest whole cycles (refills after the first) that make a depth cycle.
CYCLE_MIN_RUNS
Fewest runs between two refills: a depth that jumps every other run is noise, not a cycle.
FEW_SIZES
How many sizes the few-sizes signal adds up.
FEW_SIZES_MIN_SHARE
A size counts toward the few-sizes signal only with at least this share of the trades on its own.
FEW_SIZES_SHARE
The FEW_SIZES most common sizes in at least this share of the trades are a signal.
LADDER_DEPTH
How many levels from the top of each side the ladder signal reads.
LADDER_MIN_LEVELS
Fewest consecutive levels that make a ladder.
LADDER_SHAPE_SLACK
A level at most this much larger (or smaller) than the one before does not end a falling (or rising) ladder: one bump in a quoting curve.
LADDER_SIZE_TOLERANCE
Levels of a ladder differ in size by at most this share.
LADDER_STEP_TOLERANCE
Price steps of a ladder differ by at most this share of the first step.
METRONOME_MAX_CV
Gaps whose standard deviation is under this share of their mean are a metronome.
MIN_GAPS
Fewest gaps between trade events the timing signal needs.
MIN_PING_PONG_PAIRS
Fewest ping-pong pairs that count as a signal.
MIN_TRADES
Fewest trades the tape signals need. Below this they are not judged.
PING_PONG_PRICE_TOLERANCE_PCT
A ping-pong pair’s prices differ by at most this, in percent.
PING_PONG_SHARE
Trades in ping-pong pairs, as a share of all trades, at or above this are a signal.
PING_PONG_WINDOW_MS
A ping-pong pair is at most this far apart in time.
REPEATED_SIZE_SHARE
One exact size in at least this share of the trades is a signal.
ROUND_LEVELS
The round-notional signal reads this many levels from the top of a side.
ROUND_MIN_LEVELS
At least this many of those levels with a whole quote amount are a signal.
TIMER_MAX_CV
Gaps whose standard deviation is under this share of their mean, with the floor below, are a jittered timer. Real order flow is near 1 or more.
TIMER_MIN_FLOOR
The 5th-percentile gap at or above this share of the median is a floor: a timer never fires early. Real order flow puts it near 0.
TRADE_SAMPLE
How many recent trades the summary asks the venue for.

Functions§

cadence
Cadence: the interval (of at least CADENCE_MIN_GAP_MS) that the most gaps between trade events are at, within CADENCE_TOLERANCE, when those gaps are at least CADENCE_SHARE of all gaps.
depth_cycle
Depth cycle: in points (time in ms, depth), oldest first, a refill (a rise of CYCLE_JUMP) at least CYCLE_MIN + 1 times, at least CYCLE_MIN_RUNS runs apart, at a period within CYCLE_MAX_CV, with the depth flat or falling for CYCLE_FALLING_SHARE of the steps between.
detect
Runs every signal. trades is the venue’s recent tape, or why there is none. book is the bids and asks of a real exchange book, or None for a synthetic one (a DEX pool’s curve is an even ladder by design).
few_sizes
Few sizes: the FEW_SIZES most common sizes (each with at least FEW_SIZES_MIN_SHARE) cover FEW_SIZES_SHARE of the trades. A bot that rotates through a few sizes passes under repeated_size.
ladders
Ladder quotes on either side of a real exchange book.
metronome
Metronome timing: the whole tape, else the dominant size’s trades, at a near-fixed interval.
ping_pong
Ping-pong: buy/sell pairs of the same size within PING_PONG_WINDOW_MS and PING_PONG_PRICE_TOLERANCE_PCT. Each trade is in one pair at most. Returns the finding and the paired trades.
repeated_size
Repeated sizes: the dominant size and the trades it covers, when it reaches REPEATED_SIZE_SHARE.
round_notionals
Round notionals on either side of a real exchange book.
timer
Jittered timer: gaps between trade events with a median of at least CADENCE_MIN_GAP_MS, a coefficient of variation under TIMER_MAX_CV, and a 5th percentile at least TIMER_MIN_FLOOR of the median.