Hi together,
I struggle around and need help: How can I use signals from indicators, like from the InvestorSentimentSurveyAlphaModel?
I guess, that I should extend the "Update" area with some kind of signal; but in addition to that: How could I use that signal afterwards for deciding "buying stocks or not"?
Thank you very much in advance!
class InvestorSentimentSurveyAlphaModel(AlphaModel):
def __init__(self, algorithm):
## Add Quandl data for AAII Investor Sentiment Survey
self.bullBearSpread = algorithm.AddData(QuandlData, 'AAII/AAII_SENTIMENT',Resolution.Daily).Symbol
def Update(self, algorithm, data):
insights = []
# Return if no data
if not data.ContainsKey(self.bullBearSpread): return insights
# This Alpha model uses the Bull-Bear spread from AAII Investor Sentiment Data.
# A Bull-Bear spread is the difference in percentage between bullish investors and the percentage of bearish investors.
# A positive Bull-Bear spread might be a leading indicator that predicts an equity market rally.
# Similarly, a negative Bull-Bear spread might be a leading indicator that predicts an equity market selloff.
return insights
def OnSecuritiesChanged(self,algorithm,changes):
## The Quandl Symbol, self.bullBearSpread, will appear in changes.AddedSecurities
pass
class QuandlData(PythonQuandl):
def __init__(self):
## Retrieve the data from the the Quandl object, specifying the data field used on Quandl
self.ValueColumnName = "BULL-BEAR SPREAD"
Shile Wen
Hi Martin,
If I am assuming you are talking about using indicators within the alpha model, we can initialize an indicator similarily to how we do in the QCAlgorithm, but instead of using self.indicator, e.g. self.SMA, however, we'd do algorithm.indicator. If you are asking about how to get the custom value from the Quandl data, we can get the value through data[symbol].Value. To make a decision on whether we want to buy or not off this data, we add an insight to our list of insights, and to read more about them, see our documentation. I've shown all 3 in the attached backtest.
Best,
Shile Wen
Martin Kammerer
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!