Entropy Pooling and CVaR Portfolio Optimization in Python
Explore an elegant combination of Entropy Pooling and CVaR portfolio optimization in Python using the fortitudo.tech package.
Entropy Pooling (EP) is a very powerful method for implementing subjective views and performing stress-tests for fully general investment distributions. It can be seen as a generalization of the Black-Litterman model that does not rely on the oversimplifying assumptions of normally distributed returns and the CAPM.
Conditional Value-at-Risk (CVaR) is a coherent measure of investment tail risk. CVaR is the expected loss below the Value-at-Risk (VaR), which is not a coherent risk measure and is hard to optimize. Compared to variance, which is the traditional portfolio risk measure, CVaR portfolio optimization focuses on minimizing large losses.
If returns happen to be normally or elliptically distributed, and CVaR is computed with demeaned returns, CVaR and variance optimization will coincide. Hence, nothing is lost from using CVaR optimization in the textbook case where returns are normally distributed, while CVaR optimization gives much more meaningful results for more complex market distributions that resemble real-world returns, see Vorobets (2022a)¹ for more details.
EP and CVaR optimization go very well together because the two methods operate on the same representation of the market. Hence, you can implement views and stress-tests using EP and subsequently optimize the CVaR of your portfolio, making the analysis very elegant. Using the fortitudo.tech Python package², you can explore these methods on your own data and portfolios.
Investment framework overview
You can get a high-level overview of the investment framework presented in this article by watching this YouTube video. The video directly compares this framework using general Monte Carlo distributions, Entropy Pooling, and CVaR to the current standard with normal distributions, Black-Litterman, and mean-variance. After watching the YouTube video, it will be clear to you that the old methods are simple subsets of the new ones. You can also get an overview of the fortitudo.tech Python package² functionality through this YouTube video series³.
If you want to build a really deep understanding of this investment framework, there is currently a project to write a Portfolio Construction and Risk Management book⁴ that you can support and receive perks for.
Market representation
For both EP and CVaR portfolio optimization, the market is represented by an S×I matrix of joint scenarios R and an associated S-dimensional prior scenario probability vector p. Each row in R represents a joint realization of the I assets, and each column represents a simulation from the marginal distribution of asset i=1,2,…,I. The scenarios in R can be either historical or simulations from a Monte Carlo simulation engine, see Vorobets (2021)⁵ for more information on the market representation.
Entropy Pooling
Entropy Pooling (EP) implements subjective views and stress-tests by adjusting the scenario probability vector p in a way that imposes the least amount of spurious structure by minimizing the relative entropy, also known as the Kullback–Leibler divergence, between the prior probability vector p and the posterior probability vector q defined below:
The matrices G and A are general functions of the market represented by the matrix of joint scenarios R. While these functions can be nonlinear, the constraints must be linear in the posterior probabilities x. This is necessary to solve the problem quickly and efficiently. For a further introduction to EP and its sequential refinements, see Vorobets (2021)⁵. For the original article and details about view confidences, see Meucci (2008)⁶.
CVaR portfolio optimization
CVaR portfolio optimization problems are usually solved using linear programming with a discretization and linearization of the objective function. The theory and justification is quite complex, so I refer to the original article by Rockafellar and Uryasev (2000)⁷.
The original linear programming CVaR formulation requires an introduction of S auxiliary variables and introduces a trade-off between approximation quality and computation time. This aspect is often used as an excuse for not performing CVaR optimization. However, algorithms that utilize the structure of the linear program and drastically improve computation time exist. You can see an implementation of one such algorithm in the fortitudo.tech Python package².
The fortitudo.tech Python package
The fortitudo.tech Python package² is comparatively low-level because it requires you to specify EP views and portfolio optimization constraints using matrices and vectors. The benefit is that you have full flexibility in relation to working with these methods.
Instead of presenting code snippets in this article, I refer directly to the package’s examples. The portfolio return distributions you see in the featured image come from the derivatives framework example. You can read more about the derivatives framework in Vorobets (2022b)⁸. For a sophisticated use of EP in combination with Bayesian networks for causal and predictive analysis, see Vorobets (2023)⁹.
You can also explore the examples using Binder without installing anything locally. Note, however, that Binder servers are quite slow and are not always available.
[1]: Vorobets, Anton, Variance for Intuition, CVaR for Optimization (February 16, 2022a). Available at SSRN: https://ssrn.com/abstract=4034316
[2]: fortitudo.tech Python package: https://github.com/fortitudo-tech/fortitudo.tech
[3]: fortitudo.tech package playlist: https://www.youtube.com/playlist?list=PLfI2BKNVj_b2rurUsCtc2F8lqtPWqcs2K
[4]: Portfolio Construction and Risk Management book crowdfunding: https://igg.me/at/pcrm-book
[5]: Vorobets, Anton, Sequential Entropy Pooling Heuristics (October 5, 2021). Available at SSRN: https://ssrn.com/abstract=3936392
[6]: Meucci, Attilio, Fully Flexible Views: Theory and Practice, Risk, Vol. 21, №10, pp. 97–102, October 2008, Available at SSRN: https://ssrn.com/abstract=1213325
[7]: R. Tyrrell Rockafellar and S. Uryasev. Optimization of conditional value-at-risk. Journal of Risk, 2(3):21–41, 2000. URL: https://doi.org/10.21314/JOR.2000.038
[8]: Vorobets, Anton, Portfolio Management Framework for Derivative Instruments (September 14, 2022b). Available at SSRN: https://ssrn.com/abstract=4217884
[9]: Vorobets, Anton, Causal and Predictive Market Views and Stress-Testing (May 11, 2023). Available at SSRN: https://ssrn.com/abstract=4444291