FAQ · Getting systematic research right

How do I backtest years of minute data that won't fit in RAM?

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.

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 float32 and 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 .bin file. 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.

Next questions

Why is my Python backtest so slow?Usually because a Python loop does expensive work on every bar, and that cost is multiplied by every bar and every run. Reading a value through pandas inside the loop is often the largest part. In one test, reading a single column row by row took about 12 seconds per 500,000 bars with iterrows and about 0.06 seconds with a NumPy array. Profile first, move data out of pandas before the loop, precompute what you can, run sweeps in separate processes, and move the loop to compiled code only if that is still not enough.How do I backtest a portfolio of several tickers?Run every ticker in one backtest against one shared account, so positions compete for the same capital and margin. Process bars in time order across all tickers, act on each ticker only when it has a fresh bar, and size each position against total equity. Testing tickers one at a time and adding the results misses the shared capital constraint.Where does the market data come from?From whichever vendor you choose, in one call. Reamer Research's bundled fetchers pull historical bars from your own Alpaca or Databento account straight into a backtest, and bars of any type from any other source go in as arrays or as memory-mapped files built from CSV. You pick the vendor, pay it directly and switch whenever you like, and the engine stays lean because it carries no data feed of its own. Reamer Server takes orders from your strategies, which price from your own feed.How do I do walk-forward testing in Python?Split your history into consecutive windows. Tune the strategy on one window, test the chosen settings on the next window it has never seen, then roll both forward and repeat. The out-of-sample pieces joined end to end are your walk-forward result, and they are the only part that counts.

Every answer here restates the documents that ship in the kit, which are authoritative. All questions.

Reamer Research

Your first backtest in a minute

Backtesting and live trading in Python and C++. Free to install in Evaluation Mode, with no key or sign-up.

pip install reamer-research

A licence at $20 a month removes every limit. The same code runs unchanged.

Reamer Server

The order-management core for your firm

Your venues, your risk rules on every order, one strategy per CPU core, on your own Linux servers.

$24,000 / year

Or start with a 30-day trial at $2,000.