Portfolio Optimization and Quantitative Strategic Asset Allocation in Python
Project description
Riskfolio-Lib
Quantitative Strategic Asset Allocation, Easy for Everyone.
Description
Riskfolio-Lib is a library for making quantitative strategic asset allocation or portfolio optimization in Python made in Peru 🇵🇪. Its objective is to help students, academics and practitioners to build investment portfolios based on mathematically complex models with low effort. It is built on top of cvxpy and closely integrated with pandas data structures.
Some of key functionalities that Riskfolio-Lib offers:
-
Mean Risk and Logarithmic Mean Risk (Kelly Criterion) Portfolio Optimization with 4 objective functions:
- Minimum Risk.
- Maximum Return.
- Maximum Utility Function.
- Maximum Risk Adjusted Return Ratio.
-
Mean Risk and Logarithmic Mean Risk (Kelly Criterion) Portfolio Optimization with 18 convex risk measures:
Dispersion Risk Measures:
- Standard Deviation.
- Mean Absolute Deviation (MAD).
- Gini Mean Difference (GMD).
- Range.
- Conditional Value at Risk Range.
- Tail Gini Range.
Downside Risk Measures:
- Semi Standard Deviation.
- First Lower Partial Moment (Omega Ratio).
- Second Lower Partial Moment (Sortino Ratio).
- Conditional Value at Risk (CVaR).
- Tail Gini.
- Entropic Value at Risk (EVaR).
- Worst Case Realization (Minimax).
Drawdown Risk Measures:
- Maximum Drawdown (Calmar Ratio) for uncompounded cumulative returns.
- Average Drawdown for uncompounded cumulative returns.
- Conditional Drawdown at Risk (CDaR) for uncompounded cumulative returns.
- Entropic Drawdown at Risk (EDaR) for uncompounded cumulative returns.
- Ulcer Index for uncompounded cumulative returns.
-
Risk Parity Portfolio Optimization with 14 convex risk measures:
Dispersion Risk Measures:
- Standard Deviation.
- Mean Absolute Deviation (MAD).
- Gini Mean Difference (GMD).
- Conditional Value at Risk Range.
- Tail Gini Range.
Downside Risk Measures:
- Semi Standard Deviation.
- First Lower Partial Moment (Omega Ratio)
- Second Lower Partial Moment (Sortino Ratio)
- Conditional Value at Risk (CVaR).
- Tail Gini.
- Entropic Value at Risk (EVaR).
Drawdown Risk Measures:
- Conditional Drawdown at Risk (CDaR) for uncompounded cumulative returns.
- Entropic Drawdown at Risk (EDaR) for uncompounded cumulative returns.
- Ulcer Index for uncompounded cumulative returns.
-
Hierarchical Clustering Portfolio Optimization: Hierarchical Risk Parity (HRP) and Hierarchical Equal Risk Contribution (HERC) with 22 risk measures using naive risk parity:
Dispersion Risk Measures:
- Standard Deviation.
- Variance.
- Mean Absolute Deviation (MAD).
- Range.
- Conditional Value at Risk Range.
- Tail Gini Range.
Downside Risk Measures:
- Semi Standard Deviation.
- First Lower Partial Moment (Omega Ratio).
- Second Lower Partial Moment (Sortino Ratio).
- Value at Risk (VaR).
- Conditional Value at Risk (CVaR).
- Entropic Value at Risk (EVaR).
- Tail Gini.
- Worst Case Realization (Minimax).
Drawdown Risk Measures:
- Maximum Drawdown (Calmar Ratio) for compounded and uncompounded cumulative returns.
- Average Drawdown for compounded and uncompounded cumulative returns.
- Drawdown at Risk (DaR) for compounded and uncompounded cumulative returns.
- Conditional Drawdown at Risk (CDaR) for compounded and uncompounded cumulative returns.
- Entropic Drawdown at Risk (EDaR) for compounded and uncompounded cumulative returns.
- Ulcer Index for compounded and uncompounded cumulative returns.
-
Nested Clustered Optimization (NCO) with four objective functions and the available risk measures to each objective:
- Minimum Risk.
- Maximum Return.
- Maximum Utility Function.
- Equal Risk Contribution.
-
Worst Case Mean Variance Portfolio Optimization.
-
Relaxed Risk Parity Portfolio Optimization.
-
Ordered Weighted Averaging (OWA) Portfolio Optimization.
-
Portfolio optimization with Black Litterman model.
-
Portfolio optimization with Risk Factors model.
-
Portfolio optimization with Black Litterman Bayesian model.
-
Portfolio optimization with Augmented Black Litterman model.
-
Portfolio optimization with constraints on tracking error and turnover.
-
Portfolio optimization with short positions and leveraged portfolios.
-
Portfolio optimization with constraints on number of assets and number of effective assets.
-
Tools to build efficient frontier for 18 risk measures.
-
Tools to build linear constraints on assets, asset classes and risk factors.
-
Tools to build views on assets and asset classes.
-
Tools to build views on risk factors.
-
Tools to calculate risk measures.
-
Tools to calculate risk contributions per asset.
-
Tools to calculate uncertainty sets for mean vector and covariance matrix.
-
Tools to calculate assets clusters based on codependence metrics.
-
Tools to estimate loadings matrix (Stepwise Regression and Principal Components Regression).
-
Tools to visualizing portfolio properties and risk measures.
-
Tools to build reports on Jupyter Notebook and Excel.
-
Option to use commercial optimization solver like MOSEK or GUROBI for large scale problems.
Documentation
Online documentation is available at Documentation.
The docs include a tutorial with examples that shows the capacities of Riskfolio-Lib.
Dependencies
Riskfolio-Lib supports Python 3.7+.
Installation requires:
- numpy >= 1.17.0
- scipy >= 1.1.0
- pandas >= 1.0.0
- matplotlib >= 3.3.0
- cvxpy >= 1.0.15
- scikit-learn >= 1.0.0
- statsmodels >= 0.10.1
- arch >= 4.15
- xlsxwriter >= 1.3.7
- networkx >= 2.5.1
- astropy >= 4.3.1
Installation
The latest stable release (and older versions) can be installed from PyPI:
pip install riskfolio-lib
Citing
If you use Riskfolio-Lib for published work, please use the following BibTeX entry:
@misc{riskfolio,
author = {Dany Cajas},
title = {Riskfolio-Lib (3.1.1)},
year = {2022},
url = {https://github.com/dcajasn/Riskfolio-Lib},
}
Development
Riskfolio-Lib development takes place on Github: https://github.com/dcajasn/Riskfolio-Lib
RoadMap
The plan for this module is to add more functions that will be very useful to asset managers.
- Add more functions based on suggestion of users.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Riskfolio_Lib-3.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 748020afd5a0627a254d404fa7ed5bd09cd44efe74a075a4847c51dae7206cd0 |
|
MD5 | 8e57d5f271c525a8fc181561c4494bc0 |
|
BLAKE2b-256 | 91d41086addb901a3ec34b2d7babf459dea923efe8bc80986157cef0f72f17ae |