Back

12 hour bars at 00:00 and 12:00

I have started off attempting this using a

QuoteBarConsolidator(timedelta(hours=12))

but I notice that the bars can come at any time like 12:00, 13:00, 17:00, 18:00...

Is there a way to have the bars only come at 00:00 and 12:00, or do I have to roll my own consolidation using a scheduler?

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.


From my experience, a consolidator will start at a time given by the exchange timezone of the security in question. Currently there is no way to specify a custom starting time for a consolidator but I have raised this issue on GitHub, feel free to subscribe to that thread or otherwise suggest workarounds.

I'm currently building a consolidator which will be able to consolidate bars at any chosen time but it's not finished yet nor ready to release publicly.

1

A happy coincidence. The linked thread looks great, apart from the fact that as you say, it's using TimeSpan to offset from the exchange timezone, whereas we probably want to be able to specify a schedule start in any arbitrary timezone.

You could use a DateTimeOffset and just ignore the date part. Or you could look at using NodaTime, which has both LocalTime and OffsetTime classes.

Do you have a GitHub fork that you are working on yet?

0

Indeed offsetting from exchange timezone is not ideal. The consolidator I'm working on will take a) timespan from midnight in timezone X, b) timezone X and c) exchange timezone as inputs where X is anything you want it to be. It will use NodaTime (as you rightly suggest) as this is probably the most robust way to get around edge cases like daylight saving transitions.

I'll let you know as soon as I have a working prototype ready. What's easiest do you think - a repo with only the consolidator files or a full fork of Lean including the new consolidator?

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