Overall Statistics
import numpy as np
from datetime import timedelta, datetime

### <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(2010, 1, 1)  #Set Start Date
        self.SetEndDate(2018,4,1)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash
        # Find more symbols here: http://quantconnect.com/data
        self.symbol = 'GOOGL'
        self.AddEquity(self.symbol, Resolution.Daily)
        
        self.ha = self.HeikinAshi(self.symbol, Resolution.Daily)
        
        self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.AfterMarketOpen(self.symbol, -1), Action(self.BeforeMarketOpen))
        
    def BeforeMarketOpen(self):
        if not self.ha.IsReady: return
    
        position = self.Portfolio[self.symbol].Quantity
        
        if self.ha.CurrentBar.Close > self.ha.CurrentBar.Open:
            self.SetHoldings(self.symbol, 1)
            
        if position >= 0 and self.ha.CurrentBar.Close < self.ha.CurrentBar.Open:
            self.Liquidate(self.symbol)

    def OnData(self, data):
        pass