Financial bubbles never deflate in an orderly way, and now we contend with two — a housing bubble and a credit bubble, both ending badly.

Today the question is not whether the stock market and the economy will be hurt, but how much. A recession "may be unavoidable at this point," Merrill Lynch economist David Rosenberg tells clients.

Economist Ed Yardeni, known for his optimism, recently doubled (to 30 percent) his odds of a recession in the next six to 12 months. Most recessions are preceded by stock-market declines of 20 percent or more.

Most menacing is the collapse of the market for mortgages written to poor-risk homebuyers. These subprime loans were packaged and sold with investment-grade ratings to hedge funds, banks and pension funds.

Then in July, with delinquencies rising sharply, the rating agencies reclassified a slew of these securities as junk, causing them to be marked down by as much as two-thirds and setting off a panic that threatened to cut off credit to even the best risks, not just for mortgages but for short-term business loans.

Nobody knows the full dimensions of the subprime debacle, so it's impossible to predict how it will play out. At one extreme, J. Kyle Bass, managing partner of Hayman Capital Partners, was told on a visit to California's Central Valley that up to 90 percent of the subprime loans in that region involved fraud.

Most subprime paper is held by secretive banks and hedge funds. Every time word trickles out that a highly leveraged fund holding subprime paper has imploded, the stock market shudders. The Dow Jones industrial average, which hit an all-time high on July 19, had fallen almost 10 percent a month later.

One victim of the subprime debacle is the leveraged buyout, which was a pillar holding up the stock market. There hasn't been a major deal announced since early July.

Merrill Lynch's Rosenberg observes that total public and private U.S. debt now amounts to 340 percent of our annual economic output — a record-breaking ratio fed by cheap loans.

Big contributors were private-equity firms that borrowed at very low rates to take public companies private. Those low rates disappeared this summer.

At some point, the Federal Reserve Board will lower short-term interest rates to relieve some of the financial pressure and encourage lenders to lend. But some of the banks and hedge funds that took the biggest risks may go belly up by then.

In the meantime, you would be wise to seek safety in the storm. Sell speculative stocks, including those in emerging markets, and use the cash to pick up quality names when the rainbow ultimately appears.