Skip to content

Data Pipeline

Sergey Gerasimov edited this page Oct 23, 2026 · 2 revisions

Data Pipeline

DerivLab is designed to keep working when the network does not.

Data lifecycle

flowchart LR
    YF[Yahoo Finance] --> CACHE[Local Parquet cache]
    SEED[Bundled seed] --> CACHE
    CACHE --> HV[30-day realised HV]
    HV --> IV[Synthetic implied volatility]
    IV --> CHAIN[Black-Scholes chain + Greeks]
    CHAIN --> ENGINE[Backtrader engine]
    ENGINE --> GAME[Hold the Position]
    ENGINE --> ARENA[AI Arena]
    YF -. failure .-> SEED
    SEED -. missing .-> SYN[Synthetic fallback]
Loading

In plain English: the seed and cache are both valid starting points; a refresh is optional. The option chain is derived locally, so the simulation and the agent decisions never depend on a live quote feed.


Sources and precedence

  1. Bundled seed — committed five-year snapshot in data/seed/.
  2. Local cache — per-machine Parquet files in data/cache/.
  3. Yahoo Finance — optional refresh via yfinance.
  4. Synthetic fallback — deterministic generated prices for the last resort.

The UI labels the active source on the Data Vault screen: Live cache, Bundled seed, or Synthetic fallback.


Instruments

Fourteen instruments across US and European equities, FX, gold, Brent, and four indices. Each asset carries its own contract multiplier, currency, and base volatility assumptions.


Refresh

From the UI: Data Vault → Refresh all (5Y).

From the command line:

docker compose run --rm derivlab-seed

The seeder:

  • retries transient failures;
  • keeps the last good cache file if a download fails;
  • writes a manifest with source, row count, and dates;
  • never deletes a successful file during a failed refresh.

Synthetic implied volatility

Realized volatility is computed from 30-day log returns. Synthetic IV is derived from that with an asset-specific base and a configurable multiplier. The option chain is priced with Black-Scholes.

This is a teaching model: it gives a realistic-looking surface without pretending to be an executable market.


Historical window

Backtests, the game, and the AI Arena share the same scenario slicing. The AI context is computed strictly before the scenario start, so no future bars leak into the agents' decisions.


Seed and cache layout

data/
├── seed/        # committed demo snapshot (Parquet + manifest)
└── cache/       # per-machine runtime cache (gitignored)

The cache is stored in a named Docker volume in Compose deployments, so docker compose down -v resets it.


Failure behavior

  • Missing cache + no network → seed.
  • Missing seed + no network → synthetic fallback with a visible warning.
  • A failed refresh keeps the existing cache.
  • A corrupt asset is reported per asset, not as a global crash.

See Troubleshooting.

Clone this wiki locally