Chinese and Hong Kong stocks edged higher on Wednesday after Huawei's chief financial officer was granted bail by a Canadian court, and as U.S. President Donald trump sounded upbeat about a trade deal with China.

However, investors stayed on the sidelines, fearing further losses towards the end of a challenging year.

The Shanghai Composite index edged 0.2 percent higher at 2,599.16. The blue-chip index also traded 0.2 percent higher.

The CSI300 financial sector sub-index climbed 0.2 percent, the consumer staples sector rose 0.1 percent, and the real estate index was up almost 1 percent.

The smaller Shenzhen index was up 0.1 percent and the start-up board ChiNext Composite index traded flat.

In an interview with Reuters, U.S. President Donald Trump said on Tuesday he would intervene in the Justice Department's pursuit of Meng Wanzhou, CFO at Chinese technology giant Huawei Technologies Co Ltd, if such a move would enhance national security or help close a trade deal with China.

Meng Wanzhou was granted bail by a Canadian court on Tuesday, 10 days after her arrest in Vancouver.

Trump said talks were taking place with Beijing by phone and he would not raise tariffs on Chinese imports until he was sure about a deal.

The comments came after Chinese and U.S. officials spoke on the phone to hammer out a timetable and roadmap to the bilateral trade negotiations. Earlier this month, the two sides agreed to refrain from adding tariffs for 90 days.

"People still care about (trade war) headlines, such as the news about Huawei," said Linus Yip, chief strategist at First Shanghai Securities in Hong Kong. "But we also know that there is still time, things may still change before the deadline."

Market sentiment is turning more positive as China celebrates the 40th anniversary of reform and opening up, said Zhang Qi, a Shanghai-based analyst with Haitong Securities, noting that investors "believe the government will come up with more measures to support" the economy and the stock market to mark the occasion.

But many investors stayed on the sidelines this week. Daily turnover in Shanghai dropped to 85.4 billion yuan ($12.42 billion) on Tuesday, the lowest since January 2016. The figure stood at 49.8 billion yuan at midday.

"The market has not done very well this year," said Zhang. "Many large institutional investors are not willing to take the risk of losing more towards the end of the year."

In Hong Kong, expectations that the U.S. Federal Reserves will slow down in hiking rates lifted local stocks. The Hang Seng index was up 1.5 percent at 26169.35 points, whereas Chinese companies listed in the city climbed 1.6 percent. Rate-sensitive property stocks, up 2.6 percent, led the gains.

While markets still expect the Fed will tighten at its policy meeting next week, Trump said the central bank would be "foolish" to do so.

The largest percentage gainers in the main Shanghai Composite index were Aurora Optoelectronics Co Ltd, up 7.2 percent, followed by Ningbo Jifeng Auto Parts Co Ltd, gaining 6.4 percent and Guangdong Wencan Die Casting Co Ltd, up by 6.1 percent.

The top gainer on the Hang Seng was China Resources Land Ltd, up 5.9 percent, while the biggest loser was Hengan International Group Company Ltd, down 5.7 percent.

($1 = 6.8733 Chinese yuan)

(Reporting by Shanghai and Hong Kong newsrooms, Editing by Sherry Jacob-Phillips) ((noah.sin@thomsonreuters.com; Reuters Messaging: noah.sin.thomsonreuters.com@reuters.net))