Prompt
How do I store financial tick data efficiently over long periods?
Latest observation
Storing financial tick data efficiently over long periods is mostly about balancing compression, query speed, and data fidelity. The best approach depends on whether you mainly need:
- historical research / backtests
- real-time analytics
- regulatory audit / replay
- low-cost archival storage
Here’s a practical way to think about it.
1) Store raw ticks in an append-only, compressed format
Tick data is naturally time-ordered and append-only, so avoid row-store databases as the primary archive unless your query needs demand it.
Good storage formats:
- Parquet: very common, columnar, compressed, great for analytics
- ORC: similar to Parquet, also efficient
- Zstandard (zstd) compression: often better balance than gzip
- Delta Lake / Apache Iceberg / Hudi: if you want table management, partitioning, schema evolution, and ACID-like workflows
Why columnar works well:
- You often query only a few fields: time, symbol, price, size, exchange, condition
- Compression is much better when values are similar within a column
- It supports fast scanning over time ranges
2) Partition by time and symbol
Partitioning matters a lot for long-term storage.
Typical scheme:
date=YYYY-MM-DD/- optionally
symbol=BTCUSD/orvenue=NASDAQ/
For very large universes, too many symbol partitions can create “small file” problems, so often:
- partition by date
- cluster/sort by symbol within each file
Example:
ticks/
date=2026-10-25/
part-0001.parquet
part-0002.parquet
If you need quick symbol-specific queries, you can add:
- bucketing
- secondary indexing
- sorted files by symbol, timestamp
3) Normalize the schema
Don’t store repeated text strings unnecessarily.
Use compact fields:
ts_eventas int64 epoch nanosecondssymbol_idas int32/int64 instead of stringexchange_id,condition_code,sideas small integers/enums- prices as:
- integer “ticks” if possible
- or scaled integers like price × 1e4 / 1e6
Example schema:
ts_event_ns: int64symbol_id: int32price: int64(scaled)size: int32side: int8exchange_id: int16trade_id: int64
This improves:
- compression
- CPU efficiency
- storage size
4) Separate raw and derived data
Keep two layers:
Raw layer
- exact vendor feed or consolidated tick record
- immutable
- used for audit, reconstruction, and reprocessing
Derived layer
- cleaned, deduplicated, normalized
- maybe aggregated to 1ms/1s bars or event-based features
This prevents repeatedly recomputing from raw and lets you optimize different use cases.
5) Use hierarchical retention tiers
Long-term tick storage gets expensive fast, so use tiers:
- Hot: recent data in fast storage (SSD / local NVMe)
- Warm: compressed columnar files on object storage or network storage
- Cold/archive: infrequently accessed older data in cheaper object storage
You can also retain:
- full tick data for 1–3 years
- downsampled bars or summaries indefinitely
This is common if full replay beyond a certain point is rarely needed.
6) Deduplicate and compress intelligently
Ticks often contain:
- repeated quotes
- duplicate vendor messages
- out-of-order records
- canceled corrections
Strategies:
- deduplicate on a unique event key if available
- store corrections separately or as versioned events
- use compression codecs like:
- zstd
- snappy for speed
- lz4 for very fast reads
If your data has lots of repeated prices/sizes, columnar compression works especially well.
7) Consider event sourcing for exact replay
If you need exact market replay or full auditability:
- store every inbound event exactly as received
- assign a monotonic ingest sequence
- keep metadata like source feed, receive timestamp, and sequence number
This is more robust than trying to store only “cleaned ticks.”
8) Use a database only for indexing, not as the main archive
Databases like:
- ClickHouse
- TimescaleDB
- kdb+
- QuestDB
can be excellent if you need interactive querying. But for very large long-term archives, many teams use:
- object storage + Parquet
- plus a query engine on top:
- DuckDB
- Spark
- Trino
- ClickHouse external tables
A common hybrid:
- Parquet on S3/GCS/Azure Blob
- metadata/index in a database
- query engine for analytics
9) Keep metadata catalogs
Store metadata separately:
- symbol mapping history
- corporate actions / splits
- trading session calendars
- vendor source info
- schema versions
- data quality flags
This is essential because tick data alone is not enough to interpret values correctly over long periods.
10) Practical architecture recommendation
A solid default design:
-
Ingest
- receive raw feed
- write immutable raw events immediately
-
Normalize
- convert to compact schema
- map symbols to IDs
- store timestamps as integers
-
Persist
- write daily Parquet files
- partition by date
- sort by symbol, timestamp
- compress with zstd
-
Query
- use DuckDB/ClickHouse/Spark/Trino depending on scale
-
Archive
- move older partitions to cheaper storage
- keep metadata/indexes online
11) If you want maximum efficiency
For very large scale, use:
- Parquet + zstd
- date partitions
- symbol integer encoding
- scaled integer prices
- sorted files
- object storage
- Iceberg/Delta/Hudi for table management
That combination is usually the best tradeoff.
12) Quick rule of thumb
If you’re unsure, start with:
- Parquet
- partition by day
- sort by symbol, timestamp
- zstd compression
- store prices and timestamps as integers
- keep raw and cleaned datasets separate
That will scale much better than CSV, JSON, or a naive SQL row table.
If you want, I can also give you:
- a sample schema for tick trades and quotes,
- a recommended file layout, or
- a Python implementation using PyArrow/Parquet.