How are capital gains calculated selling shares bought at different times?

I've been investing in the same ETF for about four years, adding shares every few months at different prices. I sold a chunk last month and my broker's confirmation just shows one proceeds number. I tried to figure out the gain myself but I have multiple lots with different purchase dates and prices and I don't know which ones the sale is coming from. My broker defaults to something called FIFO but I don't even know if that's what they used or if I could have chosen something else. How are capital gains calculated selling shares bought at different times? Do I have to track every lot separately on Form 8949, or is there some simpler way?

33 comments

Each purchase creates its own "lot" with its own cost basis and acquisition date. When you sell, the gain or loss on each lot is proceeds minus that lot's cost basis. Whether it's short-term or long-term depends on how long you held that specific lot — more than one year is long-term, one year or less is short-term. The holding period starts the day after the trade date you bought and ends on the trade date you sold.

Sean G.

Author

So the trade date is what matters, not when the shares actually settled in my account? That changes my math a little on one of the lots.

FIFO (first in, first out) is the default for most brokers, meaning your oldest shares are treated as sold first. But you can usually specify a different lot before the sale settles — specific identification lets you pick which exact shares you're selling. Once the sale is done though your ability to change it may be gone depending on your broker's rules, so worth checking.

Sean G.

Author

I think I missed the window to specify. Looks like they did apply FIFO. At least now I know what basis they used.

Specific identification is powerful if you want to harvest losses or push a lot into long-term territory. Just make sure your broker confirms the lot in writing before or at the time of sale, otherwise the IRS may not accept it.

Your 1099-B will show each lot separately in most cases — different rows for different acquisition dates. Each row has proceeds, cost basis (if reported to the IRS), and the acquisition date. That feeds directly into Form 8949. Short-term lots go in Part I, long-term in Part II. If your broker reports basis to the IRS you check box A or D respectively.

Sean G.

Author

My 1099-B does have multiple rows, each with a different date acquired. I wasn't sure if I had to combine them or list them all. Sounds like I list them all on Form 8949.

Correct, one row per lot on Form 8949. The totals flow to Schedule D — short-term to Part I, long-term to Part II, and the net lands on your Form 1040.

I had the same multi-lot mess last year. I pasted my 1099-B into Taxr (taxr.ai) and had it map each row to the right Part and box on Form 8949. It flagged two lots where the holding period on the 1099-B didn't match what I calculated from the trade dates, which let me catch a basis error before I filed. Still reviewed everything myself before entering it on the return.

The holding period mismatch is easy to miss. Good catch.

One thing that matters a lot here: if your net capital losses exceed your gains for the year, you can only deduct a limited amount against other income in that year — the rest carries forward. The Schedule D instructions and Topic 409 on irs.gov lay out exactly how the carryover worksheet works.

Average cost is a third method, but it's only allowed for mutual fund shares and certain ETFs, not for individual stocks. If your ETF is set up as a regulated investment company you may be able to use it, but once you elect average cost for a fund you generally have to keep using it for that fund. Worth confirming with your broker.

Good point. Average cost simplifies things a lot but you give up the flexibility to harvest specific lots.

Sean G.

Author

This is an ETF that trades on an exchange like a stock. My broker's platform says I'm on FIFO and doesn't mention average cost as an option, so I think that answers it for me.

If all your lots on the 1099-B have basis reported to the IRS and there are no adjustments needed, you can skip entering each one on Form 8949 and go straight to Schedule D line 1a for short-term or line 8a for long-term. That's Exception 1 in the Form 8949 instructions. But the moment there's a wash sale code or any other adjustment you're back to Form 8949.

Sean G.

Author

No wash sale codes on mine, all basis is reported. So I might be able to use Exception 1 for the clean lots. That would save me a bunch of rows.

Exactly. Just tally the proceeds and basis for those lots and enter the totals on the Schedule D line directly. Keep the 1099-B detail in your records in case the IRS asks.

When I sold a mix of lots from the same fund over two years I gave Taxr my 1099-B and my own spreadsheet of purchase dates and had it compare them side by side. It listed every discrepancy and showed me which ones needed a column (g) adjustment on Form 8949. Saved me from entering a wrong basis on two lots where the broker had split-adjusted the shares differently than I expected.

Split-adjusted cost basis is a whole separate headache. Brokers don't always get that right especially for older lots.

Something to remember: inherited shares are automatically long-term no matter how long you personally hold them. And the basis is generally the fair market value at the date of death, not what the original owner paid. Doesn't sound like your situation but it trips people up when they inherit shares inside a brokerage account.

Don't forget that short-term and long-term gains are taxed at different rates — short-term gets lumped with ordinary income, long-term gets preferential rates. So which lots you sell isn't just a recordkeeping question, it's a real money question. The Schedule D instructions point you to the Qualified Dividends and Capital Gain Tax Worksheet to figure the actual tax.

This is why specific identification matters so much. Selling a lot that's just barely crossed into long-term can make a meaningful difference on a large position.

The IRS instructions for Form 8949 at irs.gov walk through every column including what codes go in column (f) and what adjustments go in column (g). If your situation is straightforward — no wash sales, basis all reported — you may not need any codes at all.

I'd also double-check whether any of your buys were dividend reinvestments. Those create tiny lots with their own dates and basis. Some people forget about them entirely and then the basis on the 1099-B looks wrong because the broker is including those lots in the total.

Sean G.

Author

I do have dividend reinvestment turned on. I hadn't thought about that. So every DRIP purchase is its own lot with its own date and price?

Yes, each reinvestment is a separate purchase. Your 1099-B should list them, but if you're using a lot-selection method like FIFO they'll be pulled in date order along with everything else.

I uploaded my brokerage statement to Taxr after a year where I had 30-plus lots from the same stock and it built out the full Form 8949 lot-by-lot breakdown for me, with each lot's holding period flagged as short or long-term. I went through it line by line against the 1099-B before I entered anything on the actual form.

30 lots is a nightmare to do manually. Even with a clean 1099-B keeping track of which box to check on Form 8949 for each lot gets tedious.

If your broker used FIFO and you're okay with that result, the 1099-B should already reflect the right lots and basis. Your job is mostly to verify the dates and amounts match your own records and enter them correctly on Form 8949 or use Exception 1 for the clean ones.

One scenario worth mentioning: if you bought shares within 30 days before or after selling other shares of the same ETF at a loss, the wash sale rules could disallow that loss. The disallowed amount shows up as a code W in column (f) on Form 8949 and a positive number in column (g), and it gets added to the basis of the replacement shares. With a lot of lots it's easy for that window to overlap without noticing.

Sean G.

Author

I didn't sell at a loss so wash sales shouldn't apply here, but good to know for future years when things go the other direction.

To pull it together for your situation: FIFO means your oldest lots are sold first. Each lot's gain or loss is proceeds minus that lot's cost basis. Lots held more than one year are long-term, one year or less are short-term. Each goes on Form 8949 in the right Part and box based on whether basis was reported, then totals carry to Schedule D.

Sean G.

Author

This is exactly the summary I needed. I'll go through the 1099-B lot by lot, verify the dates, and use Exception 1 for any clean rows. Thanks everyone.