I found this:
--------------------------
Trading in stocks, securities, and commodities.
If your only U.S. business activity is trading in stocks, securities, or commodities (including hedging transactions) through a U.S. resident broker or other agent, you are not engaged in a trade or business in the United States.
For transactions in stocks or securities, this applies to any nonresident alien, including a dealer or broker in stocks and securities.
For transactions in commodities, this applies to commodities that are usually traded on an organized commodity exchange and to transactions that are usually carried out at such an exchange.
This discussion does not apply if you have a U.S. office or other fixed place of business at any time during the tax year through which, or by the direction of which, you carry out your transactions in stocks, securities, or commodities.
Trading for a nonresident alien's own account.
You are not engaged in a trade or business in the United States if trading for your own account in stocks, securities, or commodities is your only U.S. business activity. This applies even if the trading takes place while you are present in the United States or is done by your employee or your broker or other agent.
https://www.irs.gov/publications/p519#en_US_2017_publink1000222317
https://www.irs.gov/pub/irs-pdf/p519.pdf