Portfolio Construction using Efficient Frontier Optimization

Abhishek Chikara
Analytics Vidhya
Published in
4 min readFeb 5, 2021

--

Not a Blog just Notes for myself :)

Let’s Take Two Asset in risk-return Space which is also known as a mean-variance framework where on our X-axis we have variance or std-dev (risk) while on the Y-axis we have our returns pf the Asset

We Got 2 Assests A and B
A has a std deviation of 10%(Volatility) and return 4%
B has 14% volatility, and a 6% return
Let's combine A and B to Build our portfolio and calculate our risk and return?Let's Split the money equally in the both the asset
So our return of our portfolio will be the weighted average of A and B which will be 2% + 3% = 5%
But the Volatility doesn't get calcuted in such a way Because it depends on the correlation between A and B.So our Return will be r(wa,wb) = ra*wa + rb*wb
while our Volatility can be expressed in variance which is
σ²(wa,wb) = σ²a*w²a + σ²b*w²b + 2wa*wb*σa*σb*ρ(a,b)
From the above equation we can deduce that As long as the two weights are non-zero and the correlation between the two assets are less than 1, the volatility of the portfolio will always be less than the weighted average volatilities of the two assets.
correlation between A and B is 0.4

if we look at this curve, what we got at the left end of the curve is the portfolio that consists of 100% in A, and what you’ve got at the right top end of the curve is the portfolio that consists of 100% in B.

Also, You can see a nose inside the graph which we got with the help of diversification which is simply that we can take two assets, and mix them in a certain ratio, and end up with a portfolio that has lower volatility than either one of them.

if you take two decorrelated assets and you put them together, you can construct a portfolio that has lower volatility.

Lets introduce One more Asset C  which completely changes the picture so it's expanded our region into our risk-return Space and gave us an entire region of portfolios
Adding a new stock C

By adding an extra asset we have an entire region of portfolios to choose from but the objective still remains the same to get the most efficient portfolio using Assets A B and C

Portfolios on the edge represent the best you can do either in terms of expected return or expected volatility while you never select from the inside region of mean/variance space

The portfolios we care about holding, are the ones sitting on that edge, sitting on the frontier, and that space is what we call that edge, (that outside left most curved line is what we call the efficient frontier.)

OBJ: We have to find out what is the point in that mean-variance(return-volatility) space that the efficient frontier passes through.

We will use an Optimizer that will find that point in our space

So our returns will be expressed as

Rp =ΣwiRi

While Volatility can be expressed as

σ²p=ΣΣwi wj cov(i,j) where covariance cov(i,j) = σa*σb*ρ(a,b)

Matrix Notation

Rp = w^T R (Matrix Notation where w =(K x 1) matrix and R is (K x 1) matrix ) of Asset returns

σ²p = wTΣw

cov(i,j) matrix is a symmetric square matrix of k x k elements

So start by selecting two portfolios which has the highest and lowest return as we know these 2 point portfolios lies on the efficient frontier through that we are able to identify two points in our space Rmin and Rmax

So we start with R min and we want to move up to R max so what we do is that we take that space between the minimum return and the maximum return and we split it into a grid. Then at every point on that grid, what we want to do is run the optimizer to try and find the set of weights that give you the portfolio that minimizes the volatility for that level of return.

So Minimize σ²p =1/2 wTΣw

So our Quadratic Optimizer has an objective to minimize volatility/variance with constraints that return must be at a certain level and we are going to run over and over again across that grid of return values so that we can plot each point along the curve.

Other constraints are, typically, you want all the weights to be greater than zero. So in other words, no shorting :(

the final constraint that typically you’ll want is that the weights all add up to 1

We can write this in Python :

--

--