Did you know an estimated 95% of day traders ultimately lose money? This leads many to believe the stock market is nothing but a sophisticated casino where the house always wins.

But there's an alternative way to participate in the stock market that has a much higher rate of success: long-term investing. The S&P 500, the benchmark often attributed to the overall stock market, has risen 10% per year on average (dividends reinvested). So, by simply staying invested in the market over the long run, you're very likely to make money.

This strategy presents a dilemma, however: If holding stocks longer increases your chances of making money, when should you sell?

This is a complicated question that likely has much to do with your personal financial situation. But there are two key scenarios where it makes sense to part ways with your stocks.

Person concentrating on stock chart on computer screen.

Image source: Getty Images.

No. 1: The thesis is broken

Remember, your thesis is the compass that should guide your buying and selling decisions for each stock you own. You should never open a position in a company without first developing a well-thought-out investment thesis.

When this thesis is proven incorrect, it's time to sell.

For example, if you invested in Peloton Interactive (PTON 6.98%) in 2020 with a general thesis centered around the company's superior brand loyalty, you're now likely facing a situation where that thesis is very questionable.

The connected fitness company recently reported a 23% drop in year-over-year revenue, which would have been much worse if it wasn't for a surprising rise in its subscription sales.

It's possible the company could make a turnaround, as it has been steadily narrowing its reported losses. But a thesis built around the strong brand recognition and loyalty has to be seriously questioned, since its bikes have seen a steep drop-off in sales as the economy has tightened.

The nail in the coffin for me was when the company announced in September that it would begin selling its "luxury" bikes in select Dick's Sporting Goods locations. This is an excellent example of a busted thesis that I personally wouldn't hesitate in parting ways with.

No. 2: Tax-loss harvesting

While the investment thesis should be the north star for your buying and selling decisions, it's not always as black and white as the Peloton example above.

If you're feeling uneasy about the thesis, but you're not 100% sure it's busted, you might consider selling your shares for tax-loss harvesting.

If you're sitting on a clunker of a stock, you could offset capital gains taxes from other stocks by realizing the loss (selling the stock for less than you paid). In addition to offsetting capital gains taxes, you can also use losses to reduce your ordinary income taxes.

Let's take a look at an example: Say you're sitting on $10,000 of short-term capital gains from a recent investment in ExxonMobil, but you're also down $15,000 on Rivian Automotive.

If you sell your Rivian shares, you'll completely offset the short-term capital gains taxes on your ExxonMobil sale, and you'll be able to reduce your overall income tax bill for the year by $3,000 (the maximum allowable by the IRS).

Additionally, since you still have $2,000 in losses remaining, you can carry that over to offset your taxes in the next year.

Tax-loss harvesting shouldn't be the driving factor behind any stock sale, but if you're feeling uneasy about a thesis, it can certainly make the decision to sell a bit easier.

Wealth is built in holding, not selling

While it's important to know when to sell, it's equally important to understand that wealth is built in holding great companies for very long periods of time. If you find yourself selling stocks on a regular basis, you should consider whether you're doing enough research when developing your initial investment thesis.

That being said, if you've lost faith in the underlying business, it's likely time to look for other places to deploy your capital. The silver lining is that you just might get a tax benefit in the process.