Stocks rallied Tuesday as technology companies continued to recover from their recent losses.
The approach of Hurricane Florence sent home improvement retailers and gas prices higher. The Department of Energy said it's seeing signs that shipments of oil from Iran are falling as the U.S. prepares to resume sanctions on the Iranian energy industry and pushes other countries to stop buying.
Apple climbed a day before it's set to announce new phone designs and other products. Video game companies Activision Blizzard and Take-Two Interactive also jumped. Other big technology companies, and their compatriot Amazon, rose for a second day after big declines last week.
Brad McMillan, chief investment officer for Commonwealth Financial Network, said that when investors' confidence in the technology sector wavers, it tends to come back quickly because the companies are so profitable.
"There's no way smaller companies can compete," he said, although that comes with risks. "When a company gets successful beyond a certain level it does draw government attention."
The S&P 500 index rose 10.76 points, or 0.4 percent, to 2,887.89. The Dow Jones Industrial Average gained 113.99 points, or 0.4 percent, to 25,971.06. The Nasdaq composite added 48.31 points, or 0.6 percent, to 7,972.47. The Russell 2000 index of smaller and more U.S.-focused companies inched up 0.94 points, or 0.1 percent, to 1,718.40.
Investors also anticipated possible gas shortages linked to Florence. Wholesale gasoline futures surged 2.8 percent to $2.01 a gallon.
Property and casualty insurance companies have slumped in the last week as the storm has grown.