In his 1986 letter to shareholders, Warren Buffett noted that greed and fear are recurring phenomena in the financial markets. The investing legend continued:

[T]he market aberrations produced by [fear and greed] will be equally unpredictable, both as to duration and degree. Therefore, we never try to anticipate the arrival or departure of either disease. Our goal is more modest: we simply attempt to be fearful when others are greedy and to be greedy only when others are fearful.

A tide of greed has swept across the stock market -- or at least parts of it -- in recent weeks. Investors should take this as a signal to become more cautious about their investments. I have done just that by selling my shares in some of this month's biggest winners, such as Dillard's (DDS 1.16%).

Cars in the parking lot outside of a Dillard's store

Image source: Author.

Short squeezes drive some stocks higher

A loosely organized band of investors have targeted heavily shorted stocks over the past month, attempting to trigger short squeezes. These efforts have caused many of these stocks to skyrocket. GameStop stock felt the biggest impact, surging from $20 to a high of nearly $500 in barely more than two weeks, before surrendering some of its gains. Many other heavily shorted stocks have posted big gains in recent weeks as well.

However, while a short squeeze can push a stock higher in the short term, it can't keep the stock at an elevated level forever (assuming no change in the company's fundamental performance). Eventually, the short squeeze loses steam and shareholders start to take profits -- or other investors enter new short positions -- causing the share price to fall.

For example, Volkswagen stock nearly quadrupled in a few days near the end of October 2008 because of an epic short squeeze. Yet by the end of November 2008, the stock was up just 20% from its pre-squeeze price. Volkswagen shares fell further in 2009 and remain well below the pre-squeeze price today, more than a decade later.

VWAGY Chart

Volkswagen stock performance, data by YCharts.

This highlights Buffett's key point. It's impossible to know when periods of greed or fear will strike -- or how long they will last. One thing is certain, though: Such episodes never last forever. Eventually, prices correct to more "normal" levels. Consequently, prudent investors shouldn't give in to greed and get caught up in the speculative frenzy. Instead, they should become more fearful. Practically speaking, that means selling stocks that have surged beyond their intrinsic value.

Why I sold Dillard's stock

As speculative, heavily shorted stocks surged in recent weeks, I sold some of my investments long before I had planned to do so. Less than two months ago, I flagged Dillard's as a stock that could be primed to soar in 2021.

At the time, Dillard's stock traded for less than $50. Earlier this week, the stock blew past $100, reaching a multiyear high before surrendering some of its gains. Importantly, Dillard's hasn't released any newsworthy information during this period. The stock doubled purely due to speculation and a short squeeze.

DDS Chart

Dillard's stock performance, data by YCharts.

Dillard's stock remains heavily shorted, which could pave the way for further share-price gains in the weeks ahead. But any such gains would likely prove ephemeral. Dillard's faces plenty of headwinds in its core department-store business. Moreover, after the recent surge in its stock price, the company's real estate value no longer provides much downside protection. With the risk-reward balance worsening, I sold all of my Dillard's shares on Tuesday.

Fear can be healthy -- in small doses

While Buffett urged his followers to be fearful when others are getting greedy, investors shouldn't take that advice too far. A healthy dose of caution can help you make good decisions rather than getting caught up in market hype. (Conversely, a healthy dose of optimism may help you keep your cool when the market is plummeting.) By contrast, automatically selling all of your stock probably isn't the right move, even in the midst of a speculative mania.

Maintaining a long-term mindset represents the surest path to investing success. In the current environment, investors can heed Buffett's advice while focusing on the long term by holding on to stocks with substantial long-term upside while selling short-term winners with less future upside potential.