GithubHelp home page GithubHelp logo

vishalbelsare / portfolio_optimization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from druce/portfolio_optimization

0.0 0.0 0.0 2.11 MB

Portfolio optimization with cvxopt

License: MIT License

Jupyter Notebook 100.00%

portfolio_optimization's Introduction

Portfolio optimization with CVXPY

Do a few classic portfolio optimizations using:

Efficient Frontier

Optimal portfolio transition map

Steps

  1. Load asset return data from Damodaran website using pd.read_excel.
  2. Load gold and GDP data from FRED using pandas_datareader module.
  3. Manually fill in some missing data back to 1928.
  4. Compute covariance matrix, long-only efficient frontier, and transition map using historical data (see above). Also compute same outputs for 1972-present (post-gold standard) and 1983-present (post-inflation era).
  5. Compute long-short efficient frontier and transition map, adding a random short asset with 5% annualized negative return and 90% correlation to S&P, and adding a 150% gross exposure constraint.
  6. Compute an efficient frontier using a factor model, using a random set of returns for 1000 stocks and 10 random factor exposures and a random factor covariance matrix.

This follows the cvxpy tutorial but uses real historical data, and visualizes the full efficient frontier and transition map.

Takeaways / blinding glimpses of the obvious:

  • Gold adds some value for most portfolios, except in most disinflationary environment at higher risk tolerances. (Of course TIPS may be a better inflation hedge but we don't have data back very far).
  • If you can find good shorts and use leverage, you can supercharge returns.

Setup

You should be able to run directly in Google Colab.

Or, to run locally

  1. git clone this repo, cd to repo directory

  2. Install Anaconda

  3. Create virtual environment

conda create -n portfolio_opt
conda activate portfolio_opt
pip install -r requirements.txt

or

conda env create -f environment.yaml
conda activate portfolio_opt
  1. jupyter notebook

  2. Run Portfolio optimization.ipynb

portfolio_optimization's People

Contributors

druce avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.