I am a newbie here and came across an interesting article on using Google trends (
) and wondered if I could replicate the results. I wasn't able to exactly replicate them, but the results still look pretty good.
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Article discusses using Google Trends to predict markets with positive results.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
Using Google Trends to Predict Markets
Ahmad Emad | October 2018
I am a newbie here and came across an interesting article on using Google trends (
) and wondered if I could replicate the results. I wasn't able to exactly replicate them, but the results still look pretty good.
QuantConnectâ„¢ 2025. All Rights Reserved
Ahmad Emad
Actually, this would be the accurate backtest.
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.
SLPAdvisory
Super Interesting! Thanks for sharing!
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.
Jared Broad
Really cool! We should try and make this one a LEAN custom data type to avoid any potential look-ahead bias. If the API is fairly robust we can make it available to the whole community with one line of code:
AddData<GoogleTrends>("SearchFilter");
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.
Emilio Freire
That would be amazing!
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.
Douglas Stridsberg
Interesting to see this! I wrote a paper on this many years ago actually: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2502508
I think having Google Trends data would be interesting on the QC side.
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.
Walter
I remember looking into this a while back and noticed the Google trends data has a look ahead bias. If I remember correctly, the numbers are % of popularity. So if suddenly a topic becomes way more popular than in the past, previous values will change to reflect this new popularity. Backtesting this data, the %'s might have been different at the actual time of the hypothetical trades.
So for example, bitcoin became very popular in 2017, like the picture below. However, if we were back in 2012, those little spikes would have been the 100% mark at the time.
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.
Tocht
Post above is true but irrelevant -- interesting & out of the box. Thanks for the share OP
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.
Douglas Stridsberg
Tocht I would say it is quite relevant. Let's say you're building an interface to access this Google Trend data - not only would you need to pass a parameter for the date range of the data (i.e. get me data for Nov 1 2012) but you would also need a second parameter to specify the "simulated date of access".
Looking at the graph above, if you got Nov 2012 data as of today, it would be around 5-10. However, if you got the Nov 2012 data as of, say, Dec 2012, then it would probably be in the ~100 range.
This means thought needs to be put into how to design the data interface. You might be able to get away with simply scaling the data up by the maximum value attained prior to "simulated date of access" - but if Google's scaling is more complex, you may need to somehow store a copy of the data for each "simulated date of access".
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.
Walter
Exactly. I don't know if the scaling is just (current value) / (max historical value) or something more complex. And I don't think they give you the raw values.
Another thing to be mindful of are the actual search terms used. For example now we all know bitcoin was super popular in 2017, but if we were to start trading a strategy with bitcoin as a keyword in 2010, we wouldn't know bitcoin would be popular. So a systematic way of choosing keywords needs to be implemented.
In the example above, would we have known to use the word debt prior to the GFC?
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.
Alex Pressl
Thank you for the post, I agree that adding that data to lean would be excellent. Is there an idea when this might be available?
For now I guess using the pyinterface of trend data is the way to go?
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.
Lucas
Hi Guys, I am keen on recreating the above algo without the discussed look ahead bias. I have ~180 google trends CSV files. Would anyone know the best way of getting theses into arrays within QC?
https://www.quantconnect.com/forum/discussion/5366/using-google-trends-to-predict-stock-market-direction-without-look-ahead-bias/p1Sorry to hijack the thread, I have created a separate post here:
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.
Samuel Schoening
Was wondering if anyone ever went through with this plan. I am not the greatest programmer and the world so I am about to manually convert all of the data from 2004 onward and adjust the value of each day by working my way down the intervals google provides and adjusting all values in each particular dataset. If someone already did this or automated this procedure, I would very much appreciate it if you could share some insight on it or just tell me to stop wasting my time lol.
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.
Derek Melchin
Hi Samuel,
I'd recommend using pandas to automate the data adjustments of historical CSV files. To increase your skills with pandas, checkout our Introduction to Financial Python tutorials.
Best,
Derek Melchin
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!