Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Image: ubuntu2004
Performance portfolio management
Camilo A. Garcia Trillos 2020
In this notebook
We retrieve the same database available to us when choosing efficient portfolios, but now focus on how to manage an existing portfolio to improve its performance using the ideas of risk allocation and Sharpe ratio.
Reading data
We read again the database we used on the exercise on efficient frontiers. If in doubt of any on the commands below, go back to that notebook.
Improving performance of a portfolio
Assume that we have a long only portfolio. Assume for example that we have an equally weighted portfolio
Assume, for the exercise, that we have this portfolio on 2011-12-31. We will use the risk allocation technique and Sharpe ratio to progressively improve the performance of the portfolio.
First, let us calculate the mean and variance of the portfolios using the 9 years prior to the date we have fixed.
We can now calculate the Sharpe ratio of each asset and the Sharpe ratio of the whole portfolio. For this exercise, we are going to assume that only risky assets are available.
A naive way to try to improve the performance is to increment the investment in those assets whose Sharpe ratio are larger than the overall portfolio Sharpe ratio, while reducing it on the ones that fall below.
A better way is to make a risk allocation following the Euler per unit allocation, and calculate the relative performance of each asset. Recall that when we use standard deviation to estimate risk, we obtain
With the above function, we can calculate the relative Sharpe (also printing again the individual Sharpe for comparison)
Note that there is already a big improvement: the performance increased by an order of magnitude. We can repeat the process to improve even further until we cannot improve any more without violating our constraints.
After 6 iterations, we found a portfolio whose Sharpe portfolio cannot be improved: it invest the minimal allowed amount on all assets except JNJ, PG, and WMT. Note that it does not focus on just the asset with the largest Sharpe ratio, although, due to the constraints, the obtained Sharpe is slightly worse than investing in JNJ alone... but if this investment is put together with the constraints on minimal portfolio, we would produce a less performing portfolio.
Indeed,
This is smaller. The interaction between the two assets helps to obtain a more performant portfolio within the constraints.
The above discussion is all 'static', that is, we are doing all changes as if we could go back and modify our portfolio several times. The idea of using such incremental steps is to slowly adjust the portfolio as time passes by. To do so, let us make evolve our portfolio and run again the improvement, but updating the information.
A good tool for this purpose is the exponentially weighted moving average (EWMA). This is a way to smoothly decrease the influence of old observations: the idea is as follows: let . We update a time average of asset by posing and
This is a simple and common way of slowly 'forgetting' the information in the distant past. We use this to update our mean and standard deviation estimations. For one element in the variance-covariance matrix, we can use
Then, we can simultaneously update our estimation for these parameters and the best portfolio. This is the purpose of the following code
The figure shows that the strategy in this period becomes more and more concentrated on only one asset. Note, though that this process is not monotone, and sometimes the proportion changes. If the data starts supporting a more diversified portfolio.
Before finishing, let us check that our estimation (through the use of the EWMA estimator ) is close to the one we would have obtained by using the whole data. This occurs since we chose a factor that roughly gives every new data the same weight as one week in a period of 10 years (which is how it works within the whole data series).
Exercises
Download 5 years of history for the price of 10 of your favorite stocks (use, for example yahoo finance). Set, a priori, a long-only portfolio that you would constitute in those shares and a minimal proportion investment on each asset. then reproduce the above discussion to tune progressively your portfolio.
Assume you start with 100 pounds to invest. Moreover, assume that you have to pay a fee of 0.001 times the value of any operation you make in the market (for example, if you sell 50 pounds worth of one asset to buy 50 of another, you pay a fee of 0.0001*(50+50) = 1 cent).
Modify your code above to include the effect of this fee in your calculations (ideally, code it with a variable for the transaction cost)