ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
11.99k stars 2.21k forks source link

Index Components #935

Open BeThaGlo opened 2 years ago

BeThaGlo commented 2 years ago

Hi, would it be possible to add functionality allowing access to an index's component stocks. So for example, a get_components() method for a Ticker for the S&P500 (^GSPC)? Thanks a lot!

ProgrammingDao commented 2 years ago

It seems possible with utils.get_json(ticker_url + '/components', proxy, self.session) and then more specifically by extracting the components with data['components']['components'] at yfinance.utils line 108.