Reputation: 734
I am currently working in Python and I am trying to do some language processing on finance articles. However, every way I know of for querying information about a stock is via its ticker. So, my question is, do you know of a way to look up stock tickers from a general company name (not just the official name of the company) or some other way to find the ticker of a company given its name? Just as a quick example, if I were to query "Huntington Bank" on Yahoo's API or any other method I know of it will return no results (because the stock is official "Huntington Bancshares"). Possibly I might have to find the parent company of the initial query so that I am querying the correct company.
Upvotes: 0
Views: 1506
Reputation: 1396
Sounds like a cool application. You could probably try creating a tuple for each company and make the values be a ticker and all possible nicknames for the company. Then you could store the tuples in a list and iterate through them to perform a search for the desired ticker.
For example,
google = ('GOOG', 'Google', 'Alphabet', 'Alphabet Inc.')
apple = ('AAPL', 'Apple', 'Apple Inc.')
netflix = ('NFLX', 'Netflix', 'Netflix Inc.')
huntington = ('HBAN', 'Huntington Bancshares', 'Huntington Bancshares Incorporated', 'Huntington Bank', 'Huntington')
companies = [google, apple, netflix, huntington]
def getTicker( str ):
for company in companies:
if str in company:
return x[0] # returns the corresponding ticker
There is probably a better way to dynamically populate your tuples and list of companies (i.e. source the tickers and company nicknames from another website or API), but I think this is a good way to organize them.
Obviously you have to prepare for common searches like 'Bank'. This would return the first company in the list whose tuple of keywords include 'Bank'.
Upvotes: 1