Sorry for confusions.
Please see this example from IRC regulations
Example 1. B, a nonresident alien individual not engaged in trade or business in the United States and using the calendar year as the taxable year, is present in the United States from May 1, 1971, to November 15, 1971, a period of more than 182 days. While present in the United States, B effects for his own account on various dates a number of transactions in stocks and securities on the stock exchange, as a result of which he has recognized capital gains of $10,000. During the period from January 1, 1971, to April 30, 1971, he carries out similar transactions through an agent in the United States, as a result of which B has recognized capital gains of $5,000. On December 15, 1971, through an agent in the United States B sells a capital asset on the installment plan, no payments being made by the purchaser in 1971. During 1972, B receives installment payments of $50,000 on the installment sale made in 1971, and the capital gain from sources within the United States for 1972 attributable to such payments is $12,500. In addition, during the period from January 1, 1972, to May 31, 1972, B effects for his own account, through an agent in the United States, a number of transactions in stocks and securities on the stock exchange, as a result of which B has recognized capital gains of $20,000. At no time during 1972 is B present in the United States or engaged in trade or business in the United States. Accordingly, for 1971, B is subject to tax under section 871(a)(2) on his capital gains of $15,000 from the transactions in that year on the stock exchange. For 1972, B is not subject to tax on the capital gain of $12,500 from the installment sale in 1971 or on the capital gains of $20,000 from the transactions in 1972 on the stock exchange.
As we see a nonresident alien who spent in the US less than 183 days DO NOT pay any taxes on capital gains realized from trading stocks.
You must provide Form
W8-BEN and additional required documents to your broker and establish that you are a nonresident alien and claim that you are the beneficial owner of the income.
Sorry for confusion.