Check Market Trading Day
How can I check the current market trading day in the next() loop?
Should i add the market index (say "XJO") to the data feed, then in the next() statement, as I loop over my many datafeeds, have something like this if I were to only consider buys/sells on a MONDAY?:
weekday = self.data['XJO'].datetime.date().isoweekday() if weekday == 1: ...assess stocks...
Thanks again for your help!
isoweekdayPython 2 Docs - datetime - isoweekday returns
Monday, so it would be the value to check.
@backtrader thanks but I am wanting to know if the
self.data['XJO']...is the way to go if I want to use a market index data freed called 'XJO' as the date reference point?
That depends if you have put a
dictwith the asset in the key
self.data. You would be overwriting one of the automatically created references (in this case to
self.datas), but it is up to the developer to do so if wished.
If not, then see
Check out also this thread where a discussion on the same topic on access by name has also started: Community - Multi-asset ranking and rebalancing