The last time the stock market posted an annual value drop two years in a row was in 2002, when it fell for the third consecutive year. Back-to-back annual losses have happened only three other times since the Great Depression in 1929, making them a real rarity. 

Are we on track for that to happen again? The S&P 500 lost most of its year-to-date gains last weekend, but it's already climbing back, up 3% year-to-date as of this writing. Many individual stocks that were soaring this year have retained most of their gains. Investors are still tentatively confident.

The market experiences upheaval from time to time, and ups and downs every day, making it crucial for investors to have some stocks in their portfolios that provide resilience and security in any market. Costco Wholesale (COST -0.12%) is a great example.

The valuable fee-based model

Costco's fee-based membership model provides lucrative membership fees and generates loyalty. The company charges low markups on products to cover associated expenses, and the fees go straight to the bottom line. The beauty of the model is that low prices drive high volume in any environment, particularly in a challenging environment, giving Costco incredible resilience in the toughest times. Those low prices also allow Costco to improve profitability despite rising costs and economic pressure.

In fact, it posted its best-ever renewal rates in the 2023 fiscal second quarter (ended Feb. 12). U.S. and Canada renewal rates were 92.6%, with worldwide rates at 90.5%. Fee income increased 6% over last year to more than $1 billion. Household members and cardholders were both up 7% from last year as well.

It's slowing down -- but don't let that scare you

Costco has demonstrated approximately two years of highly elevated earnings growth since the pandemic began, with double-digit quarterly increases occasionally reaching above 20%, well above its pre-pandemic average of mid-to-high single digits. However, the second quarter of fiscal 2023 marked a return to that average, with a 6.5% year-over-year increase, including a 5% increase in comparable sales.

That's competitive, considering the current environment, and profitability is also rising. Net income increased 13% over last year, and the operating margin is higher than it was five years ago.

COST Operating Margin (Quarterly) Chart

COST Operating Margin (Quarterly) data by YCharts

More tricks up its sleeve

Costco's management has a pretty pragmatic growth strategy. It opens warehouses at a fairly slow rate of around 22 to 25 per year. This keeps the costs of new openings down and leaves the growth runway long. Each store generates billions of dollars, so it doesn't need many new stores to drive higher revenue. As of the end of the second quarter, Costco operates 848 total stores, including 584 in the U.S. It still doesn't even have a store in every U.S. state, and globally, the opportunities are enormous. It just opened its third warehouse in China, and that market alone represents a huge opportunity.

Management has indicated several times that at the right time, it will raise the membership fee. The average time between fee hikes has been five years and seven months, which is exactly how long it's been since the last one. Adding $5 or so to the annual fee isn't likely to deter renewals, and when management feels the necessity, that will just add more cash to its coffers. Management has noted that it uses that cash to improve its services, which makes it even more likely that members will stick around to benefit. 

A compelling entry point

One thing Costco stock isn't is cheap. On the contrary, it typically trades at a premium valuation to its peers for many of the reasons mentioned earlier -- it's consistently strong and reliable in any market.

Costco stock is down 10% over the past year, but it's up 7% so far in 2023. At this price, it trades at 35.8 times trailing 12-month earnings, or well below its three-year average of more than 39.

COST PE Ratio Chart

COST PE Ratio data by YCharts

Costco is an excellent all-weather stock that has beaten the market over time and offers the opportunity for more. Now is a great time to buy.