US non resident capital gains tax — what actually applies when you sell US stocks?
Trying to figure out the US non resident capital gains tax situation for my own filing. I'm a nonresident alien (no green card, no substantial presence met this year) and I sold shares in a US-listed company through my brokerage account. The broker sent a 1099-B but I know nonresidents aren't always taxed the same way residents are. The gain is long-term. I can't tell if I owe anything to the IRS, whether I need to file a 1040-NR, or whether the treaty between my country and the US changes anything. I looked at the IRS digital assets page and Publication 550 but neither one really addresses the nonresident side. Has anyone dealt with this? What determines whether a nonresident owes US capital gains tax on stock sales, and what form actually gets filed?