Skip to main content
src/producers/replay_master.py · chapter Replaying the data, file 3 · 83 lines · open in the repository

What it does

Replay clean/master.parquet into Kafka, one trading day at a time, as if the past ten years were happening live. Run on the course cluster:
Faster or slower: —seconds-per-day 0.05 (2,514 trading days x 0.1 s = about 4 minutes) Local Kafka: —bootstrap localhost:9092 (or set KAFKA_BOOTSTRAP) Each message is one row of the master table as JSON, keyed by ticker:
Empty values (SPY’s views, ordinary days’ event_type) are sent as null. Testing late and out-of-order data (for the streaming job’s watermark):
holds back about 2% of messages and sends them 3 trading days late. The choice is random but repeatable (—seed), so the same test can be re-run.

Connections

Uses: src/common/contracts.py, src/common/settings.py

Source

src/producers/replay_master.py