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