One source, checked on arrival
The only source of market history is Binance’s public archive of USDT-margined futures. It needs no account and no key, and every file it publishes comes with a SHA-256 checksum. Each download is checked against that checksum before anything is written. The archive was chosen partly because the exchange’s own API was blocked by the development machine’s internet provider. For the same reason, each instrument’s price and size steps were derived from the archived prices.
- Download a monthly or daily archive file
data.binance.vision - Check it against the published checksum A file that does not match is never written.
- Keep the one-minute bars Times are converted to seconds once, here.
- Roll the longer timeframes from the minutes A bucket the minutes only partly cover is dropped, not guessed.
- Write each month to Parquet To a temporary file first, then renamed, so a crash never leaves half a month.
- Read it through DuckDB The loader stamps each bar at its close, in the engine's nanoseconds.
FIG. 1 How a month of market history enters the store.
Stored by month, from one-minute bars
Only one-minute bars are downloaded. The longer timeframes, from five minutes to a day, are rolled from them month by month when the month is written, never on request. Each symbol, timeframe and month is one file:
{store}/klines/{SYMBOL}/{timeframe}/{YYYY-MM}.parquet
{store}/funding/{SYMBOL}/{YYYY-MM}.parquet
A month counts as done only when its minutes reach the month’s last minute, which is read from the file itself. There is no separate record of what was fetched that could drift from the files. The research store holds 101 symbols, each back to the first month Binance archived.
Holes in the archive
Binance’s monthly files are not always complete. For some symbols they skip whole days that its daily files do have, so before a month is written those days are fetched from the daily files. A single missing minute is reported but does not stop the month; a structural fault does. A coverage check sorts every shortfall into missing, shallow or stale, and fails while there is one.
The archive publishes a day’s file several hours after the day ends, so the store is never real time. On the server, a timer fetches the current and the previous month every hour. The engines take their latest bars from the exchanges’ live feeds, not from the store.
Postgres holds what happens; Parquet holds what happened
Market history never enters the database. Postgres holds what the live system writes: the event log, the job queue and the control tables. There is no candles table and no fills table; positions and results are folded from the events.
A bar is known at its close
The store counts time in seconds and the engine in nanoseconds, and the conversion happens in exactly one place, the loader. The same loader stamps each bar at its close, not its open. A daily bar that opens at midnight is only knowable at the next midnight; stamping it earlier would let a strategy act on a candle that had not finished.
Pinned slices
Research numbers are pinned to a slice of the store that is committed with the code, bounded at both ends, and rebuilt byte for byte from the same command. A number pinned to an archive that keeps growing is not pinned.