Created
August 4, 2020 15:45
-
-
Save vvksh/2f6f8861855e934b7f77ec97bb05ea07 to your computer and use it in GitHub Desktop.
Yahoo finance get last 20 mins of stock data
This file contains hidden or 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 | |
import time | |
def getUrl(symbol): | |
now = int(time.time()) | |
return "https://query1.finance.yahoo.com/v8/finance/chart/{}?symbol={}&period1={}&period2={}&interval=1m&includePrePost=true&lang=en-US®ion=US&corsDomain=finance.yahoo.com".format(symbol, symbol, now-20*60, now) | |
def main(): | |
print(getUrl("UBER")) | |
r = requests.get(getUrl("UBER")) | |
response = r.json() | |
print(response['chart']['result'][0]['indicators']['quote'][0]['close']) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment