Tax loss harvesting strategy

I’m looking to backtest the idea if tax loss harvesting early (1-2 months prior to typical December harvesting), and then buying the same stocks in December provides any added benefit.

-Selling losers in Oct/Nov (i.e. stocks with x YTD decline)
-Buying the same stocks in Mid Dec and holding for a year

Is there a way to do this?

It would need to be in the simulator.

Your sell rule would be:

Month=10 and GainPct<0

and your buy rules would be:

Month=12
LastSellDaysLT(60)=True

So two quirks here: First, GainPct, IMO, is going to be A LOT simpler than trying to figure out a YTD from the first of the year. We have a function to give you the number of trading days since a specified date, but I think that the specified year tested would need to be updated each year. Using the position return knowing that you bought it just before the year-end, would, I hope, show you if there’s any gas in that tank with a lot less effort.

The second quirk is the LastSellDaysLT rule: Its typical use is to exclude things that you sold recently, usually to avoid wash sales. This has two big consequences for this system: First, your simulation will buy a bunch of holdings at the beginning of the run and then just buy and sell the same holdings for the duration of the test. It can’t buy anything else because the buy rule is limiting you to only stocks that you sold recently.

Second, if you repurchase within 30 days there are wash-sale tax consequences that Portfolio123 does not address. (We consider all tax-related stuff to be an externality to our system.) This shouldn’t be a problem with the rules as written: There should be more than 30 days between 10/31 and 12/1 every year, because 30 days hath November. But if you were to change the numbers to month 11 and repurchased within 30 days then you’ll face enough tax penalties to explain why people don’t usually do this. That just won’t be reflected in the stated annualized returns.

I just tried it and it doesn’t purchase any stocks at all…