Applying portfolio optimization well to a specific asset class requires careful handling of forecast data, rebalancing logic, and constraints that generic optimizers don't account for. This case study walks through how I built a Treasury portfolio optimizer deployed as an interactive Streamlit app.
Classic Markowitz mean-variance optimization: given expected returns and a covariance matrix of Treasury instruments across maturities, the model finds the portfolio weights that minimize risk for a given expected return.
Expected returns are generated from Blue Chip Financial Forecasts survey data stored in a MariaDB database, giving the model a forward-looking view that updates as new consensus forecasts are published.
The tool includes rebalancing logic for existing portfolios and a separate workflow for allocating new capital without fully unwinding current positions.