Building a $0, no-backend portfolio backtester and the data-licensing rabbit hole
Description and use
A static portfolio backtester that respects data licensing, accurately models bond returns, and stores portfolio state in the URL.
Problem
Create a lightweight, static portfolio backtester for Indian investors that respects data licensing constraints and provides accurate bond return calculations.
Outcome
A zero‑cost, no‑backend backtester that complies with data licenses, accurately models bond returns, and shares state via URL.
Workflow
- 1. Build script fetches data from Yahoo, Stooq, NSE, FRED, Federal Reserve DDP, BLS, OECD SDMX, and World Bank.
- 2. Data is stored in a 108 KB JSON file refreshed monthly via GitHub Action.
- 3. User uploads CSV for licensed indices; parsed client‑side with FileReader.
- 4. Engine (≈200 lines JS) calculates returns; a pandas implementation verifies statistics to 1e‑9.
- 5. Bond return logic corrected using closed‑form dirty price formula.
- 6. Portfolio state is encoded in URL hash; share card generated with toDataURL; embed mode provides iframe badge.
Evidence
Yahoo, Stooq and NSE all forbid redistribution.
The result is a 108 KB JSON file, refreshed monthly by a GitHub Action.
Bond returns are modelled from yields. Each month you buy a 10-year par bond and reprice it at the new yield.
The whole portfolio state is in the hash, e.g. #p=us_eq:60,in_eq:40&s=2000-01&c=USD.
- Record date: 2026-10-18T04:56:08.967Z