In December 1996, I sold all my shares of Best Buy (NYSE: BBY).

It was one of the most boneheaded investment moves I ever made.

A year later the stock was up more than fivefold. A few years more, it was up more than thirtyfold.

The worst part is that I liked the business prospects for Best Buy at the time.

I sold it only because the stock was below my purchase price and I had taken substantial capital gains earlier in the year.

The IRS, of course, allows you to offset realized gains with realized losses each calendar year. (You can also take up to $3,000 in realized losses against earned income.)

If you do this, however, you must wait at least 30 days before buying the stock back. Otherwise you run afoul of what’s called the “wash-sale rule.”

As I learned the hard way – and despite what your tax advisor may tell you – you should never sell a stock for tax reasons alone.

Especially since, if you follow the strategy I’m about to describe, you can enjoy the tax benefits of a realized loss without ever taking the risk of being out of the stock.

Sounds impossible – or at least dodgy? It’s not.

Offsetting gains at the end of the year is generally a sensible move.

Your tax bill will be lower. Trading costs and spreads are negligible these days, so they’re not a factor. And most stocks are not appreciably higher 30 days later.

So if you still like the company, you can always scoop up its shares again a month later.

However, there is a risk to this year-end strategy. It’s called the January effect.

The first month of the year is traditionally a strong one for the market. A lot of pension and IRA money gets invested right after New Year’s.

Plus, there is often a rebound from the tax-loss selling that happens each December.

If a stock you sold in December soars in January, there is a natural reluctance to buy it back. The temptation is to wait until it comes back down.

Yet it may not. In that case, you sold an investment with unlimited upside potential to take a limited loss.

That’s what happened to me with Best Buy.

There is a way around this problem, however. But you have to act on this strategy within the next two weeks.

Here’s how it works…

In late November each year, I look to offset realized gains by identifying any companies in my nonretirement accounts that are trading below my purchase price.

If I still like their prospects, I often double down on them for 30 days.

Why? If my original shares are still down, I can sell them at the end of December for a tax loss.

And if the market rallies strongly in January – as it often does – it’s not a problem.

After all, thanks to my November purchase, I will own the same number of shares I bought originally but with a new lower cost basis.

What if you don’t have the cash available to double down on your losing positions?

In that case you should do something I rarely recommend: Use margin.

Again, I’m recommending it only for that 30-day period between late November and late December.

Your margin interest charge – especially with rates at today’s levels – will be minimal.

The risk, of course, is that your second purchase could also be worth less a month from now.

But you will have a lower cost basis on those shares, giving you a bigger gain when the stock eventually rallies. And, of course, the opposite may happen.

The January effect is often preceded by the “Santa Claus rally,” the tendency of the stock market to do well in December.

As a result, you could well have a paper gain on your new purchase – and a smaller realized loss on your original purchase.

(The Santa Claus rally and the January effect – while real seasonal trends – are never certain, of course, another reason you should add to only those companies whose business prospects remain strong.)

Bear in mind, when selling for tax purposes, the IRS requires that you buy the identical shares at least 30 days before you sell the original shares to avoid the wash-sale rule.

So to use this strategy for 2019, you must act within the next two weeks – and wait at least 30 days to take any loss on the original purchase.

If we have the traditional mid-December to late January rally, you’ll thank me.

And then again on April 15.

Good investing,

Alex