Skip to main content

Risk parity portfolio via the improved CCD method (Choi & Chen, 2022)

Project description

riskparity

Risk parity portfolio optimization via the improved CCD method of Choi & Chen (2022).

Choi, J., & Chen, R. (2022). Improved iterative methods for solving risk parity portfolio. Journal of Derivatives and Quantitative Studies, 30(2). https://doi.org/10.1108/JDQS-12-2021-0031

What is risk parity?

A risk parity (equal risk contribution) portfolio chooses weights w so that every asset contributes the same fraction of total portfolio volatility:

$$\frac{w_i (\mathbf{C}\mathbf{w})_i}{\mathbf{w}^\top \mathbf{C}\mathbf{w}} = b_i \quad \forall i$$

where C is the return covariance matrix and b is the risk-budget vector (defaults to 1/N for equal risk parity).

Algorithm

The improved CCD method (Algorithm 1 in the paper) works on the correlation matrix and adds a rescaling step after each sweep, making it ~3× faster than the original CCD method and saving ~40% of iterations.

Installation

pip install riskparity

Quick start

import numpy as np
from riskparity import risk_parity

# 3-asset covariance matrix
cov = np.array([
    [0.04,  0.01,  0.002],
    [0.01,  0.09,  0.015],
    [0.002, 0.015, 0.0025],
])

result = risk_parity(cov)
print(result.weights)            # portfolio weights, sum to 1
print(result.risk_contributions) # fractional risk contributions, sum to 1
print(result.iterations)         # number of CCD iterations
print(result.converged)          # True if tolerance was met

Custom risk budgets

b = np.array([0.5, 0.3, 0.2])   # 50 / 30 / 20 % risk allocation
result = risk_parity(cov, b=b)

Standalone risk contribution utility

from riskparity import risk_contributions
rc = risk_contributions(weights, cov)  # fractional RC for any portfolio

API reference

risk_parity(cov, b=None, tol=1e-6, max_iter=1000)

Parameter Type Description
cov (N, N) array Covariance matrix (positive semi-definite)
b (N,) array or None Risk budgets, must be positive and sum to 1. Default: 1/N
tol float Convergence tolerance (default 1e-6)
max_iter int Maximum iterations (default 1000)

Returns a RiskParityResult dataclass:

Field Type Description
weights (N,) array Portfolio weights, sum to 1
risk_contributions (N,) array Fractional risk contributions, sum to 1
iterations int Outer iterations used
converged bool Whether tolerance was met

risk_contributions(weights, cov)

Compute fractional risk contributions for any portfolio.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mafn_pypackagetest-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mafn_pypackagetest-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file mafn_pypackagetest-0.1.0.tar.gz.

File metadata

  • Download URL: mafn_pypackagetest-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mafn_pypackagetest-0.1.0.tar.gz
Algorithm Hash digest
SHA256 311e9f46097d6f9bb60425cabdad45b7264588fcff876d1bca6abbb2a0b87288
MD5 3425bcfbdef0cc7a09be32680ab07c4c
BLAKE2b-256 7b6463bef3178b99fdf52b93e2dfbe6f193f43e70cf9f556e67fd2c9405fa736

See more details on using hashes here.

Provenance

The following attestation bundles were made for mafn_pypackagetest-0.1.0.tar.gz:

Publisher: publish.yml on jaehyukchoi/pypackagetest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mafn_pypackagetest-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mafn_pypackagetest-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a05c6dad376d13cc9ab7eca3b2e90a081cfa61da948e99abc6c0144e3c7119d9
MD5 3b231142dd14d63295b5976a5db52306
BLAKE2b-256 e1a3c95197b84f881d085cc1449c7b8c7967015422d77411a8735dcccbb58989

See more details on using hashes here.

Provenance

The following attestation bundles were made for mafn_pypackagetest-0.1.0-py3-none-any.whl:

Publisher: publish.yml on jaehyukchoi/pypackagetest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page