Building an Algo on Privacy Keywords using TiingoNews
Earlier this year, the Guardian reported that WhatsApp was again trying to change its privacy policy over ongoing concerns regarding access to and logging of personal information. While the company did roll out a new policy in May, WhatsApp continues to face scrutiny, criticism, and user defection, according to Business Insider.
WhatsApp is not the only company to come up against privacy concern issues, and incidents of data breaches, hacks, and other security issues are likely to continue to increase. So how can you, as a quant, leverage news regarding privacy concerns to potentially short the companies involved?
In the latest installment of Idea Streams, we walk you through how to build and backtest a trading strategy that shorts technology companies that are featured in news articles regarding privacy concerns.
Our Process
We first created a universe of securities that have a dollar volume of greater than $100 Million.
def SelectCoarse(self, coarse):
return [c for c in coarse if c.DollarVolume > 1e8]
We then narrow the universe to technology stocks.
def SelectFine(self, fine):
return [f.Symbol for f in fine if f.AssetClassification.MorningStarSectorCode == MorningStarSectorCode.Technology]
For every security in our universe, we used the TiingoNews data source to gather their news releases throughout the backtest. As we received news releases, we scanned the title. If the title contained any of the following words: privacy concern, vulnerability, compromised, or security flaw, we shorted the stock for three (3) days. By using the InsightWeightedPCM, we assure that more of the news articles related to privacy concerns are given a larger weighting in the portfolio.
self.SetPortfolioConstruction( InsightWeightingPortfolioConstructionModel() )
Finally, we used the ImmediateExecutionModel to have orders fill at the market open.
self.SetExecution( ImmediateExecutionModel() )
Results
To test our strategy, we set the timeframe to be between January 1, 2019 and January 1, 2020. Since this strategy is short stocks, and, in effect, short the market, we wanted to avoid the market dynamics brought on by the Covid-19 crash, and subsequent recovery, which would skew our results.
We let the algorithm run and saw that while overall performance was not great, the strategy did perform well on several occasions (see interactive backtest chart below).
We hope that you now have a better idea of how to implement a keyword strategy using TiingoNews data on QuantConnect. You can view the full, step-by-step video tutorial here, including how to use our debugging tools to check that your algorithm is working as intended. Should you need any clarification on anything we’ve covered, please reach out to us, we’re always here to help.
Happy coding!
