Skip to main content

Market Data Collector

Polymarket and Kalshi don’t retain all historical data indefinitely. Orderbook depth, trade history, and market metadata can disappear. The collector module creates a persistent PIT (point-in-time) data archive that captures:
  • Full L2 orderbooks: every bid/ask level at configurable intervals
  • Trade-by-trade history: individual trades with deduplication
  • Market metadata: names, tokens, volumes, liquidity, status
  • Event metadata: event-level data with associated markets

Two Modes

Pipeline Mode

Integrate directly into your hz.run() strategy to record orderbooks alongside trading:

Standalone Daemon

Run as a 24/7 passive collector without any trading:
Or with full configuration:

Parquet Export

Export collected data to Parquet for batch analysis with pandas, polars, or DuckDB:
Requires pyarrow:

Query Helpers

Query collected data directly:

Programmatic Access (Rust)

For maximum control, use the Rust Collector directly:

Schema Reference

orderbook_snapshots

market_trades

market_metadata

Storage Estimates

Use retention_hours and purge() to control storage growth. Parquet export + purge is recommended for long-term archiving.