Does a non-resident alien need to file 1040-NR with US stock capital gains?

Trying to figure out my filing situation. I'm on an F-1 visa, have been in the US about 14 months total, and my broker here generated a 1099-B showing gains from selling shares in a few US-listed companies. I sold everything before the end of the year, no losses, just straightforward gains. My university's tax office told me I'm still a non-resident alien for tax purposes under the substantial presence test, so I'd file 1040-NR. But then I read somewhere that capital gains for non-resident aliens might not even be taxable by the US, which confused me. Does a non-resident alien need to file 1040-NR with US stock capital gains, and if so, where do those gains actually go on the form?

35 comments

The answer depends on the type of gain and whether it's "effectively connected" with a US trade or business. For most non-resident aliens who just hold US stocks passively, capital gains from selling US-listed securities are generally NOT effectively connected income, and the US doesn't tax them. So those gains wouldn't create a filing requirement on their own. That said, if you had other US-source income (like wages or a scholarship stipend), you'd still file 1040-NR and just leave the capital gains section empty or note them as exempt.

Sean W.

Author

So the 1099-B my broker sent doesn't automatically mean I owe tax on those gains? That's what I assumed. Do I need to do anything with that 1099-B on the return?

F-1 students are specifically treated as non-resident aliens during the period their visa status exempts them from the substantial presence count, usually the first 5 calendar years. So your uni tax office is right. And under the Internal Revenue Code, non-resident aliens are generally exempt from US tax on capital gains unless they were present in the US for 183 days or more in the tax year AND the gains aren't from effectively connected income. That 183-day rule for NRAs is a separate test from the substantial presence test residents use.

Sean W.

Author

Wait so there's a 183-day count specifically for the capital gains exemption? That's separate from whether I'm a resident or non-resident?

Exactly. For non-resident aliens, IRC section 871(a)(2) applies a flat rate on net capital gains if you were in the US 183 days or more during the tax year. But if you were here fewer than 183 days, those gains escape US tax entirely. Your uni office can confirm your day count.

Had a similar situation last year on an F-1. What helped me was uploading my 1099-B and my entry/exit records to taxr.ai — Taxr went through the documents, flagged whether my day count crossed the 183-day threshold, and drafted a summary of which lines on 1040-NR I needed to fill and which to leave blank. I still reviewed the whole thing and confirmed the numbers myself, but it saved me from guessing. Main point: if your day count is under 183, those capital gains don't go on the return as taxable income.

Sean W.

Author

Did Taxr pull the day count automatically from your travel records, or did you have to enter that separately?

I uploaded a list of my entry and exit dates. It read through them and calculated the total days present, then mapped that against the 183-day threshold. I double-checked the math and it matched.

One thing worth flagging: even if the gains aren't taxable, some people still file 1040-NR just to get a refund of backup withholding. If your broker withheld anything on those sales — which they shouldn't for a properly documented NRA account — you'd want to file to claim it back. Did your 1099-B show any federal tax withheld in box 4?

Sean W.

Author

Box 4 on mine shows zero. So no withholding to recover.

Then no refund angle. If the gains are exempt and you have no other US-source income, you likely have no filing requirement at all. But confirm with your tax office since your situation (F-1, length of stay, any stipends) can shift things.

Something I wish someone told me earlier: make sure you gave your broker a valid W-8BEN. That certifies your foreign status and prevents backup withholding. If the W-8BEN wasn't on file when you sold, the broker might have withheld. Worth checking your account documents.

Sean W.

Author

I did fill out a W-8BEN when I opened the account. Good to know that's what prevents the withholding.

The 183-day rule for NRA capital gains is easy to misread. It's calendar days present in the US during that specific tax year, not a rolling average or weighted count like the substantial presence test. So if you were here fewer than 183 days in the year you sold the stock, the gain is not subject to US tax regardless of how long you've been in the country overall.

Also worth asking: were these US stocks held through a US brokerage account, or through a foreign broker that happened to trade US-listed securities? The sourcing rules can differ. For a standard US brokerage account with gains on exchange-traded equities, the passive NRA exemption generally applies. A foreign broker account with US securities is usually the same result, but the reporting path is different.

Sean W.

Author

US brokerage account, opened here when I started school. So I think I'm in the straightforward case.

If you do end up needing to report the gains — say your day count is at or over 183 — they'd go on Schedule NEC of the 1040-NR. That schedule handles capital gains and other income not effectively connected with a US business. The rate that applies is stated in the form instructions, so look there rather than assuming the same rates as a US resident's Schedule D.

Correct on Schedule NEC. And to be clear, effectively connected capital gains would go on a different part of the return, but that's a rarer situation for a student just holding stocks.

Went through the same question two years ago. My day count was 161 so the gains were exempt. I filed 1040-NR anyway because I had a teaching stipend that was taxable. The capital gains just weren't included anywhere on the return as income. The 1099-B sits in my records but nothing on the actual return reflected it.

Sean W.

Author

That's basically my situation except I'm not sure if my research stipend counts as US-source income. Need to confirm that part.

Stipends paid by a US university to an F-1 student are generally US-source income and show up on a 1042-S, not a W-2. If you got a 1042-S, that income goes on 1040-NR. Your tax office should know whether a treaty exemption applies.

Quick check: did you receive a 1042-S from anyone? Banks, universities, and brokers sometimes issue those for NRA payments. If a 1042-S exists with withholding, that's a separate reason to file 1040-NR even if the stock gains themselves are exempt.

I ran into this last filing season with a mix of 1099-B proceeds and a 1042-S from my institution. I gave Taxr both documents and it mapped out exactly which amounts belonged on 1040-NR, which were treaty-exempt, and which lines on Schedule NEC would be populated if my day count had been 183 or more. It also flagged that my broker's 1099-B cost basis reporting was for covered securities, so Form 8949 would apply if the gains were taxable. Useful to see it laid out before deciding whether to file.

Sean W.

Author

So even if the gains end up exempt, Form 8949 would still be involved if they were taxable? I didn't know NRAs used 8949.

Yes — if the gains were taxable as effectively connected income, you'd report them through Form 8949 and Schedule D, same as a US resident. The NEC route is specifically for the flat-rate non-effectively-connected gains. Two different tracks depending on the nature of the income.

Worth clarifying something from earlier: the 183-day test for NRA capital gains under section 871(a)(2) uses days present in the US during the tax year. It doesn't blend in prior years the way the substantial presence test does for residency. So your total time in the country across multiple years is irrelevant for this specific calculation.

I had a complicated year with RSU vesting on an F-1 and then sold some shares the same year. Taxr read through my 1042-S, my broker's 1099-B, and the equity award documents and walked me through which parts of 1040-NR each piece of income belonged to — the RSU compensation piece versus any subsequent gain on the shares after vesting. Helped me see the two amounts weren't the same thing and needed to land in different places on the return.

Sean W.

Author

RSUs on an F-1 sounds like a lot to sort out. Was the compensation piece from vesting treated as effectively connected?

Yes, because I was performing services in the US when they vested. That part was effectively connected income and went through the normal wage section of 1040-NR. Only the subsequent gain (or loss) from selling after vesting gets analyzed under the capital gains rules.

Don't overlook Publication 519 (US Tax Guide for Aliens) on irs.gov. It covers the NRA capital gains rules in more detail than Publication 550 does, and it has the residency determination rules, the 183-day NRA gains threshold, and treaty considerations all in one place. Worth reading alongside your tax office's guidance.

To pull the thread together: if you're a non-resident alien, your day count in the tax year is under 183, and the gains are from passively held US exchange-traded stocks through a US broker, the capital gains are generally exempt from US tax and don't create a standalone filing requirement. File 1040-NR if you have other US-source income (wages, stipends, fellowship payments) and report those through the correct schedules. The 1099-B sits in your records. The gains don't appear as taxable income on the return.

That's a solid summary. The one edge case to add: if someone is a non-resident alien but their broker didn't have a W-8BEN on file and withheld on the proceeds anyway, filing to recover that withholding becomes the reason to file, even with otherwise exempt gains.

Sean W.

Author

This thread answered it completely. W-8BEN was on file, day count is well under 183, gains are from a US brokerage account, no withholding in box 4. Looks like I don't have a filing obligation just from the stock sales.

One procedural note: even when you're not required to file, some NRAs file a protective return or a "sailing permit" (Form 1040-C) when they leave the country. That's a separate topic but worth knowing exists if you plan to depart the US permanently this year.

Sean W.

Author

Staying through the end of the program, so that's not immediately relevant, but good to know the concept exists.