Home

Awesome

Riskfolio-Lib

Quantitative Strategic Asset Allocation, Easy for Everyone.

<div class="row"> <img src="https://raw.githubusercontent.com/dcajasn/Riskfolio-Lib/master/docs/source/images/MSV_Frontier.png" height="200"> <img src="https://raw.githubusercontent.com/dcajasn/Riskfolio-Lib/master/docs/source/images/Pie_Chart.png" height="200"> </div>

<a href='https://ko-fi.com/B0B833SXD' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi1.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

GitHub stars Downloads Downloads Documentation Status GitHub license Binder

Star History Chart

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:

Documentation

Online documentation is available at Documentation.

The docs include a tutorial with examples that shows the capacities of Riskfolio-Lib.

Choosing a Solver

Due to Riskfolio-Lib is based on CVXPY, Riskfolio-Lib can use the same solvers available for CVXPY. The list of solvers compatible with CVXPY is available in Choosing a solver section of CVXPY's documentation. However, to select an adequate solver for each risk measure we can use the following table that specifies which type of programming technique is used to model each risk measure.

Risk MeasureLPQPSOCPSDPEXPPOW
Variance (MV)XX*
Mean Absolute Deviation (MAD)X
Gini Mean Difference (GMD)X**
Semi Variance (MSV)X
Kurtosis (KT)X
Semi Kurtosis (SKT)X
First Lower Partial Moment (FLPM)X
Second Lower Partial Moment (SLPM)X
Conditional Value at Risk (CVaR)X
Tail Gini (TG)X**
Entropic Value at Risk (EVaR)X
Relativistic Value at Risk (RLVaR)X**
Worst Realization (WR)X
CVaR Range (CVRG)X
Tail Gini Range (TGRG)X**
Range (RG)X
Average Drawdown (ADD)X
Ulcer Index (UCI)X
Conditional Drawdown at Risk (CDaR)X
Entropic Drawdown at Risk (EDaR)X
Relativistic Drawdown at Risk (RLDaR)X**
Maximum Drawdown (MDD)X

(*) When SDP graph theory constraints are included. In the case of integer programming graph theory constraints, the model assume the SOCP formulation.

(**) For these models is highly recommended to use MOSEK as solver, due to in some cases CLARABEL cannot find a solution and SCS takes too much time to solve them.

LP - Linear Programming refers to problems with a linear objective function and linear constraints.

QP - Quadratic Programming refers to problems with a quadratic objective function and linear constraints.

SOCP - Second Order Cone Programming refers to problems with second-order cone constraints.

SDP - Semidefinite Programming refers to problems with positive semidefinite constraints.

EXP - refers to problems with exponential cone constraints.

POW - refers to problems with 3-dimensional power cone constraints.

Dependencies

Riskfolio-Lib supports Python 3.9 or higher.

Installation requires:

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 (6.2.3)},
      year  = {2024},
      url   = {https://github.com/dcajasn/Riskfolio-Lib},
      }

Development

Riskfolio-Lib development takes place on Github: https://github.com/dcajasn/Riskfolio-Lib

Consulting Fees

Riskfolio-Lib is an open-source project, but since it's a project that is not financed for any institution, I started charging for consultancies that are not related to errors in source code. Our fees are as follows:

All consulting must be paid in advance.

You can contact me through:

You can pay using one of the following channels:

RoadMap

The plan for this module is to add more functions that will be very useful to asset managers.