U.S. stocks closed higher on Friday amid news regarding Greece and after the release of three more economic data sets while investors' focus shifted back to the Federal Reserve. (Tweet This)
"We are accumulating data points from now until the next Fed meeting," said Mark Luschini, chief investment strategist at Janney Montgomery Scott. "I expect more volatility as we draw closer to the September meeting."
U.S. equities hit session highs less than an hour ahead of the close as news about the euro zone confirmed it agreed to launch a new bailout program for Greece. Before then, the three major indexes traded in a range similar to that of Thursday.
Stocks closed near the flatline on Thursday after giving back the bulk of their gains less than an hour ahead of the close, despite worries about China largely dissipating as investors digested a slew of economic data.
"Big picture, I think we're still contending with some of the ripple effects of of what's going on in China," said David Lefkowitz, senior equity strategist at UBS Wealth Management Americas.
China devalued its currency this week, the yuan, by over 3 percent against the greenback, taking global markets by surprise.
The major indexes managed to eke out gains for the week despite the volatility brought about by the yuan's depreciation. The Dow Jones industrial average gained 0.6 percent, while the S&P 500 rose 0.68 percent. The Nasdaq rose just 0.9 percent as biotechnology stocks fell 1.25 percent for the week.
Stock indexes this week
Friday's economic data offerings included the the U.S. Producer Price index rose 0.2 percent in July, while core PPI also ticked up 0.2 percent, both beating estimates.
"This is definitely good news," said Art Hogan, chief market strategist at Wunderlich Securities. "We're in desperate need of a modest increase in inflation."
Hogan added this piece of data also gives the Fed more ammunition to justify an increase in interest rates.
"For long-term investors, I don't care [when in 2015] they raise. I just want them to do it," said Maris Ogg, president at Tower Bridge Advisors, adding that the first increase needs to happen this year since 2016 is an election year.
U.S. industrial production for July shot up 0.6 percent, the Fed said, above the expected 0.3 percent gain as auto production surged.
"Bottom line, outside of the strong auto sector ... production was little changed m/o/m and is up just .8% y/o/y reflecting still the stronger US dollar, weakness in overseas economies and the crash in oil and industrial metals prices impacting that entire space," Peter Boockvar, chief market analyst at The Lindsey Group, said in a note.
The preliminary reading for August consumer sentiment came in at 92.9, below the estimated 93.5.
On the oil front, U.S. crude futures traded higher a day after settling at a multi-year low.
"I think oil is going to bottom sometime this year," Ogg added.
WTI closed up 0.6 percent at $42.50 a barrel after Baker Hughes said the number of oil rigs rose by 2.
"Calling a bottom is always a challenge ... but a $43 a barrel in WTI, we're going to see more aggressive cutbacks," Lefkowitz added.
US oil this week
In Europe, equities closed flat to lower after flash euro zone GDP estimates missed expectations.
In corporate news, retailer J.C. Penney's stock surged about 6 percent in early trading after reporting mixed quarterly results on Friday.
Nordstrom reported quarterly earnings and revenue that beat Wall Street's expectations on Thursday. The retailer added it increased its guidance for the year
An SEC filing revealed Tesla's secondary offering of 2.7 million common shares was priced at $242 a shares, pushing the amount raised to about $643 million.
Restaurant chain El Pollo Loco posted mixed results for the previous quarter, barely beating on the top line but missing on revenue. Still, the company said it is confident about the rest of 2015 thanks to an expanded menu.
King Digital, the maker of the popular game Candy Crush, beat expectations for the previous quarter on both lines, but said that monthly active users fell short of estimates.
Sysco shares rose more than 5 percent in afternoon trading after sources told CNBC that Nelson Peltz's Trian has taken a more than 7 percent stake in the company.
The S&P 500 closed up 8.16 points, or 0.39 percent, to 2,091.55, with utilities leading nine sectors higher and energy lagging.
The Nasdaq closed up 14.68 points, or 0.29 percent, at 5,048.24 as biotechnology stocks fell 0.64 percent and Apple ended 0.74 percent higher.
The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, traded near 13.
Gold futures settled down $2.90 at $1,112.70 an ounce.
The benchmark 10-year Treasury yield was flat at about 2.19 percent.
Advancers were two steps ahead of decliners at the New York Stock Exchange, with an exchange volume of 366.90 million on a composite volume of 1.796 billion at the close.
High-frequency trading accounted for 49 percent of August to date's daily trading volume of about 7 billion shares, according to TABB Group. During the peak levels of high-frequency trading in 2009, about 61 percent of 9.8 billion of average daily shares traded were executed by high-frequency traders.
More From CNBC.com:
- Samsung launches 2 big screen devices to rival iPhone
- Can 'file and suspend' boost your Social Security benefits?
- Coke-funded scientist fires back on obesity claims
—CNBC's Peter Schacknow contributed to this report.