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
2.832
Tracking Error
0.177
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
#region imports
from AlgorithmImports import *
#endregion
class ParticleTransdimensionalAutosequencers(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2022, 12, 5)
        self.SetEndDate(2022, 12, 8)
        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.Debug(f"Universe size after volume filter: {len(self.universe)}")
            return 
        
        for symbol in self.volume_by_symbol.keys():
            if symbol in data.Bars:
                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.Debug(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