We've written a simple Alpha Model, Tiingo NLP Sentiment, as an example of how you can use the alternative data into your own Alpha Model for the competition.In this algorithm, we use Tiingo's News to filter for Technology ETF in the universe.
The Alpha Model takes a collection of the highest volume ETFs related to technology stocks in the TechnologyETFUniverse, collects words indicating the sentiment, and scores the positive or negative side of the news for each asset. The sum of the sentiment score is calculated for each security and then used as a proxy for the direction and weight of the insights. We take a long position in the top 10 assets by sentiment ranking. The algorithm emits 10 insights per day.
One of the limitations with this model is that the words used are not exhaustive and more could be added to better categorize positive and negative sentiment. The sample size, accuracy of describing a trend of an asset, and the scoring scale determine the trade signal and algorithm's performance. Generally speaking, the larger the sample size,the more precise the scoring scale is, and the more accurately the signal. If we polish the description words sample pool, the result should reflect this more refined.
Lukas Malik
Hey Yiyun, thanks for the Algorithm. I wanted to extend the algorithm by using VaderSentiment instead of a word lookup.Â
https://github.com/cjhutto/vaderSentimentVaderSentiment is a part of the NLTK package. In order for it to work I have to download the vader lexicon using nltk.download("vader_lexicon"). However this is not possible (
connection failed: 403 Forbidden), I guess this is due to security reasons. Is there any way around this?Â
Lukas Malik
Alright here is my version. It uses VaderSentiment to analyze the sentiment. I managed to upload the dictionary to dropbox. I also changed the SentimentIntensityAnalyzer class from nltk in order to be able to retrieve the file. It works quite well!Â
Bolgac Gulen
Hello Lukas,
Firstly, it is very generous of you to problem solve and then share your solution.Â
I cloned the code for the above backtest in order to analyse your code for myself. Though I faced a problem; in trying to backtest the codei get the below error.
During the algorithm initialization, the following exception has occurred: TypeError : __init__() takes 1 positional argument but 2 were given
at Initialize in main.py:line 21
:: self.SetAlpha(NewsSentimentAlphaModel(self.vaderData))
TypeError : __init__() takes 1 positional argument but 2 were given
However I try to resolve it, when I backtest it the Algo breaches the 1.5 minute time limit in the 'Analyzing Strategy' step of Initiating the backtest. Any suggestions on how to resolve the issue would be greatly appreciated.
Regards,
Bolgac GulenÂ
Shile Wen
Hi Bolgac,To fix this, we need to add vaderData as a parameter in the constructor of NewsSentimentAlphaModel. Please see the attached backtest for reference (note: I added SetEndDate to reduce the backtest time)Best,
Shile Wen
Emiliano Fraticelli
Hi! The research environment is giving me errors Shile WenÂ
I getÂ
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-13-ce437ae3aae5> in <module>
----> 1 description
NameError: name 'description' is not defined
Â
Derek Melchin
Hi Emiliano,
The notebook above had two small errors. First, the cell that only contains `description` should be removed. Second, we should change
description = history.reset_index(level=0)['description']
to
description = history.reset_index(level=0)['description'].rename(lambda x: x.replace(tzinfo=None))
See the attached notebook for reference.
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.
Yiyun Wu
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!