The purpose of this project is to analyze financial data, by calculating financial statistics to understand the individual performance of an asset, how groups of assets are related, and how to allocate investments across assets for optimal performance
- Adjusted closing prices over time
- Daily Simple Rate of return
- Correlations between stocks
- MEAN-VARIANCE PORTFOLIO OPTIMIZATION
- Efficient Frontier
- Summary
Let’s first look at how the price of each stock has evolved over a year
Amazon and Google’s stock price was relatively more expensive than others. But since Apple, Microsoft and Facebook are at the bottom, it is hard to see the movement of these three.
By plotting daily returns, we can see the stock's volatility
Netflix has the highest returns in the first quarter and a couple of negative spikes indicating negative returns. From the above plot, we can roughly see that Amazon and Netflix looks like risky stock, and Google seems to be the most stable one among them.
It would be nice if every asset made large, consistent positive returns every period. If that were the case, we could invest all of our money in the asset with the highest expected return. But, the return of any given asset is unpredictable. This is the place where you give instructions to developers on how to modify the code.
We quantify the risk of a portfolio, by calculating the variance of each asset, and the covariance between each asset and every other asset.
If two assets have a positive covariance, then they respond similarly to market forces. Assets with a negative covariance will not
The Covariance Matrix above indicates, None of the stocks are negatively correlated. Apple and Google are highly correlated, while Microsoft and Amazon exhibit the lowest correlation.
The fundamental goal of portfolio theory is to allocate investments between multiple assets optimally. Markowitz mean-variance optimization (MVO) is an approach to choose how to allocate money between multiple assets by considering the risk-return trade-off of asset combinations.
The efficient frontier is a set of portfolios that give us the highest return for the lowest possible risk. This method returns a set of portfolios where:
- The expected return is greater than any other with the same or lesser risk
- The risk is less than any other with the same expected return
The blue dots above indicate a set of portfolios, Using return_portfolios() function that accepts the expected returns and covariance matrix for a collection of assets, I generated random 5000 portfolios of random asset weights.
Given that our goal is to minimize volatility and maximize expected return, the portfolios that fall on the left-most edge are the best portfolios.
The yellow line is on top falls on the portfolios that maximize the expected return at all risks, and minimize the risk at all expected returns. The vertical red lines in the figure above display the standard deviation of each asset.
As you can see from the above plot, the stocks with the least risk are Google at around 0.00225 and Microsoft at around 0.00175, these stocks are optimized for historical risk and return data.
Thank you for reading!