July 2019
Beginner to intermediate
740 pages
16h 52m
English
To collect data from a stock market index, we can use the get_index_data() method of the StockReader class. This method uses the pandas_datareader package to grab the data from Yahoo! Finance:
@label_sanitizerdef get_index_data(self, index='SP500'): """ Get historical OHLC data from Yahoo! Finance for the chosen index for given date range. Parameter: - index: String representing the index you want data for, supported indices include: - 'SP500' for S&P 500, - 'DOW' for Dow Jones Industrial Average, - 'NASDAQ' for NASDAQ Composite Index Check the `available_tickers` property for more. Returns: A pandas dataframe with the index data. """ if index not in self.available_tickers: raise ValueError( 'Index ...
Read now
Unlock full access