This article introduces readers to the mean-variance optimization of asset portfolios. The underlying formulas are implemented in Python. Market data has been downloaded from Google Finance. The case study is available here. Calculation of assets' weights, returns and covariances Our example starts with the calculation of vector of asset weights \(\mathbf{W}_{n \times 1}\), expected annual returns