Skip to content
All library documents

Tracking Share Cost Basis and Average Trading Price After Sales

Article Quant Q&A · Author: Bick

Summary

The document considers how to report remaining shares and an average price after buying and selling part of a position. Its example starts with a purchase of four shares at one price, followed by selling two at a higher price. It shows why simply averaging purchase and sale prices can produce a misleading figure, especially when the position is fully closed and a displayed average would remain despite holding no shares.

The responses distinguish two different metrics: average purchase price for acquired shares, and average trading price across both purchases and sales. Under the example, the latter combines buy and sell activity, while the former should track purchases separately. The discussion also includes an alternative net-cash calculation, but it does not settle on a single accounting convention or explain tax-lot methods, realized profit reporting, or transaction costs. The key practical point is to label the metric according to what it measures rather than treat buys and sells as ordinary positive weights in one average.

Key ideas

  • Average purchase price and average trading price measure different things.
  • A sales-inclusive trading average can remain defined even after the position is closed.
  • A zero share balance should not be presented as if it had a meaningful remaining-share cost basis.
  • The document does not specify tax accounting, lot selection, or treatment of transaction costs.

Tags

Full text
# How do I calculate weighted mean with negative weights?


# 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.

## Answer by SBF (score 3, accepted)

https://quant.stackexchange.com/a/974

I think there are two ways:

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$.

## Answer by user7056 (score 1)

https://quant.stackexchange.com/a/4054

The weights are, by definition, positive, and add to do normalization to the total amount the wights are calculated for. The title of the question does not make sense.

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$.

The question here is more about the fact of selling the TWO actions because you HAD FOUR actions and because you wanted to be left with TWO actions in the end. And selling them at 110 because you have bought them at 100. In practice you have 100=100(4) and 120=120(2) - the number you buy/sell does influence the price. The events are not indipendent, so you can not apply "normal" averaging and weighting, but you have to work with bayesian statistics.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.