You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Please refer to the roadmap for a list of areas that I think PyPortfolioOpt coul
4
4
from. In addition, the following is always welcome::
5
5
6
6
- Improve performance of existing code (but not at the cost of readability) – are there any nice numpy tricks I've missed?
7
-
- Add new optimisation 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).
7
+
- 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).
8
8
- 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.
9
9
10
10
## Guidelines
@@ -37,7 +37,7 @@ If you have questions unrelated to the project, drop me an email – contact det
37
37
38
38
## Bugs/issues
39
39
40
-
If you find any bugs or the portfolio optimisation 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:
40
+
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:
41
41
42
42
- Descriptive title so that other users can see the existing issues
43
43
- Operating system, python version, and python distribution (optional).
new plots. All other plotting functions (scattered in different classes) have been retained,
207
207
but are now deprecated.
208
208
209
-
## An overview of classical portfolio optimisation methods
209
+
## An overview of classical portfolio optimization methods
210
210
211
-
Harry Markowitz's 1952 paper is the undeniable classic, which turned portfolio optimisation 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**.
211
+
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**.
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.
218
-
The main drawback of mean-variance optimisation 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.
218
+
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.
219
219
220
220
Thus this project provides four major sets of functionality (though of course they are intimately related)
221
221
222
222
- Estimates of expected returns
223
223
- Estimates of risk (i.e covariance of asset returns)
224
-
- Objective functions to be optimised
225
-
-Optimisers.
224
+
- Objective functions to be optimized
225
+
-Optimizers.
226
226
227
227
A key design goal of PyPortfolioOpt is **modularity** – the user should be able to swap in their
228
228
components while still making use of the framework that PyPortfolioOpt provides.
@@ -253,7 +253,7 @@ The covariance matrix encodes not just the volatility of an asset, but also how
253
253
- an unbiased estimate of the covariance matrix
254
254
- relatively easy to compute
255
255
- the de facto standard for many years
256
-
- however, it has a high estimation error, which is particularly dangerous in mean-variance optimisation because the optimiser is likely to give excess weight to these erroneous estimates.
256
+
- however, it has a high estimation error, which is particularly dangerous in mean-variance optimization because the optimizer is likely to give excess weight to these erroneous estimates.
257
257
- Semicovariance: a measure of risk that focuses on downside variation.
258
258
- Exponential covariance: an improvement over sample covariance that gives more weight to recent data
259
259
- Covariance shrinkage: techniques that involve combining the sample covariance matrix with a structured estimator, to reduce the effect of erroneous weights. PyPortfolioOpt provides wrappers around the efficient vectorised implementations provided by `sklearn.covariance`.
@@ -280,7 +280,7 @@ The covariance matrix encodes not just the volatility of an asset, but also how
280
280
281
281
### Adding constraints or different objectives
282
282
283
-
- Long/short: by default all of the mean-variance optimisation methods in PyPortfolioOpt are long-only, but they can be initialised to allow for short positions by changing the weight bounds:
283
+
- 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:
284
284
285
285
```python
286
286
ef = EfficientFrontier(mu, S, weight_bounds=(-1, 1))
ef = EfficientFrontier(mu, S, weight_bounds=(0, 0.1))
300
300
```
301
301
302
-
One issue with mean-variance optimisation is that it leads to many zero-weights. While these are
302
+
One issue with mean-variance optimization is that it leads to many zero-weights. While these are
303
303
"optimal" in-sample, there is a large body of research showing that this characteristic leads
304
304
mean-variance portfolios to underperform out-of-sample. To that end, I have introduced an
305
305
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
@@ -328,14 +328,16 @@ ef = EfficientFrontier(rets, S)
328
328
ef.max_sharpe()
329
329
```
330
330
331
-
### Other optimisers
331
+
### Other optimizers
332
332
333
-
The features above mostly pertain to solving efficient frontier optimisation problems via quadratic programming (though this is taken care of by `cvxpy`). However, we offer different optimisers as well:
333
+
The features above mostly pertain to solving mean-variance optimization problems via quadratic programming (though this is taken care of by `cvxpy`). However, we offer different optimizers as well:
334
334
335
+
- Mean-semivariance optimization
336
+
- Mean-CVaR optimization
335
337
- Hierarchical Risk Parity, using clustering algorithms to choose uncorrelated assets
336
338
- Markowitz's critical line algorithm (CLA)
337
339
338
-
Please refer to the [documentation](https://pyportfolioopt.readthedocs.io/en/latest/OtherOptimisers.html) for more.
340
+
Please refer to the [documentation](https://pyportfolioopt.readthedocs.io/en/latest/OtherOptimizers.html) for more.
339
341
340
342
## Advantages over existing implementations
341
343
@@ -350,10 +352,10 @@ Please refer to the [documentation](https://pyportfolioopt.readthedocs.io/en/lat
350
352
351
353
## Project principles and design decisions
352
354
353
-
- It should be easy to swap out individual components of the optimisation process
355
+
- It should be easy to swap out individual components of the optimization process
354
356
with the user's proprietary improvements.
355
357
- Usability is everything: it is better to be self-explanatory than consistent.
356
-
- There is no point in portfolio optimisation unless it can be practically
358
+
- There is no point in portfolio optimization unless it can be practically
357
359
applied to real asset prices.
358
360
- Everything that has been implemented should be tested.
359
361
- Inline documentation is good: dedicated (separate) documentation is better.
0 commit comments