A rocky week for the stock market ended on a bright note as investors bought stocks across industries.
Stocks wavered in the morning before climbing steadily during the afternoon amid a mix of earnings results. The market also got a lift as China's currency steadied after a slump earlier in the week that shook financial markets around the world. The gains were modest but broad, with nine of the 10 sectors of the Standard and Poor's 500 index ending higher.
The S&P 500 climbed 8.15 points, or 0.4 percent, to 2,091.54. The Dow Jones industrial average rose 69.15 points, or 0.4 percent, to end at 17,477.40. The Nasdaq composite rose 14.68 points, or 0.3 percent, to 5,048.24.
At the close of stock trading, the dollar was buying 6.391 Chinese yuan, little changed from the previous day. Reassuring comments from a Chinese central bank official on Thursday seemed to ease concerns that China's government would seek to devalue its currency further. Investors who worried that devaluation suggested the world's second-largest economy could be more fragile than they previously thought.
"We were in a sell-first-ask-questions-later mode, but we've rallied back," said Piers Cornelius, a managing director at J.P. Morgan Private Bank. He says he expects stocks to stabilize over the next few weeks as companies, flush with record cash, continue to buy back their own shares.
Stocks of retailers rallied after some solid earnings reports.
Nordstrom rose $3.21, or 4.3 percent, $78.13 after beating analysts' expectations in results announced late Thursday. J.C. Penney rose 45 cents, or 5.6 percent, to $8.52 after a narrower loss on stronger-than-expected sales as the retail chain continues to turn its business around.
Investors are hoping for good retailer news in the current quarter, too. On Thursday, the Commerce Department reported U.S. retail sales climbed last month, suggesting that strong hiring and lower gas prices are encouraging consumers to spend more.
Sean Lynch, co-head of global equity strategy at Wells Fargo Investment Institute, said investors have been remarkably calm in the face of several potentially unnerving events, including a slowing Chinese economy, Greece's debt troubles, plunging oil prices and the Federal Reserve possibly raising interest rates next month.
"You've got recurrent issues worrying the market … yet it's been pretty lethargic," he said. "It's been trading at a narrow range despite all the noise."
The S&P 500 ended the week up 0.7 percent. The index is basically unchanged in the last six months.
Europe had a tougher week. Germany's DAX fell 4.4 percent, the CAC-40 in France dropped 3.9 percent and Britain's FTSE 100 was down 2.5 percent. All three indexes were down Friday.
In addition to worries about China, European economic growth is weak. Figures from the European Union's statistics agency on Friday showed that growth across the region was 0.3 percent, down slightly from 0.4 percent growth in the first three months of the year.
Among other U.S. stocks making big moves:
— Applied Materials fell 41 cents, or 2.4 percent, to $16.64 after the chip-making equipment company said that revenue for its most recent reporting period fell short of analysts' expectations. The company also said sales for the current quarter could fall as much as 7 percent.
— Sysco rose $2.86, or 7.4 percent, to $41.38 after an investment firm run by activist investor Nelson Peltz said it had acquired a 7.1 percent stake, making it the food distributor's largest shareholder.
The price of U.S oil rose slightly, but still ended the week sharply lower as rising supplies continue to outpace global demand growth. U.S. crude rose 27 cents Friday to close at $42.50, but finished the week down 3 percent after hitting a six-year low on Thursday. Brent crude, a benchmark for international oils used by many U.S. refineries, fell 19 cents to close at $49.03 in London.
In other futures trading on the NYMEX:
— Wholesale gasoline fell 2.7 cents to close at $1.687 a gallon.
— Heating oil fell 1.1 cents to close at $1.558 a gallon.
— Natural gas rose 1.4 cents to close at $2.801 per 1,000 cubic feet.
In metals trading, gold fell $2.90 to $1,112.70 an ounce and silver dropped 18.6 cents to $15.21 an ounce. Copper was little changed at $2.35 per pound.
Prices of U.S. government bonds barely moved, keeping the 10-year Treasury yield at 2.19 percent.