Stocks remained higher mid-afternoon Tuesday after crude oil recovered to close at a level above $48 a barrel.

The S&P 500 was up 0.3%, the Dow Jones Industrial Average climbed 0.15%, and the Nasdaq gained 0.4%. Nasdaq hit an intraday record high during the session.

Crude oil turned higher Tuesday after being down for most of the session. Oil changed direction after Reuters reported that Iran could possibly participate in discussions over a production freeze. The Organization of the Petroleum Exporting Countries will meet in September. 

Oil snapped a seven-session winning streak on Monday after Morgan Stanley analysts threw doubt on whether an agreement between OPEC would come to passh. Analysts wrote in a note on Monday that a deal was "highly unlikely" as producers remain reluctant to give up market share.

West Texas Intermediate crude oil on Tuesday closed 1.5% higher at $48.10 a barrel on Tuesday.

Stocks veered wildly from modest losses to minor gains for much of the session before settling mixed on Monday. Investors opted to sit on the sidelines until further clues of a rate-hike timeline come out from Federal Reserve speeches at the end of the week.

Central bank officials will convene at the two-day annual Monetary Policy Symposium in Jackson Hole, Wyo., at the end of the week. A speech on Friday from Fed Chair Janet Yellen will provide important context to the markets' outlook for rates. Yellen's comments will likely remain dovish and conservative, pushing data dependency for any future rate moves.

The chances of a September rate hike currently sit at 18%, according to CME Group fed funds futures. A rate hike in November has better chances at 41%.

The number of newly constructed homes sold in the U.S. reached 654,000 in July, up 12.4% at a seasonally adjusted rate, according to the Commerce Department. The reading topped economists' forecasts of 581,000. New home sales have risen for five straight months.

"The upbeat tone of this report was quite encouraging and it points to sustained buoyancy in the housing sector recovery, which has been one of the few bright spots of the U.S. economy in recent months," said Millan Mulraine, deputy chief U.S. macro strategist, TD Securities. "When combined with the sustained positive momentum in the existing homes market and the constructive tone in building activity, a very rosy picture is beginning to emerge on the U.S. housing market."

Best Buy (BBY) - Get Report soared 19%, on track to close with its biggest one-day percentage gain since early 2001, after breezing past earnings estimates and reporting an unexpected increase in same-store sales. The electronics retailer earned an adjusted 57 cents a share in its July-ended quarter, above consensus of 43 cents. Sales at stores open for at least 12 months rose 0.8%, far better than an expected decline. Online sales drove momentum with the segment seeing 24% growth over the quarter.

Toll Brothers (TOL) - Get Report was 7% higher after clearing high quarterly expectations. The real-estate company reported a 24% jump in sales over the quarter to $1.27 billion, above consensus of $1.25 billion, as a recovery in the housing market benefited demand. Per-share profit of 61 cents a share rose from 36 cents in the year-ago quarter and met expectations.

JM Smucker (SJM) - Get Report fell 8% after posting a mixed first quarter. The owner of Jif peanut butter reported adjusted income of $1.86 a share, above estimates of $1.74. Revenue fell 7% to $1.8 billion, below expectations of $1.9 billion. The company also decreased its full-year comparable sales estimates, expecting growth to be flat or down 1% compared to a previous increase of 1%.

Zoe's Kitchen (ZOES) slid 18% after cutting guidance for the full year. The company expects full-year revenue no higher than $280 million, down from a previous high-end target of $281 million. Second-quarter sales also came in weaker than expected.

The second-quarter earnings season is drawing to a close with more than 96% of S&P 500 companies having reported their earnings. Most companies managed to clear lowered expectations over the quarter -- 71% of companies exceeded earnings estimates over the quarter, according to Thomson Reuters.

Monsanto (MON) rose 3% on reports its discussions with Bayer (BAYRY) - Get Reportwere advancing toward a deal. Negotiations over a purchase price and termination fee have progressed, according to Bloomberg.

Tesla (TSLA) - Get Report increased 2% after CEO Elon Musk announced he will make a "product announcement" at noon Pacific time. Musk refrained from giving any specific information in a post on Twitter.

Tableau Software (DATA) - Get Report soared 12% after the company appointed Adam Selipsky as CEO late Monday. Selipsky had previously held the position of vice president of sales, marketing and support for's (AMZN) - Get Report Web Services. Baird upped its price target on shares to $65 from $60 and maintained its outperform rating.

CF Industries (CF) - Get Report added 5% after UBS hiked its rating to buy on the expectation that the company will return to positive free cash flow next year. The firm increased its price target on shares of the nitrogen fertilizer producer to $28 from $22.

Square (SQ) - Get Report climbed 5% after being upgraded to buy from hold at Stifel Nicolaus. The firm said the payments operator could grow sales and gain market share in the coming quarters.