I am relatively new to QuantConnect and am having some difficulty building my first algorithm. My goal is as follows:
I want to take a csv that I have hosted on dropbox that provides a list of 5 stocks for each day of 2017, and on each day I want to place orders for these 5 stocks, 10 minutes after market open and then liquidate the positions 10 minutes before market close.
I have looked through the documentation and example scripts and have found both how to load custom data and execute scheduled events but I can't seem to get them working together. If anyone could provide a rough framework in Python of how I should approach this, it would be greatly appreciated.
Ben stelzer
I have attached my current attempt. I don't seem to be getting any errors but the algorithm isn't executing any trades and I can't workout why.
Jason Gaskin
I'm also relatively new but I think the issue may lie in trying to set up your custom data as a universe. You could try importing the data and using csv read to save a list or Pandas Series. You could then continue with your SetHoldings set up and read in the symbol with some sort of loop to go through each symbol.
self.file=self.Download("FileURL")
self.file = StringIO(self.file)
self.Symbollist= pd.read_csv(self.file,index_col = 0)
I've used code similar to this to read in data I brought from Dropbox into a DataFrame
Alexandre Catarino
Hi ben stelzer, sorry about missing your thread.
I fixed the algorithm you have shared. The main issue was assigning the config.Symbol to the StockDataSource.Symbol and trying to pass all the symbols as an attribute of StockDataSource. It couldn't work, because each symbol was found in a different line.
Thank you Jason Gaskinfor the workaround, but you would need to subscribe and unsubscribe the symbols accordingly.
Ben stelzer
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!