NEW YORK (Reuters) - Stocks edged higher worldwide on Monday as Wall Street extended a rally that has pushed U.S. stocks near all-time highs, while the dollar got a boost from Federal Reserve Chair Janet Yellen who sounded optimistic about the U.S. labor market.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York City, U.S., December 16, 2016. REUTERS/Brendan McDermid - RTX2VD7J

Deadly attacks late in the trading day in Turkey and Germany made stocks pare their gains, while Treasuries prices rose and the safe-haven yen firmed.

U.S. stock indexes hit record highs last week as investors piled on bets that the anticipated fiscal boost from the incoming administration of U.S. President-elect Donald Trump would support riskier assets.

That trend continued Monday with MSCI’s gauge of global equities finishing the session modestly higher, buoyed by gains in U.S. stocks, which were led by telecom and tech shares in a low-volume session.

“The Trump rally is still with us,” said Jake Dollarhide, chief executive officer of Longbow Asset Management in Tulsa, Oklahoma. “Every time something’s down for two days, people jump on it. People are looking for buying opportunities.”

Stocks pared their gains after news that a truck had plowed into a crowd in Berlin, killing nine people and injuring at least 50 others.

The Dow Jones industrial average rose 39.65 points, or 0.2 percent, to 19,883.06, the S&P 500 gained 4.46 points, or just under 0.2 percent, to 2,262.53 and the Nasdaq Composite added 20.28 points, or 0.37 percent, to 5,457.44.

Slideshow ( 2 images )

The Turkish lira and Russian rouble fell to session lows against the greenback on news the Russian ambassador to Turkey was killed in a gun attack at an art gallery in the Turkish capital of Ankara.

The lira was last down about 0.6 percent at 3.525 per dollar while the rouble hit a session low of 62.045 per dollar before retracing to 61.854, according to Reuters data.

The safe-haven Japanese yen added to gains after the reports of the ambassador being shot and the truck attack, rising 0.75 percent against the dollar .

The dollar edged into positive territory after the release of Yellen’s remarks to students at the University of Baltimore, eyeing a 14-year high against a basket of currencies touched last week. It was last up 0.2 percent.[FRX/]

U.S. Treasury prices also rose after news of the incidents, with benchmark 10-year notes gaining 16/32 in price to yield 2.538 percent. [US/]

Europe’s index of 300 leading shares retreated from Friday’s 11-month high and fell 0.07 percent. Germany’s DAX index rose 0.2 percent while France’s CAC slipped 0.22 percent. Britain’s FTSE 100 edged up 0.08 percent.

Japan’s Nikkei stock index, which has benefited from the yen’s sharp fall against the dollar, snapped its nine-day winning streak, edging down from Friday’s one-year high.

MSCI’s all-country world index that tracks stock markets around the globe rose 0.14 percent.

Oil prices edged lower but held just below $55 per barrel, with little news to influence the market.

Brent futures fell 0.8 percent to $54.77 a barrel, while U.S. West Texas Intermediate crude fell 0.2 percent to $51.79.