US Markets

Stocks close higher on Greece hopes, US data

Market believes Tsipras is out of bullets: Cashin
Santelli Exchange: Will Greece strike a deal?
European markets close: To Grexit or not to Grexit
Pisani's market open: GREK up 10%

U.S. stocks closed higher on Wednesday as investors eyed better-than-expected data and remained optimistic on resolution between Greece and its creditors. (Tweet This)

"Investors should have higher conviction we are back to trend (on economic growth)," said David Lefkowitz, Senior Equity Strategist at UBS. "I think it's mostly about Greece (and) a lot of volatility around what's happening in Europe."

Stocks advanced despite Prime Minister Alexis Tsipras' statements the country will go ahead with the referendum on Sunday and that it is not a determinant of whether or not Greece remains in the euro zone, Reuters reported.

The Dow Jones industrial average closed about 140 points higher, off a more than 170-point rise in the open. The Nasdaq Composite also briefly jumped 1 percent as Apple advanced and biotechs gained.

Dow futures leaped more than 160 points on morning news that Tsipras accepted lenders' conditions in a two-page letter originally sent to the heads of the European Commission that requested only minor revisions to their suggestions on pensions and tax reforms.

"The reason futures (were) strong this morning is the idea we might have a resolution on Greece that keeps it in the euro zone," said James Meyer, chief investment officer at Tower Bridge Advisors. "ADP confirms what we saw all along and I think tomorrow's jobs report is strong."

Financials led advancers in the S&P 500, gaining more than 1 percent as yields climbed.

It's "obviously enthusiasm that a deal will be struck (in Greece). I think probably more important (is) that we had some really good economic data today," said Peter Cardillo, chief market economist at Rockwell Global Capital. "Despite a rise in yields and the dollar is stronger, the first trading day of the second half is probably going to indicate the market is going to do well in the second half."

Read MoreWhat we need to move markets to new highs

Treasury yields held higher, with the 10-year yield near 2.42 percent. The was 0.69 percent. German 10-year bund yields trimmed gains to 0.81 percent.

The U.S. dollar advanced nearly 1 percent against major world currencies, with the euro at $1.105. The yen was weaker against the dollar at 123 yen.

"In terms of the euro I think the euro is going to be pretty much sidelined. It doesn't look like anything significant is going to happen between now and the referendum," said Jason Leinwand, managing director of Riverside Risk Advisors. "I think we're going to go back at least until the fifth to a sort of fundamental focus (that) the U.S. economy is outperforming."

"I think the markets are going to discount everything that happened on Monday," he said. "The market understands it's going to be fairly significant turmoil if (Greece leaves the euro zone)."

Stocks closed mildly higher on Tuesday, with the S&P 500 eking out its narrowest gain on record for the first half of the year. The major indices plunged nearly 2 percent or more on Monday for their worst day of the year as news of a July 5 referendum in Greece negatively surprised investors.

Read MoreGreece live blog: Tsipras suggests Athens will blink

European equities closed mostly higher on renewed hopes of a Greece deal, with the DAX up more than 2 percent. The Athens stock exchange remained closed for the third day in a row.

Greece became the first advanced nation to default on the International Monetary Fund when it failed to make a 1.5 billion euro ($1.7 billion) loan that was due to the IMF Tuesday night.

The European Central Bank kept its emergency liquidity cap for Greek banks unchanged.

The Eurogroup of regional finance ministers concluded a conference call Wednesday on Greece's latest proposal. No other meeting is expected before Sunday's referendum.

"Good economic data is being taken as good news for markets," said Kate Warne, investment strategist a Edward Jones. "I think investors are still concerned the Greece vote could be a 'no.' That continues to weigh on markets."

Asian equities outside of mainland China gained amid news of Greek default, but the Shanghai Composite plunged more than 5 percent.

Investors also kept an eye on Puerto Rico, which has indicated difficulty repaying its debt of $72 billion. On Wednesday, the island's electric power authority, or PREPA, reached a deal with its creditors to make its $416 million payment.

In the United States, Wednesday kicks off two days of data reports before the July 4 holiday.

"The stronger U.S. data will distract us from these issues (in Greece)," said Jack Ablin, chief investment officer at BMO Private Bank. He noted the "U.S. is pretty isolated" from the situation overseas.

topped expectations at 53.5, while construction spending rose 0.8 percent in May to a 6-1/2-year high.

"ISM came in pretty close to expectations, just a touch higher. Not much movement there," said Marie Schofield, chief economist and senior portfolio manager at Columbia Threadneedle Investments. New orders increased by 0.2. "I thought it was OK, still signalling modest momentum."

The ADP private sector employment report showed creation of 237,000 jobs, topping expectations of 218,000.

The final June U.S. Manufacturing Purchasing Mangers' index fell to 53.6, its lowest since October 2013, Markit said.

Weekly mortgage applications fell 4.7 percent on the highest rates in 9 months.

Read MoreGreece situation may upstage some important numbers

Auto sales posted a 17.16 million seasonally adjusted sales rate, with Nissan leading.

The key report for the week is Thursday's nonfarm payrolls report, which could strengthen the case for a September rate hike. Markets are closed Friday for the July 4 holiday.

"There is potential for us to focus on fundamentals more than Greece," said Art Hogan, chief market strategist at Wunderlich Securities. "Unfortunately that economic data may be the proverbial 'tree falling in the forest.'"

Major averages 5-day performance

The Dow Jones Industrial Average closed up 138.40 points, or 0.79 percent, at 17,757.91, with Travelers leading most blue chips higher and Caterpillar and Exxon Mobil the greatest decliners. The index remains about 0.40 percent lower year-to-date.

The closed up 14.31 points, or 0.69 percent, at 2,077.42, with financials leading nine sectors higher and energy the only decliner.

The Nasdaq closed up 26.26 points, or 0.53 percent, at 5,013.12.

The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, fell to trade near 16.

About three stocks advanced for every two decliners on the New York Stock Exchange, with an exchange volume of 856 million and a composite volume of nearly 3.7 billion in the close.

Crude oil futures settled down $2.51, or 4.22 percent, at $56.96 a barrel on the New York Mercantile Exchange. Gold futures settled $2.50 lower at $1,169.30 an ounce.

Airline stocks plunged on a report that the to grow at a slower pace as part of an effort to keep airfares high.

The Dow transports closed up 0.14 percent.

General Mills jumped 2.46 percent after posting earnings that beat expectations but missed on revenue, due in part to a stronger dollar. The cereal maker did see growth in both prices and profit margins.

McCormick closed 1.7 percent lower after the firm reported earnings that topped expectations on revenue that slightly missed estimates as the stronger dollar weighed. The spice maker also raised its full year forecast due to a reduction in its expected tax rate.

Read MoreEarly movers: CB, GIS, MKC, STZ, FB, SBUX & more

Constellation Brands closed flat despite posting earnings that beat on both the top and bottom line. The spirits maker also raised its full-year forecast, based on upbeat results for its beer business.

Reuters and CNBC's Peter Schacknow contributed to this report.

On tap this week:


Vehicle sales released by manufacturers


8:30 a.m.: Initial claims, employment report

10 a.m.: Factory orders

10:30 a.m.: Natural gas inventories


Fourth of July holiday

Bond and stock market closed

More From