ARBIMETRA LAB
Portfolio Optimization
Finds minimum-variance, global minimum-variance and maximum-Sharpe portfolios under long-only and weight constraints, and verifies convergence.
What it does
Finds minimum-variance, global minimum-variance and maximum-Sharpe portfolios under long-only and weight constraints, and verifies convergence.
Use it to explore mean-variance trade-offs.
Data you need
- Two or more return or price columns
Optional: Target return, weight limits
Supported data: Numeric. Level: Advanced.
Formula and method
min w′Σw subject to Σw = 1, l ≤ w ≤ u
A sequential quadratic programming solver minimises w′Σw, or maximises the Sharpe ratio from several starting points, under full-investment and weight constraints. A result is shown only if the solver reports convergence.
Assumptions
- Returns are described by means and covariances
Input checks
- Limits must allow weights to sum to 1
- Singular covariance is rejected
- Convergence is required
How to read the result
Treat weights as sensitive to inputs.
Worked example
Illustrative run on Simulated weekly returns (teaching data, not market data). These figures are the actual output of this model on that example, and they say nothing about your own data.
- Maximum Sharpe ratio = 1.6371 a year. Global minimum variance has annual volatility 0.118.
- These weights are best for the sample inputs, not for the future.
Limitations
- Educational use, not investment advice
- Sample means are noisy
Numerical validation
Validated 20 of 20 automated checks passed, including numerical results, invalid input, missing values, small samples, constant variables, charts and the interpretation text.
| Check | Reference | Result | Abs. error | Tolerance | Source |
|---|---|---|---|---|---|
| GMV weight a against closed form | 0.30244637 | 0.30244637 | 2.8e-16 | 1e-4 | Closed-form solution |
| Tangency weight a against closed form | 1.28261824 | 1.28261818 | 6.7e-8 | 2e-3 | Closed-form solution |
| GMV weight b against closed form | 0.05424576 | 0.05424576 | 5.2e-16 | 1e-4 | Closed-form solution |
| Tangency weight b against closed form | 0.46822145 | 0.46822141 | 3.4e-8 | 2e-3 | Closed-form solution |
| GMV weight c against closed form | 0.64330787 | 0.64330787 | 6.7e-16 | 1e-4 | Closed-form solution |
| Tangency weight c against closed form | -0.75083969 | -0.75083959 | 1.0e-7 | 2e-3 | Closed-form solution |
Computed with python 3.13.2, numpy 2.2.5, scipy 1.14.1, pandas 2.3.3, statsmodels 0.14.4, scikit-learn 1.7.0, in your browser. A passing check confirms the listed comparison only. It does not make any result suitable for your data, and it is not a claim of equivalence with other statistical software.
Questions
Why are my optimal weights so extreme?
Small errors in expected returns can move the solution a lot. Weight limits help.
ARBIMETRA LAB is an educational and research tool. Results should be checked by the researcher and are not professional advice.
