(AP) -- Oil and gas exploration companies led U.S. stocks modestly higher Wednesday, giving the market its second gain in two days.
Energy stocks, already the best-performing category this year, got a boost from U.S. crude oil prices, which climbed to $51.60 a barrel, the highest level in 15 months. Companies that make consumer products were the biggest laggards.
Investors brushed off new data showing residential construction slowed last month. Instead, the focus remained on the latest crop of companies reporting quarterly results.
Overall earnings for companies in the Standard & Poor's 500 index have been down on an annual basis the past five quarters. But the results so far suggest the start of a turnaround, said Paul Christopher, head global market strategist for Wells Fargo Investment Institute.
"We do think the earnings recession is ending," Christopher said. "We're still early in the reporting season, but we see so far the trends that we're looking for."
The Dow Jones industrial average gained 40.68 points, or 0.2 percent, to 18,202.62. The S&P 500 index rose 4.69 points, or 0.2 percent, to 2,144.29. The Nasdaq composite index added 2.58 points, or 0.1 percent, to 5,246.41.
Indexes wavered between small gains and losses in early trading Wednesday, then turned higher by midday and stayed higher for the rest of the day.
Morgan Stanley rose 1.9 percent after the investment bank said its earnings soared 62 percent in the third quarter, thanks to big gains in bond trading. Goldman Sachs disclosed similar results Tuesday. Morgan Stanley added 61 cents to $32.93.
Quarterly results from other companies failed to impress traders.
Intel, which issued a downbeat earnings outlook late Wednesday, slumped $2.24, or 5.9 percent, to $35.51.
Manhattan Associates tumbled 10.4 percent after the business software company reported weak quarterly sales and cut its revenue outlook. The stock fell $6.16 to $52.85.
Lighting maker Cree also served up weak sales and an earnings outlook that fell short of Wall Street's expectations. The stock tumbled $2.79, or 11.1 percent, to $22.41.
About 80 of the companies in the S&P 500 were scheduled to report quarterly results this week. Earnings for the third quarter are projected be down about 0.9 percent overall from a year ago, according to S&P Global Market Intelligence. That forecast is largely due to the energy sector, which has been hard hit by falling energy prices.
That wasn't the case Wednesday.
A report of a drawdown in oil inventories helped lift crude prices. U.S. benchmark crude oil gained $1.31, or 2.6 percent, to close at $51.60 a barrel in New York. Brent crude, the international standard, added 99 cents, or 1.9 percent, to close at $52.67 a barrel in London.
The pickup in oil prices sent shares in several energy, exploration and drilling services companies higher.
Transocean jumped 56 cents, or 5.7 percent, to $10.46. Halliburton rose $2, or 4.3 percent, to $49.07, while Newfield Exploration climbed $1.65, or 3.9 percent, to $44.18.
Global stock markets were mostly steady Wednesday after China reported its economy expanded at a firm pace in the July-September quarter.
In Europe, Germany's DAX rose 0.1 percent, while France's CAC 40 gained 0.3 percent. The FTSE 100 in Britain added 0.3 percent. Earlier in Asia, Japan's Nikkei 225 index rose 0.2 percent, while Australia's S&P ASX/200 added 0.5 percent. The Kospi in South Korea was flat. Hong Kong's Hang Seng index lost 0.4 percent.
Other energy futures closed mostly higher. Wholesale gasoline was little changed at $1.51 a gallon. Heating oil rose 2 cents to $1.59 a gallon. Natural gas fell 9 cents to $3.17 per 1,000 cubic feet.
In metals trading, the price of gold rose $7 to $1,269.90 an ounce, while silver added 3 cents to $17.66 an ounce. Copper was little changed at $2.10 a pound.
Bond prices barely budged. The yield on the 10-year Treasury note held steady at 1.74.
In currency markets, the dollar fell to 103.39 yen from 103.89 yen, while the euro weakened to $1.0969 from $1.0977.