NEW YORK (AP) -- Large technology and health care companies and smaller U.S.-focused firms rose again Friday as stocks finished the third quarter at record highs.
Stocks were mixed at the start of trading, as they had been the day before. But chipmakers and big-name technology companies pulled stocks higher, as they have done all year. Health care companies also did better than the rest of the market. Tyson Foods climbed after it gave strong profit forecasts, and investors cheered strong quarterly results from homebuilder KB Home.
The market ended the quarter on a four-day winning streak that began after Federal Reserve Chair Janet Yellen said the central bank plans to continue to raising interest rates.
"It's all about the confidence they have that despite low inflation, it still makes sense to raise interest rates," said Randy Frederick, vice president of trading and derivatives at the Schwab Center for Financial Research. "She's confident in the economy and the economic backdrop is very solid."
The Standard & Poor's 500 index rose 9.30 points, or 0.4 percent, to 2,519.36. The Dow Jones industrial average turned higher to finish with a gain of 23.89 points, or 0.1 percent, at 22,405.09. The Nasdaq composite jumped 42.51 points, or 0.7 percent, to 6,495.96. The S&P 500 and Nasdaq both closed at all-time highs.
The Russell 2000 index of small-company stocks added 2.08 points, or 0.1 percent, to 1,490.86. It's also at record highs after a big rally this month. It climbed 6 percent in September as investors felt positive about the U.S. economy and hoped Congress and President Donald Trump's administration will reduce taxes.
Tyson Foods jumped after the food company raised its annual guidance and said profits for its beef business were better than expected. Thanks in part to cost cuts, Tyson also forecast a bigger profit than analysts expected for next year.
Tyson climbed $5, or 7.6 percent, to $70.45. The stock gained more ground Friday than it had for the rest of this year put together. Rival Hormel Foods, whose brands include Skippy, rose 43 cents, or 1.4 percent, to $32.14. Those companies and their competitors have struggled in recent years as Americans look for fresher food options.
Technology companies rose further and were the best-performing S&P 500 sector in the third quarter. They also held that distinction in the first quarter. The S&P 500 technology index has climbed 26 percent in 2017, while the S&P 500 is up 12.5 percent.
Facebook added $2.14, or 1.3 percent, to $170.87 and chip equipment maker Applied Materials rose $1.47, or 2.9 percent, to $52.09. Chipmaker Nvidia advanced $3.09, or 1.8 percent, to $178.77.
The recent gains for tech companies have come in spite of a slump for Apple, the world's most valuable publicly-traded company. While Apple has soared this year, it's down 4 percent since it announced its new line of iPhones and other products Sept. 12.
KB Home advanced after its third-quarter profit and sales beat estimates. The stock rose $1.90, or 8.6 percent, to $24.12. Other homebuilders also rose. Meritage Homes picked up 85 cents, or 2 percent, to $44.40 and D.R. Horton advanced 95 cents, or 2.4 percent, to $39.93.
Oil prices recovered and turned higher just before the close of trading. Benchmark U.S. crude rose 11 cents to $51.67 a barrel in New York. Brent crude, the standard for international oil prices, rose 13 cents to $57.54 a barrel in London.
U.S. crude oil rose 12 percent in the third quarter, which helped energy companies do better than the rest of the market. But on Friday those companies gave back some of their recent gains.
Stocks have risen for eight quarters in a row, and Frederick, of the Schwab Center, said he expects that to continue in the fourth quarter as the global economy is likely to keep growing and interest rates in the U.S. should rise more, which will help profits for banks. However Frederick said it's possible that concerns about domestic politics, including the federal debt limit, or international concerns such as tensions with North Korea will weigh on stocks again, as they did at times in the third quarter.
In other energy trading, wholesale gasoline slid 3 cents to $1.61 a gallon. Heating oil declined 2 cents to $1.81 a gallon. Natural gas gave up 1 cent to $3.01 per 1,000 cubic feet.
Bond prices turned lower. The yield on the 10-year Treasury note rose to 2.33 percent from 2.31 percent.
Gold lost $3.90 to $1,284.80 an ounce. Silver slid 17 cents to $16.68 an ounce. Copper fell 3 cents to $2.96 a pound.
The dollar rose to 112.51 yen from 112.39 yen. The euro rose to $1.1816 from $1.1791.
Germany's DAX added 1 percent and the FTSE 100 in Britain and CAC 40 in France both gained 0.7 percent. In Japan, the benchmark Nikkei 225 inched down less than 0.1 percent. South Korea's Kospi jumped 0.9 percent and Hong Kong's Hang Seng edged up 0.5 percent.