Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mberrien-fitzsimons/bfea418039bc052a8252f4314a8440ed to your computer and use it in GitHub Desktop.
Save mberrien-fitzsimons/bfea418039bc052a8252f4314a8440ed to your computer and use it in GitHub Desktop.
# this blog of code allows me to import my secrets file from the conf folder in my
# current jupyter notebook
root_dir = os.path.join(os.getcwd(), '..')
sys.path.append(root_dir)
from conf import secrets
# Download data as CSV from API
function = 'TIME_SERIES_DAILY_ADJUSTED'
symbol = 'MSFT'
datatype = 'csv'
url = f"https://www.alphavantage.co/query?function={function}&symbol={symbol}&\
datatype={datatype}&apikey={ALPHA_VANTAGE_KEY}"
msft_raw = pd.read_csv(url)
# before making any changes save this to raw data folder
msft_raw.to_csv('../data/01_raw/msft_raw.csv', index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment