Return on investment is calculated by taking the value of the investment held at the beginning of the ROI period compared to the current value. In other words:
((Current Value) - (Beginning Value) + (Income))
(Current Value) = (the current total shares) x (the last price),
(Beginning Value) = [(Number of shares held prior to the period - any shares sold) x (the closing price prior to the period)] + the "Cost Basis" of any shares added in this period (Buys, Reinvest, Add Shares, etc), and (Income) = any income events such as Dividends/Interest (not Reinvested) and Realized gain/loss from Sells in this period.
For example, assume that on 1/1/99 you owned 1000 shares of XXYY (which had been purchased prior to this date), the last price (on 12/31/98) was Rs.69 11/32, and you still own the 1000 shares and the current price is Rs.90 1/8. The ROI (YTD) for XXXX Script would be calculated:
If you had purchased 200 additional shares at Rs.75 each during this period, the formula would be modified as follows: