joshriang
← Back to portfolio

Quant research & trading·Python·Published

Market Data Store

Every research project I had was re-downloading the same Yahoo history and re-parsing it, so this is the storage layer I now put underneath them. Bars persist as partitioned Parquet at {root}/ticker={TICKER}/year={YYYY}/data.parquet with a schema version stamped on write and idempotent deduplication, so re-running a load does not double the row count. YFinanceLoader pulls incrementally, asking only for rows newer than the last stored bar, which turns a full-history refresh into a handful of rows on the second call. ReplayEngine streams bars chronologically into an on_bar(bar, state) -> state callback with the state threaded through, and it supports wall-clock pacing where speed=1.0 means one second per bar of calendar time and speed=0 means as fast as the machine allows. The Bar, Tick and Quote dataclasses are tz-aware UTC, which is the detail that saves me from silent off-by-one-day joins later. Tests cover callback ordering, sorting, state threading, speed pacing and error handling, all synthetic.

Date
2026
Main stack
Python
Code
github ↗
01
02
  • Partitioning by ticker and year makes a single-ticker read touch one file instead of scanning the whole store, and it makes deleting a bad year a directory operation rather than a filter.
  • Idempotent dedup on write is what makes an incremental loader safe to re-run; without it every retry after a partial failure silently duplicates rows and every downstream return calculation is wrong.
  • Threading state through the replay callback instead of holding it on the engine means the same replay code can drive a stateless strategy and a stateful one without a special case.
03

Scale 0–100: how much this project relied on each skill.