Last active
July 29, 2021 03:29
-
-
Save McKlayne/9d59c42962279ed67a779ef15d05d7da 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
from io import BytesIO | |
import requests | |
import time | |
import pandas as pd | |
def earnings_calendar_api(api_key, horizon, symbol=None): | |
if symbol is not None: | |
url = f'{BASE_URL}function=EARNINGS_CALENDAR&symbol={symbol}&horizon={horizon}&apikey={api_key}' | |
response = requests.get(url) | |
else: | |
url = f"{BASE_URL}function=EARNINGS_CALENDAR&horizon={horizon}&apikey={api_key}" | |
response = requests.get(url) | |
return pd.read_csv(BytesIO(response.content)) | |
API_KEY = "INSERT_YOUR_API_KEY_HERE" | |
horizon=["3month","6month","12month"] | |
earnings_calendar_api(API_KEY,horizon[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment