Plan: Cost-of-Carry and Arbitrage Intelligence (14 Oct 2026)
Reference: Cost of Carry (methodology, API, sample analysis).
Existing architecture found
- FastAPI routers in
backend/app/api/*, registered inapp/main.pybehindrequire_min_rank("DEVELOPER"); sync data helpers run viarun_in_threadpool; results as{success, data}. - Price history behind stores, never raw tables:
eq_store(cash and index),fo_store(NSE F&O, monthly Parquet + 90-day staging),mcx_fo_store,mcx_spot_store(MonthStoreinstances). Masters:scr_master(typ 2 index, typ 3 futures),scr_mcx_master(typ 20 spot, typ 21 futures, unit and pricequote).scr_indexpepb.divyie,te_price(SBI FD). - Frontend: React 18 + Vite, recharts, Tailwind
trading-*tokens, all calls inservices/api.js, routes inApp.jsx, links inSidebar.jsx. - Pytest runs against the real local Postgres (
tests/conftest.py).
Gaps found
- MCX futures history 2009-03 to 2026-07 is absent locally (see follow-up 1).
- No dividend yield before 2012-02; financing series ends 2025-12-31.
- No bid-ask, margin or historical brokerage anywhere.
- No cost or tax module in the platform:
BrokerageCalculatoris a single current-rate Zerodha intraday approximation, unsuitable for a historical, effective-dated net carry, socarry/costs.pywas added.
Built
backend/carry/{calc,costs,data,service}.py, backend/app/api/carry.py, frontend page CarryDashboard.jsx, 83 tests.
Migrations: none (derived results are cached in memory keyed by parameters, calc version and store dates; nothing
persisted).
Follow-ups
- Load MCX F&O history 2009-03 to 2026-07 locally (
mcxeod.mcx_archive_import import, thenmcx_fo_store export) or copy from the VPS; then Gold / Silver gain about 17 years. Re-runpython -m scratch.coc_sample. - Refresh the financing proxy beyond 2025-12 (add an MIBOR / repo / T-bill series to
te_asset) so net carry stops relying on a carried-forward rate; the cost code only needsFIN_PROXY_CODEchanged or a second source. - Verify the statutory schedules in
costs.SCHEDULESagainst circulars (especially STT from 2026-04). - If margin or bid-ask data ever lands (broker API), feed the scanner's
marginand liquidity fields. - Optional: persist daily scanner snapshots to measure what happened after each classification (a real backtest would be the only way to claim win rate or Sharpe).