NEW YORK (Reuters) - U.S. stocks closed up on Wednesday afternoon, though well below their session highs as investors pulled back in the last few minutes of trading despite optimism about U.S.-China trade relations and some reassuring signs in British politics.

U.S. President Donald Trump, in an interview with Reuters on Tuesday, said trade talks were under way with China. Traders said China made the first major purchase of U.S. soybeans since Washington and Beijing agreed to a temporary trade truce this month.

Also, Trump said he would intervene in a case against a top executive at Huawei Technologies if it would help secure a trade deal.

While investors were still wary of market volatility between now and a March 1 deadline for a trade agreement, they sounded optimistic about the latest news.

“Everything Trump says is a negotiating posture ... You’d want statements that are more data and fact driven from the president. However this approach is making China think twice about their hard stance,” said Ernesto Ramos, Managing Director of Active equities for BMO Global Asset Management in Chicago.

“This relentless pushing by Trump is making China give up some ground. That’s what’s cheering up the market.”

Equities trading has been especially choppy in the past few days amid headlines on topics ranging from China trade and a potential U.S. government shutdown to Brexit uncertainty.

And a rapid paring of gains in the last 20 minutes of Wednesday’s session pointed to a decline on Thursday, according to Ramos.

The Dow Jones Industrial Average .DJI rose 157.03 points, or 0.64 percent, to 24,527.27, the S&P 500 .SPX gained 14.29 points, or 0.54 percent, to 2,651.07 and the Nasdaq Composite .IXIC added 66.48 points, or 0.95 percent, to 7,098.31.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., December 11, 2018. REUTERS/Brendan McDermid

While he expects the market to stay above the 2018 lows it has tested multiple times recently, Robert Phipps, director at Per Stirling in Austin, Texas expects volatility to continue.

“Not only is Trump unlikely to seal a deal until the end of February but the rhetoric gets more abrasive the closer he gets to the deadline,” Phipps said. “There’s a lot of political issues that are going to keep pressure on the market from now to the end of February.”

Investors seemed to shrug after British Prime Minister Theresa May won a confidence vote from her Conservative party as 117 of her lawmakers said she was no longer the right leader to implement Britain’s exit from the European Union.

May had failed to reach a Brexit deal this week, creating uncertainty for investors as it opened up the possibility for a delay to Brexit or even another referendum on membership.

With the confidence vote over BMO’s Ramos said “she still has to sell the deal to Parliament.”

Of the S&P's 11 major sectors 8 showed gains but only one, consumer discretionary .SPLRCD increased more than 1 percent on the day. The real estate sector .SPLRCR was the biggest loser with a 1.9 percent drop while utilities .SPLRCU followed with a 0.6 percent decline and consumer staples nudged 0.2 percent lower, showing a lack of appetite for defensive sectors.

The S&P technology sector .SPLRCT, which is heavily exposed to China trade, gained 0.8 percent but well below its session low.

On the bright side, China-based music streaming company Tencent Music Entertainment TME.N gained 7.7 percent in its New York Stock Exchange debut on Wednesday.

Advancing issues outnumbered declining ones on the NYSE by a 2.02-to-1 ratio; on Nasdaq, a 2.09-to-1 ratio favored advancers.

The S&P 500 posted 14 new 52-week highs and 8 new lows; the Nasdaq Composite recorded 21 new highs and 169 new lows.

Volume on U.S. exchanges was 8.13 billion shares, compared to the 8.06 billion average for the last 20 trading days.