Stocks extended January's rally, climbing more than 1 percent, on Wednesday after upbeat global manufacturing data and as Greece neared a long-delayed deal on its debt.

An index of the U.S. manufacturing sector rose in January to its highest level since June, an industry group said, while China's factory sector expanded slightly, confounding expectations for a contraction. Germany recorded its first rise in manufacturing output in four months.

Manufacturing numbers are what the market is jumping on, said John Manley, chief equity strategist at Wells Fargo Funds Management in New York.

Stocks also got a boost after Greek Finance Minister Evangelos Venizelos said talks between Athens and its private creditors were one formal step away from a deal needed to avoid a messy default.

U.S. and European banks rallied on the news. Bank of America gained 3.6 percent to $7.39 and Citigroup rose 3.8 percent to $31.88.

Homebuilder shares advanced after U.S. data showed construction spending surged in December to its highest level in more than 1-1/2 years. An index of housing stocks <.HGX> rose 1.5 percent.

The Dow Jones industrial average <.DJI> rose 138.65 points, or 1.10 percent, to 12,771.56. The S&P 500 Index <.SPX> gained 14.33 points, or 1.09 percent, to 1,326.74. The Nasdaq Composite <.IXIC> added 32.03 points, or 1.14 percent, to 2,845.87.

After the S&P 500 rose 4.4 percent last month, some traders see the benchmark index near a short-term top. Wells Fargo's Manley said the index is near the upper end of a trading band, with a top below 1,350.

I'd rather own stocks than not, but on a year horizon, he said, indicating stocks could pull back in the near term.

Amazon slid 9.1 percent to $176.61 a day after the online retailer warned of a possible first-quarter loss and posted a steep drop in fourth-quarter profit.

According to Thomson Reuters data, with 228 companies having

reported results, 61 percent have beaten expectations - below the 70 percent beat rate of recent quarters.

Whirlpool surged 15.6 percent to $62.80 after giving an optimistic full-year outlook.

Facebook was expected to submit paperwork to regulators for a $5 billion initial public offering and selected Morgan Stanley and four other bookrunners to handle the IPO, sources told Reuters unit IFR.

Morgan Stanley shares gained 5.1 percent to $19.60.

(Reporting by Rodrigo Campos; editing by Kenneth Barry)