Skip to content

Instantly share code, notes, and snippets.

@McKlayne
Last active July 29, 2021 03:29
Show Gist options
  • Save McKlayne/9d59c42962279ed67a779ef15d05d7da to your computer and use it in GitHub Desktop.
Save McKlayne/9d59c42962279ed67a779ef15d05d7da to your computer and use it in GitHub Desktop.
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