I need help adding with my code to prevent pattern day trading. Basically, I want to implement the following on the attached code
1: Once I buy a stock, hold it for at least one day before selling (even if it meets the selling condition before one day is over)
2. If I sell a stock, wait at least one day before repurchasing the same stock (even if it meets the buying condition before one day is over after selling)
Will appreciate any help I can get
Louis Szeto
Hi Lemuel
My suggestion would be adding a marker to check should it continue to iterate in the remaining time of that day. (self.state in the attched example) If you want to do it symbol-wise, you can change the marker to be a dictionary contains symbol as key and marker as value, and set the if condition inside the for loop.
hope this helps
Cheers
Louis
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.
Louis Szeto
Example on symbol-wise scenario
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.
Varad Kabade
Hi Lemuel and Louis,
Thank you, Louis, for the excellent response. Moving forward, we can simplify the algorithm above by removing the SymbolData class and removing the warmup period.
Best,
Varad Kabade
Lemuel Mwangi
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!