Tax Loss Harvesting strategy
Author: flroots
Creation Date: 3/15/2019 8:03 PM
profile picture

flroots

#1
Just starting to think about developing a tax loss harvesting strategy for a portfolio of ETFs. Basically I want to sell an ETF on stop loss order and use the proceeds to buy a similar ETF. This means that in real time I'll need to calculate the proceeds of the sale and then calculate the number of shares to purchase of the similar ETF. Can someone let me know a) is it possible with Wealth-Lab and b) how one might get started? Thanks.
profile picture

Eugene

#2
QUOTE:
This means that in real time I'll need to calculate the proceeds of the sale and then calculate the number of shares to purchase of the similar ETF.

And of course to make sure that the similar ETF isn't substantially identical for the wash-sale rule. So what's the stumbling block? Does it require to maintain the same dollar size, right?
profile picture

flroots

#3
Yes, that's my question. In fact I have two questions:
1. Is what I want to accomplish possible with Wealth-Lab?
2. How best to set it up?
Thanks
profile picture

Eugene

#4
Well, there's "Fixed Dollar" position sizing option to keep the same position size for the similar ETF purchase.
profile picture

superticker

#5
QUOTE:
And ... to make sure that the similar ETF isn't substantially identical for the wash-sale rule.
That's not the only problem. Chances are if you're selling a falling sector ETF, say for oil, then other similar ETFs will be falling as well. You'll just be trading one looser for another. What makes more sense is to have an ETF rotation strategy between a sector ETF (e.g. long on oil) and its contra ETF (e.g. short on oil). And you would still be able to harvest tax losses provided its rotated over a +30 day period.

I could be wrong, but if you check out the ETF Pairs Arbitrage strategy at WealthSignals, I believe they are rotating an ETF and its contra ETF, and this rotation is over a +30 day period. This approach makes the most sense for trading (and maybe tax loss harvesting). Wealth-Lab has some example rotational strategies available.
profile picture

flroots

#6
I think you misunderstand the nature of what I'm trying to do. It's called "Tax Loss Harvesting". I'm actually trying to turn paper losses into realized losses for tax purposes. The idea is to accumulate losses purely for tax purposes. I'm always fully invested; it's swapping between ETFs to realize losses.

While I'm just learning Wealth Lab Pro, I don't think I can use "Fixed Dollar" positions because if I'm correct that applies to both buys and sells. Each sell is for a variable amount (depending on the market) and the subsequent buy tries to match the proceeds from the prior buy so that I'm always fully invested.

profile picture

Eugene

#7
Not sure what "each sell is a variable amount" means exactly. If this what is known by "partial exits" then your task gets more difficult as the resulting Strategy will require the use of SplitPosition() and multiple position management (e.g. Help menu > WealthScript Programming Guide > Programming Trading Strategies > Multi-Position Strategies). But in general it should be possible. You can run a code search inside the downloadable Strategies ("Open Strategy" dialog > "Download..." + enable "Download public strategies") for more examples.

Considering that you intend to sell on stop loss order, calculating the proceeds of the sale does not have to be in real time. The purchase after an exit on that bar can take place with AtClose order (which doesn't generate Alerts) or on AtStop/Limit order which is tricky for reason explained in the FAQ > I want to test a strategy that buys and sells with stop/limit orders on the same bar. So as long as you use the proceeds to purchase a similar ETF on the next bar it's conceptually fine.
profile picture

KGo

#8
QUOTE:
I don't think I can use "Fixed Dollar" positions because if I'm correct that applies to both buys and sells.

Not so. In Wealth-Lab an entry creates a "Position" using rules from any of the position sizing methods. An exit always sells all of a position at then current value. So the fixed sizing entry method does not affect selling proceeds. However, it will force each buy to be the same dollars which is not what you want.

You have not said how many ETF's are simultaneously held. For a small number, the simplest way be to create a strategy for each ETF and its Tax harvest successor(s). Then a simple 100% equity position sizing can be used and the substitute buy will automatically use all proceeds from the prior sale.

You can write a script that tracks the dollars with gain/loss associated with each ETF position. You could use SetShareSize() to control variable sizing for each ETF and calculate shares to use all proceeds but this adds a lot of complexity that can be avoided with a strategy for each ETF group.

So if you're just learning WLP, maybe take a shot a writing a strategy for one ETF and its' tax substitutes using 100% position sizing.
profile picture

Eugene

#9
QUOTE:
using 100% position sizing.

@flroots, be careful with 100% sizing. See the User Guide (Help menu) > Strategy Window > Backtesting Strategies > 100% of Equity Sizing.
profile picture

flroots

#10
I've now got a pretty good strategy working. It uses 2 pairs of ETFs (ie, total of 4). VTI and SCHB are one pair and VEA and SCHF are the other pair. They cover US and International stocks, respectively. The final strategy will use 5 pairs, but that will be a simple extension once I'm happy with the strategy. An important part of the strategy is setting Position Sizing to WealthScript Override (SetShareSize). This allows me to specify the number of shares on each buy. Whenever a loss meets my sell criteria, the program makes the sale at market, calculates the proceeds and based on that calculates the number of shares of its pair ETF to make the buy. It then calculates residual cash and adds that to the balance for future trades. One area that could be refined is the sell criteria. Right now I just look for a fixed percent loss from entry price. It seems to work fine, but I'm sure a refinement would be possible. I would like to maximize the realized capital loss while minimizing number of transactions since ETF trades for non-iShare/Fidelity ETFs are $4.95 each.

While the strategy runs in backtest mode, I am not able to get it working in a paper trading account yet. I tried following the tutorial here: https://www.youtube.com/watch?v=c0Za26ncyvE, but no orders were created? If anyone knows of another tutorial for paper trading that would be appreciated
profile picture

Eugene

#11
QUOTE:
but no orders were created?

Start here: FAQ | Strategies and WealthScript > Alerts are not triggered.
profile picture

KGo

#12
You may want to calculate the proceeds from dividends within the strategy. Add them to residual cash for future transactions. Otherwise dividends will not be reinvested.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).