Case study · Personal project
Bond Portfolio Centre
A personal portfolio analytics app: 1-day VaR, a Monte Carlo fan chart, diversification and stress tests, optimiser mixes, a rebalance plan, goal glide paths, and a rule-based investment committee that reviews each book.
Demo with synthetic data. Not investment advice.
- Stack
- Python, pandas, vanilla JS, Chart.js
- Code
- Code available on request
01 Context
Bond Portfolio Centre is a personal project. It started life as a Google Sheets and Apps Script workbook and was ported to Python, with the parts that only existed to work around the spreadsheet removed.
02 Problem
The spreadsheet version had limits that mattered for risk numbers. It ran the Monte Carlo simulation twice, so the box plots could disagree with the fan chart at the same horizon. Holdings that trade on different exchanges close on different days, and misaligned dates can quietly turn volatility, beta and VaR into missing values.
03 Approach
- Data in, dataclasses out. The analytics never fetch prices or talk to a broker. Every entry point takes a returns matrix (dates by tickers) and a weight vector.
- Dates are aligned, never array positions. Only dates on which every series printed are kept.
- Covariance is EWMA-weighted (λ = 0.94, the RiskMetrics default), so recent volatility counts for more than a print from three years ago.
- One simulation feeds every Monte Carlo view, so the fan chart and the horizon box plots always agree.
04 What it does
- 1-day VaR with volatility and beta, and a view of which positions the risk sits in.
- Monte Carlo: a fan chart and horizon box plots from one simulation of the book.
- Diversification: flags holdings that move together closely enough to behave like one position, and shows what buying a candidate fund would do, measured on the dates it actually traded.
- Stress tests: how far below its peak the book has been, its worst and best stretches, and synthetic episodes modelled on past market stresses.
- Optimiser mixes: growth-optimal, risk-parity, least-risk and smoothest-ride allocations to compare against what is held.
- A rebalance plan paced month by month, with dated orders.
- Goals and a mortgage glide path that moves money with a date on it out of the market as the date approaches.
- A rule-based investment committee that reviews each book.
05 Stack
06 Notes
Everything the app shows is descriptive, not advice. The public demo runs on synthetic data.
Correlations measured in calm markets understate what happens in a crash: pairs that look diversifying are the ones most likely to converge when it matters.
The repository is private. Code available on request.
Next
Weekly Market Update