Foreign nationals who qualify as nonresident aliens generally do not have to pay US capital gains taxes unless a) they have been in the US for more than 183 days and b) the US has become their tax home. In such cases, they will be subject to a flat capital gains tax of 30%.