>>>>Hi All,
>>>>
>>>>I have an interesting debate with some users of ours about how to calculate the average unit price for a stock bought and sold and bought again in various transactions at different price levels. So I put it to the market players in the forum for your input :)
>>>>
>>>>When we consider only BUY transactions then the calculation is quite simple: we simply add up the total cost of buying all the shares we have and divide by the total number of shares we have. However, the problem seems to get complicated when in between buying we also sell some shares. Then, later, perhaps even buy some back again. How to calculate the average unit prices now?
>>>>
>>>>Some websites indicate that we should sell off those shares that we first bought (first in, first out) and then re-calculate the average unit price based on the BUY transaction left. Each new BUY transaction changes the AUP, and each SELL transaction removes old BUY transactions from consideration as the shares are now sold.
>>>>
>>>>Other websites say that only BUY transactions affect the AUP. Simply add up all the costs to buy the shares, subtract the monies received from SELL transactions, and divide the net by whatever number of shares we have left.
>>>>
>>>>Below is a simple table of transaction. There are various BUY transactions (denoted by positive shares) and then some SELLS (denoted by negative shares), then some more buying and selling. What do you say the average unit price is at the end of these sequence of transaction and why?
>>>>
>>>>
>>>>Shares bought / sold Buy / Sell Price Shares Running Total
>>>>
>>>>3700 1389 3700
>>>>5000 894 8700
>>>>5000 810 13700
>>>>6000 1000 19700
>>>>4200 1163 23900
>>>>1100 1182 25000
>>>>10000 910 35000
>>>>15000 777 50000
>>>>20000 856 70000
>>>>15000 976 85000
>>>>-35000 813 50000
>>>>-25000 742 25000
>>>>25000 833 50000
>>>>50000 829 100000
>>>>-50000 572 50000
>>>>-25000 553 25000
>>>>
>>>>
>>>>
>>>
>>>Basically, you should decide which accounting method to use: FIFO or LIFO and use it consistently. The difference between the methods will transpire on the each sell point, i.e. you calculate cost basis either based on first shares bought (historically, eliminated by subsequent sell transaction, FIFO) or last shares bought (before the sale, i.e. reduced in backward direction, LIFO).
>>
>>Thanks for the feedback Edward. So using FIFO when we sell we remove enough BUY transactions from the top of the list going down in order to satisfy the number of shares being sold. Then re-calculate the AUP based on the remaining BUY transactions up to the SELL record. Is that correct?
>
>Yes, IIRC, this is default method to record this kind of transactions.
This may or may not be relevant to your application, but I prefer to determine myself which buy/sell transactions match up. Particularly when dealing with multiple trades over multiple years.
Update : Following my response I re-read the initial post and I'm less sure my suggestion is relevant. If your looking for a way to calculate AUP as a measurement of performance over many accounts then I agree with Edward that either way is appropriate as long as you implement it consistently. My suggestion is geared more towards an individual account.
Wine is sunlight, held together by water - Galileo Galilei
Un jour sans vin est comme un jour sans soleil - Louis Pasteur
Water separates the people of the world; wine unites them - anonymous
Wine is the most civilized thing in the world - Ernest Hemingway
Wine makes daily living easier, less hurried, with fewer tensions and more tolerance - Benjamin Franklin