Fast, exchange-agnostic trade tick aggregation for market data pipelines.
tick-to-ohlcv converts raw trade CSVs into clean OHLCV candles with volume,
turnover, trade counts, taker buy/sell volume, optional flat gap candles, and
CSV or Parquet output. It is built for crypto, FX, equities, and any market
where raw ticks need to become analysis-ready candles.
- Generic CSV mapping: point the tool at your timestamp, price, size, symbol, side, turnover, and trade-id columns.
- Fast Rust CLI: aggregate large folders of trade files without writing one-off scripts.
- Python compatibility: use the same core ideas from Python data pipelines.
- Flexible intervals: create
1m,5m,1h, daily, or custom-second candles. - Gap filling: emit zero-volume flat candles between observed trades when you need continuous time series.
- CSV and Parquet output: write quick CSVs or columnar datasets for analytics.
- Folder discovery: include and exclude file patterns under a root instead of listing every input file.
Build the Rust CLI:
cargo build --releaseInstall the Python package:
pip install tick-to-ohlcvInstall Python with optional Parquet support:
pip install "tick-to-ohlcv[parquet]"Convert one CSV file to one-minute candles:
tick-to-ohlcv csv trades.csv \
--symbol BTCUSDT \
--timestamp-column timestamp_ms \
--price-column price \
--size-column size \
--turnover-column quote_volume \
--side-column side \
--trade-id-column trade_id \
--interval 1m \
--output candles.csvDiscover many files, fill gaps, and write Parquet:
cargo run --release -- csv \
--input-root /data/raw-trades \
--include "**/*.csv" \
--exclude "**/bad/*.csv" \
--symbol-column symbol \
--timestamp-column timestamp_ms \
--price-column price \
--size-column size \
--turnover-column notional \
--side-column side \
--interval 5m \
--fill-gaps \
--output-format parquet \
--output /data/candles.parquetUse second timestamps instead of milliseconds:
tick-to-ohlcv csv fills.csv \
--symbol ETHUSD \
--timestamp-column time \
--timestamp-unit s \
--price-column px \
--size-column qty \
--interval 1h \
--output eth_1h.csvCandles use Unix-second interval starts and ISO UTC datetimes:
symbol, ts, datetime, open, high, low, close, volume, turnover,
trade_count, buy_volume, sell_volume, first_trade_ts_ms, last_trade_ts_ms
Notes:
volumeis base-asset volume.turnoveris quote/notional volume when provided, otherwiseprice * size.buy_volumeandsell_volumeare taker-side base volumes from the mapped side column.- Gap candles have
trade_count = 0, zero volume/turnover, and flat OHLC.
from pathlib import Path
from tick_to_ohlcv import CsvTradeMapping, aggregate_csv_files, discover_files, write_candles
from tick_to_ohlcv.intervals import parse_interval_seconds
files = discover_files(
input_root=Path("/data/raw-trades"),
include_patterns=["**/*.csv"],
exclude_patterns=["**/bad/*.csv"],
)
mapping = CsvTradeMapping(
symbol_column="symbol",
timestamp_column="timestamp_ms",
price_column="price",
size_column="size",
turnover_column="notional",
side_column="side",
trade_id_column="trade_id",
)
candles = aggregate_csv_files(
files,
mapping,
interval_seconds=parse_interval_seconds("1m"),
fill_gaps=True,
)
write_candles(candles, output=Path("/data/candles.csv"))- Rebuilding OHLCV candles from public trade archives.
- Normalizing multiple venues into one candle schema.
- Creating research datasets from raw fills.
- Backtesting and market microstructure workflows.
- Converting tick data to Parquet for warehouse or lakehouse ingestion.
Fast Rust/Python CLI for converting raw trade ticks into OHLCV candles, CSV, and Parquet.
ohlcv, tick-data, market-data, crypto, trading, parquet, rust-cli, python, csv, candles