Say, I bought 10 stocks at average price B at different times and then decide to sell 5 out of them at price S at one go. We neglect the brokerage charges here.

  1. Is there a way to estimate the profit or do we need to keep track of the purchase history?

  2. Which stocks get sold first? Since one may still like to hold the cheapest stocks, so could one selectively pick up stocks with higher prices or does the exchange decide in its own one way?

  3. Does the rule of FIFO or LIFO apply here and is it universal across all the exchanges in the globe?

Let me provide the following real market example below.

  1. I had total 19 stocks before selling. Invested amount (total buy price) = 26,722.93 (in Indian Rupees).

enter image description here

  1. Now I sold 4+5=9 stocks. Total sell price: 1503 X 4 + 1502 X 5 = 13522.

enter image description here

  1. Expected remaining invested amount: 26722.93 - 13522 = 13200.93.

  2. However, I see 14,594.50 remaining as invested in my portfolio. How can this mismatch be justified?

enter image description here

  • 2
    Are you asking about profits for tax purposes? Or some other purpose? If for tax purposes, you'd need to specify a country. The US, for example, allows you to choose either FIFO or specific lots when selling. Other countries likely have similar rules but may have different options or defaults. Mar 14, 2022 at 11:53
  • No, just want to calculate the total returns from my investment in a quarter or year. Presently I've invested only in Indian exchanges.
    – hbaromega
    Mar 14, 2022 at 12:01
  • If you are calculating a number merely for your own personal purposes, you are free to choose whatever approach appeals to you. No one is, for example, going to legally compel you to do the bookkeeping to track which shares were sold at what time for a number that you are using merely to track your personal investments just as no one is going to compel you to do the calculation in the first place. Or limit you to calculating it only one way. It's only if you intend to use this number for something like calculating your taxes that someone other than you will care what method you use. Mar 14, 2022 at 12:06
  • @JustinCave Nope, I used to think that my average buy price won't be affected after partially selling. But that didn't happen when I checked. That possibly means I need to track my stocks and this exercise can be tedious.
    – hbaromega
    Mar 14, 2022 at 20:02
  • Sorry, I don't follow. You can use any method you want. If your actual problem is that you want to match the calculation that some other system is making, you'd need to specify what system you are trying to match and look at what algorithm that particular system is using. "Average buy price" for example might mean "Average purchase price of all the shares you currently hold" which would change when you sell or it might mean "Average purchase price of all the shares of this stock you have ever purchased" which would not change when you partially sell but the former would be more logical. Mar 14, 2022 at 20:07

2 Answers 2

  1. You cannot keep track of P&L with only average cost per share. You need total cost as well as total current value. If you sell (or even buy another) stock, that number must also be accounted for.

  2. Exchanges do not decide which shares are sold if selling partial lots. That is your decision to make, assuming that your tax laws permit this.

  3. In the USA, FIFO is the default method unless you designate another option. Universality? Tax law varies from country to country.

  • I have edited my post with a real example.
    – hbaromega
    Mar 21, 2022 at 8:11

Using the numbers from your example:

Step 1: You own 19 shares, you spent 26,722.93 buying those 19 shares. That gives you an average purchase price of 1,406.47. At the moment of the screen capture the price per share had risen to 1,501.65. That means your portfolio had risen 1,808.42 to 28,531.35, All the numbers are in that screen capture.

step 2:

Now I sold 4+5=9 stocks. Total sell price: 1503 X 4 + 1502 X 5 = 13522.

That means you exchanged those 9 shares for 6,012 and 7,510 cash or a total of 13,522.

Step 3:

Expected remaining invested amount: 26722.93 - 13522 = 13200.93.

That isn't correct.

At the moment, just after you sold the 2nd batch of shares, you had 10 shares left. Since the most recent sale was for 1,503 the market believed those 10 shares were worth 10 times 1,503 or 15,030.

Step 4:

However, I see 14,594.50 remaining as invested in my portfolio. How can this mismatch be justified?

At the moment of that last screen capture the price had dropped to 1,459.45 per share; thus the valuation of 14,594.50.

What you paid for shares and what you sell them for determines if you made or lost money.When you buy at different price levels and sell at different price levels the calculation of gains and losses becomes more complex. You have to know which shares were sold.

The current valuation of your investment depends on only two numbers: the number of shares you own now, and the price per share at this moment in time. That price and thus the value can change every second.

  • Sorry, I couldn't follow. How come invested amount changes with the market? If I spend 100 bucks for a share, the invested amount will still remain 100 bucks. The market price can be 90 or 110.
    – hbaromega
    Mar 22, 2022 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .