Login / Sign up
Discover Bonzai
Terms of Use
Legal notice
Privacy
Region
Language
Niokoz
Niokoz
35
Subscribers
Facebook
X
Whatsapp
Telegram
Feed Shop

I rebuilt the NANEX-style 3D Depth Mapper… for crypto.

Facebook
Twitter
Whatsapp
Telegram
1 month ago

I rebuilt the NANEX-style 3D Depth Mapper… for crypto.

JS + three.js + WebGL2 + Binance WebSocket streams = a real-time 3D order book & tape you can fly through. Because flat charts are comfy—until you need to see where size is actually hiding. 😉


What it is (at a glance)

  • Client-side, zero-install Web app (PWA-ready). Pure JavaScript/TypeScript on the front end.

  • 3D market microstructure: price axis, size axis, and a “time/depth” axis, with a golden plane locked to current price.

  • Cameras: Orbit / Top / Side / Front / Free with inertia, damping, and keyboard shortcuts.

  • Made for flow: liquidity walls (🟢 bids / 🔴 asks), voids/gaps, tape particles, and per-price cumulative depth—all live.


Data Ingest & Synchronization

  • Streams: @depth@100ms, @aggTrade, @bookTicker from Binance Spot/Futures over WSS.

  • Bootstrapping: seeds L2 from REST snapshot (/depth?limit=1000), aligns with lastUpdateId, then applies incremental diffs.

  • Drop/Gap recovery: sequence tracking, checksum verification (when available), automatic resync on out-of-order or missed IDs.

  • Backpressure handling: adaptive throttling + coalescing (per-price accumulator) under burst.

  • Clock alignment: server timestamp drift correction; monotonic event time for consistent tape decay.

  • Symbol normalizer: tick-size & lot-size aware, integerized price grid to avoid float drift.


Rendering Engine (WebGL2 + three.js)

  • GPU-accelerated everything:

    • InstancedMesh for thousands of depth bars and volume tiles.

    • Dynamic VBO updates via BufferAttribute.setUsage(DynamicDrawUsage) and sparse region updates.

    • Frustum culling + LOD rules (drop distant micro bars).

  • Materials & Shaders:

    • Custom GLSL vertex/fragment shaders for signed volume coloring (green↔red), alpha falloff, and time-decay.

    • Log/linear scaling for size with gamma correction to keep “whales” visible without flattening the book.

    • Optional FXAA pass; MSAA when supported.

  • Tape particles:

    • One particle per trade, GPU-instanced quads with size mapped to qty and hue mapped to aggressor side.

    • Time-to-live & fade-out done in shader (no per-frame CPU churn).

  • Golden plane:

    • Physical plane anchored to markPrice/indexPrice (configurable), providing context for micro-moves.


Data Structures & Math

  • Lock-free ring buffers (typed arrays) for tick/event queues.

  • Price ladder as contiguous Float32Array with prefix sums for instantaneous cumulative depth.

  • Spatial hashing for price→mesh index, enabling O(1) updates of individual bars.

  • Aggregation:

    • Configurable L2/L3: group by n * tickSize buckets.

    • Rolling window order-book imbalance: (bid - ask) / (bid + ask) per slice.

  • Derived metrics (overlays):

    • Spread, mid, imbalance heat, absorption score (trade volume vs. resting depth), micro-trend slope, “iceberg suspicion” (rapid refresh at same level).


Concurrency & Latency

  • Web Workers for JSON parse & diff application; UI thread reserved for render.

  • Optional OffscreenCanvas path (Chrome/Edge) to push all draw calls off the main thread.

  • End-to-end latency: sub-100 ms on a normal laptop in burst scenarios; typical steady-state ~40–60 ms.

  • Reconnect logic with exponential backoff + state warm-start from last valid snapshot.


UI / UX for Operators

  • Camera presets + smooth transitions; gizmo with axes & grid snapping.

  • Selection/raycasting: hover any price level to read cumulative depth, recent trades at/near that level, and last change delta.

  • Hot keys: toggle overlays, switch aggregation, freeze frame, recenter on price.

  • Themeable (dark by default), dpi-aware, and resize-stable.

  • Performance HUD: FPS, object counts, particle count, stream status.


Profiling & Stability

  • GC-friendly: object pools, typed arrays, minimal allocations per tick.

  • Micro-benchmarks in dev mode; frame budget enforcement (drops non-critical updates first).

  • Error fences around stream handlers; telemetry events (dropped seq, resyncs, parse spikes).


Tech Stack Shout-outs

  • JavaScript/TypeScript, three.js, WebGL2, GLSL

  • WebSocket (binary-capable client), Web Workers, OffscreenCanvas

  • Vite build, ES modules, PWA manifest, Workbox (optional) for cache

  • Zod (schemas for stream payloads) + ts-pattern (exhaustive switching)

  • Vitest + Playwright for headless render & input sanity checks


Roadmap (already spiked)

  • Multi-venue aggregation (Binance + Bybit + OKX) with per-venue color ribbons.

  • Session recording & time-scrub replay.

  • Custom shader nodes for adaptive transparency based on micro-volatility.

  • RESTful snapshot fallback cache & offline demo mode.

  • Simple API for alerts: “ping me when size ≥ X appears within Y ticks of price”.


Why this, why now?

Because “green candle means number go up” is a nice bedtime story. Markets move on liquidity, not feelings. This lets you see the book breathe—spoofs, absorptions, air pockets—while they happen. Screenshots don’t fill bags. 😉

Dropping soon for the fam. 🧠⚡️🚀

Follow Niokoz to comment
Niokoz

Niokoz

Trading, research, developpement, Futures, Crytpo, WEB3 ! Market Making, and HFT analysis. META_quant.
35
Visit this Bonzai
Follow Niokoz to get the latest updates.

🤖 THE ULTIMATE LIQBOT AI V8 PARAMETERS GUIDE IS HERE! 📘

5 days ago
22

Ultra-Aggressive HFT Settings + 7-Module Brain (MT5 Liqbot AI v8)

6 days ago
15

🚀 What happens when seven brains go HFT on the DAX?

6 days ago
15

MT5 Liqbot AI v8 on DE40 (DAX) — Early Results

1 week ago
26

🚀 LIQBOT AI v8 is live — plug it in, print money* (*almost)

2 weeks ago
28

🚀 MT5 LIQBOT AI v8 | UPDATE MESSAGE

2 weeks ago
52

|MT5 Liqbot_AI v8| ALERT !

2 weeks ago
33

MT5_Liqbot_AI🔥 V8 is coming... and it's going to change everything 🧠

2 weeks ago
30

🚀 META_quant 4D: The Ultimate Order Book Visualization Revolution for ETHUSDT Scalping

4 weeks ago
49

Rigged Playbook: The House Always Wins on ES — The MM Tactic They Don’t Teach You | META_quant 4D

1 month ago
48

COMEX Gold (GC) — the most “gamey” market on earth?

1 month ago
47

Want Trading Success?

1 month ago
39

Major Update to the Python BRIDGE that links MT5 with META_quant 4D!

1 month ago
48

Read the ORDERFLOW on GOLD with META_quant 4D

1 month ago
56

🔥 META_quant 4D: When You Finally SEE How the Gold Market Really Moves ⚔️

1 month ago
45

🚨 JUST IN: The Bitcoin Doomsday Whale Returns 🐋💣

1 month ago
43

🚀 META_quant 4D Bridge – Now Available as an .exe Version!

1 month ago
42

Understanding Market Trap Detection: The Quantitative Edge in Ultra-Short-Term Scalping

1 month ago
47

⚡ 12 Real Advantages of Reading Volume Price Impact in 4D with META_quant 4D

1 month ago
54

🚀 META_quant 4D – Anticipating the BTCUSDT Bullish Expansion

1 month ago
39
© 2025 Bonzai Privacy Legal notice Terms of Use