2 Commits

Author SHA1 Message Date
ramseshk 00bb06434e fix: collector WebSocket trade parsing + DuckDB 1.5 API compatibility
data/collectors/hyperliquid.py:
- Fixed _handle_trades to handle HL WebSocket trade data as list[dict]
  (each trade dict has its own 'coin' field) instead of assuming single dict
- Fixed _poll_funding and _poll_open_interest to guard against
  data[0] being list vs dict (mainnet vs testnet response format difference)

data/duckdb_load.py:
- Replaced deprecated duckdb.from_sequence() with executemany() for
  l2_snapshots, trades, and funding table inserts (DuckDB 1.5.x API)

Tick runner verified on real mainnet BTC data:
- 324 events (45 L2 + 279 trades), VPIN-gated A-S MM, 1 trade, 98 cancels
- HFT dashboard generated with 8 panels from real tick data
2026-08-11 14:45:48 +08:00
ramseshk a7f811eb81 feat: Phase 1 — real-time & historical data system
New data/ module with:
- data/store.py: Parquet-based raw message storage with background writer
  thread. Messages partitioned by channel/coin/date. Thread-safe queue.
  Supports pyarrow Parquet with zstd compression. Includes read_range()
  helper for replay.

- data/collectors/hyperliquid.py: HL WebSocket + REST collector
  - WebSocket: l2Book (full book reconstruction), trades, allMids (mark prices)
  - REST pollers: funding rates, predicted funding, open interest, liquidations
  - Per-coin OrderBook class with snapshot/update reconstruction
  - Sequence gap detection with per-coin re-snapshot on gap
  - Latency tracking (exchange transport, signal, order, roundtrip)
  - Periodic stats reporter (book stats + latency summary every 60s)
  - CLI entrypoint: python -m data.collectors.hyperliquid --coins BTC ETH

- data/normalizer.py: Timestamp normalization (ms, s, ISO strings from
  HL/Binance/Bybit/OKX/Coinbase/Deribit) + SequenceTracker with gap detection

- data/latency.py: Rolling-window latency metrics (p50/p90/p95/p99) for
  transport, signal computation, order submission, and roundtrip

- Added pyarrow + aiohttp to requirements.txt
2026-08-07 14:28:21 +08:00