With the addition of TradingHours (or SessionIterator) in NT8 I'm looking to programmatically calculate whether a futures contract is trading within CashHours. Where "CashHours" is defined as occurring within the Regular Trading Hours (RTH) of the "instrument" the futures contract derives from. (applying the RTH of the derived from "instrument" to the futures contract is not a suitable solution)
For example, where the futures contract is ES, the "instrument" derived from is ^SP500. Thus CashHours would occur within the ^SP500 RTH.
Requirements:
- Return boolean isCashHours
- Chart is in local time (i.e. not the timezone of the ES or ^SP500)
- Function appropriately with Historical and Live data (which may be an issue as found by @NJA_MC in Bars.TradingHours.Sessions[0].Begin/EndTime Documentation
Given the work of @GrumpyTrader AddDataSeries Question, I imagine others have partial solutions to the problem.
Short of an existing solution, I would expect the code would require:
- Add the appropriate DataSeries
- Based on BarsInProgress[1] determine CashHours (possibly referencing IsInSession() noting the performance hit noted in SessionIterator)
Any guidance would be appreciated.
Regards
Shannon
Comment