Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
5.113
Tracking Error
0.075
Treynor Ratio
0
Total Fees
$0.00
class ParticleTransdimensionalAutosequencers(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 21)
        self.SetEndDate(2020, 1, 24)
        self.SetCash(100000) 
        self.AddEquity("SPY", Resolution.Minute)
        
        self.AddUniverseSelection(CoarseFundamentalUniverseSelectionModel(self.CoarseSelectionFunction))
        self.UniverseSettings.Resolution = Resolution.Minute

        self.Schedule.On(
            self.DateRules.EveryDay("SPY"),
            self.TimeRules.At(10, 0),
            self.SelectUniverse
        )
        
        self.universe = []
        self.volume_by_symbol = {}
        
        self.logged = False
        
    def OnData(self, data):
        if len(self.volume_by_symbol) == 0:
            
            if not self.logged:
                self.logged = True
                self.Log(f"Universe size after volume filter: {len(self.universe)}")
            return 
        
        for symbol in self.volume_by_symbol.keys():
            if data.ContainsKey(symbol):
                self.volume_by_symbol[symbol] += data[symbol].Volume
    
    def CoarseSelectionFunction(self, coarse):
        self.volume_by_symbol = {c.Symbol: 0 for c in coarse if c.Price > 400}
        
        self.Log(f"Universe size before volume filter: {len(self.volume_by_symbol)}")
        
        return list(self.volume_by_symbol.keys())
        
    def SelectUniverse(self):
        self.universe = []
        
        for symbol, volume in self.volume_by_symbol.items():
            if volume > 50000:
                self.universe.append(symbol)
        
        self.volume_by_symbol.clear()
        self.logged = False