# Return calculation on a security that you are rebalancing

Suppose you have some security A, and the suppose the following:

Initial amount of security bought: 100

Initial price: $10 Suppose after some time: Sold qty: 10 Sold at: 11 Then you buy some again: More bought: 20 At the price: 15 And then you sell some again: Sold: 40 At the price: 11 And also suppose that you want to know unrealized and realized and a total percentage return for each of the days that security is traded, and not just when you rebalance. I tried to Google this, but can't seem to find anything, nor can I figure out how to calculate the return in this setting myself. ## 2 Answers Not really clear what your asking, so here's a try. You can calculate the rate of return of security A using the time-weighted return method (11 / 10) * (15 / 11) * (11 / 15) - 1 = 10 %  • after you buy 20, you have 90 that you bought for 10 and then you have 20 that you bought for 15. How is the percentage return 15/11? Wouldn't it have to be ((90)/(90+20))*(15/10) + (20/(90+20))*(15/15), or if no rebalancing happens in some next discrete time step, and the price is 16 then: ((90)/(90+20))*(16/10) + (20/(90+20))*(16/15) – i squared - Keep it Real Aug 26 '16 at 8:12 • When you buy the 20 that's a new investment and it doesn't have any return; you're only gaining from the 90 you held earlier. The percentage return is indifferent to the amount held; it's just a percentage representing the change in price. See Investopedia: "The time-weighted rate of return is the preferred industry standard as it is not sensitive to contributions or withdrawals. It is defined as the compounded growth rate of$1 over the period being measured." – Chris Degnen Aug 26 '16 at 8:25

How to calculate your gain will depend on which method you use. I have always used first in, first out (FIFO) and I believe that the IRS assumes that everyone uses this method unless they specify otherwise.

Using FIFO your gain for all shares sold would be $1 (11 sale price - 10 purchase price) due to the shares for$10 being purchased first. If you continue to sell portions then your gain/loss will be the sale price compared to the $10 purchase price for the next 50 shares (until the original 100 shares have been sold) and then compared to the$15 share price for the next 20 shares and so on if you later buy more. If you sell the remaining shares all at once it would be mathematically the same to just use the average purchase price of the remaining shares. 50@$10 + 20@$15 = $800/70 shares =$11.43/share. If you sell for more than that you will have a gain, less would produce a loss.