How to calculate capital gains on a stock sale — what actually goes into the number?

Sold shares of a company I'd held for a while and my brokerage sent a 1099-B but I'm honestly not sure I trust the cost basis number they're showing. When I bought in, some shares were purchased through dividend reinvestment and some were bought outright at different times. The 1099-B shows a proceeds number and a cost basis, but I don't know if that's right or how to verify it myself. I've looked at my old trade confirmations and the numbers don't quite match what the brokerage is showing. I'm trying to figure out how to calculate capital gains on this stock sale before I just plug the 1099-B numbers into my return. Do I use the 1099-B as-is, or can I correct it? And does it matter that some of the shares are over a year old and some aren't?

37 comments

Are all of these shares in the same account, or did you ever move shares between accounts? That changes how you handle the basis correction on Form 8949.

Leah A.

Author

All in the same brokerage account the whole time. Never transferred them anywhere.

To figure out how to calculate capital gains on a stock sale yourself, the basic formula is: proceeds minus adjusted cost basis equals your gain or loss. Proceeds come from column (d) on Form 8949, basis goes in column (e). The tricky part is making sure your basis is right before you fill anything in. I had a similar DRIP situation last year. I uploaded my 1099-B and all my trade confirmations to taxr.ai and it compared each lot, flagged where the brokerage basis was off, and listed exactly which column (g) adjustments I needed on Form 8949. I did my own review before filing but it saved me a lot of spreadsheet work.

Leah A.

Author

This is helpful. So if the 1099-B basis is wrong I don't just cross it out — I have to put the brokerage's wrong number in column (e) and then fix it in column (g)?

Correct. Whether you correct it in column (g) depends on which box you check. If box A or D is checked (basis reported to the IRS), you enter the 1099-B basis in column (e) even though it's wrong, then put code B in column (f) and the adjustment — negative in parentheses if the correct basis is higher — in column (g). If box B or E (basis not reported), enter the correct basis in column (e) and -0- in column (g). The instructions for Form 8949 at irs.gov lay this out exactly.

DRIP shares are annoying because every reinvestment is a separate lot with its own purchase date and basis. Each dividend reinvestment is treated as a purchase at the share price on that date. So you might have dozens of tiny lots, each with its own holding period.

Cost basis and holding period — this is where I am right now. I've been manually listing every lot from my statements. It's tedious but the alternative is overpaying because the brokerage basis can be understated.

Leah A.

Author

That explains why the numbers don't match. I think the brokerage might be missing some early DRIP lots.

Does it matter which shares you tell the brokerage you sold? Like can you pick which lots to sell to control whether the gain is long or short?

Specific identification — yes, you can choose which lots you're selling, but you have to tell the broker before the sale settles, or use their standing instructions. If you don't specify, most brokers default to FIFO (first in, first out). Check your brokerage account settings.

Holding period — got it. So if the older lots are long-term that's the better ones to sell if I want the lower rate. Makes sense.

How long did you actually hold the shares you sold? That's the first thing to pin down because it determines whether you're in Part I or Part II of Form 8949.

Leah A.

Author

Mix of both. Some I've held more than a year, some less. So I guess I need to split them and report short-term in Part I and long-term in Part II separately?

Exactly. The holding period starts the day after you acquired the shares and ends on the trade date you sold — not the settlement date. More than one year is long-term and goes in Part II; one year or less is short-term, Part I. Each lot gets its own row on Form 8949.

One thing worth checking: did you sell any of these at a loss in the 30 days before or after buying shares of the same company anywhere — including a spouse's account or an IRA? Wash sale rules can disallow the loss and you'd need code W in column (f) of Form 8949.

Leah A.

Author

No losses here, all gains, so I think I'm fine on that. But good to know for next time.

Publication 550 on irs.gov has a whole section walking through basis, holding period, and how gains and losses interact on Schedule D. Worth reading alongside the Form 8949 instructions. When I sold a mixed lot last year I had Taxr read through my 1099-B and my brokerage's lot-by-lot detail report side by side. It flagged three DRIP lots where the basis looked understated and drafted the column (g) worksheet entries so I could review them before entering them on my actual 8949.

Column (g) worksheet — that's the part I keep getting confused on. The sign convention trips me up every time. Negative in parentheses means you're increasing the basis, right?

Yes. If your correct basis is higher than what the 1099-B shows, the adjustment in column (g) is a negative number written in parentheses. That reduces the reported gain (or increases the loss). If the 1099-B basis is too high, the adjustment would be a positive number. The instructions for Form 8949 have a worked example in the column (g) section.

Are you planning to file yourself or use a preparer? With multiple lots and a possible basis discrepancy, an enrolled agent or CPA can verify the math and make sure the 8949 entries match the 1099-B properly. Not saying you can't do it yourself, just that the column (g) adjustments are where errors show up in audits.

Leah A.

Author

I'd like to do it myself if I can get the basis right. Might go to an EA if the DRIP lot count gets too overwhelming.

What method did your brokerage say they used for basis — average cost, FIFO, specific ID? That should be on the 1099-B or in your account settings. It affects whether their number can even be compared directly to your lot-by-lot records.

Leah A.

Author

I'll check. I never actually set a preference so it might be FIFO by default.

FIFO by default is common. If the brokerage used FIFO but your records show a different lot was actually sold (maybe you specified at the time), that would explain a basis difference. Worth pulling the trade confirmation from the sale date to see what it says.

Does the gain eventually flow to Schedule D or does it stay on Form 8949?

Both. Form 8949 is where you list each transaction. The totals from Part I and Part II of Form 8949 carry to Schedule D lines 1b, 2, 3 (short-term) and 8b, 9, 10 (long-term). Schedule D then feeds into Form 1040. You don't skip 8949 and go straight to Schedule D unless every transaction qualifies for Exception 1 — basis reported to the IRS, no adjustments needed.

Schedule D lines — okay, that clears it up. I was confusing myself thinking they were separate things.

If your losses end up exceeding your gains, there's a limit on how much of the net loss you can deduct against other income in one year. The rest carries forward. Topic 409 on irs.gov has the details and points you to the Capital Loss Carryover Worksheet.

Leah A.

Author

All gains in my case so not a concern this year, but I'll bookmark that for the future.

Did the brokerage mark the shares as covered or noncovered on the 1099-B? Covered securities have basis reported to the IRS, noncovered don't. That's what determines which box — A, B, D, or E — you check on Form 8949, and it changes how you handle a basis correction.

Leah A.

Author

Some are marked covered, some noncovered. The really old DRIP shares are noncovered I think.

Noncovered shares — for those, the brokerage isn't required to report basis to the IRS, so if the basis shown is wrong you just enter the correct basis in column (e) and -0- in column (g) under box B or E. No need to carry the wrong number through. That's actually simpler than the covered correction.

Worth double-checking whether any of your DRIP reinvestments happened around the same time as a sale at a loss in a prior year. If a wash sale disallowed a loss back then, that disallowed amount would have been added to the basis of the replacement shares — meaning your current basis could be higher than the purchase price alone.

Good catch. If the replacement shares had the same CUSIP and were in the same account, the 1099-B from the year of the disallowed loss should have shown the disallowed amount in box 1g, with code W going in column (f) of Form 8949. If that ever happened, those lots carry an adjusted basis.

To put the steps in order for your situation: (1) pull every lot from your brokerage's lot detail report, (2) match each DRIP reinvestment to your statements to verify the per-share basis, (3) separate short-term and long-term lots by trade date, (4) fill Part I and Part II of Form 8949 with proceeds in column (d), basis in column (e), and any adjustments in column (g) with the right code in column (f), (5) carry the totals to Schedule D. Publication 551 on irs.gov covers basis rules in detail if you need to work through the DRIP shares one by one.

Leah A.

Author

This is exactly the order I needed. Going to start with the lot detail report and work from there. Thank you.

Lot detail report — once you have that, the Form 8949 entries are mostly mechanical. The only judgment calls are which lots you're treating as sold (if you specified) and whether any basis adjustments apply from prior wash sales.