When news broke of Amazon.com's purchase of Whole Foods (WFM) for $42 per share, I started kicking myself. Roughly two months earlier, I'd sold my entire Whole Foods position for $31.16 per share, meaning I missed out on over $10 per share in gains, or about $564 total.

Compounding the pain still further, I sold the stock for a loss in a tax-advantaged retirement account, meaning I didn't even get to take a tax deduction for my realized losses.

Dollar symbol turning to ash and blowing away

A visual representation of my portfolio. Image source: Getty Images.

Brutal.

But it turns out that selling my Whole Foods position may have been the best investing decision I've made in the past year. Here's why.

In the eye of the beholder

You might think the issue was that I sold too early. But the mistake on my part was selling too late.

Let's back up a little. I originally bought Whole Foods back in 2013 with a relatively simple thesis: Organic food was going more mainstream, Whole Foods had an incredible brand that would enable it to charge a premium, and same-store sales were rapidly growing.

By early 2016, most of that thesis had fallen apart. Yes, organic food has continued to go mainstream -- so mainstream, in fact, that a variety of competitors started carrying produce... and cutting in to Whole Foods' niche. Whole Foods' response was to offer discounts and cut prices, something that then-co-CEO Walter Robb euphemistically referred to as efforts to "improve price perception." So much for charging a premium.

In Q4 2015, Whole Foods reported that same-store sales had decreased 0.2% on a constant-currency basis, the first of seven back-to-back quarters of comparable sales reductions. So much for that same-store-sales growth.

I didn't know how Whole Foods planned to turn it all around. Management was in a difficult place with no easy answers.

Yet I still held my shares -- 18 months after I stopped believing in the Whole Foods story.

I could easily clothe my choice in the values of long-term investing: holding because I believed in management; refusing to sell even though sentiment had turned against the stock. It's tempting to present my Whole Foods position that way -- and had that been the reason, it would have been a legitimate decision.

But that wasn't why I stayed. My thesis had collapsed, and I was just hoping management would find a way -- any way -- to improve things so I could regain the cash I had "lost."

These are all classic signs of an investor bias known as the disposition effect.

A sunny disposition

According to Hersh Shefrin and Meir Statman, who originally coined the term, the disposition effect is the tendency "to sell winners too early and hold losers too long."

Shefrin and Statman identified "mental accounting," or the tendency to think of each stock as its own individual account, as one of the big psychological contributors to the disposition effect. The investor views selling a stock at a loss as closing a particular "account" and locking in the trade losses, with no potential for new gains. That leads lots of investors to choose to hold losing stocks in the hopes that they'll "break even" in those individual stocks at some point. As Shefrin and Statman cite, Leroy Gross notes that "investors who accept losses can no longer prattle to their loved ones, 'Honey, it's only a paper loss. Just wait. It will come back.' Investors who realize losses must admit their folly to the IRS."

Girl holding onto her mom's leg

Sometimes you just have to let go. Image source: Getty Images.

The mental anguish of publicly admitting you were wrong is substantial. But the worst part isn't admitting it to others -- it's admitting it to yourself. It's recognizing that there may have been a flaw in your investing thesis from the very beginning -- something perhaps you should have seen before you bought. And if you missed something once, it's possible you're sitting on other "bad" investments. That recognition can be overwhelming and paralyzing. It's much easier to just sit and wait for your stock to rebound.

What's worse, recent research published in The Journal of Finance shows that the disposition effect disproportionately affects individual investors who make their own investing decisions, as opposed to those working with overpriced mutual fund managers. So the disposition effect is something that folks like you and me have to be particularly careful to avoid.

Everyone's solution to defeating the disposition effect will be different. Fundamentally, though, the decision to reinvest in other stocks requires two components: deciding that your current stock is no longer attractive, and finding other attractive stocks. Here are two ways I'm planning to fight the disposition effect -- hopefully they're useful to you too.

1. Start an investing journal

That first decision requires you to recall what made the business attractive to you in the first place. Put another way, you'll want to ask yourself: "What was my original investing thesis?"

It can be surprisingly hard to remember. I had to go through old notes I'd written myself about Whole Foods four years ago to figure it out. This is where an investing journal can be useful, whether it's a notebook, a spreadsheet, an email chain to yourself, whatever. Document your original decision-making process somewhere central and revisit it from time to time with updates for when things change. I'm planning on evaluating my major holdings at least once every six months.

To be clear, a shift in your investing thesis shouldn't automatically trigger a sale, because sometimes a company provides you with new (and better!) reasons to own it after you've already purchased. For example, imagine an investor who bought Apple during the late '90s based on the Steve Jobs turnaround. By the time Jobs died, Apple hadn't just turned its struggling computer business back around -- it had also produced the wildly successful ipod, ipad, and -- most importantly -- iphone. Even though there were some missteps after Jobs' death, the business was undeniably in a much stronger position -- even strong enough to pay a dividend! This hypothetical investor who held Apple's shares after Jobs' death saw their original investing thesis disappear, but new information provided compelling reasons to stay.

On the flip side, when your primary thesis has collapsed and you aren't seeing compelling reasons to keep the stock, it may be time to sell. If, for example, you bought Ford stock strictly as a bet on Alan Mulally's leadership -- two CEOs later, with the business stuck in neutral, that thesis is far gone.

2. Keep a "buy" list handy

The single thing that enabled me to exit my Whole Foods position -- again, 18 months later than I should have -- was reframing the conversation from "Do I think Whole Foods can hang in there?" to "Do I think there are better places to invest my money today?"

I put together a list of stocks I wanted to buy (or buy more of), and the only thing getting in my way was a lack of funds -- funds that were tied up in Whole Foods shares. Having that list enabled me to get past the mental accounting and think of my investment accounts as one big pot of money that I could better deploy elsewhere.

Key to that, of course, is having a list of stocks I find to be compelling investments. This process dovetails nicely with my New Year's resolution to devote more time to finding stocks to grow my portfolio. I'd encourage you to do the same -- it makes that internal conversation a little easier.

To be clear: I do not believe in portfolio-churning to chase profits. But when you're invested in a business that's struggling and without any compelling thesis tying you to it, I think it's appropriate to seek greener pastures.

It all comes down to this

The suggestions I've made here all rest on the same foundational truth: The only way to beat the disposition effect is to shift your focus forward. Evaluate whether you would still invest in a particular company today. If you wouldn't, then why do you have the stock in your portfolio in the first place? Living by these rules and consistently trimming stocks that no longer meet your investing criteria -- and that goes for winners and losers alike -- helps create a portfolio you can trust and hopefully brings better long-term returns.

Had I held my Whole Foods stock and earned gains when shares rose after the Amazon purchase announcement, I might have been able to convince myself that I held my shares for the right reasons. That intellectual dishonesty would have cost me far more in the long run than what I lost on Whole Foods. Learning to confront the disposition effect and applying the lesson across my portfolio is well worth the $564 I missed out on with Whole Foods.