Building a $0, no-backend portfolio backtester and the data-licensing rabbit hole
说明与用途
一个不需要后端、符合数据许可的静态投资组合回测工具,准确计算债券收益,并将组合状态编码在 URL 中。
问题
Create a lightweight, static portfolio backtester for Indian investors that respects data licensing constraints and provides accurate bond return calculations.
结果
A zero‑cost, no‑backend backtester that complies with data licenses, accurately models bond returns, and shares state via URL.
工作流
- 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.
证据
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.
- 记录日期: 2026-10-18T04:56:08.967Z