My goal is to compare a portfolio of stocks with a benchmark over time. Calculating the normalized value of a static portfolio is no problem, but I am struggling when stocks are removed or added to the portfolio.
With the current method I am using (sum of normalized value of each stock times the weight of each stock in the portfolio), the normalized value of the portfolio reduces immediately after selling a stock or adding a new one.
What i would like to achieve is that the earnings that the portfolio achieved over time are reflected in the normalized value. My idea is to “remember” the normalized value of the each sold stocks and to add them on top of the normalized value of the portfolio, but I am not sure this is the correct way to do it. Can someone point me in the right direction?