Quant: Market data client + cache

t-711·WorkTask·
·
·
Created1 month ago·Updated1 week ago·pipeline runs →

Description

Edit

REST client for daily price data + local JSONL cache.

Files: Omni/Fund/Data/Market.hs

Deliverables:

  • getDailyPrices :: Text -> Int -> IO (Either ApiError [DailyBar]) — fetch from Twelve Data (or fallback)
  • DailyBar type (date, OHLCV)
  • Local JSONL cache in /var/fund/quant/prices/ — one file per ticker
  • loadCachedPrices :: Text -> IO [DailyBar] — read from cache
  • refreshPrices :: [Text] -> IO () — fetch missing days, append to cache
  • Pure derived functions: trailingReturn, realizedVol, sma, meanReversionZ
  • correlationMatrix :: [[DailyBar]] -> [[Double]] — NxN realized correlation (pure list-of-lists, no hmatrix)
  • Tests for derived functions on synthetic data

API key: Twelve Data free tier (800 req/day). Store in pass, add to provision-secrets.sh. If Twelve Data doesn't work, fall back to Yahoo Finance CSV download (no key needed).

Cache strategy: Initial backfill fetches 5 years of daily data per ticker (16 calls). Daily timer appends new bars. Cache is append-only JSONL.

Timeline (7)

💬[human]1 month ago

Part of epic t-709 (Quant Phase 1)

🔄[human]Open → InProgress1 month ago
🔄[human]InProgress → Review1 month ago
💬[human]1 week ago

Ava verified: implementation present in live tree (file/feature confirmed via inspection). Moving to Verified.

🔄[human]Review → Verified1 week ago