0

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.

Dylan Siegler
  • 742
  • 8
  • 23
  • 1
    Related: http://stackoverflow.com/questions/885456/stock-ticker-symbol-lookup-api – RIanGillis Jul 19 '16 at 20:58
  • I have seen those questions however the services either require you to know the ticker or have to look up a specific substring of the name. I am trying using Google and bs4. – Dylan Siegler Jul 19 '16 at 21:06

1 Answers1

1

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'.

Andrew Kirna
  • 1,346
  • 16
  • 18
  • Thanks for the suggestion on how to organize the data. However, populating this by hand is obviously not feasible. On a slightly different note I have tried using bs4 and requests to Google the name + "stock price." However, when I look for a div with the class of vk_gy vk_sh (that's what it is when I inspect it), nothing comes up. I've checked through the request (and I've tried it with urllib) and it doesn't get the Google page at all. It must get some redirect page. I get the same thing when I try this with Bing. – Dylan Siegler Jul 20 '16 at 12:09