Overall Statistics |
Total Trades 127 Average Win 0.91% Average Loss -0.90% Compounding Annual Return -2.615% Drawdown 11.800% Expectancy 0.020 Net Profit -1.097% Sharpe Ratio 0.032 Probabilistic Sharpe Ratio 22.747% Loss Rate 49% Win Rate 51% Profit-Loss Ratio 1.01 Alpha -0.229 Beta 1.035 Annual Standard Deviation 0.227 Annual Variance 0.051 Information Ratio -1.156 Tracking Error 0.191 Treynor Ratio 0.007 Total Fees $1001.70 Estimated Strategy Capacity $21000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X Portfolio Turnover 165.94% |
# region imports from AlgorithmImports import * from QuantConnect.DataSource import * class TiingoNewsDataAlgorithm(QCAlgorithm): current_holdings = 0 target_holdings = 0 word_scores = {'good': 1, 'great': 1, 'best': 1, 'growth': 1, 'bad': -1, 'terrible': -1, 'worst': -1, 'loss': -1} def Initialize(self) -> None: self.SetStartDate(2021, 1, 1) self.SetEndDate(2021, 6, 1) self.SetCash(100000) # Requesting data self.aapl = self.AddEquity("AAPL", Resolution.Minute).Symbol self.tiingo_symbol = self.AddData(TiingoNews, self.aapl).Symbol def OnData(self, slice: Slice) -> None: if slice.ContainsKey(self.tiingo_symbol): # Assign a sentiment score to the news article title_words = slice[self.tiingo_symbol].Description.lower() score = 0 for word, word_score in self.word_scores.items(): if word in title_words: score += word_score if score > 0: self.target_holdings = 1 elif score < 0: self.target_holdings = -1 # Buy or short sell if the sentiment has changed from our current holdings if slice.ContainsKey(self.aapl) and self.current_holdings != self.target_holdings: self.SetHoldings(self.aapl, self.target_holdings) self.current_holdings = self.target_holdings