Skip to content
All library documents

Using CSV Files as a Custom Backtest Data Source

Article FMZ digest · Author: 发明者量化-小小梦

Summary

The document explains how to adapt a market data collector so a trading platform’s backtester can read historical bars from a CSV file. A configuration flag selects between CSV input and data previously collected into a database, while a file path identifies the CSV on the server. The service parses the header, maps columns into the expected time and OHLCV schema, applies requested price and volume precision, and returns records to the backtesting system through an HTTP endpoint.

The accompanying example describes running the service and requesting bars with a simple strategy, then comparing the resulting chart with the source file. It also outlines the alternative database-backed path, where the collector stores bars and serves a time-filtered query. This is a practical data plumbing example rather than a trading method or performance study. CSV consistency and correct timestamp, column, and precision handling matter; the described implementation assumes a compatible file layout and server setup.

Key ideas

  • A custom HTTP data provider can make local CSV bar data available to a backtesting engine.
  • A mode flag selects CSV input or data stored in a database.
  • The provider maps CSV columns to time, open, high, low, close, and volume fields.
  • The example checks that bars returned to a strategy match the source file.
  • Backtest reliability depends on correct column mapping, timestamps, and numeric precision.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.