Average share (opening) price

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the following data, where a negative number represents a sell of shares and a positive number a purchase and column C shows at what price the transaction happened.
ABCDEF
TickerQuantityPrice TickerAverage Price
TSCO LN Equity VOD LN Equity?
TSCO LN Equity TSCO LN Equity?
TSCO LN Equity
TSCO LN Equity
TSCO LN Equity
TSCO LN Equity
VOD LN Equity
TSCO LN Equity
TSCO LN Equity
VOD LN Equity
VOD LN Equity
VOD LN Equity
VOD LN Equity
VOD LN Equity

<COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 104px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 104px"><COL style="WIDTH: 98px"></COLGROUP><TBODY>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: right"]50 [/TD]
[TD="align: right"]323[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="align: right"]-30 [/TD]
[TD="align: right"]330[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="align: right"]60 [/TD]
[TD="align: right"]300[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="align: right"]300 [/TD]
[TD="align: right"]325[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]

[TD="align: right"]-5 [/TD]
[TD="align: right"]360[/TD]

[TD="bgcolor: #cacaca, align: center"]7[/TD]

[TD="align: right"]200 [/TD]
[TD="align: right"]310[/TD]

[TD="bgcolor: #cacaca, align: center"]8[/TD]

[TD="align: right"]-50 [/TD]
[TD="align: right"]190[/TD]

[TD="bgcolor: #cacaca, align: center"]9[/TD]

[TD="align: right"]10 [/TD]
[TD="align: right"]350[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]

[TD="align: right"]-40 [/TD]
[TD="align: right"]320[/TD]

[TD="bgcolor: #cacaca, align: center"]11[/TD]

[TD="align: right"]25 [/TD]
[TD="align: right"]150[/TD]

[TD="bgcolor: #cacaca, align: center"]12[/TD]

[TD="align: right"]25 [/TD]
[TD="align: right"]155[/TD]

[TD="bgcolor: #cacaca, align: center"]13[/TD]

[TD="align: right"]-150 [/TD]
[TD="align: right"]180[/TD]

[TD="bgcolor: #cacaca, align: center"]14[/TD]

[TD="align: right"]-200 [/TD]
[TD="align: right"]170[/TD]

[TD="bgcolor: #cacaca, align: center"]15[/TD]

[TD="align: right"]40 [/TD]
[TD="align: right"]130[/TD]

</TBODY>

And I've been asked to calculate the average price per ticker. For now it doesn't matter whether it's based on a first in first out principle or first in last out principle.

Has anyone got a formula to calculate this?

Thanks in advance,
Jack
 
Wouldn't SUMIF()/COUNTIF() (Or AVERAGEIF() IN Excel 2007+) work?

Is there a catch in BUY/SELL averaging?
 
Upvote 0
Not when I tried (hence asking on here!). No catches, just the data as it is
 
Upvote 0
Does this work for you?
Excel Workbook
ABCDEF
1TickerQuantityPriceTickerAverage Price
2TSCO LN Equity50323VOD LN Equity162.5
3TSCO LN Equity-30330TSCO LN Equity327.25
4TSCO LN Equity60300
5TSCO LN Equity300325
6TSCO LN Equity-5360
7TSCO LN Equity200310
8VOD LN Equity-50190
9TSCO LN Equity10350
10TSCO LN Equity-40320
11VOD LN Equity25150
12VOD LN Equity25155
13VOD LN Equity-150180
14VOD LN Equity-200170
15VOD LN Equity40130
Sheet2
Excel 2003
Cell Formulas
RangeFormula
F2=SUMIF(A:A,E2,C:C)/COUNTIF(A:A,E2)
F3=SUMIF(A:A,E3,C:C)/COUNTIF(A:A,E3)
 
Upvote 0
I think it does! I'll test it out and don't know why it wasn't working for me, but thank you very much :)
 
Upvote 0
No it doesn't, remember why now. That formula doesn't take into account the different weightings due to the different quantities bought and sold at different prices. Your formula averages the price based on the number of trades only and doesn't include the quantities. Thank you for trying and replying though
 
Upvote 0
Well, that was the catch!
Can you define "weighting" in this particular scenario?
If you can calculate the weighted average by hand, then it usually can be implemented in Excel.
We just need to know / decide on a logic.
Give an example of how you'd do it by hand.
 
Upvote 0
For security x
Example 1: You buy 10 shares at price 10.00, another 10 at price 20.00, you now hold 20 shares at an average price of 15.00
Example 2: You buy 20 shares at price 10.00, another 10 at price 20.00, you now hold 30 shares at an average price of 13.33

These are simple examples and don't take into account if you sell some and then subsequently buy some more, e.g.

Example 3: You buy 20 shares at price 10.00, another 10 at price 20.00, sell 5 at price 18.00, you now hold 25 shares at an average price of:
(i) 13.33, based on the average price prior to the sell
(ii) 14.00, based on a first-in first-out principle (i.e. your original purchase of 20 shares has now been reduced to 15 and you are taking the post sale average price)
(iii) 12.00, based on last-in first-out principle (i.e. the last most recent purchase of 10 shares has now been reduced to 5 and you are taking the post sale average price)

For now, I don't care which of the 3 prices the formula calculates
 
Upvote 0
Actually if I can get a formula that calculates all 3 average prices, that would be even better...
 
Upvote 0
I am not very good with finance! So I don't really get FIFO/LIFO effect.
How far does this take you?
Excel Workbook
ABCDEFG
1TickerQuantityPriceQuantityAbsCostTickerAverage Price
2TSCO LN Equity503235016150VOD LN Equity170.05
3TSCO LN Equity-30330309900TSCO LN Equity318.92
4TSCO LN Equity603006018000
5TSCO LN Equity30032530097500
6TSCO LN Equity-536051800
7TSCO LN Equity20031020062000
8VOD LN Equity-50190509500
9TSCO LN Equity10350103500
10TSCO LN Equity-403204012800
11VOD LN Equity25150253750
12VOD LN Equity25155253875
13VOD LN Equity-15018015027000
14VOD LN Equity-20017020034000
15VOD LN Equity40130405200
Sheet6
Excel 2003
Cell Formulas
RangeFormula
D2=ABS(B2)
E2=IF(B2<0,-B2*C2,B2*C2)
G2=SUMIF(A:A,F2,E:E)/SUMIF(A:A,F2,D:D)
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top