NEW YORK (CNN/Money) -
The stock market chalked up solid gains for the third quarter but rising energy prices made it a rocky ride.
The rest of the year may not be much easier.
For the quarter, the Nasdaq jumped 4.6 percent, the S&P 500 gained 3.2 percent and the Dow industrials climbed nearly 2.9 percent.
That's a bit better than average. Yet, most of those gains came in July and late September, with the rest of the quarter plagued by murky sentiment and volatile trading.
"I'd characterize third-quarter stock performance as disappointing and event-driven, although it was understandable why the market reaction was what it was," said William Hummer, principal at money manager Wayne Hummer, Inc.
Hummer was referring the surge in oil prices in August and September, the pair of rate hikes we got from the Federal Reserve and the one-two punch of hurricanes Katrina and Rita.
Granted, even without all of this, the period wasn't expected to be particularly positive for stocks. September is usually the worst month for the three major averages, according to the Stock Trader's Almanac, and August and October aren't much better.
But this year was a little different. Stocks were more upbeat than usual in the often upbeat month of July, then sputtered for the rest of the quarter. Strip that out and you'd have a much more negative picture.
Stocks jumped that month as investors breathed a sigh of relief that second-quarter earnings were stronger than initial expectations. Hopes that the Fed might pause in its interest-rate hiking campaign and a certain "head in the sand" take on rising oil prices helped.
Yet the optimism faded come August, with worries beginning to surface about the economy heating up too fast. Then Katrina and Rita hit, and that added to the uncertainty, said Subodh Kumar, chief U.S. investment strategist at CIBC World Markets.
"The overriding issue in the market is still the reality of higher energy prices and interest rates," Kumar added. "It looks like these things are holding the market back, even though earnings are good and the economy, both here and globally, seems OK."
The twin worries will keep the market nervous "until they are addressed," he added.
Double, double, oil and trouble
One result of surging oil prices: energy stocks were again the strongest sector in the S&P 500, just as they were in the first two quarters and in 2004. (For a look at the top sectors in the quarter, see the chart).
Whether that will continue is a matter of some debate on Wall Street.
"I think energy stocks will flatten or worse," said Hummer. "I'm not looking at the sector to tank, but I don't think it will hold the same appeal for money managers as it has in the previous three quarters."
Energy prices were already significantly higher before Katrina and Rita, and the storms mean oil prices will stay high, said Ben Halliburton, chief investment officer and founder of Tradition Capital Management. But the underlying stocks are approaching fair value after having run up for nearly two years, he said.
Even so, he thinks oil exploration and production stocks may still be worth a look. Some of the stocks are trading as if oil is $50 a barrel whereas "oil is at $65 right now," said Halliburton. "So even if oil prices were to fall back, that sub-sector would still be undervalued."
Oil and gas exploration and production stocks jumped nearly 30 percent in the quarter and are up 71 percent year-to-date.
Elsewhere coal stocks led the industry, jumping about 46 percent in the quarter, and are up 87 percent year-to-date. Oil and gas refiners and marketers held the second spot, with gains of 44 percent and 94 percent, respectively.
Clothing retailers and department stores, home furnishing firms and thrifts and mortgage companies were among the worst performers. (For a look at S&P 500 winners and losers, see the chart.)
Crystal ball gazing
Regardless of whether the stocks pull back, oil prices look to remain high, which will keep pressure on the broader market as investors worry about the impact of high energy costs on the economy -- and earnings.
"Consumers are going to be in for an ugly winter, heating their homes and fueling their cars," Halliburton said "As a result, consumer spending in other areas is going to change."
Non-essentials will feel the impact, with recreation and consumer electronics stocks likely to slump, said Michael Swanson, senior economist at Wells Fargo.
"If you have to reapportion money on energy, you're not going to take it out of money you spend on food, medicine or clothing," Swanson said. "The staples aren't effected, but the discretionary items are, and you're likely to see that reflected in the stock market."
Stocks that could do well in the quarter include those affected by the reconstruction of the Gulf Coast, said CIBC's Kumar.
Financials, which have had a tough time amid rising rates, could see a bit of a recovery in the fourth, Kumar added. Additionally, he said that people are underestimating select companies in info tech.
Health care, excluding the big drugmakers, are likely to benefit as investors look for defensive stocks, some analysts said.
As for the broader market, it may not suffer that much overall though trading could be volatile, Swanson said, noting pressure from oil and interest rates could spur sector rotation or some modest moves out of the market, rather than wholesale selling.
"The question is, if you have money to invest, do you want to put it into the bond market, which has inflation issues, or keep it in stocks," Swanson said. "Stocks will probably continue to hold up in the quarter because other asset classes are less attractive."
Additionally, November and December are traditionally up months for the stock market, with strong inflows into mutual funds, holiday retail sales, and other stimulative factors in play.
"Earnings growth for the S&P 500 continues to be robust, and could end up beating north of 10 percent for the year," Tradition Capital's Halliburton said, adding he thinks those will support stocks even if short-term rates keep rising.
"Looking into the fourth quarter, the market could move up a little from here," he added.