I am attempting to create a script that downloads a list of stocks from dropbox(I have that part down already) and invests in them if there is available buying power. The list of stocks on dropbox updates every day at 8:30. Everyday at 9:00, I would like the quantconnect script to check to see if we are holding any stocks, if we are, do nothing. If we are not holding any stocks, I want the script to download the data and run my analysis. How should I order this in the code? What parts of the script should go in the Initialize part and what parts should go in the onData part? The parts are: download data, add equities, find momentum, set benchmark, set trailing stop loss, and the checking if the portfolio is invested.
Ben L
Shile Wen
Hi Benjamin,
I instead suggest creating the Universe as shown in this algorithm, which can handle both the download and adding equities to the universe. Setting the benchmark should be done in Initialize, while finding the momentum, trailing stop loss, and checking if the portfolio is invested can be done in OnData.
Best,
Shile Wen
Ben L
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!