This tool should be viewed as a statistical model of the stock market rather than investment advice. Use the Portfolio Allocation Optimizer completely at your own risk. None of the creators or hosts of this software assume any responsibility for financial loss or other damages resulting from its use.
This portfolio optimizer is an Angular 2.0 web application that takes a list of stocks in your portfolio (or a hypothetical portfolio) and returns the optimal allocations for each stock. A backend Python SimpleHTTP server runs the data analysis and serves it up to the frontend Angular application.
We choose to optimize the portfolio's Sharpe ratio. Sharpe ratio is a metric for risk-adjusted returns, so it penalizes portfolios that contain stocks with high volatility. Other metrics could be used and may be added in the future.
We use Yahoo Finance data from Quandl. Admittedly, there are better data sources, but Quandl is a great compromise for its ease of use, price (free), and accuracy.
git clone https://github.com/mwytock0812/portfolio_optimizer.git
.cd
into the application root, ./portfolio_optimizer/
conda env create -f ./backend/environment.yml
to install the Python dependencies for the backend. This will create a conda
environment called stocks
.stocks
environment using source activate stocks
on Linux/OS X or activate stocks
on Windows. You can deactivate the conda environment using source deactivate
on Linux/OS X or deactivate
on Windows.stocks
environment activated, run python app.py
from ./portfolio_optimizer/backend
.python app.py --port=5678
../portfolio_optiizer
.npm install -g angular-cli
.npm install
to install node dependencies.ng server
to begin serving the application on http://localhost:4200.cd
into ./portfolio_optimizer/backend
, activate the conda environment, and finally run python app.py
. See Setup The Backend Data Service for more details on these steps.cd
into ./portfolio_optimizer/backend
, and activate the conda environment.python -m tornado.testing test.optimizer_test
to test the optimizer module.python -m tornado.testing test.app_test
to test the backend app itself.