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
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
class MyAlgorithm(QCAlgorithm):

    def Initialize(self):
        

        self.SetStartDate(2019,1,1)
        self.SetCash(100000)

        tickers = ["SPY", "TLT", "BND"] # can be more..
        
        self.symbolData = {}
        
        for ticker in tickers:

            self.equity = self.AddEquity(ticker, Resolution.Daily)
            symbol = self.equity.Symbol
            self.symbolData[symbol] = SymbolData(self, symbol)
            self.equity.SetDataNormalizationMode(DataNormalizationMode.Raw)   
            self.equity.SetLeverage(1.0)    
        
        
        # Warm up algorithm for 50 days to populate the indicators prior to the start date
        self.SetWarmUp(50)


    def OnDailyData(self, sender, bar):
        
        self.symbolData[bar.Symbol].window22.Add(bar)
        self.symbolData[bar.Symbol].window11.Add(bar)
        self.symbolData[bar.Symbol].window2.Add(bar)
   
    
    def OnData(self, data):
        
        # Don't run if we're warming up our indicators.
        if self.IsWarmingUp: 
            return
        
        ## code to add here for adding information to rolling window:
        # Something of this sort: 
        # window.Add(data[symbol])
        
        # Also, making sure it is ready:
        # Something like this:
        # if not window.IsReady: continue
        
        
class SymbolData:
    
    def __init__(self, algorithm, symbol):
        
        self.algorithm = algorithm
        self.symbol = symbol
        
        self.window22 = RollingWindow[TradeBar](22)
        self.window11 = RollingWindow[TradeBar](11)
        self.window2 = RollingWindow[TradeBar](2)