Like its customers, fast-food stocks have fallen on hard times.

Fast-food companies have underperformed the broader market this year as consumers pull back from higher prices. Investors have instead favored technology and artificial intelligence companies, leaving consumer discretionary stocks behind.

While the S&P 500 is up 13% this year, shares of the four largest fast-food companies have fallen between 28% for Jack in the Box and 8% for Yum! Brands, which owns Taco Bell and KFC.

“Investors right now are concentrating on hyper-spender AI companies. They’re not interested in consumer sectors,” said Roger Lipton, founder of Lipton Financial Services. “Consumers are still stretched.” The tech-heavy NASDAQ rose 17% year-to-date.

Financial pressures are leading consumers to rethink their spending habits. Fast-food chains depend heavily on lower- and middle-income customers, many of whom are contending with higher prices for food, gasoline and other necessities. The pullback is showing up most clearly in restaurant traffic.

Restaurant companies can raise menu prices and still report higher sales even when fewer customers are coming through the door, said Lipton. U.S. foot traffic at McDonald’s has declined year over year every month since March according to data analytics firm Placer.ai.

While McDonald’s is the most financially established company in the group, Lipton said it is not insulated from the consumer slowdown. In response to weaker traffic, McDonald’s plans to invest $8.5 billion in improving hospitality and technology across its more than 40,000 locations worldwide. McDonald’s is down 22%, closing at $237 on Friday.

“McDonald’s is not going away, it’s a well-run company,” Lipton said. “They have tremendous strength and a bulletproof balance sheet.”

Yum! Brands is facing a different set of challenges. Yum! Brands sold Pizza Hut, which has weighed on its performance in recent years, for $2.7 billion on Sept. 1 leaving Taco Bell and KFC as two of its most important businesses

Taco Bell faced a cyclospora outbreak over the summer, adding another short-term challenge. John Gordon, an analyst at Pacific Management Consulting Group said foodborne illnesses typically have their greatest effect on restaurant companies during the first two months, after which the impact tends to narrow. Yum! Brands closed at $138 a share on Friday.

Inflation and slower income growth have made restaurant visits easier to postpone, while operators themselves continue to contend with higher labor, food and distribution costs said Gordon 

“The fast food industry in the United States is a disaster for many different reasons right now,” Gordon said.

Inflation and food-away-from-home prices rose 3.4% over the past year, while U.S.-Iran attacks pushed oil above $100 a barrel in September. Higher gasoline prices can squeeze consumers’ budgets while simultaneously increasing costs for restaurant operators and distributors. Broadline food distributors have added surcharges, putting additional pressure on restaurant margins. 

Over the same period, Wendy’s fell 20% to $6.58, while Jack in the Box dropped 28% to $13.46.

Restaurant Brands International, which owns Burger King, Tim Hortons, Popeyes and Firehouse Subs, has been an outlier in the fast-food slump. Its shares have risen about 6% to $72 since last year. Gordon said changes in Burger King’s management and marketing have helped the brand improve. “Burger King is on a roll right now,” Gordon said.

Some retail investors see falling valuations as an opportunity to buy established restaurant companies at lower prices. KentDDS, a Reddit user who commented in the r/dividends community, said McDonald’s could appeal to investors willing to hold the stock for the long term.

“When recessions hit, MCD tends to outperform the overall market. It’s a good defensive play,” Kent said in the comment.

Until traffic improves, the sector remains caught between higher prices and weaker demand. In response, companies such as McDonald’s are investing in technology and customer service, while Burger King has focused on management and marketing changes.

“They’re  down at the bottom of their trading ranges in terms of valuations, but the restaurant industry has always been seductive in terms of people gravitating to it,” Lipton said.