def history(self, period="1mo", interval="1d",
                start=None, end=None, prepost=False,
                actions=True, auto_adjust=True):
        """
        :Parameters:
            period : str
                Valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
                Either Use period parameter or use start and end
            interval : str
                Valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
                Intraday data cannot extend last 60 days
            start: str
                Download start date string (YYYY-MM-DD) or _datetime.
                Default is 1900-01-01
            end: str
                Download end date string (YYYY-MM-DD) or _datetime.
                Default is now
            prepost : bool
                Include Pre and Post market data in results?
                Default is False
            auto_adjust: bool
                Adjust all OHLC automatically? Default is True
        """

        if period is None or period.lower() == "max":
            if start is None:
                start = -2208988800
            elif isinstance(start, _datetime.datetime):
                start = int(_time.mktime(start.timetuple()))
            else:
                start = int(_time.mktime(
                    _time.strptime(str(start), '%Y-%m-%d')))
            if end is None:
                end = int(_time.time())
            elif isinstance(end, _datetime.datetime):
                end = int(_time.mktime(end.timetuple()))
            else:
                end = int(_time.mktime(_time.strptime(str(end), '%Y-%m-%d')))

            params = {"period1": start, "period2": end}
        else:
            period = period.lower()
            params = {"range": period}

        params["interval"] = interval.lower()
        params["includePrePost"] = prepost
        params["events"] = "div,splits"

        # 1) fix weired bug with Yahoo! - returning 60m for 30m bars
        if params["interval"] == "30m":
            params["interval"] = "15m"

        # Getting data from json
        url = "{}/v8/finance/chart/{}".format(self._base_url, self.ticker)
        data = _requests.get(url=url, params=params).json()

        # Work with errors
        if "timestamp" not in data["chart"]["result"][0]:
            _DFS[self.ticker] = _pd.DataFrame()
            raise ValueError(self.ticker, 'No data found for this date range')

        error = data["chart"]["error"]
        if error:
            _DFS[self.ticker] = _pd.DataFrame()
            raise ValueError(self.ticker, error["description"])

        # parse quotes
        quotes = self._parse_quotes(data["chart"]["result"][0])

        # 2) fix weired bug with Yahoo! - returning 60m for 30m bars
        if interval.lower() == "30m":
            quotes2 = quotes.resample('30T')
            quotes = _pd.DataFrame(index=quotes2.last().index, data={
                'Open': quotes2['Open'].first(),
                'High': quotes2['High'].max(),
                'Low': quotes2['Low'].min(),
                'Close': quotes2['Close'].last(),
                'Adj Close': quotes2['Adj Close'].last(),
                'Volume': quotes2['Volume'].sum()
            })
            try:
                quotes['Dividends'] = quotes2['Dividends'].max()
            except Exception:
                pass
            try:
                quotes['Stock Splits'] = quotes2['Dividends'].max()
            except Exception:
                pass

        if auto_adjust:
            quotes = self._auto_adjust(quotes)

        quotes = _np.round(quotes, data[
            "chart"]["result"][0]["meta"]["priceHint"])
        quotes['Volume'] = quotes['Volume'].fillna(0).astype(_np.int64)

        quotes.dropna(inplace=True)

        # actions
        dividends, splits = self._parse_actions(data["chart"]["result"][0])

        # combine
        df = _pd.concat([quotes, dividends, splits], axis=1, sort=True)
        df["Dividends"].fillna(0, inplace=True)
        df["Stock Splits"].fillna(0, inplace=True)

        # index eod/intraday
        df.index = df.index.tz_localize("UTC").tz_convert(
            data["chart"]["result"][0]["meta"]["exchangeTimezoneName"])

        if params["interval"][-1] == "m":
            df.index.name = "Datetime"
        else:
            df.index = _pd.to_datetime(df.index.date)
            df.index.name = "Date"

        self._history = df.copy()

        if not actions:
            df.drop(columns=["Dividends", "Stock Splits"], inplace=True)

        return df
def history ( self , period = "1mo" , interval = "1d" , start = None , end = None , prepost = False , actions = True , auto_adjust = True ) : if period is None or period . lower ( ) == "max" : if start is None : start = - 2208988800 elif isinstance ( start , _datetime . datetime ) : start = int ( _time . mktime ( start . timetuple ( ) ) ) else : start = int ( _time . mktime ( _time . strptime ( str ( start ) , '%Y-%m-%d' ) ) ) if end is None : end = int ( _time . time ( ) ) elif isinstance ( end , _datetime . datetime ) : end = int ( _time . mktime ( end . timetuple ( ) ) ) else : end = int ( _time . mktime ( _time . strptime ( str ( end ) , '%Y-%m-%d' ) ) ) params = { "period1" : start , "period2" : end } else : period = period . lower ( ) params = { "range" : period } params [ "interval" ] = interval . lower ( ) params [ "includePrePost" ] = prepost params [ "events" ] = "div,splits" if params [ "interval" ] == "30m" : params [ "interval" ] = "15m" url = "{}/v8/finance/chart/{}" . format ( self . _base_url , self . ticker ) data = _requests . get ( url = url , params = params ) . json ( ) if "timestamp" not in data [ "chart" ] [ "result" ] [ 0 ] : _DFS [ self . ticker ] = _pd . DataFrame ( ) raise ValueError ( self . ticker , 'No data found for this date range' ) error = data [ "chart" ] [ "error" ] if error : _DFS [ self . ticker ] = _pd . DataFrame ( ) raise ValueError ( self . ticker , error [ "description" ] ) quotes = self . _parse_quotes ( data [ "chart" ] [ "result" ] [ 0 ] ) if interval . lower ( ) == "30m" : quotes2 = quotes . resample ( '30T' ) quotes = _pd . DataFrame ( index = quotes2 . last ( ) . index , data = { 'Open' : quotes2 [ 'Open' ] . first ( ) , 'High' : quotes2 [ 'High' ] . max ( ) , 'Low' : quotes2 [ 'Low' ] . min ( ) , 'Close' : quotes2 [ 'Close' ] . last ( ) , 'Adj Close' : quotes2 [ 'Adj Close' ] . last ( ) , 'Volume' : quotes2 [ 'Volume' ] . sum ( ) } ) try : quotes [ 'Dividends' ] = quotes2 [ 'Dividends' ] . max ( ) except Exception : pass try : quotes [ 'Stock Splits' ] = quotes2 [ 'Dividends' ] . max ( ) except Exception : pass if auto_adjust : quotes = self . _auto_adjust ( quotes ) quotes = _np . round ( quotes , data [ "chart" ] [ "result" ] [ 0 ] [ "meta" ] [ "priceHint" ] ) quotes [ 'Volume' ] = quotes [ 'Volume' ] . fillna ( 0 ) . astype ( _np . int64 ) quotes . dropna ( inplace = True ) dividends , splits = self . _parse_actions ( data [ "chart" ] [ "result" ] [ 0 ] ) df = _pd . concat ( [ quotes , dividends , splits ] , axis = 1 , sort = True ) df [ "Dividends" ] . fillna ( 0 , inplace = True ) df [ "Stock Splits" ] . fillna ( 0 , inplace = True ) df . index = df . index . tz_localize ( "UTC" ) . tz_convert ( data [ "chart" ] [ "result" ] [ 0 ] [ "meta" ] [ "exchangeTimezoneName" ] ) if params [ "interval" ] [ - 1 ] == "m" : df . index . name = "Datetime" else : df . index = _pd . to_datetime ( df . index . date ) df . index . name = "Date" self . _history = df . copy ( ) if not actions : df . drop ( columns = [ "Dividends" , "Stock Splits" ] , inplace = True ) return df
:Parameters:
            period : str
                Valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
                Either Use period parameter or use start and end
            interval : str
                Valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
                Intraday data cannot extend last 60 days
            start: str
                Download start date string (YYYY-MM-DD) or _datetime.
                Default is 1900-01-01
            end: str
                Download end date string (YYYY-MM-DD) or _datetime.
                Default is now
            prepost : bool
                Include Pre and Post market data in results?
                Default is False
            auto_adjust: bool
                Adjust all OHLC automatically? Default is True