Day 20 — The store, part one: schema and ingestion
Wednesday, 26 August 2026 · Week 3 of 52 · Markets · Study day · 60 min
Everything for the next eleven months reads from this, so the schema decisions today are the ones you will live with, and the two-date rule from yesterday is the one that matters most.
What you should be able to do tonight
- Justify each column in your bars table, including the two date columns, to someone who thinks one date is enough.
- Re-run the ingestion from an empty directory with one command and get an identical file.
Tasks 60 min
30 min Write qlib/store.py: a DuckDB database with three tables. security with an internal integer id, ticker, valid_from, valid_to. bar_daily with security_id, session_date, open, high, low, close, volume, and ingested_at. corporate_action with security_id, effective_date, action_type, factor, and ingested_at. Create them with explicit types and a primary key on each.
30 min Write qlib/ingest.py: pull daily unadjusted bars for your universe via yfinance, map tickers to security ids, and insert. Make it idempotent, so running it twice does not double the rows. Use a session calendar from exchange_calendars to assert you have no bars on non-trading days.
The running strategy
The data store begins. qlib/store.py defines the schema and qlib/ingest.py fills it; every table carries both the date a fact refers to and the date you learned it, which is the constraint that makes point-in-time queries possible later rather than retrofitted.
Resources
Deliverable
data/prices.duckdb, populated with unadjusted daily bars for your universe, created by one command from an empty directory.
Checkpoint
Why does bar_daily need an ingested_at column when a daily bar is never revised? Answer in terms of what you will want to know in March.
Prepare for tomorrow
Ten minutes tonight so Day 21, Thursday, 27 August 2026 starts clean. This is what the evening email sends you.
Run the ingestion once more from scratch and time it. Write the number down; it is the number you will complain about in week 20.
Count the rows and the distinct securities in your store, and check both against what you expected.
Look at the arithmetic drill numbers from days 7 and 14 so you know what you are trying to beat tomorrow.