# How can I calculate total return of stock with partial sale?

I have searched the internet for hours and still can't find the formula to calculate the Total Return in percentage with the below scenario.

1. Bought 310 shares at \$3.15 brokerage \$19.95
2. Sold 200 shares at \$4.75 brokerage \$19.95
3. Bought 277 shares at 3.54 brokerage \$19.95
4. still holding 387 shares at \$6.060

I can easily work out the total return when there is no sale of any shares, but I get unstuck when there is a partial sale of shares in the transactions.

• If you show us the total return with no sale of any shares and the total return with a complete sale of shares, we can show you how to calculate total return including a partial shares in a way consistent with those. As is, it's unclear what the basis would be. Total return in terms of what? Nominal gain? Real gain? On the sold shares? Or sold and currently owned combined? Is there inflation? Capital gains tax? Opportunity cost? Aug 17 '17 at 18:48
• Just edited my answer to show I'm still holding the remaining 387 shares at the current market price. Aug 17 '17 at 20:10

If you just want to know total return, either as dollars or a percentage, just add up the total amount spent on buys and compare this to current value plus money received on sales. In this case, you spent (310 x \$3.15 + \$19.95) + (277 x \$3.54 + \$19.95). So your total investment is ... calculator please ... \$1996.98. You received 200 x \$4.75 on the sale minus the \$19.95 = \$930.05. The present value of your remaining shares is 387 x \$6.06 = \$2345.22. So you have realized plus unrealized value of \$2345.22 + \$930.05 = \$3275.27. Assuming I didn't mix up numbers or make an arithmetic mistake, your dollar gain is \$3275.27 - \$1996.98 = \$1278.29, which comes to 1278.29 / 1996.98 = 64%.

If you want to know percentage gain as an annual rate, we'd have to know buy and sell dates, and with multiple buys and sells the calculation gets messier.

You have only sold 200 shares for \$4.75 from those bought for \$3.15. So your profit on those 200 shares is \$1.60 per share or \$320 or 51%.

From that you have 110 shares left that cost you \$3.15 and 277 shares that cost you \$3.54. So the total cost of your remaining shares is \$1,327.08 (110 x \$3.15 + 277 x \$3.54). So your remaining shares have a average cost of \$3.429 per share (\$1,327.08/387).

We don't know what the current share price is as you haven't provided it, nor do we know what the company is, so lets say that the current price is \$5 (or that you sell the remaining 387 shares for \$5 per share). Then the profit on these 387 shares would be \$1.571 per share or \$607.92 or 46%.

Your total profit would then be \$320 + \$ 607.92 = \$927.92 or 47% (note that this profit neglects any brokerage or other fees, as you have not provided any).

Edit due to new info. provided in question

With the current share price at \$6.06 then the profit on these 387 shares would be \$2.631 per share or \$1018.20 or 77%.

Your total profit would then be \$320 + \$1018.20 = \$1338.20 or 75% (note that this profit neglects any brokerage or other fees, as you have not provided any).

• Awesome answer btw! I've added brokerage now at 19.95 per transaction. I also use a portfolio tracking website and they have calculated my gain at 1274.42 with a percentage of 37.26%. So I'm struggling to figure out how they arrived at that figure. Aug 17 '17 at 22:06

Treat each position or partial position as a separate LOT. Each time you open a position, a new lot of shares is created. If you sell the whole position, then the lot is closed. Done. But if you sell a partial quantity, you need to create a new lot. Split the original lot into two. The quantities in each are the amount sold, and the amount remaining. If you were to then buy a few more shares, create a third lot. If you then sell the entire position, you'll be closing out all the remaining lots.

This allows you to track each buy/sell pairing. For each lot, simply calculate return based on cost and proceeds. You can't derive an annualized number for ALL the lots as a group, because there's no common timeframe that they share.

If you wish to calculate your return over time on the whole series of trades, consider using TWIRR. It treats these positions, plus the cash they represent, as a whole portfolio. See my post in this thread: How can I calculate a "running" return using XIRR in a spreadsheet?

It's very complex, remember the shares sold take their total returns with them, ie. you've already had their profit so don't need to keep accounting for it.

Those bought have none and need to be calculated from their purchase date.

All that matters is what number of shares you're left with after all the transactions and what that amount of shares, and only that amount, has each individually returned.

What you have to do is, as suggested already, treat whatever you're left holding after each new share purchase transaction as a new individual lot. Assign a number to the shares. That lot number then has a date and a cost associated with it.

Initial purchase (new shares) = lot #1 First additional purchase (added shares total) = lot #2 Second additional purchase (added shares total) = lot #3 etc.

Then for any sales use a first in first out basis. So number of shares first sold taken from lot #1 then any sales exceeding the number of shares in lot #1 have to be taken from lot #2, then from lot #3 etc.

Each lot has a relevant date and purchase price so once you've got that the income and capital return for each share lot (and so individual shares within) can easily be calculated and the results added.

That sum of income and capital gain is then divided by the cost of all the lots still held which gives a total return of all the shares still held.

I'm in a similar situation, hold a lot of lines and just can't face the slog of sorting it all out.

You could use the time-weighted return, assuming bid and ask values are the same for the price point at valuations.

Including brokerage fees for net time-weighted return. (Exclude fees for gross return.)

``````1. investment value is 310*3.15 = 976.50
2. price now 4.75
investment is worth 310*4.75 - 19.95 = 1452.55
return is 1452.55/976.5 - 1 = 0.487506
200 sold, 110 still held
value = 110*4.75 = 522.50
3. price now 3.54
investment is worth 110*3.54 - 19.95 = 369.45
return is 369.45/522.50 - 1 = -0.292919
277 bought, total held = 387
value = 387*3.54 = 1369.98
4. price now 6.06
investment is worth 387*6.06 - 19.95 = 2325.27
return is 2325.27/1369.98-1 = 0.697302

TWR = (1 + 0.487506)*(1 - 0.292919)*(1 + 0.697302) - 1 = 78.52 %
``````

There is no clear answer as to the cost basis for the shares sold, when shares have been bought at more than one price.

I would suggest whatever you do is consistent from one holding to another. I think for performance measures, First in first out makes the most sense. It seems less likely to overstate or understate current performance.

https://www.investopedia.com/terms/a/averagecostbasismethod.asp

• The shares sold were all bought at one price. Please read the question again. Sep 30 '20 at 19:55

There are many ways to calculate the return, and every way will give you a different results in terms of a percentage-value.

One way to always get something meaningful - count the cash. You had 977 (+ 31) and in the end you have 1.370, which means you have earned 363 dollars.

But what is your return in terms of percentage?

One way to look at it, is by pretending that it is a fund in which you invest 1 dollar. What is the fund worth in the beginning and in the end? The tricky part in your example is, you injected new capital into the equation.

Initially you invested 977 dollars which later, in the second period became worth 1.473. You then sold off 200 shares for 950 dollars. Remember your portfolio is still worth 1.473, split between 950 in cash and 523 in Shares. So far so good - still easy to calculate return (1.473 / 977 -1 = 50.8% return).

Now you buy share for 981 dollars, but you only had 950 in cash? We now need to consider 2 scenarios. Either you (or someone else) injected 31 dollars into the fund - or you actually had the 31 dollars in the fund to begin with. If you already had the cash in the fund to begin with, your initial investment is 1.008 and not 977 (977 in shares and 31 in cash). In the end the value of the fund is 1.370, which means your return is 1.370 / 1.007 = 36%.

Consider if the 31 dollars was paid in to the fund by someone other than you. You will then need to recalculate how much you each own of the fund. Just before the injection, the fund was worth 950 in cash and 387 in stock (310 - 200 = 110 x 3.54) = 1.339 dollars - then 31 dollars are injected, bringing the value of the fund up to 1.370. The ownership of the fund is split with 1.339 / 1.370 = 97.8% of the value for the old capital and 2.2% for the new capital. If the value of the fund was to change from here, you could calculate the return for each investor individually by applying their share of the funds value respective to their investment.

Because the value of the fund has not changed since the last period (bullet 3), the return on the original investment is (977 / 1.339 - 1 = 37.2%) and the return on the new capital is (31 / 31 = 0%).

If you (and not someone else) injected the 31 dollar into the fund, you will need to calculate the weight of each share of capital in each period and get the average return for each period to get to a total return. In this specific case you will still get 37.2% return - but it gets even more comlex for each time you inject new capital.

• "There are many ways to calculate the return, and every way will give you a different results in terms of a percentage-value." WHAT? Are you kidding??? Aug 17 '17 at 10:37
• Consider my calculations - if you take the capital injection into consideration or not will give you different results. Did the 31 dollars magically appear - have they been sitting as cash (yielding zero percent from period 0) or have they been invested in something else - should that yield be taken into account when calculating the total return?
– ssn
Aug 17 '17 at 10:49
• This is not a fund - it is simply a calculation of profits from buying and selling parcels of shares. The % return is simply the profit over the initial costs x 100%. The OP has funded a purchase of shares, then sold some and then bought some more. You actually don't know the total profit until all the shares are sold. Aug 17 '17 at 11:26
• I realise that it is not a fund - but you can treat it as such for calculating OP's total return in (%). If you do not treat it as a fund, you will run into problems when trying to calculate return on more than one asset. We do know total (unrealised) profit; because we are told that price is 3.54 in period 3.
– ssn
Aug 17 '17 at 11:52
• \$3.54 is the last price bought at not the current price, and if it was the profit would simply be \$320 or 51% for the 200 sold and \$42.90 or 12% for the remaining 110 originally bought. A total of \$362.90 or 37% for the original 310 bought. The 277 subsequently bought would basically be at breakeven. No problems at all and no need to use a hypothetical fund assumption. This is how calculations are done all the time to determine capital gains for tax purposes - no difference in any values - just simple calculations that will always give the same results. Aug 17 '17 at 12:16