Skip to content

Commit bbe56de

Browse files
committed
revisit the README file
1 parent 9977525 commit bbe56de

1 file changed

Lines changed: 30 additions & 61 deletions

File tree

README.md

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
<a href="https://github.com/pyportfolio/pyportfolioopt/actions">
2020
<img src="https://github.com/pyportfolio/pyportfolioopt/actions/workflows/main.yml/badge.svg?branch=main"
2121
alt="build"></a> &nbsp;
22-
<a href="https://app.codecov.io/gh/pyportfolio/pyportfolioopt">
23-
<img src="https://codecov.io/github/pyportfolio/pyportfolioopt/coverage.svg?branch=main"
24-
alt="codecov"></a> &nbsp;
2522
<a href="https://pepy.tech/project/pyportfolioopt">
2623
<img src="https://pepy.tech/badge/pyportfolioopt"
2724
alt="downloads"></a> &nbsp;
@@ -72,72 +69,33 @@ Head over to the **[documentation on ReadTheDocs](https://pyportfolioopt.readthe
7269
- [Contributing](#contributing)
7370
- [Getting in touch](#getting-in-touch)
7471

75-
## Getting started
72+
## 🚀 Installation
7673

77-
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
78-
while to set up, but it lets you try out the cookbook recipes without having to deal with all of the requirements.
79-
80-
_Note: macOS users will need to install [Command Line Tools](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)._
81-
82-
_Note: if you are on windows, you first need to installl C++. ([download](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16), [install instructions](https://drive.google.com/file/d/0B4GsMXCRaSSIOWpYQkstajlYZ0tPVkNQSElmTWh1dXFaYkJr/view))_
83-
84-
This project is available on PyPI, meaning that you can just:
74+
### Using pip
8575

8676
```bash
87-
pip install PyPortfolioOpt
77+
pip install pyportfolioopt
8878
```
8979

90-
(you may need to follow separate installation instructions for [cvxopt](https://cvxopt.org/install/index.html#) and [cvxpy](https://www.cvxpy.org/install/)).
91-
92-
However, it is best practice to use a dependency manager within a virtual environment.
93-
My current recommendation is to get yourself set up with [poetry](https://github.com/sdispater/poetry) then just run
94-
95-
```bash
96-
poetry add PyPortfolioOpt
97-
```
80+
### From source
9881

99-
Otherwise, clone/download the project and in the project directory run:
82+
Clone the repository and install using the provided Makefile:
10083

10184
```bash
102-
python setup.py install
85+
git clone https://github.com/PyPortfolio/PyPortfolioOpt.git
86+
cd PyPortfolioOpt
87+
make install
10388
```
10489

105-
PyPortfolioOpt supports Docker. Build your first container with `docker build -f docker/Dockerfile . -t pypfopt`. You can use the image to run tests or even launch a Jupyter server.
106-
107-
```bash
108-
# iPython interpreter:
109-
docker run -it pypfopt poetry run ipython
110-
111-
# Jupyter notebook server:
112-
docker run -it -p 8888:8888 pypfopt poetry run jupyter notebook --allow-root --no-browser --ip 0.0.0.0
113-
# click on http://127.0.0.1:8888/?token=xxx
114-
115-
# Pytest
116-
docker run -t pypfopt poetry run pytest
117-
118-
# Bash
119-
docker run -it pypfopt bash
120-
```
121-
122-
For more information, please read [this guide](https://docker-curriculum.com/#introduction).
123-
124-
### For development
125-
126-
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.
127-
128-
```bash
129-
git clone https://github.com/pyportfolio/pyportfolioopt
130-
```
131-
132-
Alternatively, you could try:
133-
134-
```bash
135-
pip install -e git+https://github.com/pyportfolio/pyportfolioopt.git
136-
```
90+
This will install [uv](https://github.com/astral-sh/uv)
91+
(a fast Python package installer) and create a
92+
virtual environment with all dependencies.
13793

13894
## A quick example
13995

140-
Here is an example on real life stock data, demonstrating how easy it is to find the long-only portfolio that maximises the Sharpe ratio (a measure of risk-adjusted returns).
96+
Here is an example on real life stock data,
97+
demonstrating how easy it is to find the long-only portfolio
98+
that maximises the Sharpe ratio (a measure of risk-adjusted returns).
14199

142100
```python
143101
import pandas as pd
@@ -190,7 +148,10 @@ Annual volatility: 22.2%
190148
Sharpe Ratio: 1.28
191149
```
192150

193-
This is interesting but not useful in itself. However, PyPortfolioOpt provides a method which allows you to convert the above continuous weights to an actual allocation that you could buy. Just enter the most recent prices, and the desired portfolio size ($10,000 in this example):
151+
This is interesting but not useful in itself.
152+
However, PyPortfolioOpt provides a method which allows you to
153+
convert the above continuous weights to an actual allocation
154+
that you could buy. Just enter the most recent prices, and the desired portfolio size ($10,000 in this example):
194155

195156
```python
196157
from pypfopt.discrete_allocation import DiscreteAllocation, get_latest_prices
@@ -211,18 +172,26 @@ Discrete allocation: {'GOOG': 1, 'AAPL': 4, 'FB': 12, 'BABA': 4, 'BBY': 2,
211172
Funds remaining: $11.89
212173
```
213174

214-
_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._
175+
_Disclaimer: nothing about this project constitues investment advice,
176+
and the author bears no responsibiltiy for your subsequent investment decisions.
177+
Please refer to the [license](https://github.com/PyPortfolio/PyPortfolioOpt/blob/main/LICENSE.txt) for more information._
215178

216179
## An overview of classical portfolio optimization methods
217180

218-
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**.
181+
Harry Markowitz's 1952 paper is the undeniable classic,
182+
which turned portfolio optimization from an art into a science.
183+
The key insight is that by combining assets with different expected returns and volatilities,
184+
one can decide on a mathematically optimal allocation which minimises
185+
the risk for a target return – the set of all such optimal portfolios is referred to as the **efficient frontier**.
219186

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

224-
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.
225-
The main drawback of mean-variance optimization is that the theoretical treatment requires knowledge of the expected returns and the future risk-characteristics (covariance) of the assets. Obviously, if we knew the expected returns of a stock life would be much easier, but the whole game is that stock returns are notoriously hard to forecast. As a substitute, we can derive estimates of the expected return and covariance based on historical data – though we do lose the theoretical guarantees provided by Markowitz, the closer our estimates are to the real values, the better our portfolio will be.
191+
Although much development has been made in the subject, more than half a century later,
192+
Markowitz's core ideas are still fundamentally important and see daily use in many portfolio management firms.
193+
The main drawback of mean-variance optimization is that the theoretical
194+
treatment requires knowledge of the expected returns and the future risk-characteristics (covariance) of the assets. Obviously, if we knew the expected returns of a stock life would be much easier, but the whole game is that stock returns are notoriously hard to forecast. As a substitute, we can derive estimates of the expected return and covariance based on historical data – though we do lose the theoretical guarantees provided by Markowitz, the closer our estimates are to the real values, the better our portfolio will be.
226195

227196
Thus this project provides four major sets of functionality (though of course they are intimately related)
228197

0 commit comments

Comments
 (0)