First, it is important to understand that a portfolio is no more than just a collection of stock investments held by an investor. Optimizing a financial portfolio requires selecting the best possible portfolio out of a set of all portfolios being considered according to an objective.
According to modern portfolio theory, one possible way to optimize a portfolio is to aim for an efficient frontier. The efficient frontier is a investment portfolio that lies on the most efficient(ideal) coordinates of the risk-return graph(spectrum). There is a formal definition that is used by many experts in this field, "Efficient frontier is the set of portfolios which satisfy the condition that no other portfolio exists with a higher expected return but with the same standard deviation of return.
Now we know the aim is to achieve one of the efficient frontier portfolios. However, we can even go one step further than the overall portfolio. We can identify the best possible proportion of the stocks to use in any given portfolio. This is possible by using the sharpe ratio.
The sharpe ratio was developed by William Sharpe in 1966. The sharpe ratio describes how much excess return of money one recieves for the extra volatile time he/she holds onto the investment. Basically, it measures how much extra capital money one can recieve by waiting and holding onto a risky stock investment. The sharpe ratio can be calculated by taking the difference between the returns of the investment and the risk-free return, divided by the standard deviation of the investment.
Usually experts define four categories for the result of the sharpe ratio:
Sharpe Ratio Category
- ratio < 1.0 sub-optimal
- ratio > 1.0 good
- ratio > 2.0 very good
- ratio > 3.0 excellent
After considering the efficient frontier theory, as well as the sharpe ratio, it is time to start the code to optimize a sample financial portfolio.
- Pypfopt
- Ploty
- PyPortfolioOpt
- Pandas
- Matplotlib
- Numpy