language:
- en
license: other
tags:
- cryptocurrency
- order-book
- level2
- timescaledb
- postgres
- coinbase
- financial-data
- cbb26
- market-microstructure
pretty_name: CBB26 Timescale Market Data (Coinbase L2 replay shards)
size_categories:
- 10G<n<100G
CBB26 Timescale market data (cbb26-timeseries-db)
Public Timescale/Postgres replay shards for the cbb26 monorepo: canonical Coinbase Advanced Trade level-2 order book history stored in the market_data schema, packaged as restorable pg_dump files for research, corpus materialization, and reproducibility.
Canonical Hub repo: deusmos/cbb26-timeseries-db
Source-of-truth for this card (edit here, then publish): docs/datasets/cbb26-timeseries-db/README.md in the cbb26 git repo.
Start here
| I want… | Use this |
|---|---|
| ML tensors / training corpus | cbb26-day-corpus-v1 — Path A Quickstart |
| Raw L2 replay / own materialize | This repo — restore + materialize (Path B, hours) |
| Run a live collector | cbb26 repo + local Docker stack |
Not a row-oriented HF dataset. Files are
pg_dumpshards and JSON sidecars. Do not expectload_dataset()to return tabular rows. Usehf download+ the restore workflow below.
NDDS = Normalized Decimated Day Slabs — 10-second decimated, loader-normalized tensor slabs cached under
_ndds_cache/(~300 MiB/day on Hub). For pre-built NDDS bundles usecbb26-day-corpus-v1. Implementation:libs/day_raster_corpus/ndds_cache.py.
Why replay shards?
Timescale replay is base truth for what happened on the Coinbase L2 order book: checkpoints, anchors, and per-second deltas with carry-forward semantics. Materializing to tensors is lossy — bucket sizes, normalization, and decimation are design choices, not facts stored in the exchange feed.
Publishing replay as restorable pg_dump shards lets you pick your own materialization profile instead of being locked into the maintainer's. cbb26-day-corpus-v1 is the fast path when you want our standard geometry; this repo is for when you need fidelity and flexibility. Restore + materialize takes longer — that is an intentional tradeoff.
| Layer | Fidelity | User flexibility |
|---|---|---|
| This dataset (replay) | Lossless L2 replay truth | Choose resolution, buckets, normalization |
| Day corpus / NDDS on Hub | Lossy, fixed profile | Fast path for one training geometry |
What this dataset is
This is not a training corpus of pre-built tensors. It is the raw replay layer that cbb26 services write and read before materialization:
| Layer | What it is | Where it lives |
|---|---|---|
| This dataset | Timescale market_data replay tables, one shard per UTC day × product |
HF data/{YYYY-MM-DD}/{PRODUCT}.dump |
| Materialized corpus | Day-bundle rasters derived from replay | Local disk or deusmos/cbb26-day-corpus-v1 |
| Training run | Checkpoints, TensorBoard, eval metrics | Separate HF model repos / local tmp/ |
Schema (market_data)
Each shard exports the four core replay tables required for deterministic order-book replay in cbb26:
| Table | Role |
|---|---|
orderbook_second_deltas |
One row per (product_id, UTC second) where the end-of-second book changed vs. the last persisted second |
orderbook_replay_anchors |
Full retained L2 book at anchor seconds (includes baseline anchor at or before day start) |
orderbook_checkpoints |
Full retained L2 book once per product per UTC hour |
orderbook_replay_metadata |
Operational replay continuity / gap metadata (not source of truth for book state) |
DDL and migrations ship in-repo on the dataset:
migrations/0001_init.sql…0004_replay_metadata_window_end_index.sqlschema/market_data_schema.dump— schema-onlypg_dump -Fcfor empty restores
Hypertables use TimescaleDB 2.x on Postgres 16. See services/timeseries-db/migrations/ in cbb26 for the live definition.
Products (20)
Shards use Coinbase product ids (BASE-QUOTE):
AAVE-USD, ADA-USD, APT-USD, ATOM-USD, AVAX-USD, BCH-USD, BTC-USD, DOGE-USD, DOT-USD, ETH-USD, HBAR-USD, LINK-USD, LTC-USD, NEAR-USD, PEPE-USD, SHIB-USD, SOL-USD, UNI-USD, XLM-USD, XRP-USD
This matches the default MARKET_COLLECTOR_PRODUCTS basket in deploy/compose/slice-a.yml.
Coverage snapshot (live)
| Metric | Value |
|---|---|
| Last verified | 2026-05-25 22:41 UTC |
| Hub revision | b6c9773744ca346dba5c37c05939349f1ae3225e |
Shard files (.dump) |
1220 |
| UTC days with ≥1 shard | 61 |
| Days with 20/20 products | 61 |
| Distinct products | 20 |
| Date span | 2024-12-01 → 2026-05-25 |
| Manifest DB bytes (operator snapshot) | 111622336995 (~104.0 GiB) |
Refresh: uv run python scripts/generate_hf_dataset_coverage.py --update-readme
Each shard sidecar (data/.../{product}.json) records row_counts, dump_size_bytes, and UTC day bounds (cbb26_timeseries_shard_manifest_v1).
Data dictionary (replay rows)
Full contract: docs/standards/specs/STORAGE_REPLAY.md · JSON source: libs/contracts/storage_and_snapshot_spec.json
| Column | Type | Meaning |
|---|---|---|
product_id |
TEXT | Coinbase product, e.g. BTC-USD |
changed_second |
TIMESTAMPTZ | UTC second truncated; primary key with product_id |
source_sequence_num_start / _end |
BIGINT | L2 sequence range incorporated in this second |
best_bid / best_ask |
NUMERIC | End-of-second BBO after applying changes |
changes |
JSONB | Array of [side, price, new_quantity] — bid or offer; quantity 0 removes level |
change_count |
INTEGER | Length of changes array |
Example orderbook_second_deltas row (sanitized static illustration):
{
"product_id": "BTC-USD",
"changed_second": "2024-12-01T12:34:56+00:00",
"source_sequence_num_start": 9876543210,
"source_sequence_num_end": 9876543299,
"best_bid": "96543.21000000",
"best_ask": "96543.22000000",
"changes": [
["bid", "96540.00", "1.25000000"],
["offer", "96543.22", "0.50000000"],
["offer", "96544.00", "0"]
],
"change_count": 3
}
Repository layout
deusmos/cbb26-timeseries-db/
├── README.md ← dataset card (this file on Hub)
├── backup_manifest.json ← export inventory + restore notes (updated at bootstrap)
├── schema/
│ └── market_data_schema.dump ← schema-only pg_dump (market_data)
├── migrations/
│ ├── 0001_init.sql
│ ├── 0002_checkpoint_delta_upgrade.sql
│ ├── 0003_replay_anchor_support.sql
│ └── 0004_replay_metadata_window_end_index.sql
└── data/
└── {YYYY-MM-DD}/
├── {PRODUCT}.dump ← pg_dump -Fc (core-replay tables for that day+product)
└── {PRODUCT}.json ← shard sidecar (row counts, sizes)
Naming conventions
{YYYY-MM-DD}— UTC calendar trade date (inclusive day window00:00:00…23:59:59UTC).{PRODUCT}— uppercase Coinbase id, e.g.BTC-USD(regex^[A-Z0-9]+-[A-Z0-9]+$).- One Hub commit per shard during sync upload (rate-limit friendly; ~30 s spacing).
Manifests and revision pinning
| File | Purpose |
|---|---|
backup_manifest.json |
Dataset-level manifest (cbb26_timeseries_db_backup_manifest_v2): scope, table list, row counts, time ranges, restore notes, migration list |
data/.../*.json |
Per-shard sidecar with row_counts and dump_size_bytes |
| Git revision SHA | Pin downloads with HF_TIMESERIES_DATASET_REVISION=<sha> or hf download … --revision <sha> |
There are no separate checksum files; verify restores with sidecar row_counts, pg_restore exit code, and scripts/smoke_restore_hf_shard.sh.
Download and restore
Quick inspect (no Postgres)
git clone https://github.com/deusmos/cbb26.git && cd cbb26
./examples/download_one_timeseries_shard.sh
Prerequisites
- Docker (for
pg_dump/pg_restoreclient Postgres 16 — use imagepgvector/pgvector:pg16ortimescale/timescaledb:2.14.2-pg16) - A running Postgres 16 + TimescaleDB target (see Run your own collector below)
- Hugging Face CLI:
uv run hf auth loginorHF_TOKENin environment
Download
Full dataset (large):
export HF_TOKEN=... # optional for public repo; required for uploads
uv run hf download deusmos/cbb26-timeseries-db --repo-type dataset --local-dir ./cbb26-timeseries-db
Pin a revision (recommended for reproducible materialization):
export HF_TIMESERIES_DATASET_REVISION=b6c9773744ca346dba5c37c05939349f1ae3225e # example; get latest from Hub
uv run hf download deusmos/cbb26-timeseries-db \
--repo-type dataset \
--revision "$HF_TIMESERIES_DATASET_REVISION" \
--local-dir ./cbb26-timeseries-db
Single day / product:
uv run hf download deusmos/cbb26-timeseries-db \
--repo-type dataset \
--include "data/2024-12-01/BTC-USD.*" \
--local-dir ./cbb26-timeseries-db
Python (huggingface_hub):
import os
from huggingface_hub import snapshot_download
path = snapshot_download(
repo_id="deusmos/cbb26-timeseries-db",
repo_type="dataset",
revision=os.environ["HF_TIMESERIES_DATASET_REVISION"], # pin SHA
allow_patterns=["data/2024-12-01/*", "migrations/*", "schema/*"],
)
Restore workflow
Start Timescale with an empty or compatible database (see collector section).
Apply migrations if the volume is fresh:
# migrations are in the downloaded tree under migrations/ psql -h 127.0.0.1 -U cbb26 -d cbb26 -f migrations/0001_init.sql # … or rely on docker-entrypoint-initdb.d on first volume initRestore schema (if needed):
docker run --rm --network host \ -e PGPASSWORD="$POSTGRES_PASSWORD" \ -v "$PWD/cbb26-timeseries-db:/in" \ pgvector/pgvector:pg16 \ pg_restore -h 127.0.0.1 -p 5432 -U cbb26 -d cbb26 --schema-only \ /in/schema/market_data_schema.dumpRestore one shard (data-only into staging schema):
scripts/smoke_restore_hf_shard.sh \ --shard-dir ./cbb26-timeseries-db \ --date 2024-12-01 --product BTC-USDOr manually with
pg_restore+ merge SQL (see script for merge statements).Verify sidecar expectations — script fails closed on row-count mismatch vs sidecar.
Replay invariant: Each shard includes the baseline replay anchor at or before
day_start_utc. Without it, same-day replay cannot be reconstructed.
Run your own collector (local Docker stack)
You can collect the same schema locally and later upload missing shards (see Contributing).
Prerequisites
- Docker + Docker Compose
- Linux or macOS host with ~50+ GiB free for sustained multi-product collection
- Network access to Coinbase Advanced Trade websocket
1. Configure environment
From the cbb26 repo root:
cp .env.example .env
# Edit POSTGRES_PASSWORD, optional ports, and MARKET_COLLECTOR_PRODUCTS
Key variables (see .env.example and deploy/compose/slice-a.yml):
| Variable | Default | Purpose |
|---|---|---|
POSTGRES_DB |
cbb26 |
Database name |
POSTGRES_USER |
cbb26 |
Database user |
POSTGRES_PASSWORD |
change-me |
Change in production |
POSTGRES_PORT |
5432 |
Host-published Postgres port |
MARKET_COLLECTOR_PRODUCTS |
20-product CSV | Coinbase products to subscribe |
MARKET_COLLECTOR_PORT |
8080 |
Collector HTTP / metrics |
TENSOR_MATERIALIZER_PORT |
8081 |
Materializer API |
Inside Compose containers, services use DB_HOST=timeseries-db (not localhost).
2. Start the stack
scripts/up_slice_a.sh
scripts/check_slice_a.sh
Services: timeseries-db, market-collector, tensor-materializer, prometheus, grafana.
3. Verify health
Expected endpoints:
- Collector:
http://localhost:8080/healthz,http://localhost:8080/readyz - Materializer:
http://localhost:8081/healthz
After the collector runs, confirm replay rows exist:
DB_HOST=localhost DB_PORT=5432 uv run python scripts/_timeseries_db_hf_backup.py inventory --scope core-replay
Internal runbook: docs/runbooks/slice-a.md.
Contributing missing shards and days
See docs/standards/CONTRIBUTING_DATA.md (operator guide).
The dataset grows by incremental sync from contributors with a populated Timescale instance. Uploads are idempotent: shards already on Hub are skipped.
export HF_TIMESERIES_DATASET_REPO=deusmos/cbb26-timeseries-db
scripts/upload_timeseries_db_to_hf.sh --sync \
--start-date 2026-05-22 --end-date 2026-05-31
Tools for researchers
This repo is replay truth, not pre-rendered tensors. To see what NDDS windows look like without restoring Postgres, use the day-corpus tooling:
| Tool | Link |
|---|---|
| Preview PNG + gallery | examples/preview_corpus_day.sh on cbb26-day-corpus-v1 |
| PyTorch DataLoader | libs/day_raster_corpus/pytorch_loader.py |
| Hub thumbnails | previews/ on day-corpus |
| Live peek | HF Space deusmos/cbb26-corpus-peek |
Raw shard preview without Postgres restore is not shipped in v1 — restore + materialize (Path B) or use day-corpus previews. See shared FAQ.
FAQ
Can I use this commercially?
Market data is governed by Coinbase market data terms. Software and schema in cbb26 are MIT licensed. Not legal advice.
Why Postgres dumps not Parquet?
Replay fidelity requires full L2 book state. See ADR-003.
Why two datasets?
Raw replay (this repo) vs materialized NDDS day bundles (cbb26-day-corpus-v1).
How complete is UTC day X?
20/20 products under data/{YYYY-MM-DD}/; sidecar orderbook_second_deltas ≈ 86400 for a full continuous day.
How do I cite this?
@dataset{cbb26_timeseries_db,
title = {CBB26 Coinbase L2 Order Book Replay Shards},
author = {deusmos},
year = {2026},
url = {https://huggingface.co/datasets/deusmos/cbb26-timeseries-db}
}
Is this affiliated with Coinbase?
No. Independent research project using public market feeds.
Full FAQ source: docs/datasets/_shared/FAQ.md.
Licensing and data use
- Software / schema / scripts: MIT License (cbb26 repository).
- Market data: sourced from Coinbase public market feeds. Respect Coinbase market data terms. Provided for research and reproducibility without warranty.
Policy: docs/standards/DATA_USE_POLICY.md.
Related (downstream)
Restoring HF shards into local Timescale lets you materialize new days/products without operator infrastructure. Pre-built NDDS day bundles for cloud training live in deusmos/cbb26-day-corpus-v1.
flowchart LR
CB[Coinbase L2 websocket] --> MC[market-collector]
MC --> TS[(timeseries-db / market_data)]
TS --> TM[tensor-materializer / materialize scripts]
TM --> CORP[Corpus artifacts]
TS --> HF[(HF timeseries shards)]
CORP --> HFC[(HF day-corpus-v1 NDDS)]
CORP --> TR[train_latent_encoder.py]
Materialization entrypoints: scripts/materialize_valid_day_bundles.py, scripts/materialize_free_tardis_17d_day_bundles.py. Training: scripts/train_latent_encoder.py (v2 contract). Vast/JOJAT runbook: docs/runbooks/vast_jojat_training.md.
References
| Resource | Location |
|---|---|
| Orderbook data standards (v1) | docs/standards/README.md |
| Examples | examples/download_one_timeseries_shard.sh |
| cbb26 repo | GitHub deusmos/cbb26 |
| Upload entrypoint | scripts/upload_timeseries_db_to_hf.sh |
| Coverage refresh | scripts/generate_hf_dataset_coverage.py |
| Materialized training corpus (NDDS) | deusmos/cbb26-day-corpus-v1 |
| Publish this README to Hub | scripts/publish_timeseries_dataset_readme.sh |
Changelog
| Date | Notes |
|---|---|
| 2026-05-25 | A+++ upgrade: decision tree, live coverage, restore smoke enforcement, FAQ, BibTeX |
| 2026-05-25 | Initial public dataset card (shards 2024-12-01+, 20 products, core-replay export) |