How to calculate the average stock price (level)

286 Views Asked by At

I know that we can calculate average stock price by using mean but this doesn't give a real picture of the portfolio specially if we have bought and sold the same stocks. How do we calculate average price of this stock in the example below?

We have to think of practical situation. In the example below first 50 stocks were bought and 49 were sold so we are left with 1 stock @ 548 + 15 stocks @ 666 in our portfolio so the current average stock price should be reflective of this.

My spreadsheet calculation and stock broker's value for average price don't mach no matter how many different combinations I tried.

First calculation

Sum of bought stocks (quantity * price) divided by total quantity.

Second calculation

Include the sold stock as well

Sum of (quantity * price) minus sold stock quantity * price divided by total bought quantity minus sold quantity

Stock broker's value for average price is 111.36

None of my calculations come anywhere near that. Any inputs?

Example

|Transaction|Quantity |Price|
|-----------| --------| --- |
|Buy        | 15      | 666 |
|Sell       |-49      | 548 |
|Buy        | 50      | 1146|
1

There are 1 best solutions below

7
On BEST ANSWER

You need to keep track of two things:

  • the number of stocks you currently have ($n$)
  • The average value of these stocks ($A$)

If you sell some stocks you reduce $n$ and keep $A$ fixed.

It you buy $m$ new stock at price $p$ (each) you update the number of stocks $n\mapsto n+m$ and the average cost $$A\mapsto \frac{An+pm}{n+m}$$ which is nothing more than a weighted average.

enter image description here