Overall Statistics
import numpy as np

### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class BasicTemplateAlgorithm(QCAlgorithm):
    '''Basic template algorithm simply initializes the date range and cash'''

    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

        self.SetStartDate(2018,6,1)  #Set Start Date
        self.SetEndDate(2018,6,2)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash
        

        self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
        self.AddCrypto("BTCUSD", Resolution.Minute)
        
        self.period = 20
        
        self.SetWarmUp(2000)
        
        # ...other initialization...
        consolidator = TradeBarConsolidator(TimeSpan.FromMinutes(15))
        consolidator.DataConsolidated += self.OnDataConsolidated
        self.SubscriptionManager.AddConsolidator("BTCUSD", consolidator)
        
        self._atr = AverageTrueRange("BTCUSD", self.period)
        self.RegisterIndicator("BTCUSD", self._atr, consolidator)
        
        self.PlotIndicator("ATR", self._atr)
        

    def OnDataConsolidated(self, sender, bar):
        self.Debug(str(self.Time) + " > New Bar!")
        self.Debug(str(bar.High))
        self.Debug(str(bar.Low))
        self.Debug(str(bar.Open))
        self.Debug(str(bar.Close))

        if not self.Portfolio.Invested:
            self.SetHoldings("BTCUSD", 1)
            
    def OnData(self, data):
        pass
        #if self._atr.IsReady:
            #self.Plot("Indicators", self._atr);