Capital gains tax and non residents: how does it actually work for US-sourced stock sales?

Trying to figure out capital gains tax and non residents — specifically my situation. I'm on an F-1 visa, have been in the US about 14 months, sold some shares through my brokerage in March, and got a 1099-B. My broker withheld nothing. I ran the substantial presence test and I think I'm still a nonresident alien for 2025 but I'm not totally sure. The 1099-B shows proceeds and cost basis both reported to the IRS. I don't know whether I even owe tax on this, whether I file Form 8949 and Schedule D the same way a resident would, or whether I file a different return entirely. I already looked at the IRS digital assets page and Publication 550 but neither one really addresses the nonresident piece directly. What should I actually do here?

38 comments

Nonresident aliens file Form 1040-NR, not the regular 1040. That changes everything about how capital gains are treated. For NRAs, gains from selling US stocks are generally NOT taxable by the US if the gain isn't effectively connected with a US trade or business — but there is one big exception. If you were physically present in the US 183 days or more during the tax year, net US-source capital gains are taxed at a flat 30% (or a lower treaty rate) on Schedule NEC of the 1040-NR. Portfolio gains from stocks traded on a US exchange are typically not US-source income for NRA purposes when you're under that 183-day mark. So if you're a pure investor, your March sale might not create any US tax liability at all, even with a 1099-B in hand — but check your 2025 day count first, because an F-1 student here all year is likely over 183 days.

Leah V.

Author

That's the part that confused me — the 1099-B made it feel like I definitely owed something. So the form existing doesn't automatically mean I owe tax as an NRA?

Correct. The 1099-B is just an information return the broker files. Having one doesn't determine your residency status or whether the gain is taxable to you. Your residency classification and whether the income is ECI are the actual questions.

The substantial presence test is the key threshold here. You count days under a specific formula — not just total days in the US. If you pass the test for 2025, you're a resident alien and file Form 1040 like anyone else, reporting the 1099-B on Form 8949. If you don't pass it, you file 1040-NR and the gain analysis is completely different. The SPT calculation for F-1 students also has an exemption for certain years that can exclude your student days entirely. That exemption is worth checking carefully.

Leah V.

Author

The exempt individual rule — I think I qualify for it for at least some of my time here, which is partly why I think I'm still NRA. That part of the calculation tripped me up.

F-1 students are generally exempt individuals for 5 calendar years. So those years' days don't count toward the 183-day threshold in the SPT formula. If you've been here fewer than 5 calendar years on F-1, you likely don't meet SPT and are still NRA. But confirm with the IRS instructions for Form 8843.

I had a similar residency question last year — NRA status, sold ETF shares, got a 1099-B, panicked. I uploaded the 1099-B and my visa entry records to taxr.ai and it walked through which lines on Form 8949 and 1040-NR would need entries if the gain was ECI versus not, and flagged that the broker may have reported proceeds but that NRA treatment of portfolio gains is a separate analysis from what the 1099-B shows. Helped me see what actually needed to be on the return versus what I was just assuming had to go there.

Leah V.

Author

That's exactly the kind of thing I need — understanding what goes on 1040-NR versus what I was just assuming transfers from the 1099-B automatically.

Worth knowing: if the gain IS treated as effectively connected income, then yes, you'd use Form 8949 and Schedule D (Form 1040, which 1040-NR filers also use) much like a resident would, with the 1099-B proceeds in column (d) and the reported basis in column (e). Box A checked for covered securities with basis reported to the IRS. The ECI analysis is what determines whether you get there at all.

Had ECI from a business I ran here while on a visa. The 8949 and Schedule D piece worked the same as for residents once ECI was established. The residency/ECI determination was the hard part.

One thing people miss: even if you owe zero US tax on the gains, you might still need to file a 1040-NR depending on other US-source income — wages, scholarships, anything subject to withholding. The capital gain question and the filing requirement question are separate.

Leah V.

Author

I do have wages from a campus job, so yes, I'm definitely filing 1040-NR for 2025. The question was really whether the stock sale goes on it and how.

Since wages are on there anyway, your 1040-NR is already happening. Whether the gain is ECI or non-ECI portfolio gain determines which part of 1040-NR it lands on — or doesn't appear at all if it's non-taxable portfolio gain.

The treaty question also matters and nobody's raised it yet. The US has tax treaties with many countries that modify how capital gains are taxed for NRAs from those countries. Some treaties give the country of residence exclusive taxing rights on capital gains, others have no provision. You'd look at your home country's treaty with the US — the IRS has a treaty table on its site. This doesn't change the ECI analysis but it's another layer.

Went through this for a client situation (not my own). The treaty article on capital gains, if there is one, can exempt gains that would otherwise be US-taxable. But you'd claim it on the 1040-NR with Form 8833 if the treaty position changes what's reported.

Mostly — if you were in the US fewer than 183 days in 2025, it would be non-ECI foreign-source or exempt income and wouldn't be reported on the 1040-NR. If you were here 183 days or more, though, net US-source capital gains are taxed at 30% (or a lower treaty rate) on Schedule NEC. The 1099-B was filed by the broker because brokers file them for all account holders; it doesn't mean you have US tax liability.

To confirm the ECI point: stock gains from trading on an exchange are almost never ECI for a passive investor NRA. ECI typically requires that you're conducting a US trade or business and the income is connected to it. Buying and selling stocks through a standard brokerage account as an individual investor is not a US trade or business under the rules. So most NRAs with a brokerage account owe zero US federal capital gains tax on those gains.

Leah V.

Author

That's reassuring. So in my case, if I'm confirmed NRA and the sales are just normal brokerage transactions, the gain likely doesn't appear on the 1040-NR at all?

Correct — it would be non-ECI foreign-source or exempt income and wouldn't be reported on the 1040-NR. The 1099-B was filed by the broker because brokers file them for all account holders; it doesn't mean you have US tax liability.

The holding period rules from Publication 550 still matter IF the gain ends up being ECI — short-term versus long-term is determined the same way, day after trade date you bought through trade date you sold. But as others have said, most passive NRA stock gains don't reach that analysis.

My situation was gains on US real estate, not stocks, so slightly different — FIRPTA applies to NRAs selling US real property and that IS subject to US tax regardless of ECI. I uploaded the closing disclosure and the withholding certificate to Taxr and it compared what the escrow withheld against what Form 8288-A showed, then drafted a summary of what Form 4797 and Schedule D on the 1040-NR needed to show. Real estate is a totally different world from stocks for NRAs.

Leah V.

Author

Mine is just publicly traded stocks, no real estate, so FIRPTA doesn't apply to me — but good to know that distinction exists.

Right — stocks on a US exchange, passive investor, NRA: not FIRPTA, likely not ECI, and not US-taxable unless you were in the US 183 days or more during the year, in which case the 30% (or treaty) rate applies. Real property is the opposite end of the spectrum.

Practical next step: nail down your residency determination first. Run the substantial presence test using the actual formula and document which days count and which don't (exempt individual days, commuter days, etc.). Then file Form 8843 if required — that's the statement exempt individuals file. Once residency is settled, the gain treatment follows from it.

Leah V.

Author

Form 8843 — I didn't realize that was separate from the 1040-NR. Is it always required or only under certain conditions?

Form 8843 is required for exempt individuals (which includes F-1 students) even if you have no US income and don't file a 1040-NR. It's a standalone statement filed separately. The instructions for 8843 say who must file it.

I had a 1099-B and a 1040-NR to reconcile and wasn't sure what to include. I gave Taxr the 1099-B, my visa timeline, and a draft 1040-NR and it identified which line items on the 1040-NR corresponded to ECI versus non-ECI income, flagged that the stock proceeds I'd put on Schedule D didn't belong there given my status, and listed what adjustments the return needed. Saved me from filing something with gains reported that I didn't actually owe tax on.

Had a similar over-reporting issue. Assumed everything on the 1099-B went straight onto the return and ended up with a larger liability than was actually owed.

State taxes are a separate question too. Some states tax NRA capital gains on US-source income even where the federal return doesn't, depending on the state and how it defines its own nonresident rules. If you have a state filing requirement (wages from that campus job would trigger it in most states), check whether your state follows the federal NRA treatment or has its own rules.

Leah V.

Author

Hadn't thought about state at all. I'm in a state with an income tax so I do file a state return for the wages. I'll need to look at how that state treats the stock sale.

To pull the residency question together: the IRS instructions for Form 1040-NR have a section on who must file and how to determine residency. That's the starting point, not Publication 550. Pub 550 assumes you're a US person. The 1040-NR instructions and Publication 519 (US Tax Guide for Aliens) are where the NRA rules actually live.

Leah V.

Author

Publication 519 — I hadn't found that one. That's probably where I should have started.

It covers the substantial presence test, the ECI rules, treaty positions, and what goes on each part of the 1040-NR. Much more directly on point than 550 for your situation.

Worth correcting something implicit in a few comments: even if you owe zero US tax, if you did receive US-source income subject to withholding (like dividends, not capital gains) you'd still see that on the 1040-NR. The stock sale gain being non-taxable doesn't affect how dividends or interest from the same account are treated — those are sourced and withheld differently.

If after all this you're genuinely unsure whether you meet the substantial presence test, an enrolled agent or CPA who handles international tax is worth consulting. The exempt individual rules for F-1 students have edge cases — multiple schools, travel patterns, prior visa categories — that can flip the analysis. The stakes of filing on the wrong form are significant.

Leah V.

Author

That's probably the right call. I'll work through 8843, confirm residency status with someone who knows international tax, and then settle the 1040-NR from there.

One last piece: if you determine you are a resident alien for 2025, the whole conversation changes — you'd file Form 1040, the gain goes on Form 8949 with box A checked (basis reported to IRS), flows to Schedule D, and you're taxed exactly like any other US investor. Long-term or short-term depends on whether you held more than one year. The 1099-B you have is already in the right format for that path.

Leah V.

Author

That at least is straightforward. The nonresident path is what needed sorting out. Appreciate everyone walking through this.