Skip to content

Commit 091df3f

Browse files
committed
Fix quick example in README
1 parent 351e13f commit 091df3f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ ef.portfolio_performance(verbose=True)
136136
This outputs the following weights:
137137

138138
```txt
139-
{'GOOG': 0.01269,
140-
'AAPL': 0.09202,
141-
'FB': 0.19856,
142-
'BABA': 0.09642,
143-
'AMZN': 0.07158,
139+
{'GOOG': 0.03835,
140+
'AAPL': 0.0689,
141+
'FB': 0.20603,
142+
'BABA': 0.07315,
143+
'AMZN': 0.04033,
144144
'GE': 0.0,
145145
'AMD': 0.0,
146146
'WMT': 0.0,
@@ -151,15 +151,15 @@ This outputs the following weights:
151151
'SHLD': 0.0,
152152
'XOM': 0.0,
153153
'RRC': 0.0,
154-
'BBY': 0.06129,
155-
'MA': 0.24562,
156-
'PFE': 0.18413,
154+
'BBY': 0.01324,
155+
'MA': 0.35349,
156+
'PFE': 0.1957,
157157
'JPM': 0.0,
158-
'SBUX': 0.03769}
158+
'SBUX': 0.01082}
159159
160-
Expected annual return: 33.0%
161-
Annual volatility: 21.7%
162-
Sharpe Ratio: 1.43
160+
Expected annual return: 30.5%
161+
Annual volatility: 22.2%
162+
Sharpe Ratio: 1.28
163163
```
164164

165165
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):
@@ -177,10 +177,10 @@ print("Funds remaining: ${:.2f}".format(leftover))
177177
```
178178

179179
```txt
180-
11 out of 20 tickers were removed
181-
Discrete allocation: {'GOOG': 0, 'AAPL': 5, 'FB': 11, 'BABA': 5, 'AMZN': 1,
182-
'BBY': 7, 'MA': 14, 'PFE': 50, 'SBUX': 5}
183-
Funds remaining: $8.42
180+
12 out of 20 tickers were removed
181+
Discrete allocation: {'GOOG': 1, 'AAPL': 4, 'FB': 12, 'BABA': 4, 'BBY': 2,
182+
'MA': 20, 'PFE': 54, 'SBUX': 1}
183+
Funds remaining: $11.89
184184
```
185185

186186
*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.*

0 commit comments

Comments
 (0)