How CME futures history gets from Databento into LRBO3, stays current every day, and reaches a backtest, all on Robodev. Options are sized at the end and need AWS when they start.
The short version: a scheduled Robodev job runs once a day. It reads how far each feed is loaded, pulls only the days after that from Databento, keeps the raw files in Robodev storage, and writes compact bar chunks into the Postgres the app already uses. A backtest reads only the chunks its date range needs. Nothing new is deployed: the job ships with the backend.
Three things are known constraints. The rest are unknowns that need an answer before the build starts, mostly from the Robodev team.
| Constraint | What it means |
|---|---|
| DuckDB cannot run in Robodev | Robodev installs only allowlisted JavaScript packages, and DuckDB ships a native binary. DuckDB is a laptop tool over the stored raw files, and there is no Parquet copy. If DuckDB must be part of the pipeline, the ingest has to run on AWS. |
| Options do not fit on Robodev | About 725 GB a year and backtests that must run next to the data. Options need AWS when they start, whatever is chosen for futures. |
| Each environment holds its own data | Preview and production have separate databases and storage, so the backfill runs once per environment: twice the storage and twice the job time. |
| Unknown | What the plan needs | If the answer is no |
|---|---|---|
Job time limit (timeoutMs) | A minute or more per run | Fewer slices per run; the backfill takes more runs |
| Job memory | ~100 MB: one slice and one chunk at a time | Daily slices in the backfill too |
| Job overlap and queue limits | A job that queues itself thousands of times during the backfill, and a daily run that never overlaps one already running | A lock row in Postgres; a slower backfill driven by the cron alone |
| Storage quota and largest file | ~6 GB per environment, files up to ~20 MB, uploaded from memory in one piece | Keep no raw files and re-download from Databento when needed |
| Reading storage from outside | A way to list and download the raw files to a laptop for DuckDB | An admin route that hands out signed links (ctx.storage.getUrl) |
| Postgres quota | ~1.5 GB per environment | No fallback on Robodev; the data has to live elsewhere |
| Postgres load during the backfill | Hours of chunk writes on the database the app is using | Throttle the job; run the backfill off-hours |
| Failure alerts | Someone is told when a daily run fails | The job sends an email itself (ctx.email); the app shows stale "data through" |
| Unknown | Why it matters |
|---|---|
| When a session becomes available on the historical API for our plan | Sets the schedule hour and how fresh "data through" can be. One check with the key answers it. |
| Whether the $0 price holds for daily pulls and re-downloads | The sizing run priced the 5-year pull at $0 on the current plan. The lookback re-reads three days every run. |
| Licence terms for storing the data and showing it to the client's traders | We keep a full copy and display prices derived from it. Worth confirming against the plan's terms. |
jobs/market-data/ingest.ts, defineJob with a daily cronctx.storage: each raw slice as downloaded, gzipped, privaterecord loads the range, engine builds the continuous series and runs| Schema | What it gives us | Records, 5 y | Raw size | Per day |
|---|---|---|---|---|
definition | Every contract: symbol, expiry, tick size, multiplier, instrument class | 8.98 M | 4.67 GB | ~3.7 MB |
ohlcv-1m | One-minute bars per contract | 70.5 M | 3.95 GB | ~3 MB |
statistics | Settlement price, open interest, cleared volume per contract per day | 79.1 M | 6.33 GB | ~5 MB |
ES.FUT and so on). Those include calendar spreads, so the job keeps outright futures only (instrument class F). About 30 M of the 70.5 M bars are outrights. est.The backfill and the daily update are the same job. On the first run the watermarks sit five years back and the job works forward a slice at a time. Once caught up, each daily run moves them forward by one day.
metadata.get_dataset_range, free).fetch on timeseries.get_range as CSV with integer prices and timestamps. The gzipped response goes to ctx.storage under a key named after the slice, so a retry overwrites the same file.packages/market-data: read the rows, drop spreads using the contracts table, convert prices to ticks (ADR-0003).metadata.get_record_count). Only when it matches does the watermark advance.ctx.jobs.enqueue) and exits. The run and its counts go into ingest_runs.Final settlement and open interest for a session arrive the next morning, and the vendor can correct recent data. Re-reading the last three trading days every run picks that up. Every write is an upsert on a deterministic key, so reprocessing is harmless.
The watermark only moves after Postgres has the slice, so the next run starts from the same place and overwrites the same files and rows. A failed run is a row in ingest_runs with its error; the app shows "data through" from the watermarks.
About 9,400 weekly slices (12 products, 3 schemas, 260 weeks), a few MB each. At a few seconds a slice that is several hours of job time, spread over many self-queued runs. It is started once by hand and can be stopped and resumed at any slice.
Schedule: cron: "0 6 * * *", daily at 06:00 UTC. A run with nothing new exits in seconds. The exact hour depends on when Databento's historical API releases the previous session; step 1 reads the available range instead of assuming it.
market-data/raw/glbx-mdp3/{schema}/{parent}/{yyyy}/{mm}/{slice}.csv.gz as downloaded, never edited, private
Roughly 4-6 GB gzipped for the five years. est. If Postgres is ever wrong, it is rebuilt from these files without calling Databento again. They are also what DuckDB reads for analytics, and what moves to S3 unchanged when options start.
| Table | Key | Holds | Size |
|---|---|---|---|
futures_contracts | product + expiry month (ES:2025-12) | Raw symbol, last trading day, tick size, multiplier, first and last bar | ~2,000 rows |
futures_bar_chunks | contract + month | That month's 1m bars in the existing compact encoding (ticks, epoch minutes), bar count, SHA-256 | ~1.4 GB |
futures_daily | contract + trading day | Settlement, open interest, volume | ~0.5 M rows |
market_data_watermarks | dataset + schema + product | Loaded through, updated at | 36 rows |
ingest_runs | run id | Started, finished, status, slices, record counts, error | a few rows/day |
Contracts are keyed by product and expiry month, not by raw symbol or instrument id: ESZ5 means December 2015 and December 2025, and instrument ids can be reused.
futures_bar_chunks, not in dataset_chunks. One market dataset per product, created by the first ingest.Datasets.bars(dataset) gains a date range. For a market dataset it picks the contracts whose life overlaps the range plus the indicator warm-up, and reads those contract-month chunks by primary key. Today it decodes every chunk of the dataset.futures_daily feeds the volume and open-interest rolls.| 2-year run, 1-minute bars | Time | Basis |
|---|---|---|
| Read ~35 MB of chunks from Postgres | 0.2-0.5 s | Estimate; depends on the hosted database |
| Decode 765k bars | 0.07 s | Measured on a laptop |
| Engine, 10 indicators, ~5,000 trades | 0.9 s | Measured: 450 ms per year |
| Total | 1.5-3 s | Runs stay inside Robodev, synchronous as today |
| Where | Change |
|---|---|
packages/market-data (new) | Framework-free rules: slice planning from watermarks, the Databento CSV rows, outright filter, contract keys, merging bars into a chunk. Unit-tested without Robodev or Databento. |
apps/robodev-be/jobs/market-data/ingest.ts (new) | The job: thin wiring of the package to fetch, ctx.storage, ctx.db and ctx.jobs. Reads DATABENTO_API_KEY from ctx.env. |
apps/robodev-be/database.ts | The five tables above. |
apps/robodev-be/api/market-data (new) | Coverage per product for the app ("data through"), and an admin route that queues a run or the backfill by hand. |
packages/record | The market dataset kind and range reads in Datasets; Runs passes its range through. |
scripts/market-data-sync.ts (new) | Downloads the raw files to a local folder for DuckDB. |
docs/adr/0009 | The decision this page describes, once agreed. |
Options on ES, NQ and RTY are a different size class and do not fit on Robodev. The plain parents (ES.OPT, NQ.OPT, RTY.OPT) miss the weeklies and dailies; covering them takes 58 option products.
| Last 12 months, all 58 products | Records | Raw size |
|---|---|---|
bbo-1m (best bid and offer per minute) | 8.83 B | 706.6 GB |
definition | 36 M | 18.7 GB |
| Total, growing about 2.8 GB per trading day | ~725 GB |
AWS S3. Raw compressed is roughly 150 GB and a Parquet copy roughly 70-110 GB. est., to measure on one month
Parquet is partitioned by underlying and trading day, sorted by expiry, strike and minute. Not Postgres: 8.8 billion rows would cost more to index than to store.
Yes, this is what it is good at. It is a library inside the worker, not a server. It reads partitioned Parquet from S3 and skips what a query's filters rule out, so one underlying, one day and a band of strikes is tens of MB. It needs to run in the bucket's region with a few GB of memory.
packages/market-data, Databento's batch download for the 725 GB backfill.About $10-30 a month pay-per-run, $180-200 with an always-on worker. est., us-east-1 list prices
What carries over from the futures build: the slice and watermark rules, the contract keys, the raw files, and the engine, which is framework-free. What is new then: the AWS account, the bucket, the two workers, and the decision whether the rest of the app follows them to AWS.
packages/market-data.robodev dev for one product and one month.record; a real ES backtest end to end on that month.