Skip to content

Commit 0cb79a6

Browse files
authored
Revise README for installation and stock weights
Updated installation instructions and removed redundant stock weights.
1 parent 12b9eca commit 0cb79a6

File tree

1 file changed

+5
-36
lines changed

1 file changed

+5
-36
lines changed

README.md

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ Head over to the **[documentation on ReadTheDocs](https://pyportfolioopt.readthe
7373

7474
### Using pip
7575

76-
```
76+
```bash
7777
pip install pyportfolioopt
7878
```
7979

8080
### From source
8181

8282
Clone the repository, navigate to the folder, and install using pip:
8383

84-
```
84+
```bash
8585
git clone https://github.com/PyPortfolio/PyPortfolioOpt.git
8686
cd PyPortfolioOpt
8787
pip install .
@@ -139,30 +139,6 @@ JPM: 0.0000
139139
SBUX: 0.0173
140140
```
141141

142-
GOOG: 0.0000
143-
AAPL: 0.1749
144-
FB: 0.0503
145-
BABA: 0.0951
146-
AMZN: 0.0000
147-
GE: 0.0000
148-
AMD: 0.0000
149-
WMT: 0.0000
150-
BAC: 0.0000
151-
GM: 0.0000
152-
T: 0.5235
153-
UAA: 0.0000
154-
SHLD: 0.0000
155-
XOM: 0.1298
156-
RRC: 0.0000
157-
BBY: 0.0000
158-
MA: 0.0000
159-
PFE: 0.0264
160-
JPM: 0.0000
161-
SBUX: 0.0000
162-
***
163-
```
164-
>>
165-
166142
```python
167143
exp_return, volatility, sharpe=ef.portfolio_performance(verbose=True)
168144

@@ -291,8 +267,6 @@ The covariance matrix encodes not just the volatility of an asset, but also how
291267

292268
- Long/short: by default all of the mean-variance optimization methods in PyPortfolioOpt are long-only, but they can be initialised to allow for short positions by changing the weight bounds:
293269

294-
<!--pytest-codeblocks:cont-->
295-
296270
```python
297271
ef = EfficientFrontier(mu, S, weight_bounds=(-1, 1))
298272
```
@@ -302,8 +276,6 @@ ef = EfficientFrontier(mu, S, weight_bounds=(-1, 1))
302276

303277
- Market neutrality: for the `efficient_risk` and `efficient_return` methods, PyPortfolioOpt provides an option to form a market-neutral portfolio (i.e weights sum to zero). This is not possible for the max Sharpe portfolio and the min volatility portfolio because in those cases because they are not invariant with respect to leverage. Market neutrality requires negative weights:
304278

305-
<!--pytest-codeblocks:cont-->
306-
307279
```python
308280
ef = EfficientFrontier(mu, S, weight_bounds=(-1, 1))
309281
for name, value in ef.efficient_return(target_return=0.2, market_neutral=True).items():
@@ -335,21 +307,18 @@ SBUX: 0.0330
335307

336308
- Minimum/maximum position size: it may be the case that you want no security to form more than 10% of your portfolio. This is easy to encode:
337309

338-
<!--pytest-codeblocks:cont-->
339-
340310
```python
341311
ef = EfficientFrontier(mu, S, weight_bounds=(0, 0.1))
342312
```
343313

344314
```result
345315
```
316+
346317
One issue with mean-variance optimization is that it leads to many zero-weights. While these are
347318
"optimal" in-sample, there is a large body of research showing that this characteristic leads
348319
mean-variance portfolios to underperform out-of-sample. To that end, I have introduced an
349320
objective function that can reduce the number of negligible weights for any of the objective functions. Essentially, it adds a penalty (parameterised by `gamma`) on small weights, with a term that looks just like L2 regularisation in machine learning. It may be necessary to try several `gamma` values to achieve the desired number of non-negligible weights. For the test portfolio of 20 securities, `gamma ~ 1` is sufficient
350321

351-
<!--pytest-codeblocks:cont-->
352-
353322
```python
354323
from pypfopt import objective_functions
355324
ef = EfficientFrontier(mu, S)
@@ -389,8 +358,6 @@ posterior estimate. This results in much better estimates of expected returns th
389358
the mean historical return. Check out the [docs](https://pyportfolioopt.readthedocs.io/en/latest/BlackLitterman.html) for a discussion of the theory, as well as advice
390359
on formatting inputs.
391360

392-
<!--pytest-codeblocks:cont-->
393-
394361
```python
395362
from pypfopt import risk_models, BlackLittermanModel
396363

@@ -528,5 +495,7 @@ Special shout-outs to:
528495
- Aditya Bhutra
529496
- Thomas Schmelzer
530497
- Rich Caputo
498+
- Franz Kiraly
499+
531500
- Nicolas Knudde
532501
- Franz Kiraly

0 commit comments

Comments
 (0)