Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
push:
branches:
- master
- main

jobs:
pytest:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
push:
branches:
- master
- main

jobs:
codecov:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: pytest

on:
push:
branches: ["master"]
branches: ["main"]
pull_request:
branches: ["master"]
branches: ["main"]

jobs:
pytest:
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Please refer to the roadmap for a list of areas that I think PyPortfolioOpt coul
from. In addition, the following is always welcome::

- Improve performance of existing code (but not at the cost of readability) – are there any nice numpy tricks I've missed?
- Add new optimization objective functions. For example, if you think that the best performance metric has not been included, write it into a function (or suggest it in [Issues](https://github.com/robertmartin8/PyPortfolioOpt/issues) and I will have a go).
- Add new optimization objective functions. For example, if you think that the best performance metric has not been included, write it into a function (or suggest it in [Issues](https://github.com/pyportfolio/pyportfolioopt/issues) and I will have a go).
- Help me write more tests! If you are someone learning about quant finance and/or unit testing in python, what better way to practice than to write some tests on an open-source project! Feel free to check for edge cases, or test performance on a dataset with more stocks.

## Guidelines
Expand All @@ -31,13 +31,13 @@ I would appreciate if changes are accompanied by relevant documentation – it d

## Questions

If you have any questions related to the project, it is probably easiest to [raise an issue](https://github.com/robertmartin8/PyPortfolioOpt/issues), and I will tag it as a question.
If you have any questions related to the project, it is probably easiest to [raise an issue](https://github.com/pyportfolio/pyportfolioopt/issues), and I will tag it as a question.

If you have questions unrelated to the project, drop me an email – contact details can be found on my [website](https://reasonabledeviations.com/about/)

## Bugs/issues

If you find any bugs or the portfolio optimization is not working as expected, feel free to [raise an issue](https://github.com/robertmartin8/PyPortfolioOpt/issues). I would ask that you provide the following information in the issue:
If you find any bugs or the portfolio optimization is not working as expected, feel free to [raise an issue](https://github.com/pyportfolio/pyportfolioopt/issues). I would ask that you provide the following information in the issue:

- Descriptive title so that other users can see the existing issues
- Operating system, python version, and python distribution (optional).
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img width=60% src="https://github.com/robertmartin8/PyPortfolioOpt/blob/master/media/logo_v1.png?raw=true">
<img width=60% src="https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/media/logo_v1.png?raw=true">
</p>

<!-- buttons -->
Expand All @@ -16,16 +16,16 @@
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg"
alt="MIT license"></a> &nbsp;
<a href="https://github.com/robertmartin8/PyPortfolioOpt/actions">
<img src="https://github.com/robertmartin8/PyPortfolioOpt/actions/workflows/main.yml/badge.svg?branch=master"
<a href="https://github.com/pyportfolio/pyportfolioopt/actions">
<img src="https://github.com/pyportfolio/pyportfolioopt/actions/workflows/main.yml/badge.svg?branch=main"
alt="build"></a> &nbsp;
<a href="https://app.codecov.io/gh/robertmartin8/PyPortfolioOpt">
<img src="https://codecov.io/github/robertmartin8/PyPortfolioOpt/coverage.svg?branch=main"
<a href="https://app.codecov.io/gh/pyportfolio/pyportfolioopt">
<img src="https://codecov.io/github/pyportfolio/pyportfolioopt/coverage.svg?branch=main"
alt="codecov"></a> &nbsp;
<a href="https://pepy.tech/project/pyportfolioopt">
<img src="https://pepy.tech/badge/pyportfolioopt"
alt="downloads"></a> &nbsp;
<a href="https://mybinder.org/v2/gh/robertmartin8/pyportfolioopt/master/?filepath=cookbook">
<a href="https://mybinder.org/v2/gh/pyportfolio/pyportfolioopt/main/?filepath=cookbook">
<img src="https://mybinder.org/badge_logo.svg"
alt="binder"></a> &nbsp;
</p>
Expand All @@ -45,10 +45,10 @@ in a risk-efficient way.

PyPortfolioOpt is now being maintained by [Tuan Tran](https://github.com/88d52bdba0366127fffca9dfa93895).

Head over to the **[documentation on ReadTheDocs](https://pyportfolioopt.readthedocs.io/en/latest/)** to get an in-depth look at the project, or check out the [cookbook](https://github.com/robertmartin8/PyPortfolioOpt/tree/master/cookbook) to see some examples showing the full process from downloading data to building a portfolio.
Head over to the **[documentation on ReadTheDocs](https://pyportfolioopt.readthedocs.io/en/latest/)** to get an in-depth look at the project, or check out the [cookbook](https://github.com/pyportfolio/pyportfolioopt/tree/main/cookbook) to see some examples showing the full process from downloading data to building a portfolio.

<center>
<img src="https://github.com/robertmartin8/PyPortfolioOpt/blob/master/media/conceptual_flowchart_v2.png?raw=true" style="width:70%;"/>
<img src="https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/media/conceptual_flowchart_v2.png?raw=true" style="width:70%;"/>
</center>

## Table of contents
Expand All @@ -74,7 +74,7 @@ Head over to the **[documentation on ReadTheDocs](https://pyportfolioopt.readthe

## Getting started

If you would like to play with PyPortfolioOpt interactively in your browser, you may launch Binder [here](https://mybinder.org/v2/gh/robertmartin8/pyportfolioopt/master). It takes a
If you would like to play with PyPortfolioOpt interactively in your browser, you may launch Binder [here](https://mybinder.org/v2/gh/pyportfolio/pyportfolioopt/main). It takes a
while to set up, but it lets you try out the cookbook recipes without having to deal with all of the requirements.

_Note: macOS users will need to install [Command Line Tools](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)._
Expand Down Expand Up @@ -126,13 +126,13 @@ For more information, please read [this guide](https://docker-curriculum.com/#in
If you would like to make major changes to integrate this with your proprietary system, it probably makes sense to clone this repository and to just use the source code.

```bash
git clone https://github.com/robertmartin8/PyPortfolioOpt
git clone https://github.com/pyportfolio/pyportfolioopt
```

Alternatively, you could try:

```bash
pip install -e git+https://github.com/robertmartin8/PyPortfolioOpt.git
pip install -e git+https://github.com/pyportfolio/pyportfolioopt.git
```

## A quick example
Expand Down Expand Up @@ -211,14 +211,14 @@ Discrete allocation: {'GOOG': 1, 'AAPL': 4, 'FB': 12, 'BABA': 4, 'BBY': 2,
Funds remaining: $11.89
```

_Disclaimer: nothing about this project constitues investment advice, and the author bears no responsibiltiy for your subsequent investment decisions. Please refer to the [license](https://github.com/robertmartin8/PyPortfolioOpt/blob/master/LICENSE.txt) for more information._
_Disclaimer: nothing about this project constitues investment advice, and the author bears no responsibiltiy for your subsequent investment decisions. Please refer to the [license](https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/LICENSE.txt) for more information._

## An overview of classical portfolio optimization methods

Harry Markowitz's 1952 paper is the undeniable classic, which turned portfolio optimization from an art into a science. The key insight is that by combining assets with different expected returns and volatilities, one can decide on a mathematically optimal allocation which minimises the risk for a target return – the set of all such optimal portfolios is referred to as the **efficient frontier**.

<center>
<img src="https://github.com/robertmartin8/PyPortfolioOpt/blob/master/media/efficient_frontier_white.png?raw=true" style="width:60%;"/>
<img src="https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/media/efficient_frontier_white.png?raw=true" style="width:60%;"/>
</center>

Although much development has been made in the subject, more than half a century later, Markowitz's core ideas are still fundamentally important and see daily use in many portfolio management firms.
Expand All @@ -236,7 +236,7 @@ components while still making use of the framework that PyPortfolioOpt provides.

## Features

In this section, we detail some of PyPortfolioOpt's available functionality. More examples are offered in the Jupyter notebooks [here](https://github.com/robertmartin8/PyPortfolioOpt/tree/master/cookbook). Another good resource is the [tests](https://github.com/robertmartin8/PyPortfolioOpt/tree/master/tests).
In this section, we detail some of PyPortfolioOpt's available functionality. More examples are offered in the Jupyter notebooks [here](https://github.com/pyportfolio/pyportfolioopt/tree/main/cookbook). Another good resource is the [tests](https://github.com/pyportfolio/pyportfolioopt/tree/main/tests).

A far more comprehensive version of this can be found on [ReadTheDocs](https://pyportfolioopt.readthedocs.io/en/latest/), as well as possible extensions for more advanced users.

Expand Down Expand Up @@ -272,7 +272,7 @@ The covariance matrix encodes not just the volatility of an asset, but also how
- implemented in `sklearn.covariance`

<p align="center">
<img width=60% src="https://github.com/robertmartin8/PyPortfolioOpt/blob/master/media/corrplot_white.png?raw=true">
<img width=60% src="https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/media/corrplot_white.png?raw=true">
</p>

(This plot was generated using `plotting.plot_covariance`)
Expand Down Expand Up @@ -420,7 +420,7 @@ BibTex::

## Contributing

Contributions are _most welcome_. Have a look at the [Contribution Guide](https://github.com/robertmartin8/PyPortfolioOpt/blob/master/CONTRIBUTING.md) for more.
Contributions are _most welcome_. Have a look at the [Contribution Guide](https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/CONTRIBUTING.md) for more.

I'd like to thank all of the people who have contributed to PyPortfolioOpt since its release in 2018.
Special shout-outs to:
Expand Down
10 changes: 5 additions & 5 deletions cookbook/1-RiskReturnModels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"\n",
"In this section, we compare how well the different risk models predict an out-of-sample covariance matrix, and how well the different returns models predict out-of-sample returns.\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
" \n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/robertmartin8/PyPortfolioOpt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/cookbook/1-RiskReturnModels.ipynb)\n",
" \n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
" \n",
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/pyportfolio/pyportfolioopt/blob/master/cookbook/1-RiskReturnModels.ipynb)\n",
"\n",
"## Risk models"
]
Expand All @@ -37,7 +37,7 @@
"!pip install pandas numpy matplotlib PyPortfolioOpt\n",
"import os\n",
"if not os.path.isdir('data'):\n",
" os.system('git clone https://github.com/robertmartin8/PyPortfolioOpt.git')\n",
" os.system('git clone https://github.com/pyportfolio/pyportfolioopt.git')\n",
" os.chdir('PyPortfolioOpt/cookbook')"
]
},
Expand Down
10 changes: 5 additions & 5 deletions cookbook/2-Mean-Variance-Optimisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"\n",
"To download data, we will use `yfinance`, an excellent library that provides free price data from Yahoo Finance, no API key needed.\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)\n",
" \n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/robertmartin8/PyPortfolioOpt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)\n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/cookbook/2-Mean-Variance-Optimisation.ipynb)\n",
" \n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)\n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)\n",
" \n",
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)"
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/pyportfolio/pyportfolioopt/blob/master/cookbook/2-Mean-Variance-Optimisation.ipynb)"
]
},
{
Expand All @@ -57,7 +57,7 @@
"!pip install pandas numpy matplotlib yfinance PyPortfolioOpt\n",
"import os\n",
"if not os.path.isdir('data'):\n",
" os.system('git clone https://github.com/robertmartin8/PyPortfolioOpt.git')\n",
" os.system('git clone https://github.com/pyportfolio/pyportfolioopt.git')\n",
" os.chdir('PyPortfolioOpt/cookbook')"
]
},
Expand Down
10 changes: 5 additions & 5 deletions cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"\n",
"As discussed in the previous notebook, assets are an exogenous input (i.e you must come up with a list of tickers). We will use `yfinance` to download data for thesee tickers\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)\n",
" \n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/robertmartin8/PyPortfolioOpt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)\n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)\n",
" \n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)\n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)\n",
" \n",
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)"
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/pyportfolio/pyportfolioopt/blob/master/cookbook/3-Advanced-Mean-Variance-Optimisation.ipynb)"
]
},
{
Expand Down Expand Up @@ -87,7 +87,7 @@
"!pip install pandas numpy matplotlib yfinance PyPortfolioOpt\n",
"import os\n",
"if not os.path.isdir('data'):\n",
" os.system('git clone https://github.com/robertmartin8/PyPortfolioOpt.git')\n",
" os.system('git clone https://github.com/pyportfolio/pyportfolioopt.git')\n",
" os.chdir('PyPortfolioOpt/cookbook')"
]
},
Expand Down
10 changes: 5 additions & 5 deletions cookbook/4-Black-Litterman-Allocation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"In addition to price data, constructing a market prior requires market-caps.\n",
"\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)\n",
" \n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/robertmartin8/PyPortfolioOpt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)\n",
"[![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/cookbook/4-Black-Litterman-Allocation.ipynb)\n",
" \n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)\n",
"[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/pyportfolio/pyportfolioopt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)\n",
" \n",
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/robertmartin8/PyPortfolioOpt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)"
"[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/pyportfolio/pyportfolioopt/blob/master/cookbook/4-Black-Litterman-Allocation.ipynb)"
]
},
{
Expand All @@ -48,7 +48,7 @@
"!pip install pandas numpy matplotlib yfinance PyPortfolioOpt\n",
"import os\n",
"if not os.path.isdir('data'):\n",
" os.system('git clone https://github.com/robertmartin8/PyPortfolioOpt.git')\n",
" os.system('git clone https://github.com/pyportfolio/pyportfolioopt.git')\n",
" os.chdir('PyPortfolioOpt/cookbook')"
]
},
Expand Down
Loading