yahoofinancials icon indicating copy to clipboard operation
yahoofinancials copied to clipboard

How t oget instrument name from ticker

Open typhoon71 opened this issue 4 years ago • 1 comments

Is it possible to use yahoofinancials to get the name of a financial instrumento from the ticker?

For example, I know the ticker of an ETF is SWDA.MI How can I get iShares Core MSCI World UCITS ETF USD (Acc) (SWDA.MI)?

Is this possible at all? I'd like to d othis for funds, stocks, ... too. The relevant dat is available on the /quote page, so it should be feasible.

Thanks.

typhoon71 avatar Jun 09 '20 14:06 typhoon71

@typhoon71 What you look for is inside the JSON structure returned by get_stock_price_data(). The following sample code prints out the entire JSON structure and you can pick and choose whatever you need.

#!/usr/bin/env python3
import json
from yahoofinancials import YahooFinancials
yf = YahooFinancials( 'QQQ' )
stock_price = yf.get_stock_price_data()
# print out whole JSON structure
print( json.dumps(stock_price, indent=4) )
# print out the long name of the ticker
print( stock_price['QQQ']["longName"] )

giteho avatar Sep 02 '20 19:09 giteho