Skip to content
All library documents

Collecting OHLCV Records for a Custom Backtest Data Source

Article Strategy library · Author: 发明者量化-小小梦

Summary

This utility collects exchange candlesticks and serves them to a custom data source for backtesting. In collection mode, it reads bars from the exchange, stores completed records in MongoDB, and checks timestamps to avoid duplicate inserts. An HTTP endpoint responds to data requests with time, open, high, low, close, and volume fields, applying the requested price and volume precision. In CSV-only mode, the endpoint reads the same bar fields from a configured file instead of the database.

The document also describes optional table deletion and logging, and notes that the backtest interface requires selecting an exchange name for a custom source. It is data infrastructure rather than a trading method: it provides no signal rules or performance evidence. Its usefulness depends on correctly aligned CSV headers, timestamps, bar periods, and precision settings. The shown service uses a local MongoDB connection and a basic HTTP server; deployment, data validation, access controls, and handling malformed requests are not addressed in the explanation.

Key ideas

  • The collector stores exchange OHLCV bars in MongoDB and skips records with existing timestamps.
  • An HTTP endpoint serves requested bars in the schema expected by the backtest source.
  • CSV-only mode supplies bar data from a file instead of the database.
  • Price and volume values are converted using precision parameters from the request.
  • The document explains data plumbing but provides no trading rules or strategy results.

Tags

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