# How do I calculate weighted mean with negative weights?

I need to display in my system the amount of stocks that I own and the average price it took me to buy them. I am having a problem doing that when I include the selling.

Lets say I bought 4 stocks in 100 usd each.
and I sold 2 stocks for 110 usd each.

Now my position is 2 stocks for what average price ?
Option A: (4 * 110 + 2 * 100)/6 = 106.667
or
Option B: (4 * 110 - 2 * 100)/2 = 120 (doesnt think so )

If I do go with option A then if I sold 2 more for 110 I would get 0 amount but average (4*100+2*110+2*110)/8 - 105 . 0 stocks for 105 doesnt make any sense. thanks.

• Do you mean you buy 4 shares of company A and then sell 2 of the them (same stock)? – Karol J. Piczak Apr 13 '11 at 11:17
• yepp. and then I need to know how much "I am worth". What I would like to do is amount*average – Bick Apr 13 '11 at 12:14
• I don't really get it. Your average purchase price is still 100. And your current position is worth: current share price * number of shares. Maybe you need to rephrase your question. And BTW, I don't think it's very on topic here in its current form. – Karol J. Piczak Apr 13 '11 at 13:30
• Agreed with @Karol. The average price it took me to buy them doesn't depend on the sale price. And this is a very basic question. – chrisaycock Apr 13 '11 at 13:40
• @user722 What data are you trying to show? Cumulative P&L? Transaction cost modeling? The appropriate formula will depend on what you want, which isn't clear from your question. – chrisaycock Apr 13 '11 at 14:06

1) distinguish sells and purchases and calculate average for each of them; it will be $100$ and $110$ for sells.
2) calculate not average price which took you to buy... but average trading price. Then it will be $106.67$.
However, what it happend in your case is that you have bought 4 and sold 2, and in the end, you have remained with 2 bought ones. Between T0 and T_final you have paid $P&L= -4*100+ 2*120 = -400 + 240 =-160$ and you are left with 2. Therefore their (net) price is $-160/2=-80$.