Back

Using google trends to predict stock market direction (without look ahead bias)

Hi All, I am interested in implementing some of the feedback in the comments of the thread in the link below: my goal is to eliminate look ahead bias by using a new CSV file where the most recent google trends date is the same date inside my backtest.

https://www.quantconnect.com/forum/discussion/4755/using-google-trends-to-predict-markets

I've written a little python script (using pytrends) to automatically download each month (ie Jan04 to Feb04, then Jan04 to Mar04) and uploading it to dropbox isnt an issue.

This issue I am having is getting these ~180 csv files into quantconnect. My only solution is to write ~180 lines with unique variable names and download link using the QC Download() function, which I see as tedious and error prone.

I have considered creating a dropbox link to the folder they are contained in, however that would mean downloading a zip file within quantconnect and I am not sure how to do this?
(Parsing the zip file using the QC Download() function I believe won't work)

Does anyone have a better idea to go around this? Cheers

Update Backtest







0

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.


Why not upload each file to something other than Dropbox (so that you can use the actual filename), name each file by the date on which it was downloaded and then Download() the appropriate file using the date?

Otherwise the best option would be to, like you said, zip the files together and Download() that file once. Unzipping in C# or Python is not difficult and you can still use the same naming convention as I described above to aid in using the appropriate file for the appropriate date.

A more complete and robust solution  of course (which you can later open source!) is to create a custom data type entirely. 

0

Hi Lucas.

I suggest you create a custom data object and read your data into the custom data object. There are useful examples and tutorials on the topic in this documentation section on Importing Custom Data.

You can probably simplify the procedure by combining all of the values in one large csv file. Good luck!

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed