Created
August 5, 2019 00:05
-
-
Save cameronhotchkies/7e7ccf6c599737678abc0cc2d6e81384 to your computer and use it in GitHub Desktop.
Simple python script for alphavantage API
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
#!/usr/bin/env python3 | |
import urllib.request | |
import urllib.parse | |
import json | |
api_key = 'demo' | |
ticker = 'MSFT' | |
url = f'https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={ticker}&apikey={api_key}' | |
f = urllib.request.urlopen(url) | |
res = f.read().decode('UTF-8') | |
global_quote = json.loads(res) | |
gq = global_quote['Global Quote'] | |
price = gq['05. price'] | |
print(f"Current price for {ticker} is {price}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment