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
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
import numpy as np
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Data.Consolidators import *
from datetime import timedelta

### <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(2014,8, 7)  #Set Start Date
        self.SetEndDate(2014,8,12)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash
        # Find more symbols here: http://quantconnect.com/data
        equity = self.AddEquity("SPY", Resolution.Daily)
        self.spy = self.Securities["SPY"].SetDataNormalizationMode(DataNormalizationMode.SplitAdjusted)
        self.spySymbol = equity.Symbol
        
        self.volumeArray = [0 for i in range(5)]
        self.arrayNum = 4
        
        consolidator = TradeBarConsolidator(timedelta(1))
        consolidator.DataConsolidated += self.DailyConsolidator
        self.SubscriptionManager.AddConsolidator(self.spySymbol, consolidator)

    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.

        Arguments:
            data: Slice object keyed by symbol containing the stock data
        '''
    def DailyConsolidator(self, sender, bar):
        
        if self.arrayNum >= 0:
           self.volumeArray[self.arrayNum] = bar.Volume
           self.arrayNum = self.arrayNum - 1
        else:
            self.arrayNum = 4
            
        self.Log("{0} {1}".format(str(bar), bar.Volume))
        self.Log("{0} , {1}, {2}, {3}, {4}".format(self.volumeArray[0],self.volumeArray[1],self.volumeArray[2],self.volumeArray[3],self.volumeArray[4]))