def _handle_history_out_of_bounds(self, bar_count): suggested_start_day = ( self.trading_calendar.all_minutes[self._first_trading_minute_loc + bar_count] + self.trading_calendar.day).date() raise HistoryWindowStartsBeforeData( first_trading_day=self._first_trading_day.date(), bar_count=bar_count, suggested_start_day=suggested_start_day, )
def _get_days_for_window(self, end_date, bar_count): tds = self.trading_calendar.all_sessions end_loc = tds.get_loc(end_date) start_loc = end_loc - bar_count + 1 if start_loc < self._first_trading_day_loc: raise HistoryWindowStartsBeforeData( first_trading_day=self._first_trading_day.date(), bar_count=bar_count, suggested_start_day=tds[self._first_trading_day_loc + bar_count].date(), ) return tds[start_loc:end_loc + 1]
def _handle_minute_history_out_of_bounds(self, bar_count): cal = self.trading_calendar first_trading_minute_loc = (cal.all_minutes.get_loc( self._first_trading_minute) if self._first_trading_minute is not None else None) suggested_start_day = cal.minute_to_session_label( cal.all_minutes[first_trading_minute_loc + bar_count] + cal.day) raise HistoryWindowStartsBeforeData( first_trading_day=self._first_trading_day.date(), bar_count=bar_count, suggested_start_day=suggested_start_day.date(), )