Stocks gain thanks to Best Buy, Dollar Tree

S&P 1 mo
Click for more market data.

Close, but no cigar. The S&P 500 flirted with a new high Thursday, but didn't quite get there.

The Dow Jones industrial average, the S&P 500 and the Nasdaq all closed with gains. Earlier, the S&P 500 came within one point of its record high from last week. The gains build on momentum from Wednesday, when the Dow surged more than 160 points.

HP tech error?

In an apparent error, Hewlett-Packard (HPQ) released its latest quarterly report early. The computer company's stock fell more than 2% just before the closing bell. HP's earnings were in line with expectations, but the company announced plans to lay off an additional 11,000 to 16,000 job cuts on top of the previously announced 34,000 job cuts.

Is Best Buy getting its groove back?

Over in retail stock land, Best Buy (BBY) shares were up as much as 5% after the electronics retailer reported earnings that beat analysts' expectations, raising hopes the company's turnaround plan is bearing fruit. The stock was down sharply in the futures market before active trading started. It ended the day up 3.4%.

Some traders on StockTwits were surprised to see Best Buy shares bounce back.

A trader using the handle TheGenius was stumped. "$BBY why the heck is this up?"

Best Buy was one of the top performing S&P 500 stocks last year, but it's down more than 30% so far in 2014. Still, some traders believe changes under CEO Hubert Joly, including store closings and headcount reduction, are steps in the right direction.

"$BBY Bottom line better than expected, good signs in online area. Still has ways to go, but reasonable turnaround progress. Remain long," read a post by kgpittm.

Retail stocks rally -- to a point

Dollar Tree (DLTR) also reported better-than-expected earnings, sending shares of the discount retailer up nearly 7%.

Sears Holdings (SHLD), which operates the Kmart and Sears brands, said the pace of store closings picked up to 80 closings in the first quarter and that further store closings are possible the rest of this year. Shares ended the day up more than 4%, reversing earlier losses.

House wares retailer Williams-Sonoma (WSM) reported strong earnings and boosted its outlook for the coming months late Wednesday. The stock was up over 8%.

It was the second quarter in a row that William-Sanoma beat expectations. Wednesday's report, coming on the heels of a strong quarter for Tiffany & Co (TIF)., raised expectations for the luxury retail sector.

Related: The 1% is spending: Luxury stocks soar

"$WSM destroys... again. Good news on the end of $RH. Luxury consumer is doing so well," said crbarnette.

Shares of RetailMeNot (SALE), a provider of online coupons, sank almost 19% on a report that changes to a Google (GOOG) search algorithm caused a sharp drop in the company's online traffic. But some traders said the selling was an overreaction.

"$SALE SELL SELL SELL SELL!!!!!! So I can get pick up cheaper.. This is Google backed, you really think they are going to punish themselves?" asked StockTwits user rml251.

Chinese ecommerce company JD.com (JD) started trading today on the Nasdaq. The stock priced at $19 a share, on the high end of its expected range, and popped 10% on its first day.

Related: Good news for Alibaba: Rival JD pops in IPO

After hours: Gap and Aeropostale

Gap Inc (GPS). said earnings and same-store sales fell in the first quarter, but the maker of khaki pants maintained its profit outlook for the year. The company reported after hours, and the stock is barely moving.

It wasn't so pretty for Aeropostale (ARO). Shares plunged after the market closed. The teen-focused apparel company said net sales were down 12% in the first quarter, while earnings fell due to restructuring costs.

Smoke 'em if you got 'em

Shares of big tobacco companies were also lighting up.

Reynolds American (RAI) and Lorillard (LO) are reportedly in talks to join forces and create the second largest U.S. tobacco company. Lorillard, which makes the e-cigarette blu, would give Reynolds access to the growing market for electronic cigarettes. A deal could also benefit U.K.-based British American Tobacco (BTAFF), which owns a large stake in Reynolds.

Forget pot. Cigarette stocks are smokin'!
Forget pot. Cigarette stocks are smokin'!

Both Reynolds and Lorillard were down Thursday after big spikes late yesterday when news of the potential deal surfaced.

Related: Fear & Greed Index

In economic news, the government said first-time claims for unemployment benefits rose sharply in the week ended May 17. Sales of existing homes rose 1.3% in April, according to the National Association of Realtors.

Related: CNNMoney's Tech30

European markets ended modestly higher. Asian markets closed mostly higher, buoyed by better-than-expected manufacturing data from China. Stocks in Thailand were little changed despite news that military officials had taken control of the government, marking the latest in a string of coups in the past few decades.

CNNMoney Sponsors