I've had a few stocks bought out from me. Some deals were fortunate, allowing me to lock in a quick gain. Others were ill-timed, costing me more in taxes while taking away companies that I wanted to hold for years more, if not decades.

Getting bought out is a great feeling -- a confirmation that you weren't the only one who thought a stock was undervalued. But in the weeks and months after the press release, when the warm and fuzzy feeling wears off, investors have some tough decisions to make.

Hand holding fortune with four choices: Buy, Sell, Hold, or question mark.

Image source: Getty Images.

Sell now or hold on?
Shortly after a buyout is announced, the acquired company's stock almost always rockets to trade close to the price of the takeover offer. If the buyer agrees to pay $15 in cash per share for the target's stock, Wall Street might push its share price to $14.75 in a matter of minutes.

The difference between the offer price and the current stock market price reflects the risk the buyout won't go through, as well as the waiting time for the deal to close. After all, investors who expect a return on their money won't pay $15 for a company's stock just to get $15 back in cash a few months later. They might, however, pay $14.75 per share to pocket $15 per share if the deal closes.

Buying stocks ahead of a merger is risky business. So-called merger arbitrage has been likened to "picking up pennies in front of a steamroller," which should say something about trying to make money on the difference between the current market price and the takeout price. When deals go through, you can make a few percentage points. When they don't, investors can easily lose in excess of 20%.

The upside to holding on
There are clear benefits to holding on to a stock after a takeover offer. For one, you'll almost always get a higher price when the buyout closes than you would selling at the current market price. Furthermore, in industries with several potential acquirers, it's possible for another bidder to enter the scene with a better offer. These bidding wars can be huge wins for shareholders, since more competitive sales almost always result in higher prices.

It's not all about the price at which you sell, though. It's also about what you keep. Holding on to a stock after an announced merger can create substantial tax savings.

Capital gains generated from stocks held for less than one year are subject to taxation at your marginal tax rate. Capital gains earned from stock held for more than one year are taxed at the much lower capital gains rate, which is 0% for many middle-class earners. Since it can easily take three to six months for a takeover to finalize, you can turn a short-term capital gain into a long-term capital gain just by holding on. 

Finally, holding until the buyout closes usually results in a commission-free sale of stock. As commissions have plummeted to less than $10 for most discount brokers, though, this tends to be nothing more than a rounding error.

Why you might sell now
Holding on might net you a few extra pennies per share, but if taxes aren't in play, most of the advantages are small. Selling now might be a better alternative.

The best reason to sell is to minimize your risk. The simple fact is that the majority of gains from buyouts are made on the day of the offer. The next several months will likely only reward you with a few percentage points in added return.

The CFA Institute found that from 2002 to 2007, stocks that were part of a successful acquisition traded at a median discount of roughly 2% to the announced price at the time of the takeover announcement. After 90 days, the median spread shrunk to little more than 1%. The markets are very efficient when it comes to pricing in the risks that a deal won't go through -- there simply isn't much money to be made by holding on.

All things considered, unless you can turn a short-term capital gain into a long-term capital gain, selling at the time of the announcement makes more sense than holding on for a couple percentage points in added returns.