US Markets

Stocks close higher for July amid earnings, global growth concerns

Cashin says: Uphill fight for stocks
Pisani's market open: Exxon conserving cash
What could derail a 2015 Fed hike?
Cashin: Keep eye on oil
Employment data's 'shocking trend': Pro

U.S. stocks closed mildly lower on Friday, the final day of trade for July, as investors digested energy earnings misses and soft data that could push an initial rate hike further out. (Tweet This)

Stocks were mixed to slightly lower in afternoon trade after earlier attempting to rally. The Nasdaq struggled to hold higher in afternoon trade as shares of major tech firms declined. The S&P 500 and Dow Jones industrial average traded lower as declines in energy stocks weighed.

"This tug of war between the data and the stock market—that's why we haven't gone anywhere," said Lance Roberts, general partner at STA Wealth Management.

However, in a month marked by volatility around Greece and China, selloff in commodities and mixed economic data that raised concerns about growth, the major U.S. averages posted weekly and monthly gains. The Nasdaq outperformed with a 2.8 percent gain for the month. The S&P 500 gained nearly 2 percent for the month, while the Dow posted a 0.40 percent gain for July but remained off 0.74 percent for 2015.

"I think that is just another example that Greece and Ebola will flare up (but) what ultimately drives stocks is earnings," said John Canally, investment strategist and economist at LPL Financial.

The energy sector fell more than 2.5 percent as the greatest laggard in the S&P 500. Exxon Mobil and Chevron plunged more than 4.5 percent each as the greatest decliners in the Dow Jones industrial average.

Exxon Mobil and Chevron both posted earnings that missed expectations. Exxon posted the lowest profit in six years, while Chevron posted the worst quarterly profit in nearly 13 years.

Read MoreChevron's ugly earnings put focus on oil dividends

Crude oil futures settled down $1.40, or 2.89 percent, at $47.12 a barrel. Oil lost nearly 21 percent in July, its worst month since October 2008 during the financial crisis.

Other than the pressure from energy stocks, the major story of the day was "clearly the employment cost index and its impact on the dollar, gold, oil and Treasurys," said Peter Boockvar, chief market analyst at The Lindsey Group. "I think the stock market is struggling with continued soft economic data. Maybe it means the Fed won't raise interest rates. (But) the U.S. economy is struggling and that's not a good thing."

The employment cost index disappointed analysts with a rise of 0.2 percent, the smallest increase in 33 years and below expectations of 0.6 percent.

It's "telling us there's very little wage pressure in the U.S. economy right now. There are some FOMC members on the margin who are going to be less willing to raise rates in September," said Luke Tilley, chief economist at Willmington Trust Investment Advisors. "When we just look at the initial impact for firms, the cost of employment (was) not as much as in the first quarter."

Futures trimmed losses to trade mixed after the ECI came out at 8:30 a.m.

"What it tells us is September may not be a lock. If anything that may be a little reason why we're seeing a bit of rotation in futures here," said Art Hogan, chief market strategist at Wunderlich Securities.

The plunged after the data, trading near 0.66 percent, off from 0.75 percent before the data release. The 10-year yield edged lower, trading near 2.20 percent.

The U.S. dollar more than halved losses after briefly falling more than 1 percent. The euro fell below $1.10 and the yen traded near 124 yen against the greenback.

The Federal Reserve left interest rates unchanged after the conclusion of its July meeting on Wednesday. The statement indicated a more optimistic outlook on U.S. economic growth, but second-quarter GDP missed expectations on Thursday, while first-quarter GDP was revised from negative to slightly positive.

Read MoreEarly movers: TYC, EA, NWL, LM, ITT, WY, TPX & more

St. Louis Fed President James Bullard said a Wall Street Journal report that the GDP data cleared worries over growth outlook and supports the case for raising rates as soon as September. Bullard is a non-voting member of the Fed.

In other economic news, the Chicago PMI came in at 54.7 for July, the highest since January.

The final University of Michigan consumer sentiment survey came in at 93.1 for July, a decline from June's 96.1 read.

Read MoreAugust may mean big things for markets and the Fed

"I think we are headed to a mixed session," said Peter Cardillo, chief market economist at Rockwell Global Capital. It's the "last day of trading in July ahead of next week's busy economic calendar."

"Volume remains very moderate. It's hard to get any real grip on where we're going because it's summer holiday trading," Cardillo said.

Major U.S. Indexes

In individual stock movements, LinkedIn fell 10.5 percent after the firm reported that costs rose. The professional social network did on both the top and bottom line.

The Dow Jones Industrial Average closed down 56.12 points, or 0.32 percent, at 17,689.86, with Coca-Cola leading advancers and Chevron the greatest laggard.

Visa was the best performer for the month, rising 12 percent, while United Technologies was the worst with a near-10 percent decline. Nearly half the blue chips posted losses for July.

The closed down 4.79 points, or 0.23 percent, at 2,103.84, with utilities leading five sectors higher and energy the greatest decliner. The two sectors were the best and worst performers for the month, respectively.

The Nasdaq closed down 0.50 points, or 0.01 percent, at 5,128.28.

The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, traded near 12.5.

About two stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 977 million and a composite volume of 3.6 billion in the close.

High-frequency trading accounted for 49 percent of July to date's daily trading volume of about 6.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.

Gold settled up $6.40 at $1,095.10 an ounce, but was 6.5 percent lower for the month for its biggest monthly drop since June 2013.

Overseas, European stocks closed mostly higher amid soft U.S. data and earnings, and the continued decline in commodities and mainland Chinese stocks. The STOXX Europe 600 outperformed for the month, posting gains of 3.95 percent, while the DAX posted gains of 3.33 percent for July.

The Greek stock exchange is set to reopen on Monday after being closed for five weeks.

Chinese stocks posted their in nearly six years, down 14.3 percent. The Shanghai Composite index finished in negative territory for the second straight session, down 1.1 percent for the day, as investors remain nervous amid commodity weakness.

Read MoreWhy Brazil's slowdown is almost as bad as China's

On Friday, Reuters reported that China's 24 stock trading accounts for suspected trading irregularities and was investigating investors who used automated trading strategies. Since the beginning of the collapse in mainland shares, trade in many of the stocks was suspended and the ruling Communist Party intervened with many efforts to prevent further declines.