As cheer over energy stocks’ rally gives way to unease over valuations, retreating oil prices are prompting some investors to step away from the sector.

After years of underperforming, energy stocks are up 24% this year – sending the S&P/TSX Composite to record highs – as political tensions in Russia and Iraq stirred fears of a supply shock, sending oil prices higher. A weaker loonie also boosted company earnings.

“This has been a fantastic run, but we’re looking to take money off the table,” says Martin Pelletier, money manager at TriVest Wealth Counsel in Calgary.

Oil prices rose to a nine-month high amid violence in Iraq, the second-largest oil producer in OPEC. But prices have turned lower recently, as traders have scaled back bets that violence will lead to a global supply shortage.

“Will we be talking about Iraq two months from now? I don’t think so,” says Pelletier.

Read: Europe bounces back

Such caution stems from high valuations of the Canadian energy sector and the broader market, which is in a maturing bull phase. The energy group currently trades at 29 times earnings (trailing PE), compared to 20.2 for the benchmark S&P/TSX Composite.

“The market is getting complacent and stocks aren’t pricing in all the risks,” says Pelletier, adding energy shares tend to rally in the later stages of a bull market.

Others agree the sector is due for a reality check, but say weaknesses will be temporary. “Energy companies will continue to do well with a weakening Canadian dollar and high energy prices,” says Craig Porter, money manager at Front Street Capital in Toronto.

Read: Attract clients from the oil and gas sector

Porter says energy shares have risen due to stronger earnings, driven in part by the narrowing spread between Canadian crude oil and the benchmark WTI. The heavier Canadian crude typically trades at a discount to WTI. With more crude oil being shipped by rail, companies are skirting bottlenecks that have crimped prices in recent years.

Another reason for the rally is strong M&A activity in the sector, which is at a multi-year high.

Porter sees opportunity in drilling and energy infrastructure stocks as companies increase exploration activity in Western Canada. He likes Precision Drilling Ltd.: one of Canada’s biggest drilling services provider, the company is building more rigs with no additional debt. While the stock is up 51% this year, Porter expects Precision Drilling to benefit on expectations of increasing day rates (what the company charges its clients for rigs).

Read: Why Canada isn’t a global energy leader

Natural gas is another opportunity. A cold North American winter prompted a surge in demand, and U.S. inventories are now 33% below average. Porter expects natural gas producers to benefit as the U.S. races to rebuild its reserves.

He also likes Tourmaline Oil Corp., a low-cost energy explorer that has steadily ramped up production to more than 100,000 barrels of oil equivalent a day over the last six years. Porter expects Tourmaline to maintain its focus on growing production, which hit a record high of 102,563 earlier this year.