To make our modeling more realistic, our bars have two times—the start and end times. Other platforms tend to ignore this and have data without time, making modeling a multi-asset portfolio impossible. Markets close at different times, and ignoring this introduces look-ahead bias.
Previously, we represented daily data from midnight-to-midnight. This covered most cases but confused many people who expected to see the price data a day earlier. We've updated the start and end times of the bar to accurately reflect the market open and close times on a specific day—a new level of precision no other platform provides.
For example, in US Equity markets, Christmas Eve typically closes early. This is represented by a Time value of 9.30 am and an EndTime value of 1.00 pm, accurately reflecting the moment the bar was available. If you were trading another asset, such as FX, which might close at 5.00 pm on Christmas Eve, the FX daily bar would arrive at 5.00 pm later that day.
These timezone and market-hour-aware daily bars will soon be the default behavior for the platform. Because it is a significant change, we're rolling this out as an optional feature for the next few weeks before making it the default behavior. To opt-in and test the new timed bars early, please use the following algorithm setting:
# Python
self.settings.daily_precise_end_time = True
# CSharp:
Settings.DailyPreciseEndTime = true;
After July 8th, this behavior will be the default, and to preserve the old timestamps, you will need to set this property to false. We hope this will help make it easier to compare QuantConnect daily data with third-party platforms, as the dates will line up rather than offset one day.
In live trading, the daily bars will arrive at market close (4.00 pm for US Equities) rather than midnight. If your logic relies on the previous midnight behavior, you may want to review it to be safe.
Happy Coding!
Team @ QuantConnect
Chetan Prabhu
This is great! Does this also mean that for backtesting, daily bars will emit at the time of close, or will they still emit at midnight?
Aaron Eller
This is a great update. Is there a way (other than using a custom calendar function) to take advantage of this with bar consolidators for equities? The goal would be that they also fire at the day's closing time rather than at midnight.
Martin Molinero
Hi everyone,
From Lean Engine version 16570 onwards, precise market open and close times are the default for daily data.
If your algorithm uses daily resolution, you may notice the following changes:
- Auxiliary events like Dividends and Splits, which previously arrived at midnight with price data, will no longer include price data in the slice. Ensure price data is available for a symbol by using 'slice.bars.contains_key(symbol)', more information.
- In backtesting, daily data used to be emitted at midnight alongside security changes. Now, the first price data is emitted at the exact close time (e.g., 4 PM for equities). As a result, submitting orders on security changes will fail since assets won't have a price yet. To address this, use the warm up feature or the price seeder during security initialization. We have create an issue so that price seeding is enabled by default.
- Using daily resolution with the consolidate algorithm API will now also respect precise market open and close times by default.
To revert to the legacy daily bars behavior, set 'self.settings.daily_precise_end_time = False' in the initialize method.
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.
Lance je
Thank you.
Amir Goren
This is horrible. I see 100% difference in annual returns using daily data. Have I been relying on completely erroneous backtests?!
How can a change in bar close time create a 100% difference in performance when using daily data?!
What good is using self.settings.daily_precise_end_time = False if it produces great backtest results but doesn't match how live trading works?!
What a mess!
Enjolras Leigh
does this accurate daily end-times implemented for every dataset?
I found that
CBOE VIX doesn't provide daily end time for the data quote
i.e.
This return no timestamp
close datasourceid high low open value
symbol time
VIX.CBOE 2S 2024-08-31 15.00 2001 16.04 14.78 15.67 15.00
2024-09-03 15.55 2001 15.99 15.48 15.87 15.55
2024-09-04 20.72 2001 21.99 15.71 15.76 20.72
and indeed, even if i set the daily_precise_end_time = False, the result is the same.
I am wondering if daily precise end time is not implemented for all dataset. Please help to clarify.
Jared Broad
“Does this accurate daily end-times implemented for every dataset?”
Good question - no this is only applied on data covered in our market hours database (equities, index, futures etc). Custom data like CBOE does not have market hours.
“Precise end-times changes my backtest result”
The most common cause of this would be intraday scheduled events, while using daily data. My guess would be depending on the time of the event it would now be triggered before or after the day. We always recommend using intraday data (hour-minute) for scheduling intraday events as its the best way to ensure accurate backtests.
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.
Mark Diggory
Note, attempting to run the solution in the tutorial
https://www.quantconnect.com/learning/task/158/Preparing-Indicators-with-History
It directs me to this page with an error https://qnt.co/3YHaWHL
The tutorials only returns results if I disable the new features as described here `self.settings.daily_precise_end_time = True`
Mark Diggory
sorry, I meant by setting it “False” above
Jared Broad
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!