Hello world code to extract currency info from Alpha Vantage and return it in a CSV format.
- Ensure PYENV and Python are installed (See "PYENV and Python 3.8.10 Install" below)
- Create VENV for project (See "Create VENV for project" below)
- Get Alpha Vantage API key from https://www.alphavantage.co/documentation/
- To run:
python stocks.py <API KEY>
- To test:
python -m unittest tests/stocks_test.py
Additional Install pyenv-virtualenv Info
Example install for ingestion:
pyenv virtualenv 3.8.10 stocks-alpha-3.8.10
Then activate (will need this if you are running tests from command line):
pyenv activate stocks-alpha-3.8.10
pip install -r requirements.txt
- Use pyenv to Install Python 3.8.
# Maybe optional xcode -> xcode-select --install
# Maybe optional homebrew -> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install openssl readline sqlite3 xz zlib
brew install pyenv
Now add this to your shell profile (for me .zszchrc)
# Pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Use this to check
Latest 3.8 release
pyenv install -l - list all versions available.
pyenv install 3.8.10
pyenv shell 3.8.10
source ~/.zshrc
python --version
-> Python 3.8.10