NEW YORK (Reuters) - The dollar gained on Friday as investors sought the currency’s safety amid persistent equity market volatility and a possible U.S. government shutdown.

A man counts U.S dollar and Euro banknotes at a money exchange office in central Cairo, Egypt, March 7, 2017. REUTERS/Mohamed Abd El Ghany

The dollar had fallen two straight days after the U.S. Federal Reserve on Wednesday flagged fewer interest rate hikes for the next two years.

The safe-haven Japanese yen gained versus the dollar on overall market anxiety. On the week, the yen had its best weekly performance in percentage terms since February.

U.S. President Donald Trump conceded on Friday there was a good chance the Senate would not approve his demand for $5 billion toward funding his border wall project and a government shutdown would probably begin at midnight.

The news undermined Wall Street shares, with the S&P 500, already on pace for its worst December since the Great Depression, hitting its lowest since August 2017. The Dow Jones industrial average fell to its weakest since October 2017, while the Nasdaq sank to a 15-month low, flirting with bear market territory for a second day in a row.

“It’s not clear at this stage whether President Trump would agree to a continuing resolution to temporarily fund the government, or would instead seek a government shutdown, which would go into effect at midnight tonight,” said Nick Bennenbroek, currency strategist at Wells Fargo Securities in New York.

He added that if the shutdown goes into effect, he expects the dollar to continue its bounce next week.

U.S. economic reports on Friday were mixed and had minimal impact on the dollar.

Data showed orders for nondefence capital goods excluding aircraft, a closely watched proxy for business spending plans, dropped 0.6 percent last month after an upwardly revised 0.5 percent increase in October.

The U.S. economy also slowed slightly more than previously estimated in the third quarter, and momentum appears to have moderated further in the fourth, according to the Commerce Department.

Data also indicated U.S. consumer spending increased solidly in November, but wage growth remained moderate, suggesting the current pace of consumption was unlikely to be sustained.

The mixed data, however, should not prevent the Fed from raising rates imminently, said Michael Pearce, senior U.S. economist at Capital Economics in New York.

In afternoon trading, the dollar index rose 0.7 percent to 96.952, posting its biggest daily percentage increase in two weeks.

The euro, the largest component of the dollar index, fell 0.7 percent versus the dollar to $1.1369.

As liquidity thinned ahead of the Christmas and New Year holidays, large currency options had an impact on the cash market as well. For instance, large options around the $1.15 level also pulled the euro lower.

The dollar, meanwhile, was little changed versus the yen to 111.27 yen.