Stocks Higher for Week, S&P Logs 6-Day Rally

Stocks turned higher in the final minutes of trading Friday, with the S&P logging its sixth-consecutive rally, despite a disappointing Chinese trade report that raised worries over slowing global growth.

The Dow and S&P 500 posted their fifth-straight winning week.

The Dow Jones Industrial Average rose 42.76 points, or 0.32 percent, to close at 13,207.95, led by H-P and Alcoa.

The S&P 500 edged up 3.07 points, or 0.22 percent, to finish at 1,405.87. The Nasdaq squeezed out a gain of 2.22 points, or 0.07 percent, to end at 3,020.86.

The CBOE Volatility Index, widely considered the best gauge of fear in the market, finished below 15.

For the week, the Dow gained 0.85 percent, the S&P 500 rallied 1.07 percent, and the Nasdaq jumped 1.78 percent. H-P was the biggest weekly gainer, while AmEx lagged.

“When your investment strategy is anchored by hope that the central bank does something, that shows times are pretty tough,” said Lawrence Creatura, portfolio manager at Federated Investors. “We’re moving towards the tail end of the earnings season and the equity market will be increasingly driven by macro data, which haven’t been particularly uplifting.”

China's July exports rose just 1 percent from a year earlier, disappointing estimates by a wide margin and adding expectations that the Chinese central bank will take further policy stepsto support an economy that has seen declining growth for six-consecutive quarters.

Also on the economic front, import prices fell 0.6 percent in July for the fourth straight month, according to the Labor Department. Analysts had expected a gain of 0.1 percent. The unexpected decline could give the Federal Reserve more reason to ease monetary policy. (Read More: Do Global Equity Markets Need a Reality Check?)

Stocks have also been higher for most of the week amid hopes the ECB will act soon to lower borrowing costs for Spain and Italy.

“Draghi and central bankers are not going to let a crisis hit,” said Rex Macey, CIO of Wilmington Trust Investment Advisors. “While that’s not a well-placed sense of security, it’s what’s been supporting the market.”

JCPenney tumbled after the retailer reported a wider-than-expected quarterly loss and added it won't meet its previous 2012 earnings guidance.

Nvidia turned lower even after the chipmaker beat quarterly results and handed in a better-than-expected current-quarter revenue guidance. At least 13 brokerages boosted their price targets on the firm.

Yahoo slumped after news the Internet company is rethinking a plan to return to shareholders the cash generated from a deal to sell its stake in Chinese internet company Alibaba, according to an SEC filing. In addition, Bank of America/Merrill Lynch downgraded the stock to "neutral" from "buy."

Ubiquiti Networks plunged after the tech company's outlook disappointed.

Activision Blizzard and Electronic Arts slipped after retail sales of video game sales dropped for the eight-consecutive month as spending kept shifting to apps and digital downloads, according to NPD Group.

English soccer team Manchester United finished flat after struggling to stay in positive territoryin its first day of trading on the NYSE. Shares were priced at $14, below the company’s expected $16 to $20 target range.

CKE, the parent company of Carl's Jr. and Hardee's fast-food chains, postponed its planned initial public offering, citing market conditions. The IPO had been expected to take place this week. The company was expected to price between $14 and $16 a share as it planned to raise $200 million.

Also on the economic front, the U.S. federal budget deficit increased $70 billion in July and is on track to top $1 trillion for the fourth straight year.

—By CNBC’s JeeYeon Park (Follow JeeYeon on Twitter: @JeeYeonParkCNBC)

On Tap Next Week:

MONDAY: Kodak patent auction winners announced; Earnings from Sysco
TUESDAY: NFIB small biz optimism index, PPI, retail sales, business inventories, 13-F filings due; Earnings from Home Depot, TJX
WEDNESDAY: Weekly mortgage apps, CPI, Empire state mfg survey, Treasury int'l capital, industrial production housing market index, oil inventories, Fed's Kocherlakota speaks, credit card default rates reported, Facebook lock-up expiration, Forest Labs shareholders mtg; Earnings from Deere, Target, Cisco, Applied Materials
THURSDAY: Housing starts, jobless claims, Philadelphia Fed survey, e-commerce retail sales, Fed's Kocherlakota speaks; Earnings from Wal-Mart, Dollar Tree, Aeropostale, Gap
FRIDAY: Consumer sentiment, leading indicators; Earnings from Ann, JM Smuckers

More From CNBC.com: