Skip to content
All library documents

Loading OHLCV Bars from CSV into a Trading Database

Article Quant course library

Summary

This document describes a workflow for importing historical bar data from a CSV file into a trading database. The operator configures the input file, instrument symbol, exchange, bar interval, and the column names corresponding to timestamps and OHLCV fields. A row-by-row reader then parses the file and prepares a database record for each bar.

Most fields are mapped directly from CSV columns, while timestamps require conversion using a specified date-time format. The record also includes a combined instrument-and-exchange identifier and a database gateway label. A replace operation writes each record and can update an existing bar. The explanation gives a practical outline and brief field examples, but does not cover validation, malformed rows, duplicate handling beyond replacement, transaction management, or performance for large files. Its database and instrument examples are illustrative and should be checked against the actual venue and contract being loaded.

Key ideas

  • Configure the file path, instrument, exchange, bar interval, and CSV column names before importing.
  • Read the CSV as dictionaries and process the records row by row.
  • Parse timestamps using a format that matches the source data.
  • Populate the database bar with OHLCV values and a combined instrument-exchange identifier.
  • A replace operation can update an existing stored bar.

Tags

From a private course collection; the original is not published.