forked from mementum/backtrader
-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
PandasMarketCalendar class uses the pandas dataframe to cache the trading dates schedule. Unfortunately in schedule
method a wrong data type is used to search in this cache in case the pandas library v1.0 is used.
def schedule(self, day, tz=None):
'''
Returns the opening and closing times for the given ``day``. If the
method is called, the assumption is that ``day`` is an actual trading
day
The return value is a tuple with 2 components: opentime, closetime
'''
while True:
#### The problem is here #####
i = self.idcache.index.searchsorted(ay.date())
if i == len(self.idcache):
# keep a cache of 1 year to speed up searching
self.idcache = self._calendar.schedule(day, day + self.csize)
continue
st = (x.tz_localize(None) for x in self.idcache.iloc[i, 0:2])
opening, closing = st # Get utc naive times
if day > closing: # passed time is over the sessionend
day += ONEDAY # wrap over to next day
continue
return opening.to_pydatetime(), closing.to_pydatetime()
Unexpected behavior
I don't remember exactly whether or not an exception is raised or the search just return empty result
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working