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
from QuantConnect.Data.Market import TradeBar
from datetime import timedelta
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
import decimal as d

class MyAlgorithm(QCAlgorithm):
	def Initialize(self):
		self.SetStartDate(2015, 05, 1)  # Set Start Date
		self.SetEndDate(2015, 07, 19)
		self.SetCash(100000)  # Set Strategy Cash

		self.symbolData = dict()

		for ticker in ["SPY", "FB", "TWTR"]:
			symbol = self.AddEquity(ticker, Resolution.Second).Symbol

			consolidator_daily = TradeBarConsolidator(timedelta(1))
			consolidator_daily.DataConsolidated += self.OnDailyData
			self.SubscriptionManager.AddConsolidator(symbol, consolidator_daily)

			consolidator_minute = TradeBarConsolidator(60)
			consolidator_minute.DataConsolidated += self.OnMinuteData
			self.SubscriptionManager.AddConsolidator(symbol, consolidator_minute)
			
			self.symbolData[symbol] = SymbolData()


		self.Schedule.On(self.DateRules.EveryDay(),
						self.TimeRules.AfterMarketOpen('SPY', 1),
						Action(self.one_minute_after_open_market))

		self.Schedule.On(self.DateRules.EveryDay(),
						self.TimeRules.BeforeMarketClose('SPY', 1),
						Action(self.before_close_market))

	# Add daily bar to daily rolling window
	def OnDailyData(self, sender, bar):
		self.symbolData[bar.Symbol].daily_rw.Add(bar)

	def OnMinuteData(self, sender, bar):
		self.symbolData[bar.Symbol].minute_rw.Add(bar)

	def one_minute_after_open_market(self):
		pass

	def before_close_market(self):
		for k in self.symbolData:
			self.Debug(str(self.symbolData[k].minute_rw[1]))

	def OnData(self, data):
		pass


class SymbolData(object):
	
	def __init__(self):
		self.daily_rw = RollingWindow[TradeBar](2)
		self.minute_rw = RollingWindow[TradeBar](2)
		self.window = RollingWindow[TradeBar](2)