Back

OnData cycle through symbols instead of bulk backtest on each

I have two symbols:

def Initialize(self):
self.SetStartDate(2013,1,6)
self.SetEndDate(2013,1,7)

self.symbols = ["AAPL", "GOOG"]

for symbol in self.symbols:
self.AddEquity(symbol, Resolution.Tick)

consolidator = TickConsolidator(100)
consolidator.DataConsolidated += self.OnDataConsolidated

for symbol in self.symbols:
self.SubscriptionManager.AddConsolidator(symbol, consolidator)

And an OnDataConsolidated method:

def OnDataConsolidated(self, sender, bar):
self.Debug("on data: " + bar.Symbol.Value)

The output sequential (all one symbol, then all the other):

on data: AAPL
on data: AAPL
on data: GOOG
on data: GOOG

I need the output to look like this (alternate calls):

on data: AAPL
on data: GOOG
on data: AAPL
on data: GOOG

How can I accomplish this? Is there some sort of configuration of the SubscriptionManager I can set?

Thanks

Update Backtest








hi,

the ondata(consolidator) method gets called when data is ready....

so its there when its ready..... you cant choose the sequence its coming into your algo

so you started learning the quantconnect framework with this already challenging algo which is provided by the quantconnect team:

https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/MultipleSymbolConsolidationAlgorithm.py

and you checked out line 84: symbolData = self.Data[symbol] 

where all the infos of a stock get saved in this symboldata class so you can get it in this line 84 when you need it for further calculcations.................

0

and did you try the bootcamp in the LAb? click on the bootcamp tab when you are already in the algorithm lab.......

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed