TORONTO -- Canada's main stock edged higher Tuesday despite the majority of corporate earnings missing expectations so far this quarter.

The S&P/TSX composite index closed up 12.11 points at 16,681.92, less than 15 points off its all-time high.

In New York, the Dow Jones industrial average set a new high of 27,558.29 but closed up 30.52 points at 27,492.63. The S&P 500 index was down 3.65 points at 3,074.62, while the Nasdaq composite was up 1.48 points at 8,434.68 after setting a new record of 8,457.32 in earlier trading.

"We're in the midst of companies reporting their earnings on both the TSX and south of the border. However, it's turned out to be a rather directionless day," said Craig Jerusalim, portfolio manager at CIBC Asset Management.

In Canada, 44 companies have missed expectations so far, 37 beat them and two were in line, he said. While sales have increased about one per cent from the prior quarter, earnings are down five per cent.

In the U.S., 79 per cent to the nearly 400 companies beat muted forecasts.

The main drivers for market increases are optimism of a phase one trade deal between the U.S. and China, accommodating monetary policy and supportive economic data such as jobs growth, said Jerusalim.

In addition, there's a rotation by investors out of sectors that have done well such as technology, into cyclical stocks such as financials as they seek the next opportunities.

The Canadian dollar traded for 76.03 cents US compared with an average of 76.06 cents US on Monday.

Eight of the 11 major sectors on the TSX were higher, led by energy which rose 1.2 per cent as shares of Encana Corp. surged 8.2 per cent on heavy trading as crude oil and natural gas prices climbed.

The December crude contract was up 69 cents at US$57.23 per barrel and the December natural gas contract was up 4.1 cents at US$2.86 per mmBTU.

Jerusalim doesn't see crude breaking out of its current trading range because of the U.S. shale's ability to ramp up production, unless OPEC appeases markets by cutting back its own output.

Meanwhile, natural gas increased to an eight-month high on expectations of a cold winter, low inventories and less gas available because of declines in oil production, he said.

The heavyweight financials sector gained more ground as Fairfax Financial Holdings Ltd. was up six per cent while materials rose despite lower gold prices as Nutrien Inc. shares were up 1.2 per cent on a positive outlook for 2020.

The December gold contract was down US$27.40 at US$1,483.70 an ounce and the December copper contract was up 2.95 cents at US$2.70 a pound.

Technology lost 2.1 per cent as Shopify Inc. fell four per cent and Blackberry Ltd. was down 1.2 per cent.

Jerusalim said the markets continue to hover around all-time highs because of a lack of alternatives for investors with low interest rates and GDP looking more positive in the short to medium-term.

However, trade remains a big wild card that can drive down markets with one negative presidential tweet. Ultimately, he said China has to decide if it wants to negotiate a deal with Trump or wait for the next U.S. president in one or five years.

"The market is very jittery and would respond negatively to negative headlines."

This report by The Canadian Press was first published Nov. 5, 2019.