I have sources of dividend data in the form of files (CSV & Jason) and also webservices (IEXCloud).
I believe the least processor/IO intensive methodoloy would be to upload a file to QuantConnect. Is that possible? If so, are there file stream readers available to us to use? Please advise and thank you, Craig
Shile Wen
Hi Craig,
It is not possible to upload files, but it is possible to download files to QuantConnect with the Download method. Furthermore, data streaming is possible in LEAN.
However, for our scenario, one change we need to make to the data is to order the dates from oldest to newest, this way, LEAN will know to read all the dates. The next step is to define a custom BaseData class that contains all the fields we want, including the Dividend Yield, Dividend Pay Date, etc. Then, we create a reader that subscribes to a URL where we will pull the data from. Once we can read in the data line by line, we need to parse the data to fill in the fields we defined earlier, such as the Dividend Date. Two key fields of the BaseData class we need to fulfill is Symbol, and the Time, and we can use the ticker for Symbol and use the Ex Dividend date (EX-Date) for Time.
I’ve shown the necessary code in the attached backtest. Please note that if you choose to keep using tabs (“\t”), please comment out line 55 and uncomment line 56. Also, replace the URL with the data source, and make sure that the dates are ordered based on time as explained earlier.
Best,
Shile Wen
Craig McWilliams
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!