I just realized that the market is down almost 10% since October. So I panicked, sold every single stock I own, and invested the proceeds in goat dung futures. (We are in a commodities boom, you know, and dung can be used to heat a house in the winter!)

Umm, not really.

A drop in the markets can be frightening, but it shouldn't make you sell. When you buy a stock, it's because you think that the stock is worth more than its current price. If the stock falls, but nothing else has changed, then it has become a better deal because it's cheaper. So you should be thinking about buying, not selling, at times like these.

Successful value investors like Warren Buffett act this way. He doesn't panic and dump shares when the market falls, but rather looks upon the drop as a buying opportunity.

However, even with this philosophy, there are two very good reasons for selling now.

Something has changed
For some businesses, the world has changed. Consider the bond insurers Ambac Financial (NYSE: ABK) and Security Capital Assurance (NYSE: SCA). Six months ago, everything was smooth sailing for these companies, with investment-grade ratings and well-established positions in a growing market. Since then, the market for asset-backed securities (ABS) has collapsed. These companies may have to make good on the insurance that they sold, and they're at risk of a ratings downgrade if they don't raise capital.

But it's even worse than that. Should anyone actually have faith in these companies' investment-grade ratings after seeing ACA Capital Holdings fall from A to CCC overnight? I'm pretty suspicious. I believe that these insurers already don't deserve their AAA ratings, but haven't been downgraded because Moody's (NYSE: MCO) and Standard & Poor's are worried that a downgrade would cause cascading downgrades throughout the debt market.

Fear the fear
These ratings fears -- real or not -- will affect these businesses. Would you buy insurance from a company that you thought might have difficulties paying a claim? Of course not! And if customers become reluctant to buy, then the prospects for Ambac and Security Capital have materially changed -- the fair values of these companies have fallen. They may or may not be bargains at these prices. I have no clue. But if you bought them trusting in their AAA ratings and the strength of their businesses, it's not too late to re-evaluate these companies and potentially sell.

Of course, the damage isn't limited to the mortgage insurers. If you own a lender, a homebuilder, or any other company tied to the housing market, you should reappraise the business in light of current conditions. Often, you'll reach the conclusion that the business is still attractive. But be prepared to sell if it's not.

Time for an upgrade
The other really good reason to sell is to upgrade your portfolio, dropping weak businesses and acquiring the strong. This is particularly relevant in this market, where there are so many high-quality but inexpensive stocks available.

To start with, look closely at the balance sheets of the stocks you own. We may be entering a recession, so it's becoming riskier to own highly leveraged companies. If the recession impacts their cash flow, they'll have a harder time paying off their debt.

For example, I recently considered buying Ashford Hospitality Trust (NYSE: AHT), which looks extremely cheap when you compare its price to its book value and funds from operations (a proxy for earnings in the REIT sector). But when I realized that its debt-to-equity ratio was twice that of competitors like Host Hotels & Resorts (NYSE: HST), I decided to pass. Though Ashford looks cheap, I'd rather own Host going into a recession.

And even if you aren't worried about the balance sheet, it makes sense to sell weaker businesses to buy high-quality stocks. For instance, even though tiny, second-tier drug manufacturer King Pharmaceuticals (NYSE: KG) is cheap, it may make sense to sell that stock and buy AstraZeneca (NYSE: AZN). AstraZeneca is only a bit more expensive than King, but is in a better competitive position because of its patents, research, and financial strength.

The Foolish bottom line
So, during times like these, look to upgrade your portfolio. According to our calculations at Inside Value, there are quite a few quality stocks trading at 40%, 50%, and even 60% discounts to their fair value.

When you can buy at such a huge discount, it makes sense to sell an undervalued good business to acquire a deeply undervalued, great business. If you want a head start, we offer a free trial to Inside Value to anyone who's interested in reading about the best bargains in the market today.

Fool contributor Richard Gibbons knows why manhole covers are round, but not why his head is. He owns shares of King Pharmaceuticals and as of last Thursday is short Moody's puts. Moody's is a Motley Fool Stock Advisor pick. The Fool's disclosure policy enthralls.