Hi! I am new to quantconnect and am trying to create a simple algorithm that will buy all stocks that gapped down overnight at the beginning of each day, and then sell them at the end of each trading day. I created a universe for for the volume and price criteria (the price must be between 1 and 100 USD, and the 10 day SMA of the volume must be greater than 3,500,000). I keep getting errors, then tweaking my code and getting more errors. If anyone can help me figuring out what I am doing wrong it would be greatly appreciated. I'm not sure if I have completely on the wrong track and am wasting my time, or if I just have a few simple errors that I'm overlooking. Thanks in advance!
Ryan Riordon
Hello and welcome Cole,
You may find some code that might help or inspire you for yours since I have something that is similar to your intent without the SMA.
Cole Kuster
Thank you for the help!
Â
Shile Wen
Hi Cole,
On line 37, we iterate through the StateDatas, but we need to get the Symbol information, so we need to instead iterate over the dictionary’s .items(). Furthermore, OnSecuritiesChanged, doesn’t accept algorithm as an argument unless we are inside an Alpha Model. I’ve also added self.securities = [] in Initialize. The EveryDayAfterMarketOpen method try to access fields that don’t exist. To see an example of a Gap Down strategy, please see this post. The changes can be seen in the attached backtest.
Best,
Shile Wen
Cole Kuster
Thanks so much for your help!
Cole Kuster
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!