Realized vs unrealized gains
A realized gain or loss comes from shares you sold. It is what you received for them minus what they cost. An unrealized gain or loss comes from shares you still hold. It is their value at today’s price minus what they cost.
Add the two to get the gain or loss on the whole position. Dividends are a separate line. This page is about measuring results, not taxes.
Synthetic example · one position · USD
Split one position after a partial sale.
One purchase of 40 shares
No fees, dividends or taxes
- Buy 40 shares at $50. You pay $2,000.
- Sell 15 shares at $62. You receive $930.
- Today the price is $58. You still hold 25 shares.
Sold part Realized
- Sale amount
- 15 × $62 = $930
- Cost of the shares sold
- 15 × $50 = $750
- Realized gain
- $930 − $750 = +$180
Part still held Unrealized
- Value at today’s price
- 25 × $58 = $1,450
- Cost of the shares still held
- 25 × $50 = $1,250
- Unrealized gain
- $1,450 − $1,250 = +$200
Gain on the whole position
+$380
Realized + unrealized: $180 + $200 = $380
Check: $930 received + $1,450 held − $2,000 paid = $380
Selling 15 shares fixed their gain at $180. The $200 on the 25 shares still held is unrealized and moves with the price.
15 of 40 shares sold. Realized gain +$180. Unrealized gain +$200. Gain on the whole position +$380.
Invented prices, not market history. One purchase of 40 shares, so every share cost $50. No fees, dividends, taxes or currency changes. Today’s price is a valuation. Nothing is sold at that price.
After the sale
Only the unrealized part moves with the price.
Once the 15 shares are sold, their $180 gain is fixed. It no longer depends on the share price. The 25 shares still held are valued at today’s price, so their gain changes whenever the price does.
| Today’s price | Realized | Unrealized | Total |
|---|---|---|---|
| $40 | +$180 | −$250 | −$70 |
| $50 | +$180 | $0 | +$180 |
| $58Price in the example | +$180 | +$200 | +$380 |
| $70 | +$180 | +$500 | +$680 |
At $40, a realized gain of $180 sits next to an unrealized loss of $250. The position as a whole is down $70. A realized gain alone does not tell you how the position did.
Which shares count as sold
Bought at different prices? The method decides the split.
With one purchase, every share cost $50, so there is nothing to decide. Now say the same 40 shares were bought in two lots: first 20 at $40, later 20 at $60. That is still $2,000, or $50 a share on average. When you sell 15, which ones did you sell?
| Shares counted as sold | Realized | Unrealized | Total |
|---|---|---|---|
| First in, first out15 of the $40 shares · cost $600 | +$330 | +$50 | +$380 |
| Average cost15 × $50 · cost $750 | +$180 | +$200 | +$380 |
| A specific lot15 of the $60 shares · cost $900 | +$30 | +$350 | +$380 |
The total is $380 every time. The method only moves part of the gain between the realized and unrealized lines. It does not add or remove any money.
Brokers and tax rules may use a different method from yours. In IBKR statements, the Realized & Unrealized Performance Summary matches each sale with a purchase using a method such as FIFO (first in, first out), LIFO (last in, first out), average cost or a specific lot. IBKR’s TWS window calculates Unrealized P&L from the average cost per share. In the United States, FINRA explains that firms generally use first in, first out unless you choose another method. Before you compare a broker’s split with your own, check which method it uses.
Measuring results, not taxes
Tax rules decide when a gain is taxed and which methods you may use. They differ between countries. This page only measures investment results and is not tax advice.
Without any tool
Split your own position in five steps.
- List every purchase. Note the shares and what you paid, fees included.
- List every sale. Note the shares sold and what you received, after fees.
- Give the sold shares a cost. With one purchase, use its price. With several, choose one method, such as FIFO or average cost, and use it for every sale. Use your broker’s method if you want to match its report.
- Work out both parts. Realized gain = sale amount − cost of the shares sold. Unrealized gain = shares still held × today’s price − cost of those shares.
- Check the total. Realized plus unrealized must equal what you received from sales, plus today’s value, minus what you paid. If it does not, a share, a fee or a sale is missing.
Income
Dividends are a separate line.
A dividend is income paid on the shares. It is not a gain on their price, so it belongs to neither part. FINRA describes total return as the gain or loss in value plus investment earnings, such as dividends. To see everything a position produced, add the dividends you received to the realized and unrealized gains. Count each dividend once.
IBKR’s TWS calculates Unrealized P&L as the current market price minus the average cost per share, times the shares held. A paid dividend is not part of that figure. Our article Does IBKR Unrealized P&L include dividends? shows how to reconcile a position with the income it paid.
From dollars to a return
A gain in dollars is not yet a return.
The $380 does not say how long the money was invested or when the $930 came back. To compare the position with an ETF, use dated cash flows: the purchase, the sale amount on its date and today’s value. How to calculate IRR after a partial stock sale works through one example. The money-weighted return definition explains what that rate measures.
Sources and assumptions
The example is synthetic. Its prices are invented and show no market history. It has one purchase and no fees, dividends, taxes or currency changes. Today’s price is a valuation, not a sale. This is a glossary lesson, not tax advice, an audit result or a recommendation.
Sources checked 20 November 2026.
- Investor.gov (SEC): Capital Gain defines a capital gain as the profit when an investment is sold for more than the price paid for it.
- IBKR: Realized & Unrealized Performance Summary says a profit or loss is realized when a position is closed and that open positions are marked to market as unrealized. It matches sales with purchases by FIFO, LIFO, average cost or a specific lot, and its total adds the realized and unrealized amounts.
- IBKR: TWS Position and P&L gives the Unrealized P&L formula: (current market price − average cost per share) × total number of shares.
- FINRA: Key Concepts, Return and Rate of Return defines total return as the gain or loss in value plus investment earnings, with a dividend as an example.
- FINRA: Tax Time Topics, Cost Basis describes first in, first out and specific share identification, and says firms generally use first in, first out unless you choose another method.