Back

Various questions on Consolidators

Hi there,

I have used consolidators extensively in my systems but up to this point I have given no particular thought to their inner workings. Had a conversation with a friend, however, which sparked the following questions.

In this example, I have a QuoteBarConsolidator set-up as follows:

var MinutesConsolidator = new QuoteBarConsolidator( TimeSpan.FromMinutes( 5 ) );
  1. How does a consolidator work - does it take, say, the last 5 minute-bars received and puts them together into one 5-minute bar? Or does it take any number of bars received in the last 5 minutes and puts them together into one 5-minute bar (thereby potentially having a 5-minute bar that was missing a number of individual minute-bars)?
     
  2. I suspect the answer to #1 is that it takes any number of bars received in the last 5 minutes. If I'm right, then does the consolidator assume 5 minutes starting from 00:00 going forward? If so, can I change this assumption so that I e.g. have bars covering 00:03 - 00:08 - 00:13, etc.?
     
  3. What is the difference between using RegisterIndicator to register an indicator to a particular consolidator versus binding the indicator's Update function to the consolidator's DataConsolidated event?
 Thanks in advance for any help!
Update Backtest







Hi Douglas,

1) QuoteBarConsolidator( TimeSpan.FromMinutes( 5 ) ) will take any number of bars received in the last 5 minutes(in this example it takes all minute bars in the last 5 minutes).

2)Yes, the consolidator will starts from 00:00 by default. It's not available to customize the start time of the consolidator. However, you can also use the number of bars to construct the consolidator, for example, QuoteBarConsolidator(5) will consolidate the last 5 bars if using the minute resolution in the algorithm. For equity, the market is closed from 00:00 to 9:29. The consolidated bar will start at 9:30.

3) RegisterIndicator() and manually updating the indicator in the event handler method perform the same function. While the update() method allows more flexibility. For example, you can choose different values to update the indicator or a combination of different Open, Close, High and Low price.  RegisterIndicator() will use the close price by default. 

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.


Thank you for elaborating on this, much appreciated.

Regarding #2, I think this would be a useful setting to be able to edit. Let's say I have an alpha that performs nicely on 00:00, 00:05, 00:10, etc. Testing it on 00:03, 00:08 etc. would be useful to do, to ensure the alpha I'm capturing is not some artifact of my broker's or a market anomaly (unless of course that's what I'm trying to capture).

In particular, given that scheduled news always comes out at 00, 15, 30 or 45 minutes past the hour, it would be very useful to test an Alpha's sensitivity to such things by adjusting the start of a minute bar consolidation.

Just my 2¢! :)

0

HI Douglas, we can totally see the advantages of your suggestion in order to test the algorithm robustness.
It is not a high-priority feature for the QuantConnect team right now, but an open-source community member can be interested in implementing it.
Once again, thank you for the suggestion!

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.


Hi,

I'm running into issues regarding question #3 in my original post. In my system, I have certain indicators that are quite computationally intensive, so I definitely only want to be running them when the consolidator has consolidated a new bar.

Currently, I have used Algorithm.RegisterIndicator() to register the indicators to the consolidator.

In my algorithm, to warm the indicators up, I'm doing a History.PushThrough() to the consolidator. This, by default, Update()'s each indicator on every minute of data. In my case, I may have set my consolidator to 100-500 minutes, which obviously means the PushThrough takes 100-500x longer time than needed.

So I tried to use DataConsolidated() on my consolidator instead of RegisterIndicator():

MinutesConsolidator.DataConsolidated += ( sender, data ) => RealisedVolatility.Update( data );

However, then I get the error that the indicator expects data in the form of IndicatorDataPoint instead of QuoteBar.

 

Is there a way I can modify this so that DataConsolidated() sends the correct piece of data to my indicator? Or is there otherwise a way I can work around this so that my indicator only runs on consolidated data?

I think in general, if you've built an indicator and registered it to a particular consolidator, you expect it to only be run when that consolidator has a new bar - not on every tick.

0

I should add that this behaviour of pushing every single point of data (instead of just consolidated bars) seems to only happen with PushThrough() and not when you actually run the model. At least that's my observation given how much faster my algorithm is at runtime compared to in its warm-up phase...

0

Hi Douglas , 
DataConsolidated is meant to send the data type it is consolidating. If we are consolidating QuoteBar, it will send a QuoteBar. You can use QuoteBar properties to create an IndicatorDataPoint:

MinutesConsolidator.DataConsolidated += (sender, data) =>
{
RealisedVolatility.Update(new IndicatorDataPoint(data.EndTime, data.Value));
}
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.


Perfect! Thank you so much. Didn't know it was that easy. This fixed my problem and the warm-up now runs very fast.

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