The Week on Wall Street: Headwinds

Stocks ended the week lower as investors were rattled by rising energy prices and worries regarding potential fallout from two struggling mortgage securities funds managed by Bear Stearns.

The Dow Jones Industrial Average, which was within striking distance of a new record high at the beginning of the week,closed the week down about 2.1%, the S&P 500 fell 2.0% and the Nasdaq Composite declined 1.4%.

All ten economic sectors tracked by S&P closed lower but basic materials stocks and technology shares weathered the storm relatively well. Utilities stocks were whacked, closing with a weekly decline of 4%.

Monday

Stocks closed slightly lower on Monday as investors focused on rising oil prices and fluctuating interest rates.

"Prices for crude oil are not really moving up as much as they are being pulled up by gasoline," said Stephen Schork, editor of The Schork Report. "Specifically, there's the persistent fear in the market that there is not going to enough gasoline to get us through the season."

Tuesday

Stocks closed mostly higher on Tuesday as investor sentiment was helped by lower bond yields.

"We're kind of backing and filling in a normal pause to refresh," Al Goldman, chief market strategist at A.G. Edwards, told CNBC.com. "This market bends a little bit but it doesn't break. The buyers are a little bit tired but the sellers are not very aggressive."

Wednesday

Stocks closed sharply lower following a surge in energy prices and the Dow closed with a loss of more than 145 points.

"Over the last couple of weeks, interest rates have been very important to the market," said Peter Costa, senior managing director at Lipari Partners. "Concern about what is going to happen with the Fed is making things tenuous."

"People are starting to realize higher yields means interest rates are going to be higher and that will eventually slow the economy," said Dan Morgan, portfolio manager at Synovus Securities.

Traders were also spooked by news that two hedge funds operated by Bear Stearns were struggling to avoid a potential fire sale of their mortgage securities.

The consumer discretionary sector was the best performer, while the energy sector saw the biggest declines due to a pullback in crude oil prices. ExxonMobil helped to drag down the Dow as the biggest percentage loser, dropping more than 2%. Home Depot was the big gainer on the Dow, rising almost 6% on a share buyback announcement.

Thursday

Stocks closed higher as investors were encouraged by solid economic data amid a broad rally in technology stocks.

"We were pretty oversold yesterday," said Tom Schrader, managing director of US listed trading at Stifel Nicolaus. "We had some good news from the tech sector which propelled the Nasdaq higher."

The Dow Jones Industrial Average rebounded from a 146-point swoon and closed with a gain of 56 points, or 0.4%. Similar gains were notched by the Nasdaq Composite and S&P 500.

The market's rebound Thursday, traders said, was also due in part to JPMorgan Chase's agreement to unwind its position in two troubled debt securities funds operated by Bear Stearns .

"Today they were able to hedge that bet and ease some fears of a potential Long Term Capital situation," Schrader said, referring to the 1998 collapse of the $4.7 billion hedge fund. "Every time a new headline came out about Bear or JP Morgan or Merrill Lynch , it helped the market," he added.

Shares of chipmakers moved higher across the board after shares of Advanced Micro Devices were upgraded by an analyst.

Friday

The public debut of private equity titan Blackstone Group held the attention of investors on Friday but the widely anticipated IPO was not enough to prop up the overall market, which declined about 1%.

Financial stocks such as Citigroup and Merrill Lynch were in focus on continuing concerns regarding steep losses in two funds operated by Bear Stearns.

Peter Kang is a markets writer at CNBC.com. He can be reached at peter.kang@nbcuni.com.