Last year, inflation rose at its fastest pace in over 40 years. The annual inflation rate, as measured by the year-over-year change in the Consumer Price Index (CPI), peaked at 9.1% in July 2022 and has since fallen to 4% this past May. 

Many are optimistic that inflation is now waning. However, we may not be out of the woods quite yet. Andrew Patterson, a senior economist at Vanguard, recently told NPR that while goods and energy prices have fallen, the cost of services for things like travel and auto repairs has remained "concerningly sticky." 

While you can't predict where inflation will be in the coming months, you can diversify your portfolio with quality stocks that have historically shown resilience during inflationary periods. Following are three to consider now.

A person is holding a bag of groceries while looking at their receipt.

Image source: Getty Images.

1. Walmart

When consumers feel the pinch from inflation, they seek cheaper alternatives, and low-cost retailers are popular. Walmart (WMT -0.08%) is the world's largest retailer, operating 10,500 physical stores across 20 countries and multiple e-commerce websites.

Last year, more customers turned to the retailer to save money, driving comparable-store sales up 7% over the prior year. Walmart also operates Sam's Club, its membership-only warehouse club that provides members with other ways to save on bulk products and discounted gas prices. Sam's Club saw an even more significant surge, gaining 14.6% from a year earlier. 

The company continues to gain market share in its grocery products as higher-income households turned more to the discount retailer. It has also done a stellar job of building its e-commerce business, allowing customers to shop online for delivery or pick-up items. In the first quarter, e-commerce sales increased by 27%. 

Walmart has several advantages that make it a low-cost retailer of choice. It offers a large variety of products, including goods, groceries, and gasoline, giving its customers several ways to save money. Its focus on efficiency and its robust global supply chain allow it to keep costs low, and it continues innovating by leveraging artificial intelligence to make its supply chain even more efficient.

If inflation remains stubbornly high, Walmart is one stock you'll be glad you own.

2. Progressive

Insurance stocks can be particularly intriguing when inflation is high. That's because insurance is always in demand to ease customers' peace of mind. Well-run insurance companies can make for solid investments because of that steady stream of demand and the ability to grow alongside economic growth or during inflationary periods.

Progressive (PGR -0.97%) writes policies covering automotive insurance and has a smaller property insurance business. The company has crushed it over decades because of its excellent underwriting ability.

One key component to its success is using telematics, or data on driver behavior, to price its policies. It was one of the first to roll out the technology in 2004 and made it widely available to its customers in 2010 through its Progressive Snapshot product. The technology has given the insurance company a leg up on the competition for years, leading to industry-beating profitability.

Last year, the insurer quickly adapted to the rising costs of repairs and replacement vehicles by raising its premiums to keep pace with inflation. Its net premiums earned rose 11% from 2021 and was up 25% from 2020. Progressive has performed well across various economic periods and is positioned to continue doing well if inflation remains elevated.

3. Visa

Another resilient business during inflation is payment processing, and when it comes to moving money across the globe, no one does it better than Visa (V -0.23%). In 2021, Visa processed $13.5 billion in payments volume, nearly double that of its second-closest competitor, Mastercard

Visa's business is appealing for several reasons. For one, network effects give it the advantage of being the payment processor of choice for many merchants across the globe. The business is asset-light, meaning it doesn't spend too much on equipment or inventory, resulting in stellar margins. Finally, the company earns fees as a percentage of the payment volume through its network, which tends to grow alongside inflation.

As of March 31 -- six months into its fiscal year -- Visa's payments volume grew by double digits, helping net revenue and earnings per share grow 12% and 14%, respectively. 

While the company prefers periods of high consumer confidence and economic expansion, it has proven to be a solid performer in the face of inflation, making it another solid inflation-resistant stock to consider today.