NEW YORK (AP) -- U.S. stocks bobbed higher Tuesday as technology and consumer-focused companies regained a sliver of their losses from the day before. Oil prices and energy companies jumped as the U.S. pressed its allies to stop importing oil from Iran.
Coming off their worst loss since early April, stocks were on track for hefty gains Tuesday afternoon but weakened late in the day. Technology companies like Apple bounced back after abrupt losses on Monday. General Electric led industrial companies higher after it said it would shrink even further by spinning off its health care business and its oil service unit.
Banks and other financial companies took losses as bond yields and interest rates remained well off their highs from last month. Household goods makers also slipped.
Julian Emanuel, chief equity and derivative strategist for BTIG, said the stock market is going to be volatile as long as investors are concentrating on the trade disputes the U.S. is having with many of its biggest trading partners.
"The economy is strong as it stands now and earnings are great, but when all of the psychic energy and all of the focus is on the trade war, as it was in late March and early April, the market has responded accordingly," he said.
The S&P 500 index gained 5.99 points, or 0.2 percent, to 2,723.06. It fell 1.4 percent Monday. The Dow Jones Industrial Average gained 30.31 points, or 0.1 percent, to 24,283.11. The Nasdaq composite added 29.62 points, or 0.4 percent, to 7,561.63 after it plunged 2.1 percent a day ago. The Russell 2000 index picked up 11.02 points, or 0.7 percent, to 1,668.53.
A senior State Department official said the Trump administration wants allies to stop importing oil from Iran. If they do it would increase demand from other countries, which would likely produce more oil to pick up the slack. Benchmark U.S. crude added 3.6 percent to $70.53 a barrel in New York. Brent crude, used to price international oils, rose 2.1 percent to $76.31 per barrel in London.
President Donald Trump withdrew the U.S. from the Iran nuclear deal in May, so sanctions on Iran's energy sector will kick in again in November. The State Department official said the U.S. is telling Asian and European governments that they should completely eliminate their oil imports from Iran before the grace period expires on November 4.
Exxon Mobil jumped 1.1 percent to $80.64 and Chevron picked up 1.3 percent to $124.16.
Apple climbed 1.2 percent to $184.43 and Facebook gained 1.3 percent to $199. Technology stocks were hammered Monday as investors reacted to reports that the Trump administration might bar technology companies from selling certain high-tech products to China and other countries and limit investment in tech companies by Chinese firms. Stocks recovered some of those losses after a top U.S. trade adviser rebutted those reports.
Consumer focused companies also rose. Amazon jumped 1.7 percent to $1,691.09 and Netflix rose 3.9 percent to $399.39 after they both dropped on Monday. Homebuilder Lennar climbed 4.9 percent to $51.61 after a strong quarterly report, and its competitors also climbed.
It's been five months since the S&P 500 and Dow last closed at record highs. The S&P 500 is down 5.2 percent since Jan. 26 and the Dow has fallen 8.8 percent. However the Nasdaq, which has a high concentration of technology companies, and the smaller and more domestically-focused Russell 2000, closed at record highs on Wednesday.
Emanuel said investors' decision to shift money into smaller companies might also lead to headaches later on because those stocks are more volatile than the larger and more multinational companies in the S&P 500.
"This whole notion of small caps being a safe haven is really a headscratcher," he said.
GE jumped 7.8 percent to $13.74 after the company said it will sell its two-thirds stake in Baker Hughes and also divest its health care business. The company has sold numerous major businesses in recent years including its railroad locomotive division, lending unit, its appliance businesses and its stake in NBC, and on Monday GE agreed to sell its gas-engine business to Advent International for $3.25 billion.
Tuesday was also the first day in 110 years that General Electric wasn't part of the Dow Jones Industrial Average.
Bond prices were little changed. The yield on the 10-year Treasury note remained at 2.88 percent. Banks continued to fall, as lower interest rates reduce the profits they make on mortgages and other types of lending.
In other commodities trading, gold lost 0.7 percent to $1,259.90 an ounce. Silver sank 0.5 percent to $16.25 an ounce. Copper rose 0.2 percent to $2.99 a pound.
Wholesale gasoline rose 1.1 percent to $2.07 a gallon. Heating oil gained 1.4 percent to $2.13 a gallon. Natural gas rose 0.5 percent to $2.94 per 1,000 cubic feet.
The dollar rose to 110.13 yen from 109.45 yen. The euro fell to $1.1650 from $1.1704.
Germany's DAX lost 0.3 percent and the French CAC 40 fell less than 0.1 percent. The FTSE 100 in Britain jumped 0.6 percent.
Japan's benchmark Nikkei 225 index rose less than 0.1 percent while South Korea's Kospi lost 0.3 percent. Hong Kong's Hang Seng shed 0.3 percent.