Multi-layered manipulation detection system protecting AI trading algorithms from market manipulation tactics.
Integrates with the executor's circuit breaker system for real-time protection.
Detects price movements designed to trigger stop-losses before reversing.
S/R level pierce detection
Rapid reversal identification
Long squeeze / short squeeze classification
Hunt probability scoring
File: stop-hunt-detector.ts
2. Spoofing / Layering
HIGH IMPACTL2 DATA
Large orders placed with intent to cancel before execution.
Order book wall tracking
Wall appearance/disappearance patterns
Cancel-to-fill ratio analysis
Price impact correlation
File: spoofing-detector.ts
3. Wash Trading
MEDIUM IMPACTTICK DATA
Self-dealing to inflate volume and create false liquidity signals.
Same-size buy/sell pair detection
Time window analysis (configurable)
Volume percentage calculation
Matched pair counting
File: manipulation-detector.ts
4. Pump and Dump
HIGH IMPACT
Coordinated price/volume spikes followed by rapid sell-off.
Volume spike detection (>3x average)
Price surge identification (>10%)
Rapid crash pattern matching
Phase classification (pump/dump/complete)
File: manipulation-detector.ts
5. Closing Auction Manipulation
MEDIUM IMPACT
Price manipulation in the final minutes of trading.
Final period volume concentration
VWAP deviation analysis
Close vs session VWAP comparison
Abnormal closing activity detection
File: manipulation-detector.ts
6. Tick Classification
INTELLIGENCETICK DATA
Classify trading activity by actor type.
Whale ratio (large trades / total)
Bot signature detection
Aggressor imbalance
VPIN (Volume-Synchronized PIN)
Kyle's Lambda (price impact coefficient)
File: tick-classifier.ts
7. Real-time Spoofing
LIVE STREAML2 DATA
WebSocket-based real-time spoofing detection.
Binance depth stream integration
Real-time wall tracking
Immediate alert generation
Streaming to frontend via SSE
File: realtime-spoofing-service.ts
Detection Data Flow
Stop-Loss Hunting Detection
flowchart LR
subgraph Input
Bars["OHLC Bars"]
SR["S/R Levels"]
end
subgraph Detection["stop-hunt-detector.ts"]
Pierce["Pierce S/R Level?"]
Reverse["Rapid Reversal?"]
Squeeze["Squeeze Type?"]
end
subgraph Output
Signal["StopHuntSignal"]
DSL["DSL Primitives"]
end
Bars --> Pierce
SR --> Pierce
Pierce -->|Yes| Reverse
Reverse -->|Yes| Squeeze
Squeeze --> Signal
Signal --> DSL
style Detection fill:#16213e
Spoofing Detection Pipeline
flowchart LR
subgraph Input
Depth["L2 Order Book depth@100ms"]
end
subgraph Detection["spoofing-detector.ts"]
Walls["Detect Walls (bid/ask)"]
Track["Track Wall Changes (appear/disappear)"]
Ratio["Cancel Ratio Analysis"]
Score["Suspicion Score 0-100"]
end
subgraph Cache["Scheduler"]
Refresh["10s Refresh MONITORED_CRYPTO"]
Store["Cache in Memory"]
end
subgraph Output
DSL["DSL Sync Read"]
ASE["All-Seeing Eye"]
end
Depth --> Walls
Walls --> Track
Track --> Ratio
Ratio --> Score
Score --> Refresh
Refresh --> Store
Store --> DSL
Store --> ASE
style Detection fill:#16213e
style Cache fill:#0f3460
Tick Classification Pipeline
flowchart LR
subgraph Input
Ticks["Per-Trade Ticks Binance/Alpaca/Polygon"]
end
subgraph Classification["tick-classifier.ts"]
Whale["Whale Ratio large / total"]
Bot["Bot Signature round lots, timing"]
Aggressor["Aggressor Imbalance buy vs sell pressure"]
VPIN["VPIN toxicity metric"]
Lambda["Kyle's Lambda price impact"]
end
subgraph Labels
Retail["retail"]
MM["market_maker"]
Fund["fund_rebalance"]
Coord["coordinated"]
Liq["liquidation_cascade"]
end
Ticks --> Whale & Bot & Aggressor & VPIN & Lambda
Whale & Bot & Aggressor & VPIN & Lambda --> Labels
style Classification fill:#16213e
22 DSL Primitives
All primitives read from scheduler-populated caches for synchronous DSL evaluation.
File: manipulation-dsl-wrappers.ts
Primitive
Returns
Description
Spoofing Detection
spoofing_risk(symbol)
number
Suspicion score 0-100
is_spoofing_detected(symbol)
boolean
True if score > 50
wall_cancel_ratio(symbol)
number
Wall cancel-to-fill ratio
bid_wall_size(symbol)
number
Current bid wall size
ask_wall_size(symbol)
number
Current ask wall size
orderbook_imbalance(symbol)
number
Bid/ask imbalance -1 to 1
Tick Classification
whale_ratio(symbol)
number
Large trades / total trades
bot_signature(symbol)
number
Bot activity score 0-1
aggressor_imbalance(symbol)
number
Buy vs sell pressure -1 to 1
vpin(symbol)
number
Volume-sync'd probability 0-1
kyles_lambda(symbol)
number
Price impact coefficient
flow_label(symbol)
string
Activity classification label
Flow Labels
is_liquidation_cascade(symbol)
boolean
Liquidation cascade in progress
is_coordinated_activity(symbol)
boolean
Coordinated trading detected
is_market_maker_dominant(symbol)
boolean
MM activity dominant
is_fund_rebalance(symbol)
boolean
Fund rebalancing detected
Stop-Loss Hunting
is_stop_hunt(bars)
boolean
Stop hunt detected
stop_hunt_direction(bars)
string
'long_squeeze' | 'short_squeeze'
is_long_squeeze(bars)
boolean
Long positions being squeezed
is_short_squeeze(bars)
boolean
Short positions being squeezed
Composite
combined_manipulation_risk(symbol)
number
All signals combined 0-100
should_avoid_entry(symbol)
boolean
True if risk > 60
Executor Circuit Breaker Integration
Manipulation detection integrates with the paper/live executor's guardrail system.
File: algorithms/paper/executor.ts
flowchart TB
subgraph Tick["Executor Tick"]
Price["Get Current Price"]
Eval["Evaluate DSL"]
Manip["Check Manipulation Risk"]
end
subgraph ManipCheck["Manipulation Check"]
Risk["combined_manipulation_risk > 70?"]
Label["flow_label = liquidation_cascade OR coordinated?"]
end
subgraph Actions
Pause["Pause Entries Allow exits only"]
Kill["Kill Run Flatten all positions"]
Normal["Normal Operation"]
end
Price --> Eval
Eval --> Manip
Manip --> Risk
Risk -->|Yes| Pause
Risk -->|No| Label
Label -->|Yes + Risk ≥ 80| Kill
Label -->|No| Normal
style Tick fill:#1a1a2e
style ManipCheck fill:#16213e
style Actions fill:#2d132c
Circuit Breaker Thresholds
Condition
Action
Effect
combined_manipulation_risk > 70
Pause Entries
Block new entries, allow exits only
is_liquidation_cascade AND risk ≥ 80
Kill Run
Stop run, flatten all positions
is_coordinated_activity AND risk ≥ 80
Kill Run
Stop run, flatten all positions
Scheduler Jobs
Manipulation detection data is refreshed by scheduler jobs for cache population.
Job
Interval
Symbols
Purpose
spoofing-snapshot-refresh
10 seconds
BTCUSDT, ETHUSDT, SOLUSDT, BNBUSDT, XRPUSDT
Refresh L2 spoofing analysis cache
tick-classification-refresh
30 seconds
BTCUSDT, ETHUSDT, SOLUSDT, BNBUSDT, XRPUSDT
Refresh tick classification cache
All-Seeing Eye Integration
Manipulation signals feed into the unified data aggregation layer.
File: all-seeing-eye/aggregation/manipulation.ts
flowchart LR
subgraph Sources
Spoof["Spoofing Cache"]
Tick["Tick Classification"]
Detectors["Pump/Dump, Stop Hunt, Closing Auction"]
end
subgraph Aggregation["manipulation.ts"]
Fetch["fetchAllManipulationData()"]
Consensus["getManipulationConsensus()"]
Alerts["checkManipulationAlerts()"]
end
subgraph Output["AggregatedData"]
UDP["UnifiedDataPoint[] sourceType: 'manipulation'"]
Risk["overallRisk: low | medium | high | critical"]
end
Spoof & Tick & Detectors --> Fetch
Fetch --> UDP
Fetch --> Consensus
Consensus --> Risk
Fetch --> Alerts
style Aggregation fill:#16213e
Monitored Symbols
Crypto (Real-time)
Via Binance depth@100ms and aggTrades (keyless)
BTCUSDT, ETHUSDT, SOLUSDT, BNBUSDT, XRPUSDT
Stocks (OHLC-based)
Via Yahoo Finance for pump/dump, stop-hunt detection