The tech-heavy Nasdaq-100 index set a new all-time high at the end of 2023. In fact, it has soared by more than 25% since late October alone. But the index appears to be taking a break, because it has traded in a sideways range over the past month and sits 3% below its best-ever level. Look even closer, and some market darlings are faring even worse. Shares of artificial intelligence (AI) giant Nvidia have tumbled by 10% over the past week.

History is proof that the stock market reaches new highs given enough time, so investors shouldn't fear a sell-off. In fact, these sell-offs are often a buying opportunity, and they can also be a great time to trim positions in stocks that are underperforming.

With that in mind, here's why investors might want to buy Confluent (CFLT 2.98%) and cut Peloton Interactive (PTON 4.29%) loose during the latest Nasdaq-100 sell-off.

The stock to buy: Confluent

Confluent develops data-streaming technology, which is becoming increasingly important for companies operating in the digital age. In the past, businesses would ingest customer data, store it on-premise using physical servers, and analyze it at a later date. That process led to a delay in companies recognizing potentially useful trends that could help them save money and generate more revenue.

Cloud computing now makes it possible for businesses to ingest and access data practically instantly, thanks to powerful centralized data centers. Confluent ties it all together, allowing businesses to ingest and analyze their data in one fell swoop without delay. This creates a number of new opportunities, including the ability to deliver live experiences to their customers.

For example, live betting on a football game requires a bookmaker to rapidly calculate odds based on in-game events, feed them to the customer (usually via a mobile app), and accept bets, all within seconds. That wouldn't be possible without data-streaming technology.

Similarly, retail giant Walmart uses Confluent for real-time inventory management. The company connects all of its physical stores and digital sales channels, so whenever a product is sold, it can be restocked immediately before it runs out. This ensures customers always find what they need when they enter a Walmart store, and that inventory details are accurate on the company's website.

Confluent has over 4,960 business customers, but its highest-spending cohorts are growing the fastest. At the end of 2023, the company had 1,229 customers spending at least $100,000 annually, which was up 21% year over year. It also had 158 customers spending at least $1 million, which equaled a 24% increase, and the number of customers spending a minimum of $5 million doubled.

Confluent delivered $777 million in revenue during 2023, a 33% jump compared to 2022 and also comfortably above management's forecast. The stock is up 35% in 2024 already on the back of that strong result, though it remains 67% below its all-time high set during the tech frenzy of 2021.

That spells opportunity for investors. Confluent values the addressable market for data streaming at $60 billion, but it could grow to $100 billion by 2025. Therefore, the company has barely scratched the surface of its potential.

The stock to sell: Peloton Interactive

Market sell-offs can also be a good opportunity to exit underperforming stocks, because if they aren't delivering gains during a raging bull market, chances are they will do poorly in more challenging conditions. There are exceptions because some stocks are considered defensive, and investors rush to buy them during tough times. But Peloton certainly doesn't fit that description.

Peloton stock peaked at around $163 in late 2020, but it currently trades at just $4.32. That's a 97% decline, driven primarily by falling demand for its at-home, digitally enabled exercise equipment. Those products were a hit at the height of the pandemic when gyms were closed and people were under social restrictions, but those trends have reversed, leaving Peloton with a series of problems.

Peloton generated $4 billion in revenue during fiscal 2021 (ended June 30, 2021), and it has declined every year since. Fiscal 2024 (ending June 30, 2024) won't be an exception, with management forecasting $2.7 billion in revenue, representing a 3% annual drop.

Peloton's bottom line presents a bigger issue. Barry McCarthy took the reins as CEO in 2022, and he slashed the company's workforce by half, offshored its manufacturing, and trimmed marketing costs. But cost cuts are a race to the bottom when revenue is declining, because spending less money on growth initiatives will often lead to even less future revenue.

In the recent fiscal 2024 second quarter (ended Dec. 31), Peloton generated a net loss of $195 million, an improvement from its $338 million net loss in the year-ago period. But even after adjusting for one-off and non-cash expenses like stock-based compensation, the company's non-GAAP earnings before interest, tax, depreciation, and amortization (EBITDA) were still $82 million in the red.

Those figures are a problem because Peloton is running out of runway. It has just $738 million in cash on its balance sheet, so it can't afford to continue bleeding money each quarter. The company will struggle to borrow money in the current high interest rate environment given its circumstances, especially considering it already has $691 million in debt. Plus, its depleted stock price will make it very hard to raise fresh capital through an equity raise.

It will be really difficult for Peloton to escape its current situation, and that could drive further underperformance in its stock price. Therefore, it might be time for investors to let it go.