Check Market Trading Day
-
Hi,
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!
-
isoweekday
Python 2 Docs - datetime - isoweekday returns1
asMonday
, 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
dict
with the asset in the keyXJO
underself.data
. You would be overwriting one of the automatically created references (in this case toself.datas[0]
), but it is up to the developer to do so if wished.If not, then see
getdatabyname
-
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