ClickhouseBenchmark
Replacing the HDB: ClickHouse for historical ticker data
Summary
Historical market-data systems separate a durable archive from the real-time trading path, but the archive still must support research, backtesting, transaction-cost analysis, and regulatory reconstruction. The worked example uses Binance’s public archive to load trades and quotes for five USD-M perpetual-futures symbols into ClickHouse, with a MergeTree table ordered by (symbol, ts) and codecs including DoubleDelta and ZSTD. SQL queries calculate VWAP, hourly OHLC candles, and as-of joins, while ClickHouse’s sparse primary index skips most granules for symbol-and-time filters. Across ten months, 16.2 billion rows compress to 76 GiB on disk; the post reports a ClickHouse Cloud cost of $1.88 per month and argues that typical symbol-and-time queries retain low latency at that scale, while broader scans read more data.
Context
Historical market data is typically divided between a real-time tier for live and current-day queries and a durable historical tier for research, backtesting, transaction-cost analysis, and regulatory reconstruction. The historical tier is presented as a lower-risk place to evaluate a database because it does not affect the live trading path, does not require microsecond latency, and has a well-understood workload.
Approach / What changed
The example loads Binance’s public market-data archive into ClickHouse. Trade data is stored in a MergeTree table ordered by (symbol, ts), with LowCardinality, Decimal, Boolean, DoubleDelta, and ZSTD encodings. Data can be ingested directly from ZIP archives, and SQL queries demonstrate VWAP, OHLC candles, as-of joins, and symbol-and-time filtering that uses the sparse primary index to skip most granules.
Takeaways
ClickHouse stores ten months of trades and quotes for five busy futures pairs—16.2 billion rows—in 76 GiB, with a reported ClickHouse Cloud cost of $1.88 per month.
The demonstrated trading-desk operations—VWAP, hourly OHLC candles, and as-of joins—are expressed as standard SQL queries.
For symbol-and-time filters, the (symbol, ts) primary key lets ClickHouse read only matching granules; queries without those dimensions scan more data.
Source and freshness
- Source
- clickhouse.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.