Overall Statistics
Total Trades
126
Average Win
0.22%
Average Loss
-0.27%
Compounding Annual Return
31.101%
Drawdown
1.800%
Expectancy
0.139
Net Profit
2.327%
Sharpe Ratio
2.6
Probabilistic Sharpe Ratio
68.975%
Loss Rate
38%
Win Rate
62%
Profit-Loss Ratio
0.84
Alpha
0.138
Beta
0.295
Annual Standard Deviation
0.084
Annual Variance
0.007
Information Ratio
-0.568
Tracking Error
0.094
Treynor Ratio
0.74
Total Fees
$133.72
class Algorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2019,12,1)  
        self.SetEndDate(2020,1,1)    
        self.SetCash(100000)           
        self.UniverseSettings.Resolution = Resolution.Minute
        self.AddUniverse(self.CoarseSelectionFunction)
        self.AddEquity('SPY', Resolution.Daily)
        #self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday, DayOfWeek.Friday), self.TimeRules.At(9, 45), self.OpenTrades)# this way don't get all days
        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 15), self.OpenTrades) #this way gets all stock market days, always use this way
        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 20), self.CloseTrades)
        self.__numberOfSymbols = 3
        self.universe = {}

        
    def CoarseSelectionFunction(self, coarse):
        CoarseWithFundamental = [x for x in coarse if x.HasFundamentalData and x.Price > 25]
        sortedByDollarVolume = sorted(CoarseWithFundamental, key=lambda x: x.DollarVolume, reverse=True)
        self.universe = [x.Symbol for x in sortedByDollarVolume[:self.__numberOfSymbols]]
        self.Debug(len(self.universe))
        return self.universe
        
    def OpenTrades(self):
        self.Debug(self.Time)

        self.Debug(len(self.universe))
        for security in self.universe:
                self.Debug(security)
                self.SetHoldings(security, 1 / self.__numberOfSymbols)
    
    def CloseTrades(self):
        self.Log("EveryDay.SPY 20 min before close: Fired at: {0}".format(self.Time))
        self.Liquidate()