Store the bars in a compact binary file and memory-map it, so the operating system loads only the pages the backtest reads. Converting once from CSV to a fixed-width binary format removes the parse step and the memory limit together. Chunking a CSV by hand also works but breaks indicators and open positions at every chunk edge.
How big the data really is
Minute data grows fast. One ticker trading 24 hours a day, like crypto, has about 525,000 minute bars a year. Ten years is 5.3 million bars. At 64 bytes a bar that is about 340 MB per ticker; five hundred tickers is about 170 GB. Loaded into pandas, the same data often takes two to five times as much, because of the index, object columns and intermediate copies made during calculations.
So the limit usually appears when you go from one ticker to a universe, or from minute bars to second bars.
Ways around it
- Smaller types. Store prices as
float32and volume as integers. This halves memory but loses precision on high-priced instruments. - Columnar files. Parquet with a column filter reads only the columns you need and compresses well, but the data still has to be decoded into memory.
- Chunking. Process a year at a time. It works, but indicators must be warmed up again at each boundary, and positions open at the end of a chunk must be carried across by hand.
- Memory mapping. Write the bars once to a fixed-width binary file and map it. The operating system pages in only what the backtest reads and drops it again under memory pressure. There is no parse on each run, and the file can be larger than RAM.
- A database. Time-series databases suit huge research data sets, but they add a server and a query step before every run.
Practical tips
- Convert once, run many times. Parsing CSV is often slower than the backtest itself.
- Keep one file per ticker. It makes selecting a universe a matter of choosing files.
- Select time ranges without copying. A run over 2020–2022 should read those bytes and no others.
- Watch the strategy's own memory. Storing every bar in a Python list inside the strategy undoes all of the above.
How Reamer Research handles it
Reamer Research reads .bin files in its own 64-byte bar layout. When every ticker in a run is a .bin path, the engine maps the files in place instead of copying them into Python, so a run starts without a parse step and data larger than RAM still runs. start= and end= pick a time range inside a file without rewriting it.
import reamer_research as rr
rr.write_bin('data/BTCUSD.bin', 'BTCUSD_2015_2025_1min.csv') # once
result = rr.backtest(MyStrategy(), 'data/BTCUSD.bin', start=1_577_836_800, end=1_672_531_199)
MyStrategy can be a class, a configured object or a function on_bar(data). rr.write_bin takes anything rr.to_bars takes: a CSV path, a NumPy array, a list of tuples or a pandas DataFrame. The kit's bin/reamer-csv-build does the same from the command line, and examples/data_bin.py shows the whole flow. The strategy sees only a window of lookback bars at a time, so its memory stays fixed however long the history.
Limits to know
- Memory mapping applies when every input is a
.binfile. DataFrames and arrays passed directly are copied into the run. - Long histories need a licence. Evaluation Mode runs one ticker over at most 30 days or 50,000 bars.
A $20 month includes the full kit and the converter, so you can convert your own history and run it end to end.