Overall Statistics
Total Trades
177
Average Win
0.43%
Average Loss
-0.26%
Compounding Annual Return
11.889%
Drawdown
5.500%
Expectancy
0.294
Net Profit
5.859%
Sharpe Ratio
1.312
Loss Rate
51%
Win Rate
49%
Profit-Loss Ratio
1.62
Alpha
0.08
Beta
-0.023
Annual Standard Deviation
0.06
Annual Variance
0.004
Information Ratio
0.263
Tracking Error
0.13
Treynor Ratio
-3.464
Total Fees
$268.43
from QuantConnect.Data.Custom.Tiingo import *

class TiingoNLPDemonstration(QCAlgorithm):

    def Initialize(self):
        self.wordSentiment = {
            "bad": -0.5, "good": 0.5,
            "negative": -0.5, "great": 0.5,
            "growth": 0.5, "fail": -0.5, 
            "failed": -0.5, "success": 0.5, "nailed": 0.5,
            "beat": 0.5, "missed": -0.5,
        }
        
        self.SetStartDate(2019, 4, 1) 
        self.SetCash(100000)
        
        aapl = self.AddEquity("AAPL", Resolution.Hour).Symbol
        self.aaplCustom = self.AddData(TiingoNews, aapl).Symbol
        
    def OnData(self, data):
        if not data.ContainsKey(self.aaplCustom):
            return
        
        news = data[self.aaplCustom]
        
        descriptionWords = news.Description.lower().split(" ")
        intersection = set(self.wordSentiment.keys()).intersection(descriptionWords)
        sentimentSum = sum([self.wordSentiment[i] for i in intersection])
        
        self.SetHoldings(self.aaplCustom.Underlying, sentimentSum)