Consolidators in Research

How could I resample Indicator data in Research (QuantBook)?

In an algorithm it is done via TradeBarConsolidator(...) + algorithm.RegisterIndicator(...), but how do I do that with just the QuantBook?

Update Backtest

At this time there is not a quick way to consolidate data and register an indicator to the data via QuantBook. Consolidators are updated by the LEAN engine and QuantBook is "static" research environment. If this needs to be done, minute data could be transformed into higher resolution using a pandas.Dataframe. And then an indicator would need to manually run through that data. We are aware of this shortcoming and it is on our TODO list to automate the consolidation process.


I see, okay, thanks.

What's the best way of converting TradeBar sequences into pandas DataFrames and back?


Hi Guys,

I was also trying to do this and was about to post the same question so thanks Anton! Here's my first attempt but of course it does not work! I mean it works but gives many NAs.

Any suggestions?



symbol = "SPY"
ticker = qb.AddEquity(symbol)

startDate = datetime(2018, 4, 1)
endDate = datetime(2018, 7, 15)
resolution = Resolution.Minute

df = qb.History(ticker.Symbol, startDate, endDate, resolution)
df.reset_index(level = 0, drop = True, inplace = True)

prices = df["close"]

offset = "1H"
ohlc = prices.resample(offset).ohlc()


From close analysis, the reason as to the NaNs is because of the market hours. The data is populated from 9am-4pm while the market is in session. While .resample is a convenient method to resample time series data, it added a row for every time interval in the period. The rows that are populated by NaN can be dropped via df.dropna(). The notebook below has the code running:


Beautiful! Thanks!


Update Backtest


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.


This discussion is closed