Created
June 9, 2021 22:20
-
-
Save 0x4f53/bd7fc6ed95e6abacafa55084867c44c3 to your computer and use it in GitHub Desktop.
Get company ticker symbol / code from name in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def getTicker (company_name): | |
url = "https://s.yimg.com/aq/autoc" | |
parameters = {'query': company_name, 'lang': 'en-US'} | |
response = requests.get(url = url, params = parameters) | |
data = response.json() | |
company_code = data['ResultSet']['Result'][0]['symbol'] | |
return company_code |
Unfortunately, it returns now 403 Client Error: Forbidden for this url.
Created a new gist which will get this working again. Same code pretty much just using a different Yahoo finance endpoint.
(My username was changed from "bruhbruhroblox" to "leftmove")
Awesome dude! I'll link it up there and credit you.
It does not longer work to me unfortunately @bruhbruhroblox
Hi everyone, it seems that changing my username caused my linked gist to stop working.
@0x4f53 If you can, please link the new gist with the new link.
https://gist.github.com/leftmove/dd9d981c8c37983f61e423a45085e063
I had to change my username as I created it when I was young. Sorry for the incoveinence!
Done, we all do things we find silly as we grow up 🙃
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist doesn't work anymore. Use this one instead (credits: @leftmove).
Most tutorials online are to get a company's name from its ticker symbol (for example, supplying TSLA returns Tesla Corporation). This function does the opposite operation, where supplying 'Tesla Corporation' returns TSLA.
sample:
getTicker('Texas Instruments')
This is done by making a GET request to the Yahoo! Finance API.