pyscarcopula
A Python library for dynamic copula modelling: bivariate, multivariate, vine, and stochastic copula models for financial time series and risk analytics.
About
pyscarcopula fits bivariate and multivariate dependence models using copulas in Python. Alongside classical constant-parameter copulas, it supports stochastic copula autoregressive (SCAR) models where the copula parameter is driven by a latent Ornstein-Uhlenbeck process or Kendall's tau follows a bounded Jacobi diffusion.
The package is aimed at financial time series, risk modelling, and experiments with dynamic dependence. It provides bivariate copulas, C-vines, R-vines, conditional sampling, prediction, goodness-of-fit diagnostics, and risk metrics.
Supported estimation methods:
| Method | Key | Description |
|---|---|---|
| Maximum likelihood | mle |
Constant copula parameter |
| SCAR transfer matrix | scar-tm-ou |
Deterministic OU latent-state likelihood |
| SCAR Jacobi transfer matrix | scar-tm-jacobi |
Deterministic Kendall-tau diffusion likelihood |
| SCAR Monte Carlo | scar-p-ou, scar-m-ou |
Monte Carlo alternatives |
| GAS | gas |
Observation-driven score model |
Install
pip install pyscarcopula
Official wheels include the compiled numerical extension and do not need a local compiler. Source and editable installs require a C++17 compiler:
- Windows: Microsoft C++ Build Tools / Visual Studio Build Tools, or MinGW-w64 GCC (see below)
- Linux: GCC or Clang with the usual Python development headers
- macOS: Xcode Command Line Tools
On Windows, a MinGW-w64 GCC toolchain (for example the MSYS2 ucrt64 GCC) can
be used instead of the Microsoft compiler by opting in explicitly:
PYSCA_CPP_COMPILER=mingw32 pip install .
# or, from the source tree:
python setup.py build_ext --compiler=mingw32 --inplace
The GCC runtime is linked statically, so the resulting extension does not need MSYS2 DLLs at runtime. MSVC remains the default Windows toolchain.
For local development:
git clone https://github.com/AANovokhatskiy/pyscarcopula
cd pyscarcopula
pip install -e ".[test]"
To run the full test suite from the source tree, build the C++ extension in place first:
python setup.py build_ext --inplace
pytest --run-validation
pytest --run-validation enables optional validation tests. A source checkout
without a successfully built extension is incomplete for the default
bivariate GAS workflow.
Optional benchmark and large validation checks are disabled by default. Enable them explicitly:
PYSCA_RUN_BENCHMARKS=1 \
PYSCA_RUN_LARGE_BENCHMARKS=1 \
PYSCA_RUN_VINE_BENCHMARKS=1 \
pytest tests --run-validation
On Windows PowerShell:
$env:PYSCA_RUN_BENCHMARKS = "1"
$env:PYSCA_RUN_LARGE_BENCHMARKS = "1"
$env:PYSCA_RUN_VINE_BENCHMARKS = "1"
pytest tests --run-validation
Core dependencies: numpy, numba, scipy, joblib, tqdm.
Verify the compiled extension with:
python -m pyscarcopula._native_smoke
Features
Copula families
- Archimedean: Gumbel, Frank, Clayton, Joe, including rotations where supported
- Elliptical: Gaussian and Student-t
- Independence copula for null models and vine pruning
- Multivariate Gaussian, Student-t, equicorrelation, and stochastic Student models
- Shared APIs for bivariate, multivariate, and vine models
Vine copulas
- C-vine pair-copula construction with fixed star structure
- R-vine pair-copula construction with Dissmann-style structure selection
- Automatic family and rotation selection per edge using AIC/BIC
- Tree-level and edge-level truncation
- Mixed MLE, SCAR, GAS, and independence edges within one vine
Sampling and prediction
- Unconditional sampling from fitted bivariate, multivariate, and vine models
- Conditional sampling for static and dynamic multivariate models and R-vines
- Exact and approximate conditional modes for R-vines
PredictConfigfor explicit prediction options- Reproducible random generation via
rng - JSON persistence through
model.save()andModelClass.load()(include_data=Falsecan omit stored training data)
Diagnostics and risk
- Rosenblatt-transform based goodness-of-fit tests
- Mixture Rosenblatt transform for stochastic models
- Predictive time-varying copula parameter paths
- VaR and CVaR utilities in
pyscarcopula.contrib
Mathematical background
By Sklar's theorem, a joint distribution can be represented as
F(x_1, \ldots, x_d) = C(F_1(x_1), \ldots, F_d(x_d)),
where C is a copula and F_i are marginal distributions. This separates
marginal modelling from dependence modelling.
For a one-parameter Archimedean copula with generator phi,
C(u_1, \ldots, u_d; \theta)
= \phi^{-1}(\phi(u_1; \theta) + \cdots + \phi(u_d; \theta)).
In SCAR models the copula parameter is time-varying:
\theta_t = \Psi(x_t),
\qquad
dx_t = \kappa(\mu - x_t)dt + \nu dW_t,
where x_t is a latent Ornstein-Uhlenbeck process and Psi maps the latent
state to the valid parameter domain. scar-tm-jacobi instead evolves
Kendall's tau directly with a bounded Jacobi diffusion and maps tau back to the
copula parameter for families that implement tau_to_param.
The transfer matrix method evaluates the latent-state likelihood by exploiting the Markov structure of the latent process. The path integral is computed as a sequence of matrix-vector products on a discretized grid or spectral basis, avoiding Monte Carlo variance at the cost of numerical approximation.
For SCAR-TM-OU, transition_method='auto' uses a hybrid deterministic strategy:
Hermite spectral evaluation where it is reliable, matrix-based transition
evaluation for regimes better handled on a grid, and local Gauss-Hermite in
narrow-kernel OU cases. In broad terms, this keeps the latent path integral as
repeated deterministic linear-algebra updates while choosing the most suitable
transition representation automatically. See
docs/guide/performance.md for the details and
the available transition_method values.
result = fit(copula, u, method="scar-tm-ou")
result = fit(copula, u, method="gas")
Use the default scaling="unit" for production. scaling="fisher" remains an
experimental, numerically sensitive mode.
See docs/guide/performance.md for supported
families and numerical options.
Vine copulas decompose a d-dimensional dependence model into bivariate copulas
arranged in a sequence of trees. R-vines choose the tree structure from data
subject to the proximity condition; C-vines use a fixed star structure.
Examples and docs
Worked notebooks are available in examples/:
01_basic_api.ipynb02_bivariate.ipynb03_multivariate.ipynb04_vine.ipynb05_risk_metrics.ipynb06_pyvinecopulib_comparison.ipynb
Additional documentation is in docs/. Estimation methods are
described in docs/guide/estimation-methods.md,
and performance-related details are kept in
docs/guide/performance.md. Release history is in
CHANGELOG.md.
License
MIT License. See LICENSE.txt.
Release files for pyscarcopula 0.18.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyscarcopula-0.18.0.tar.gz | 6.1 MB | Details |
Built distributions (wheels)
Total release size:17.2 MB
Release files / pyscarcopula-0.18.0.tar.gz
| Download URL | pyscarcopula-0.18.0.tar.gz |
|---|---|
| Size | 6.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
113471ddb02167ef2d1e6c69d1a9470c354fad7e802f2929dfa895e305bb76ec
|
|
BLAKE2b-256 checksum How to use checksums |
aad28ca888ddc8bfa8f4f34edca432981ff83e116081d6826c34281138487b21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp314-cp314-win_amd64.whl
| Download URL | pyscarcopula-0.18.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 569.6 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
389a91e3d615094b2ef91538c9e75ffe57f779f1b887c4d126061750825f36a5
|
|
BLAKE2b-256 checksum How to use checksums |
d66d0582517c844860e09842769a2d8863c08f036d1cde39c9e781c5067c55e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyscarcopula-0.18.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 695.9 kB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e83dd01b46eec8c3ac944b7fac8a31dad3f2544bcb5caa39a091521794880294
|
|
BLAKE2b-256 checksum How to use checksums |
b62582befe6ebccb6c81422350112a39a1639d2081b366206c4765c6f84da642
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp314-cp314-macosx_10_15_universal2.whl
| Download URL | pyscarcopula-0.18.0-cp314-cp314-macosx_10_15_universal2.whl |
|---|---|
| Size | 969.5 kB |
| Tags | CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
2487bc967fc0216f18b7073ce63eba89a50ecddbeacc23730b188df6caeb752d
|
|
BLAKE2b-256 checksum How to use checksums |
d52b6aae7d43b05cb82e2b739b1293a3f8c6b42954adcc930a62caf064d82127
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp313-cp313-win_amd64.whl
| Download URL | pyscarcopula-0.18.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 560.3 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fa02d7f97a7eb7267bba8d01337dab27dd79aca5742f1fb6287b4a0f4722ed68
|
|
BLAKE2b-256 checksum How to use checksums |
67911d345a3c81989538f4b1243c1db4828f5f2a11c7b737c2fc26a1a2c1ca30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyscarcopula-0.18.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 695.5 kB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
1ff9a19c7cc0e8e0a7db7cd72cb8c0d2eac4b22e7f24c4504e98527948c84b16
|
|
BLAKE2b-256 checksum How to use checksums |
8f4e1c5f8ff3263611d95ed05c86d13e0e32d35f7f20d2525f02a610793f9bb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp313-cp313-macosx_10_13_universal2.whl
| Download URL | pyscarcopula-0.18.0-cp313-cp313-macosx_10_13_universal2.whl |
|---|---|
| Size | 969.2 kB |
| Tags | CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
46e2576d2e29dbfab207522dcb2afc4b7f76e81445fec3791a155502dab07a43
|
|
BLAKE2b-256 checksum How to use checksums |
dbdf9b5fb5d495fdf0698e7ee9cc3c6690339976a51a2a981a471f0b80869fd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp312-cp312-win_amd64.whl
| Download URL | pyscarcopula-0.18.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 560.3 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8b3b9759e65681ab15fa420892b8b0c91c70b671671d0a0376d00ad0422a5b62
|
|
BLAKE2b-256 checksum How to use checksums |
d7ff772563640b43c00ebd6b4d00a12257c8b7b42a3a5f46aa15fa059a6b6356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyscarcopula-0.18.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 696.2 kB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
bf9420da2d814a54341e7dd92396aae0550bd0c20a1a4592725ca5e9f56089af
|
|
BLAKE2b-256 checksum How to use checksums |
c2d8735a2c4cdf445746ff6eac4df3cea81ef9ca51ceea7bbbe3e69c4dddf4e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp312-cp312-macosx_10_13_universal2.whl
| Download URL | pyscarcopula-0.18.0-cp312-cp312-macosx_10_13_universal2.whl |
|---|---|
| Size | 969.1 kB |
| Tags | CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
ec346ac99837bf90d7d90d3a72c599ee38cfe699a6ca5fd8baf4430fcde0fd90
|
|
BLAKE2b-256 checksum How to use checksums |
ca1d75065a4ac58e19acbaa89a073f9daaa3bfdfc49a9bbab39c545804ad7109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp311-cp311-win_amd64.whl
| Download URL | pyscarcopula-0.18.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 555.8 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5af285cb1e7f74a78220119a25ce432367d7246f2b5d841cb3dcc3e20931899e
|
|
BLAKE2b-256 checksum How to use checksums |
219da66ccf869cfc94db588b44ffb0b0c85d78e886b4157bf96b889a4d0d2369
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyscarcopula-0.18.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 693.2 kB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
f058e0f25391114ddffe9d9d7872d8a9ee66d9851cb4895dcbdace0f337d573a
|
|
BLAKE2b-256 checksum How to use checksums |
aa4d93a0e2b2fab516aad685a5fa80b30a8d3a523d16f1a4f143224ba5736365
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp311-cp311-macosx_10_9_universal2.whl
| Download URL | pyscarcopula-0.18.0-cp311-cp311-macosx_10_9_universal2.whl |
|---|---|
| Size | 961.9 kB |
| Tags | CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
df2982f56d3b1f840ece431696a94a25b6a847a7dd957b43232f8ea59adde502
|
|
BLAKE2b-256 checksum How to use checksums |
022e37ea22c32d302f6c20efa9cf00b62b06e17d4cb5f473aa6e861d8ece32de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp310-cp310-win_amd64.whl
| Download URL | pyscarcopula-0.18.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 554.5 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
90ae012182780b5b859f7e896d1fe8cc79bfebb6df739cd2b5f8003d6adecb45
|
|
BLAKE2b-256 checksum How to use checksums |
01cb28014fad33a7ab343d29d8fd9402c3ad01f327f5c88c9dc079922c9c2e0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyscarcopula-0.18.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 690.6 kB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
870852d76cb211ff4cb6af92a597c6d7c1d82b184d9eddc6830202333da6a714
|
|
BLAKE2b-256 checksum How to use checksums |
10b483198e18099a3b51c84560f6ce6e122f81dc4a6c819a1bab79e0f1643294
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / pyscarcopula-0.18.0-cp310-cp310-macosx_10_9_universal2.whl
| Download URL | pyscarcopula-0.18.0-cp310-cp310-macosx_10_9_universal2.whl |
|---|---|
| Size | 959.7 kB |
| Tags | CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
b7b1561e861795aef8e86e36ef4e5554fc297f241fab7cef98e36ebed9ab3389
|
|
BLAKE2b-256 checksum How to use checksums |
c6d7269408faf40473ac0f82a3127993062630bd1dec511a3c733d9d66a720fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|