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:
            equity = self.AddEquity(ticker, Resolution.Daily)
            equity.SetDataNormalizationMode(DataNormalizationMode.Raw)   
            equity.SetLeverage(1.0)    
            symbol = equity.Symbol
            self.symbolData[symbol] = SymbolData(self, symbol)
        # Warm up algorithm for 50 days to populate the indicators prior to the start date
        self.SetWarmUp(50)
    
    def OnData(self, data):
        for bar in data.Values:
            self.symbolData[bar.Symbol].Add(bar)
        # Don't run if we're warming up our indicators.
        if self.IsWarmingUp or not all([v.IsReady for k,v in self.symbolData.items()]):
            return
        for symbol, value in  self.symbolData.items():
            self.Debug(f'{value}')


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)
    
    def Add(self, bar):
        self.window2.Add(bar)
        self.window11.Add(bar)
        self.window22.Add(bar)
    
    @property
    def IsReady(self):
        return (self.window2.IsReady 
            and self.window11.IsReady
            and self.window22.IsReady)
    
    def __repr__(self):
        if not self.IsReady:
            return 'Not ready'
        return f'Win02: {self.window2[0]}, Win11: {self.window11[0]}, Win22: {self.window22[0]}'