The S&P/TSX Composite Index closed up slightly Thursday as gains in industrials and real estate offset losses in energy.

The Canadian benchmark index finished the day up 42.18 points, to 19,062.85.

While the overall index climbed, energy stocks were down 2.15 per cent as oil prices fell.

Benchmark WTI crude was down nearly 3.5 per cent at US$96.47 a barrel as investors worried about crude demand, following a steeper-than-expected gain in U.S. gasoline inventories last week.

Meanwhile, Rogers Communications shares were little changed Thursday after the company announced it appointed Ron McKenzie as its new chief technology officer. McKenzie will replace Jorge Fernandes, less than two weeks after a nationwide network outage left millions of Rogers’ customers without access to phone or internet services.

Markets in New York were up Thursday. The S&P 500 rose 1 per cent, while the Dow Jones Industrial Average was 0.5 per cent higher and the Nasdaq was up 1.36 per cent.

Thursday’s trading marks the biggest three-day gain on the S&P 500 since May 27. However, despite some positive signs in U.S. markets, Chad Morganlander, a senior portfolio manager at Washington Crossing Advisors, said there are still hurdles ahead for equity markets.

Those hurdles, Morganlander said, include a deceleration of the U.S. economy, the U.S. Federal Reserve and European Central Bank raising rates and the Fed withdrawing liquidity from its balance sheet.

As a result, Morganlander said he would avoid commodities stocks in favour of consumer staples and health care.

“We would push more into defensive sectors, like consumer staples as well as healthcare. We think that healthcare is appropriately valued at this inflection point, based on the economic backdrop that we're looking at over the next six to 12 months,” Morganlander said in an interview.

After the close Thursday, social media company Snap Inc. reported second-quarter earnings that missed expectations. Shares of Snap fell 28 per cent in after-hours trading.

Despite market uncertainty south of the border, Art Hogan, chief market strategist at B. Riley Wealth Management, said he thinks it will become a more constructive environment for equities as inflation starts to ease, which could push the S&P 500 higher in the second half of the year.

Market pessimism is at its peak right now, that's your signal to buy: Art Hogan

Art Hogan, chief market strategist at B. Riley Wealth Management, joins BNN Bloomberg to talk on the markets. Hogan gives his optimistic outlook to where markets may go in the remainder of the year, saying market pessimism may have peaked. He dives into his barbell approach investing strategy and notes what sectors he is seeing value in including energy, financials and industrials.

“We suspect we've got a high-single-digit or low-double-digit return for the S&P 500 in the second half of this year, versus what we've seen in the first half of this year,” Hogan said in an interview Thursday.

“I think that will give us a remarkable year-over-year gain, but will certainly take us out of the hole that we're in.”

A benchmark European natural gas futures contract fell after Russia restarted gas shipments to Europe through its Nord Steam 1 pipeline.

Many European officials were worried that Russia would postpone restarting gas shipments through its biggest link to Europe, after gas flows were halted for 10 days of maintenance.

The Canadian dollar traded at 77.73 cents U.S., up 0.14 per cent Thursday.