Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
157.118%
Drawdown
0%
Expectancy
0
Net Profit
1.040%
Sharpe Ratio
118.972
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.974
Beta
0.179
Annual Standard Deviation
0.012
Annual Variance
0
Information Ratio
-25.655
Tracking Error
0.036
Treynor Ratio
7.755
Total Fees
$1.12
Estimated Strategy Capacity
$760000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
class CreativeFluorescentPinkGalago(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 10, 18)  # Set Start Date
        self.SetEndDate(2021, 10, 21)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.symbol = self.AddEquity("SPY", Resolution.Daily)
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
        self.sample_dictionary = {}
        
    def CoarseSelectionFunction(self, coarse):
        selected = [x for x in coarse if (x.HasFundamentalData) and (float(x.Price) > 5)]
        # rank the stocks by dollar volume 
        filtered = sorted(selected, key=lambda x: x.DollarVolume, reverse=True) 
        self.filtered_coarse = [ x.Symbol for x in filtered[:5]]
      
        return self.filtered_coarse
            


    def FineSelectionFunction(self, fine):
        filtered_fine = [x for x in fine if x.EarningReports.BasicEPS.TwelveMonths > 0
                                                and x.ValuationRatios.PERatio > 0]
        # filter 5 stocks with the top market cap
        top = sorted(filtered_fine, key = lambda x: x.EarningReports.BasicAverageShares.ThreeMonths * (x.EarningReports.BasicEPS.TwelveMonths*x.ValuationRatios.PERatio), reverse=True)[:5]
        self.filtered_fine = [i.Symbol for i in top]
        
        return self.filtered_fine

    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
            Arguments:
                data: Slice object keyed by symbol containing the stock data
        '''
        if data.ContainsKey("SPY"):
            
            dict_open_price = self.Securities["SPY"].Open
            Key = self.Time
            self.sample_dictionary[Key] = dict_open_price
            
            for item1 in self.filtered_fine:
                self.Log(f" Fine items: {item1} - {self.Time}")
                
            for item2 in self.sample_dictionary.items():
                self.Log(f" sample_dictionary items: {item2} - {self.Time}")


        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", 1)