NEW YORK (TheStreet) -- Stocks soared Thursday as optimism about China's economic growth and stimulus-friendly commentary from Federal Reserve officials revived the risk-on trade.

The main driver for the buying was rampant speculation that China's upcoming gross domestic product report will surprise to the upside. There was also a good bit of bullishness surrounding Google's ( GOOG) report, sending the stock up 2% in the regular session.

The Internet search giant lived up to the hype, beating the consensus profit view handily and announcing plans for a new class of non-voting shares that would essentially amount to a two-for-one stock split. The stock rose less 1% in the extended session.

The Dow Jones Industrial Average leapt 181 points, or 1.4%, to close at 12,987. The S&P 500 was up 19 points, or 1.4%, to finish at 1388 as all ten large-cap sector components rose, led by gains in materials. The Nasdaq rose 39 points, or 1.3%, to settle at 3056.

China will release data for first-quarter gross domestic product Friday. Economists polled by Dow Jones Newswires estimate that the nation's economy expanded 8.3% during the period, after growing 8.9% during the fourth quarter. There were rumors among traders that China's first-quarter GDP growth could come in at 9%.

In Asia, Japan's Nikkei Average rose 0.7% and Hong Kong's Hang Seng index settled higher by 0.9%, snapping a three-day losing streak. London's FTSE closed up 1.3% and Germany's DAX rose over 1% amid easing yields for Spanish and Italian bonds.

Also, New York Fed president William Dudley hinted Thursday at more opportunities for stimulus, if warranted by signs of any economic deterioration. That followed comments from Federal Reserve Vice Chairman Janet Yellen, the right hand of Chairman Ben Bernanke, on Wednesday voicing her continued support for an extended period of low interest rates.

The highly influential Dudley, in prepared remarks for a speech in Syracuse, NY, said "it is still too soon to conclude that we are out of the woods, as underlined by the March labor market release;" and alluded to 2010 and 2011, when economic data looked brighter at this point in time, only to fade later in those years.

Twenty-six of the Dow's 30 components closed in positive territory. Hewlett-Packard ( HPQ) was the biggest gainer, rising more than 7% after Gartner reported a 1.9% year-over-year increase in worldwide PC shipments for the first quarter. HP increased its dominance, grabbing a 17.2% share of shipments.

Other blue chips gaining more than 2% included Alcoa ( AA) , Bank of America ( BAC), Boeing ( BA), Caterpillar ( CAT) , Intel ( INTC), and Microsoft ( MSFT).

Gainers far outpaced decliners in the broad market, 5 to 1 on the New York Stock Exchange and 3 to 1 on the Nasdaq.

The narrative for first-quarter earnings season is already becoming that the low bar set for year-over-year growth -- S&P 500 companies are expected to increase earnings by 3% or so -- has a could chance of morphing into a positive catalyst. There is also a feeling that the recent five-day slump for stocks was a needed consolidation.

"I think, actually, the market might end up surprising us a little bit; I felt that we would see some sort of a digestion of gains," says Sam Stovall, chief equity strategist, S&P Capital IQ. "There's an awful lot of investors who have missed out on this move, and so they are itching to put some money back to work."

"We might retest the recent low, but I think chances are that the retest will be successful, we go to recovery highs -- maybe top out around 1450 or so -- before therefore being vulnerable to an even deeper decline."

U.S. stocks snapped their losing streak on Wednesday with buyers out in force as anxiety over the eurozone eased and Alcoa's ( AA) profit surprise lifted hopes for a better-than-expected first-quarter reporting season.

In economic news Thursday, the U.S. trade balance improved with less red ink on the deficit. The Department of Commerce reported a February trade deficit of $46.03 billion, down from $52.52 billion in January.

Economists responded to the better deficit read with a hike in first-quarter GDP estimates. Goldman Sachs, for instance, now forecasts U.S. economic growth at a 2.5% annual pace rather than the widely expected 2.3%.

The Labor Department reported unchanged March producer prices, which was much lower than expected. They rose 0.4% in February. However, the core price index, which excludes the volatile food and energy components, rose a higher than expected 0.3% in March compared with a gain of 0.2% in February.

Initial jobless claims, however, had a bigger than anticipated jump to 380,000 in the week of Apr. 7, up 13,000 from the prior week. The four-week moving average of initial claims rose 4,250 to 368,500. The Labor Department reported continuing claims for the week ended March 31 of 3.251 million, down from 3.349 million the previous week.

In other corporate news aside from Google, Sony ( SNE), the consumer-electronics giant, confirmed Thursday that it was cutting 10,000 jobs, or about 6% of its global work force, and forecast that it will make its TV business, which has lost money for eight straight years, profitable again by fiscal 2014.

Sony said on Tuesday it projects an annual loss of 520 billion yen ($6.4 billion), much wider that earlier predictions of a loss of 220 billion yen, and its worst loss ever. The stock closed down 2 cents at $18.73.

The Securities and Exchange Commission could announce Thursday that Goldman Sachs ( GS) will pay $22 million to settle allegations the bank didn't have adequate policies to prevent research from being passed inappropriately to preferred clients, Reuters reported, citing people familiar with the matter.

The SEC's case against Goldman is expected to be similar to one Goldman settled last year with Massachusetts securities regulators, several sources told Reuters.

The $22 million penalty will resolve charges by both the SEC and the Financial Industry Regulatory Authority.

The SEC agreed to the terms of the settlement a few weeks ago, several of the people told Reuters. Goldman shares rose 3.9% to $120.39.

Rite Aid ( RAD) posted a narrower fourth-quarter loss and said it expects a loss in fiscal 2013.

The drugstore chain reported a fourth-quarter loss of $161.3 million, or 18 cents a share, narrower than a year-earlier loss of $205.7 million, or 24 cents. The latest quarter included an accounting charge of 14 cents a share. Revenue of $7.1 billion was reported, up from $6.5 billion a year earlier. Analysts called for a fourth-quarter loss of 14 cents a share on revenue of $6.98 billion.

For 2013, Rite Aid said it anticipates sales of between $25.4 billion and $25.8 billion; same-store sales are seen remaining in the range of flat to up 1.5%. Rite Aid said the loss for next year is seen at between $103 million and $267 million, or 13 cents to 31 cents a share. Analysts expect a loss of 25 cents a share. The stock closed at $1.72, up 1.2%.

May oil futures were up $1.06 to $103.76 a barrel, while June gold futures advanced $16.60 at $1,676.30 an ounce.

The benchmark 10-year Treasury was down 5/32, bringing the yield to 2.06%, while the U.S. dollar index fell 0.5%.

-- Written by Andrea Tse and Michael Baron in New York.

>To contact the writer of this article, click here: Andrea Tse.

More from Markets

Billionaire Investor Tim Draper Explains Why Bitcoin Will Hit $250,000 in 2022

Billionaire Investor Tim Draper Explains Why Bitcoin Will Hit $250,000 in 2022

To Think a Trade War's Still Just a Threat Is the Dumbest Thing on Wall Street

To Think a Trade War's Still Just a Threat Is the Dumbest Thing on Wall Street

M&A Trends Still on Investors' Minds Despite Worries Over Tariffs -- ICYMI

M&A Trends Still on Investors' Minds Despite Worries Over Tariffs -- ICYMI

Dow Falls as U.S. Imposes Tariffs on $50 Billion of Chinese Goods

Dow Falls as U.S. Imposes Tariffs on $50 Billion of Chinese Goods

General Motors Spikes on Report It's Considering Listing Shares of Cruise Unit

General Motors Spikes on Report It's Considering Listing Shares of Cruise Unit