TORONTO (Reuters) - Canada's main stock index gained on Wednesday as Hudson's Bay Co (>> Hudson's Bay Co) surged on a plan to carve out its real estate assets and banking stocks rose after Royal Bank of Canada (>> Royal Bank of Canada) and National Bank of Canada (>> National Bank of Canada) posted solid earnings.

HBC said it will form two real estate joint ventures that will bring in about C$1.1 billion ($890 million) in cash. The stock shot up 19.7 percent to C$26.57.

"They have very, very attractive real estate and I think the market is viewing it as unlocking the value and as a win-win," said Philip Petursson from the portfolio advisory group at Manulife Asset Management.

RBC shares rose 3.7 percent to C$77.80, the single biggest positive impact on the index, after the country's largest bank posted stronger-than-expected quarterly profit and hiked its dividend.

The smaller National Bank of Canada also cheered investors with their earnings, with its shares ending up 3.3 percent at C$48.43.

Other banking stocks also rose, with Toronto-Dominion Bank (>> Toronto-Dominion Bank) up 1.2 percent at C$53.93 and Bank of Montreal (>> Bank of Montreal) adding 1.6 percent at C$77.01.

Investors also tuned in to a fresh round of congressional testimony from U.S. Federal Reserve Chair Janet Yellen. She said on Tuesday the Fed is preparing to consider interest rate hikes "on a meeting-by-meeting basis".

"The comments don't signal a broad shift in the Fed's strategy," said Shailesh Kshatriya, associate director for client investment strategies at Russell Investments Canada. "We still expect them to raise rates in the second half of this year," he said.

The Toronto Stock Exchange's S&P/TSX composite index <.GSPTSE> ended up 63.60 points, or 0.42 percent, at 15,213.23. It is up about 3.6 percent so far this year.

Six of the 10 main sectors on the index were higher.

($1=$1.24 Canadian)

(Editing by Peter Galloway and David Gregorio)

By John Tilak and Alastair Sharp