New York (Reuters) - The S&P 500 and the Dow closed marginally lower after volatile trading on Tuesday as investors swiveled their focus between China-U.S. trade talks, President Donald Trump’s threat to shut down the U.S. government and political uncertainty in Britain.

Wall Street’s three major indexes oscillated between positive and negative territory during the day before falling sharply in the last half hour of trading.

Late in the session, the BBC reported that enough letters were submitted by Conservative lawmakers to trigger a vote of no confidence in the leadership of British Prime Minister Theresa May, who has struggled to reach a deal on the country’s European Union exit.

Wall Street saw strong gains early in the day on news U.S. and Chinese officials had discussed a road map for trade talks, which Trump called “very productive.” But late in the afternoon two U.S. lawmakers proposed a bill to ban the sale of U.S. products to Chinese companies that violate U.S. export or sanctions laws.

And later in the morning the mood soured as Trump publicly sparred with Senate Democratic leader Chuck Schumer and House Democratic leader Nancy Pelosi over funding for a wall on the Mexican border during which the president threatened a government shutdown.

“It’s so headline driven right now and the market can’t wait for the next one,” Dennis Dick, proprietary trader at Bright Trading LLC in Las Vegas, said of news on trade and domestic politics. “Traders don’t know what to do. You’re coming into the end of December that’s typically strong.”

The Dow Jones Industrial Average fell 53.02 points, or 0.22 percent, to 24,370.24, the S&P 500 lost 0.94 points, or 0.04 percent, to 2,636.78 and the Nasdaq Composite added 11.31 points, or 0.16 percent, to 7,031.83.

FILE PHOTO: Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., December 10, 2018. REUTERS/Brendan McDermid/File Photo

Three of the S&P’s 11 major sectors ended in the red. Most of the rest were clinging to tiny gains, while the defensive consumer staples sector closed up 0.9 percent, making it the strongest gainer of the day.

The financial index was the weakest with a 1 percent drop on the day.

Carol Schleif, deputy chief investment officer for Abbot Downing in Minneapolis, said investors could take advantage of the volatility to pick up bargains.

“We can’t control the headlines but the thing we can lean on is that the underlying fundamentals remain solid,” she said.

On Monday, the S&P had bounced off an eight-month low to end higher and strategists said trading algorithms kicked in to buy at the day’s lows.

Technical trading appeared to fuel Tuesday’s moves as well, according to Bucky Hellwig, senior vice president at BB&T Wealth Management in Birmingham, Alabama.

“We had cross currents with the various policy releases and no reason to have strong buying come in a the end,” he said.

Declining issues outnumbered advancing ones on the NYSE by a 1.17-to-1 ratio; on Nasdaq, a 1.21-to-1 ratio favored decliners.

The S&P 500 posted 15 new 52-week highs and 31 new lows; the Nasdaq Composite recorded 23 new highs and 264 new lows.

Volume on U.S. exchanges was 8.01 billion shares, matching the average for the last 20 days.