def _get_predict_end(self, end):
        """
        See _get_predict_start for more information. Subclasses do not
        need to define anything for this.
        """

        out_of_sample = 0 # will be overwritten if needed
        if end is None: # use data for ARIMA - endog changes
            end = len(self.data.endog) - 1

        dates = self.data.dates
        freq = self.data.freq

        if isinstance(end, str) or (dates is not None
                                    and isinstance(end, type(dates[0]))):
            if dates is None:
                raise ValueError("Got a string or date for `end` and `dates` is None")

            if isinstance(end, str):
                dtend = self._str_to_date(end)
            else:
                dtend = end  # end could be a pandas TimeStamp not a datetime

            self.data.predict_end = dtend
            try:
                end = self._get_dates_loc(dates, dtend)
            except __HOLE__ as err: # end is greater than dates[-1]...probably
                if dtend > self.data.dates[-1]:
                    end = len(self.data.endog) - 1
                    freq = self.data.freq
                    out_of_sample = datetools._idx_from_dates(dates[-1], dtend,
                                            freq)
                else:
                    if freq is None:
                        raise ValueError("There is no frequency for these "
                                         "dates and date %s is not in dates "
                                         "index. Try giving a date that is in "
                                         "the dates index or use an integer."
                                         % dtend)
                    else: #pragma: no cover
                        raise err # should never get here
            self._make_predict_dates() # attaches self.data.predict_dates

        elif isinstance(end, int) and dates is not None:
            try:
                self.data.predict_end = dates[end]
            except IndexError as err:
                nobs = len(self.data.endog) - 1 # as an index
                out_of_sample = end - nobs
                end = nobs
                if freq is not None:
                    self.data.predict_end = datetools._date_from_idx(dates[-1],
                            out_of_sample, freq)
                elif out_of_sample <= 0: # have no frequency but are in sample
                    #TODO: what error to catch here to make sure dates is
                    #on the index?
                    try:
                        self.data.predict_end = self._get_dates_loc(dates,
                                                end)
                    except KeyError:
                        raise
                else:
                    self.data.predict_end = end + out_of_sample
                    self.data.predict_start = self._get_dates_loc(dates,
                                                self.data.predict_start)

            self._make_predict_dates()

        elif isinstance(end, int):
            nobs = len(self.data.endog) - 1 # is an index
            if end > nobs:
                out_of_sample = end - nobs
                end = nobs

        elif freq is None: # should have a date with freq = None
            raise ValueError("When freq is None, you must give an integer "
                             "index for end.")

        else:
            raise ValueError("no rule for interpreting end")

        return end, out_of_sample
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/base/tsa_model.py/TimeSeriesModel._get_predict_end