This app is heavily relying on pandas-datareader for financial quotes. Over the last couple years multiple APIs were obsoleted by their providers (Google, Morningstar) and as I am no longer a RH client I have no time to keep up with those changes. If you encounter the "Bad Gateway" error or similar it is likely that the current market data source is no longer valid. You are welcome to fork and try different sources of quotes - I will try to fix it, when/if I have time.
Current APIs are TIINGO for stock and STOOQ for market index.
Python client to access and analyze the Robinhood portfolio. Based on unofficial robinhood-api and several python libraries for financial analysis, such as:
- Creates a Flask web server with lightweight page
- Downloads orders and dividends from Robinhood account.
- Downloads market data from google API and market index from open source. Supports incremental download for additional dates to reduce a number of requests to open APIs.
- Calculates the total return of the portfolio, including dividend payouts and risk metric for the portfolio
- Calculates the risk metric for individual securities and correlations between securities
- Calculates Markowitz portfolios
- Backtesting using one of existing libraries. Enabled, but not implemented because none of the existing libraries support dividend payouts and do not provide any significant advantages vs what is implemented already.
- Automatic trading for simple portfolio allocations
It is recommended to use virtualenv:
git clone https://github.com/omdv/robinhood-portfolio && cd robinhood-portfolio
virtualenv robinhood && source robinhood/bin/activate && pip3 install -r requirements.txt
Make sure you have set the TIINGO_API_KEY
environment variable.
python3 app.py
Docker container based on Ubuntu is available. To launch it in a background mode you need to get TIINGO API key and provide it to docker.
docker run -e TIINGO_API_KEY=<API-KEY> -d -p 8080:8080 --name robinhood omdv/robinhood-portfolio:ubuntu
Once up and running connect to http://localhost:8080. If using the older versions of docker you will need to use the ip of the docker-machine.
To specify a different port run:
docker run -e TIINGO_API_KEY=<API-KEY> -d -e PORT=$PORT -p $PORT:$PORT --name robinhood omdv/robinhood-portfolio:ubuntu
You can find the Jupyter notebook using the backtrader library with pyfolio in "notebooks" folder.
This tool uses the unofficial Robinhood API to access your account. This code and the corresponding tools are provided on "as is" basis and the user is responsible for the safety of his/her own account.