Relieved investors sent stocks sharply higher on Tuesday after Russia pulled troops back from the border of Ukraine.

The rally pushed the Standard & Poor’s 500 index to an all-time high, erasing steep losses from Monday, when investors feared that the confrontation between Russia and Ukraine would escalate or even lead to a war.

Traders were relieved when Russian President Vladimir Putin ordered troops participating in military exercises near Ukraine to return to their bases.

The S&P 500 rose 28.18 points, or 1.53 percent, to close at 1,873.91. It was the biggest gain for the benchmark index since October. The Dow Jones industrial average rose 227.85 points, or 1.41 percent, to 16,395.88. The Nasdaq composite rose 74.67 points, or 1.75 percent, to 4,351.97.

As investors moved back to riskier assets, prices fell for safe-play investments like bonds and gold. Oil prices also fell as the immediate threat of economic sanctions on Russia, a major oil exporter, eased.

In another sign of a greater appetite for risk, the Russell 2000 index of small-company stocks set another all-time high after posting the biggest percentage gains of the major U.S. stock indexes. The Russell jumped 32.29 points, or 2.7 percent, to 1,208.65. It is now up almost 3.9 percent this year.

The two-day rout and rally was just the latest twist in a volatile year for stocks, which fell almost 6 percent just last month and have since recovered to set all-time highs in recent days.

So what is an investor supposed to do in the face of this volatility?

Now might be the time to revisit whether you have the investments you want, given the market’s rise and volatility, said Stephen J. Carl, head equity trader at The Williams Capital Group.

“Maybe take some positions off the table, and you hedge yourself a little bit, for the chance that if it does go the other way and there is a downturn,” he said.