I do not have a live algo yet, but I have a couple I have paper traded and would like to take live. One question I have is about wash sales. These are algos that trade actively, buying and selling daily. My thought is to simply make a class that tracks all sales that are losses and ensure I don't rebuy that security in 30 days.
Maybe we don't expect that many wash sales so we just live with the results and don't worry about it?
Fred Painchaud
Hi Cole,
I most be totally lost but it's surprising to me to read that an algo that does intraday trading would ban trading an asset for 30 days if it ever have a losing trade with it during the day.
I'm missing something.
Fred
.ekz.
This might be helpful:
https://www.tradelogsoftware.com/resources/wash-sales/
Fred Painchaud
Ok so the 30 day thing is an IRS rule. Now I understand why it makes sense. 😊
So, yeah, it is very easy to implement… And you can still use wash sales to some extent to “balance” realized capital gains and losses tax-wise.
Fred
Brandon Leonard
Fred Painchaud I also would like to implement a wash sales. You mentioned it was easy, what would be the best way to do it?
Fred Painchaud
Hi Brandon,
The best way IMHO to monitor orders is to use OnOrderEvent(). It is an event that gets called for all order events happening in the algo - for all traded assets, using a Universe or not.
My understanding of wash sales is that if you make a capital loss on a trade, you leave that traded asset aside for 30 days. That's it. My understanding may be incorrect. If so, the below will be incorrect.
So if I am correct, the gist of the algo would use OnOrderEvent to spot loosing trades.
Fred
Cole S
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!