Hello,
I'm wondering how I can keep the scanner in this algorithm going all day, but turn off the order placing for the first ten minutes of the day? I was thinking I could add something like "or self.TimeRules.AfterMarketOpen<10" to line 66, but I keep getting errors that I'm not sure how to fix. Any advice or documentation would be greatly appreciated.
Thanks!
Sean
Varad Kabade
Hi Sean,
To implement the above logic we recommend adding the following code snippet at end of the Update method before returning the insight list:
best,
Varad Kabade
S O'Keeffe
Hi Varad,
Thank you! It looks like this didn't quite work though. I think that paused both scanning and buying. For example, the attached backtest kept buying even though the true high of day ($7.33) was never broken after 9:40. Is there a way to pause trading without pausing scanning?
Thanks!
Sean
Varad Kabade
Hi Sean,
The above code will not emit any insight for the required duration. To stop the algorithm from placing orders, we recommend modifying the ExecutionModel logic to include the above code snippet, so it does not place any order for that time.
Best,
Varad Kabade
S O'Keeffe
Hi Varad,
Thank you again for your response! Sorry I'm not sure I completely followed. Your next recommendation would be to edit line 17 of my original attached backtest? You would recommend something like this?
Thanks!
Sean
Varad Kabade
Hi Sean,
We recommend modifying the Execute method of the ImmediateExecutionModel as follows:
Best,
Varad Kabade
S O'Keeffe
Hi Varad,
Amazing thank you! I placed those lines of code in line 33 of the original attached backtest. But now I am getting “SyntaxError: ‘return’ outside function." Did I place those lines of code in the wrong spot?
Thanks,
Sean
Louis Szeto
Hi Sean
Please make sure the implementation of the correct "tab" space for line 34-51/so on, like in line 27-31 that they should be inside the method header.
Best
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.
S O'Keeffe
Hi Louis,
Thank you! Sorry I'm still not quite grasping the error here. Now I'm seeing ‘unexpected indent’ with the latest try?
Thanks!
Sean
Varad Kabade
Hi Sean,
Please make sure you add indentation to the whole method as follows:
Best,
Varad Kabade
S O'Keeffe
Thanks Varad and Louis I think it's working now!
S O'Keeffe
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!