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

    def Initialize(self):
        self.SetStartDate(2020, 11, 1)  # Set Start Date
        self.SetCash(1000000)  # Set Strategy Cash
        
        self.symbols = [ Symbol.Create("BTCUSD", SecurityType.Crypto, Market.Bitfinex) ]
        
        self.AddAlpha(ConsolidatedAlpha())
        self.SetUniverseSelection( ManualUniverseSelectionModel(self.symbols) )
        self.UniverseSettings.Resolution = Resolution.Minute
        
class ConsolidatedAlpha(AlphaModel):
    def __init__(self):
        self.sd = {}
        
    def Update(self, algorithm, data):
        insights = []
        for symbol, sd in self.sd.items():
            # ...
            if not sd.consolidated:
                pass
            sd.consolidated = False
        
        return insights
    
    def OnSecuritiesChanged(self, algorithm, changed):
        for security in changed.AddedSecurities:
            symbol = security.Symbol
            if symbol in self.sd:
                continue
            
            self.sd[symbol] = SymbolData(algorithm, symbol)
            
        for security in changed.RemovedSecurities:
            symbol = security.Symbol
            sd = self.sd.pop(symbol, None)
            if sd:
                algorithm.SubscriptionManager.RemoveConsolidator(symbol, sd.consolidator)
            
            
    
    
class SymbolData:
    def __init__(self, algorithm, symbol):
        self.consolidator = TradeBarConsolidator(timedelta(minutes=60))
        self.consolidator.DataConsolidated += self.OnDataConsolidated
        algorithm.SubscriptionManager.AddConsolidator(symbol, self.consolidator)
        self.sma = SimpleMovingAverage(10)
        algorithm.RegisterIndicator(symbol, self.sma, self.consolidator)
        
        hist = algorithm.History(symbol, 10, Resolution.Daily).loc[symbol]
        if not hist.empty:
            for idx, row in hist.iterrows():
                self.sma.Update(idx, row.close)
                
        self.consolidated = False
        
    def Update(self, time, value):
        self.sma.Update(time, value)
        
    def OnDataConsolidated(self, sender, bar):
        self.consolidated = True