Back

Why the market hours for futures are closed at 12am on every weekday?

I am testing on the crude oil WTI futures and found that the market hours is closed at 12am on every weekday (It shouldn't be, right?). But just after 12am (say, 1 second later), the market hours is still open. Why is that? The following code illustrate what I am talking about:

public override void Initialize()
{
SetStartDate(2020,8,3);
SetEndDate(2020,8,3);

var FT = AddFuture(Futures.Energies.CrudeOilWTI, Resolution.Hour);

// Find the next close time after 2020-08-03 11pm
var time = new DateTime(2020, 8, 3, 23, 0, 0);
var nextClose = FT.Exchange.Hours.GetNextMarketClose(time, true);
Log($"Next close: {nextClose}");

// Add 1 second to the next close time and check if the exchange is open at that time.
time = nextClose.AddSeconds(1);
var stillOpen = FT.Exchange.Hours.IsOpen(time, true);
Log($"Still open: {stillOpen}");
}

 

After running this code, a sample log output look like this:

2020-08-03 00:00:00 :    Next close: 8/4/2020 12:00:00 AM
2020-08-03 00:00:00 :    Still open: True

 

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.


Hi Wilson,

There is currently an open GitHub Issue to have this resolved. Track our progress here.

Best,
Derek Melchin

1

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.


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