Overall Statistics
Total Trades
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-24.509%
Drawdown
1.900%
Expectancy
0
Net Profit
-0.461%
Sharpe Ratio
-1.196
Probabilistic Sharpe Ratio
37.487%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.483
Beta
-0.788
Annual Standard Deviation
0.166
Annual Variance
0.028
Information Ratio
0.458
Tracking Error
0.352
Treynor Ratio
0.252
Total Fees
$4.30
Estimated Strategy Capacity
$960000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
from AlgorithmImports import *

class RegalyticsDataAlgorithm(QCAlgorithm): 
    
    negative_sentiment_phrases = ['restrict', 'barrier', 'tariff']
    
    def Initialize(self):
        ''' Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
        self.SetStartDate(2022, 7, 10)
        self.SetEndDate(2022, 7, 15)
        self.SetCash(100000)
        
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
            
        # Requesting data
        self.regalyticsSymbol = self.AddData(RegalyticsRegulatoryArticles, "REG").Symbol
            
        # Historical data
        history = self.History(self.regalyticsSymbol, 7, Resolution.Daily)
        self.Debug(f"We got {len(history)} items from our history request")

    def OnData(self, slice):
        ''' OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        :param Slice slice: Slice object keyed by symbol containing the stock data
        '''
        data = slice.Get(RegalyticsRegulatoryArticles)
        if not data: return
        
        for articles in data.values():
            self.Log(articles.ToString())
            
            if any([p in article.Title.lower() for p in self.negative_sentiment_phrases for article in articles]):
                self.SetHoldings(self.symbol, -1)
            else:
                self.SetHoldings(self.symbol, 1)