NEW YORK (Reuters) - The S&P 500 eked out a small gain while the Dow declined after a volatile trading session on Wednesday, with weakness in sectors such as consumer staples and financials offsetting strong gains in the energy and industrial indexes.

FILE PHOTO: Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., March 29, 2018. REUTERS/Brendan McDermid

Higher oil prices boosted energy stocks while transport stocks such as CSX Corp helped the industrial sector. But IBM’s (IBM.N) 7.5 percent drop was the biggest drag on the S&P after the technology company’s quarterly profit margins missed Wall Street targets.

“There’s a lot of headlines pulling the market in different directions. The most notable is energy prices pulling that sector higher,” said David Joy, chief market strategist at Ameriprise in Boston.

Joy attributed a drop in financial stocks to a flattening yield curve in U.S. treasuries.

“Earnings and the yield curve are the two biggest influences,” said Joy, adding that “transports are very strong today which is a very good sign for the economy.”

No. 3 U.S. railroad operator CSX (CSX.O) jumped 7.8 percent after topping profit estimates. Its news lifted other railroads, and helped to push the Dow Jones Transport index .DJT up 1.7 percent.

Also United Continental (UAL.N) gained 4.8 percent and lifted other airline stocks after reporting a better-than-expected quarterly profit.

Trading was choppy, with the Dow swinging between positive and negative territory while the S&P 500 gave up most of its gains in the last few minutes of trading.

The Dow Jones Industrial Average .DJI fell 38.56 points, or 0.16 percent, to 24,748.07, the S&P 500 .SPX gained 2.25 points, or 0.08

Read more from our friends at Reuters: