Where Should Your Trading Data Live? CSV, Parquet or a Database
Most trading research starts the same way: export some bars, save them as CSV, load them into Python. That works for one symbol and one timeframe. It gets harder with years of history across many symbols, a collector adding bars every day, and a backtest or machine learning pipeline that must load exactly the slice it was designed for.
The question then is where the bar and tick history should live, in what format, and how it stays clean. This article compares the main options using their own documentation, including where each one stops.
Why a Folder of CSV Files Stops Scaling
CSV is a row format. To read one month of closes, a program usually reads every row and column, then discards most of it. Timestamps are just text, and nothing stops the same bar being appended twice when a download is re-run. Research code typically reads a few columns (time, close, volume) across long periods, which is the access pattern columnar formats are built for.
Parquet: Columnar Files for Bulk Reads
Apache Parquet describes itself as “an open source, column-oriented data file format designed for efficient data storage and retrieval”, with built-in compression and encoding schemes and support across many languages and tools (Apache Parquet, Overview). Inside a file, rows are split into row groups, each row group holds one column chunk per column, and column chunks are divided into pages (Apache Parquet, Concepts).
Parquet also has a proper timestamp type. Its TIMESTAMP logical type carries an isAdjustedToUTC flag: when true, each value counts time since the Unix epoch in UTC and “unambiguously identifies a single instant”; when false, it is a local wall-clock time that cannot be mapped to an instant without extra information (Parquet format, Logical Types). That matters for trading data. MetaQuotes’ Python documentation states that MetaTrader 5 stores tick and bar open times in UTC, and that Python creates local-time datetime objects by default, so requests should use UTC datetimes (MQL5 Reference, copy_ticks_range). The simplest rule is to store UTC instants, write them with a UTC-adjusted timestamp type, and convert to a local time zone only for display.
From Python, pandas can write Parquet directly with DataFrame.to_parquet, and its partition_cols argument splits the output into folders by column values (pandas, DataFrame.to_parquet).
Partitioning by Date and Querying in Place with DuckDB
A common layout is one folder per symbol and timeframe, then year and month folders underneath (for example year=2026/month=11/). This “Hive-style” partitioning means loading one symbol for one month touches only the files for that month.
DuckDB is an embedded analytical database that can query these files where they sit, with no server to run. It reads Hive-partitioned datasets with read_parquet(…, hive_partitioning = true), and filters on the partition keys are pushed down so files that cannot match are skipped (DuckDB, Hive Partitioning). It can also write partitioned output with COPY … (FORMAT parquet, PARTITION_BY (year, month)) (DuckDB, Partitioned Writes). Within a file, DuckDB reads only the columns a query needs and can use the statistics stored in Parquet to skip parts of a file that a filter rules out (DuckDB, Reading and Writing Parquet Files).
For one researcher or one VPS, Parquet files plus DuckDB is often all the storage needed.
Keeping the Data Clean: Keys and Safe Re-Runs
The quietest data problem is duplication. A download fails halfway, someone re-runs it, and some bars now appear twice. Nothing errors, but everything built on that data is subtly wrong.
The fix is a unique key, typically (symbol, timeframe, bar open time), enforced by the storage layer. DuckDB supports INSERT OR IGNORE, INSERT OR REPLACE and an ON CONFLICT clause on tables with a PRIMARY KEY or UNIQUE constraint; inserting a duplicate key into such a table without one of these clauses raises a constraint error (DuckDB, INSERT Statement). With a key in place, a collector can be re-run safely. Combined with UTC timestamps and date partitions, each backtest or training run loads the slice it was meant to.
When a Time-Series Database Fits Better
Files work best when one process writes in bulk and others read. They get awkward when a live collector, a dashboard and several research machines all write and read at once. SQLite’s own guidance is useful here. It allows any number of simultaneous readers but only one writer at a time, and where the data sits across a network from the application, a client/server database may be the better choice (SQLite, Appropriate Uses For SQLite). Its write-ahead logging (WAL) mode lets readers and a writer work concurrently, but all processes must be on the same host, and WAL does not work over a network filesystem (SQLite, Write-Ahead Logging).
For shared, continuously updated history, a server database designed for time series is the more natural home. TimescaleDB, a PostgreSQL extension, stores data in hypertables that are automatically partitioned by time into chunks, and routes queries to the relevant chunks instead of the whole table (Tiger Data, Understand hypertables). The cost is a server to run and maintain.
MetaTrader 5 Already Has a Database Built In
MQL5’s database functions use the SQLite engine, with the entire database in a single file. MetaQuotes lists uses including saving optimisation and test results, preparing and exchanging data with other analysis packages, and storing application settings and state (MQL5 Reference, Working with databases). For bulk inserts and changes to a database on disk, the same page recommends wrapping the work in DatabaseTransactionBegin, DatabaseTransactionCommit and DatabaseTransactionRollback.
DatabaseOpen takes a file name relative to the MQL5\Files folder, and the DATABASE_OPEN_COMMON flag places it in the common folder shared by all terminals (MQL5 Reference, DatabaseOpen). That sandbox matters: MQL5 programs can only work with files in MQL5\Files and the shared Common\Files folder (MQL5 Reference, File Functions). In the Strategy Tester, each testing agent has its own folder, so an EA’s file operations happen in that agent’s MQL5\Files rather than the terminal’s; opening a file with FILE_COMMON (DATABASE_OPEN_COMMON for a database) places it in the shared Common\Files folder, which local agents and the terminal can both reach (MQL5 Reference, Testing Trading Strategies). Recording test runs, settings or a journal in SQLite is a clean pattern; getting that data out to Python or a server needs a planned export step or the common folder.
Limits and Caveats
Parquet files are written in bulk and are not designed for row-by-row live updates, and the Parquet project itself warns that implementations don’t all support the same features, so mixing tools needs testing (Apache Parquet, Overview). SQLite has one writer at a time and is not suited to network-shared access. TimescaleDB’s uniqueness rules shape the schema: a unique index on a hypertable must include all its partitioning columns, which always includes time (Tiger Data, Enforce constraints with unique indexes). MetaTrader 5 databases live inside the file sandbox: the terminal’s MQL5\Files, a testing agent’s own folder during a test, or the shared Common\Files folder.
We have deliberately not quoted speed or size comparisons; they depend on the data, hardware and queries, while the mechanisms (fewer columns read, partitions skipped, writes batched) carry over. And clean storage says nothing about whether a strategy is any good, only that the data is what you think it is.
Conclusion
Where should your trading data live? For one researcher or one VPS, date-partitioned Parquet files with UTC timestamps, queried with DuckDB, cover most needs. When several services share the same history over a network, a server database such as TimescaleDB fits better. Inside MetaTrader 5, the built-in SQLite functions suit test results, settings and journals. Whatever the choice, a unique key on symbol, timeframe and time keeps the data honest.
Designing and running this kind of data storage is part of our Cloud Infrastructure work, and the MQL5 database side sits within our MetaTrader Services.
Drafted with AI assistance; reviewed, edited and approved by Ionut Claudiu Fratila.