Overall Statistics
Total Trades
383
Average Win
0.68%
Average Loss
-7.96%
Compounding Annual Return
-4.414%
Drawdown
71.600%
Expectancy
-0.043
Net Profit
-61.539%
Sharpe Ratio
-0.119
Probabilistic Sharpe Ratio
0.000%
Loss Rate
12%
Win Rate
88%
Profit-Loss Ratio
0.09
Alpha
-0.021
Beta
-0.031
Annual Standard Deviation
0.2
Annual Variance
0.04
Information Ratio
-0.386
Tracking Error
0.277
Treynor Ratio
0.766
Total Fees
$2144.95
class GunStocks(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(1999, 1, 1)  # Set Start Date
        self.SetEndDate(2020, 2, 25)
        self.SetCash(100000)  # Set Strategy Cash
        
        self.tickers = ["AXON", "AOBC", "RGR", "VSTO", "SPWH", "OLN", "SWBI"]
        self.symbols = [self.AddEquity(i, Resolution.Minute).Symbol for i in self.tickers]
        
        self.senators = {
            1999 : "R",
            2000 : "R",
            2001 : "D",
            2002 : "D", 
            2003 : "R",
            2004 : "R", 
            2005 : "R",
            2006 : "R",
            2007 : "D",
            2008 : "D",
            2009 : "D",
            2010 : "D",
            2011 : "D",
            2012 : "D",
            2013 : "D",
            2014 : "D",
            2015 : "R",
            2016 : "R",
            2017 : "R",
            2018 : "R",
            2019 : "R",
            2020 : "R"
        }
    
        self.AddRiskManagement(TrailingStopRiskManagementModel(0.02))
        self.lastmonth = -1
        
  
    def OnData(self, data):
        
        month = self.Time.month
        if month == self.lastmonth:
            return
        self.lastmonth = month
        
        for key, value in self.senators.items():
            timeYear = self.Time.year
            if (key == timeYear):
                for i, symbol in enumerate(self.tickers):
                    if not data.ContainsKey(symbol):
                        continue
                    
                    if value == "D":
                        if not self.Portfolio[symbol].IsLong:
                            self.Transactions.CancelOpenOrders(self.symbols[i])
                            self.SetHoldings(symbol, 0.12)
                            self.LimitOrder(symbol, -(self.Portfolio[symbol].Quantity), round(self.Securities[symbol].Price, 2) * 1.06)
                    else:
                        if not self.Portfolio[symbol].IsShort:
                            self.Transactions.CancelOpenOrders(self.symbols[i])
                            self.SetHoldings(symbol, -0.12)
                            self.LimitOrder(symbol, -(self.Portfolio[symbol].Quantity), round(self.Securities[symbol].Price, 2) * (1 /1.06))