Created
April 19, 2020 09:43
-
-
Save databyjp/e78335ce996e09247f06a30ff3d708b0 to your computer and use it in GitHub Desktop.
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
| # ========== LOAD TIINGO TOKEN ========== | |
| with open('../../tokens/tiingo_token.txt', 'r') as f: | |
| tiingo_token = f.read().strip() | |
| # ========== GET STOCK DATA ========== | |
| def get_stock_data(tkn, sym='amzn', start_date='2020-01-01'): | |
| headers = {'Content-Type': 'application/json'} | |
| requestResponse = requests.get("https://api.tiingo.com/tiingo/daily/" + sym + "/prices?startDate=" + start_date + "&token=" + tkn, headers=headers) | |
| if requestResponse.status_code == 200: | |
| logger.info(f'Success fetching {sym} data from {start_date} to today') | |
| else: | |
| logger.warning(f'Something looks wrong - status code {requestResponse.status_code}') | |
| return requestResponse | |
| amzn_data = get_stock_data(tiingo_token).json() | |
| amzn_df = pd.DataFrame(amzn_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment