Stocks rebounded in late trade on Wednesday after a day of wild price swings, with the Dow and Nasdaq eking out gains as investors hoped that corporate results would top estimates as the quarterly earnings season prepared to kick off.

Stocks were sharply lower for most of the day as investors worried that an economic recovery will be slower than thought. Those fears helped send crude oil futures to a more than a six-week low, while copper, a barometer for global demand, hit a two-week low as commodities sold off across the board.

The earnings season unofficially began after the bell, with the release of results from aluminum giant Alcoa Inc , the first Dow component to report. Investors are concerned that companies will have little good news in their quarterly reports and outlooks.

People are probably jockeying for position in front of earnings season said Kevin Kruszenski, head of listed trading at KeyBanc Capital Markets in Cleveland.

The Dow Jones industrial average <.DJI> gained 14.81 points, or 0.18 percent, to 8,178.41. The Standard & Poor's 500 Index <.SPX> dropped 1.47 points, or 0.17 percent, to 879.56. The Nasdaq Composite Index <.IXIC> added 1.00 points, or 0.06 percent, to 1,747.17.

The S&P Energy index <.GSPE> fell 0.1 percent as ConocoPhillips dropped 1.4 percent to $39.44 as crude settled down 4.4 percent to $60.14 per barrel. US Steel Corp dropped 3.6 percent to $30.50 with declining metal prices.

The U.S. Energy Information Administration released data that showed gasoline and distillate inventories rose more than expected last week, pointing to ongoing weakness in demand -- adding to fears about the economy.

Shares in the healthcare and consumer staples sectors, traditionally seen as better able to weather a weak economy, helped boost indexes as stocks such as Johnson & Johnson and Merck & Co , both up around 1.5 percent, helped push the Dow industrials into positive territory late in the session.

In an overall shift away from riskier assets, investors in global currency markets on Wednesday unwound positions in which they borrowed in yen to fund riskier, higher-yielding investments. That sent the dollar, euro and other world currencies lower against the Japanese currency.

After a rally that pushed up the S&P 500 as much as 40 percent from 12-year lows in early March, investors have been met with a rash of data -- especially the weaker-than-expected June U.S. payrolls report last week -- that has undermined hopes for an economic rebound.

(Editing by Leslie Adler)