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 AlphaFiveTechnologyUniverse(QCAlgorithm):

    def Initialize(self):
        #1. Required: Five years of backtest history
        self.SetStartDate(2014, 1, 15) 
        
        #2. Required: Alpha Streams Models:
        self.SetBrokerageModel(BrokerageName.AlphaStreams)
        
        #3. Required: Significant AUM Capacity
        self.SetCash(1000000)
        
        #4. Select Desired ETF Universe
        # See more: https://www.quantconnect.com/docs/algorithm-reference/universes
        self.UniverseSettings.Resolution = Resolution.Hour
        self.SetUniverseSelection(TechnologyETFUniverse()) 
        self.universe = { }
        
        #5. Set Relevent Benchmark
        self.reference = "XLK"
        self.AddEquity(self.reference, Resolution.Hour)
        self.SetBenchmark("SPY")
        

    def OnData(self, data):
        # Manually update the Indicators
        for symbol in self.universe.keys():
            if data.Bars.ContainsKey(symbol):
                self.universe[symbol].update(data[symbol].EndTime, data[symbol].Close)
    

            
    # Initializing ETF Universe Securities
    def OnSecuritiesChanged(self, changes):
        for s in changes.AddedSecurities:
            if s.Symbol not in self.universe:
                history = self.History(s.Symbol, 30, Resolution.Hour)
                self.universe[s.Symbol] = AssetData(s.Symbol, history)

# Indicators+Universe Demonstration
class AssetData(object):
    def __init__(self, symbol, history):
        self.std = StandardDeviation(30)
        self.macd = MovingAverageConvergenceDivergence(3,6,9,MovingAverageType.Exponential)
        
        
        for bar in history.itertuples():
            self.update(bar.Index[1], bar.close)
        
    def is_ready(self):
        return self.std.IsReady
        
    def update(self, time, price):
        self.std.Update(time, price)
        self.macd.Update(time, price)