Use a "first in, first out" approach (FIFO). So, in your example, the sale of 600 shares would be from the original 1000 puchased.