It hasn't been easy to be a stock investor in recent years. The COVID-19 pandemic sent countless tech and retail stocks soaring in 2021 as lockdowns saw consumers invest in home offices and entertainment hardware. However, spikes in inflation curbed spending the following year, with a sell-off leading the Nasdaq Composite to plunge 33% in 2022.

A recovery in 2023 saw the market swing the opposite way once again, with the same index rising 43% last year. The chart below illustrates the yo-yo motion the market has taken over the last three years.

^IXIC Chart

Data by YCharts

Recent trends would suggest the Nasdaq Composite is in for another sell-off in 2024 after soaring high last year. However, easing inflation and a return to growth for many companies indicate this year will finally break the pattern.

But it's not a bad idea to remain cautious and invest in companies worth holding indefinitely. Despite recent volatility, the Nasdaq Composite has still risen 21% since the beginning of 2021, highlighting the importance of a long-term mindset when it comes to the stock market.

Here are two magnificent stocks that I'm "never" selling.

1. Costco

According to Statista, Costco Wholesale (COST 0.37%) ranks third among the 100 biggest U.S. retailers, behind only Walmart and Amazon (AMZN -0.30%). Yet it has massively outperformed its rivals in stock growth.

COST Chart

Data by YCharts

This chart shows that, over the last five years, shares of Costco have delivered more than double the growth of its biggest U.S. competitors.

The company has become a favorite among consumers, winning over shoppers with its unique business model of charging an annual subscription fee for access to market-low prices in a wholesale setting. And it hasn't just won in the U.S. -- Costco's 873 locations span 14 countries, with plans to expand further.

Moreover, Costco's model has solved a major issue in retail, in that product sales don't actually amount to much in profit. Like Amazon's Prime, Costco's annual membership is a major growth driver for earnings. In fiscal 2023, Costco hit more than $6 billion in profits, with membership fees making up 73% of that figure. Alongside a 90% subscription renewal rate, the company will likely continue enjoying consistent gains for years.

In addition to consistent growth, Costco has kept investors happy with surprise dividends that are substantially bigger than its usual dividend yield of 0.61%. On Jan. 12, the company paid out a dividend of $15 per share, with its last special dividend released in 2020 for $10 per share.

Costco's forward price-to-earnings ratio of 44 makes it a slightly expensive option right now, with 20 or below usually considered a good value. However, the company's long-term reliability and popularity among consumers means it is worth its high valuation, and an attractive stock to hold indefinitely.

2. Amazon

As the fifth-most-valuable company in the world with a market cap of $1.7 trillion, it's probably not surprising that Amazon is on this list. The company is a behemoth in retail and tech thanks to its popular e-commerce website and cloud platform, Amazon Web Services (AWS).

However, one of the best reasons to never sell this stock is the retail giant's ability to successfully navigate a market downturn. Amazon was hit particularly hard by macroeconomic headwinds in 2022, which led its stock to fall nearly 50% during the year alongside steep profit declines.

The challenging period saw Amazon immediately begin restructuring its operations, with a priority on profits. Cost-cutting moves like closing dozens of warehouses, thousands of layoffs, and shuttering unprofitable projects like its telehealth platform Amazon Care have been instrumental to the company's recovery.

In the third quarter of 2023, Amazon posted revenue growth of 13% year over year, beating Wall Street forecasts by $1.5 billion, while operating income more than tripled. Meanwhile, the tech firm's free cash flow has skyrocketed 427% over the last year to $17 billion.

Furthermore, Amazon has a promising outlook in the booming AI market. AWS' leading 32% cloud market share could see it leverage its massive cloud data centers and steer the generative artificial intelligence (AI) market in its favor.

NVDA PS Ratio Chart

Data by YCharts

This chart shows Amazon could be one of the biggest bargains in tech right now. Its price-to-sales ratio is the lowest among heavy-hitters like Nvidia, Microsoft, Alphabet, and Apple, indicating shares in Amazon currently offer the most value.

With its reliable long-term growth and promising prospects in AI, the company is an excellent option to buy now and never sell.