Skip to main content

BaseCopula

Abstract base class for copula models used for statistical arbitrage and copula-based modeling. Method generated by attrs for class BaseCopula.

Ancestors

  • abc.ABC

Descendants

  • systematica.models.arbitrage_index.clayton.Clayton
  • systematica.models.arbitrage_index.frank.Frank
  • systematica.models.arbitrage_index.gumbel.Gumbel
  • systematica.models.arbitrage_index.joe.Joe
  • systematica.models.arbitrage_index.student_t.StudentT

Instance variables

  • model_name: str: Model name, incl. fitted rotation
  • dependence: float: Estimate the parameters from copulas and the Kendall rank correlation.
  • lower_tail_dependence: float: Theoretical lower tail dependence coefficient.
  • upper_tail_dependence: float: Theoretical upper tail dependence coefficient.
  • kendall_tau: float: Kendall’s tau correlation coefficient, with values ranging from -1 (perfect disagreement) to 1 (perfect agreement) and 0 indicating no correlation.
  • linear_space: numpy.ndarray:
  • num: int: Number of samples to generate. Must be at least 10. Default is 100.
  • rotation: str | systematica.models.arbitrage_index.utils.BaseCopulaRotation: Rotations allow the copula to be adapted for different types of tail dependence. - A 180 rotation captures extreme co-movements in the lower tail (i.e. simultaneous extreme losses). - A 90 rotation captures scenarios where one variable exhibits extreme losses while the other shows extreme gains. - A 270 rotation captures the opposite scenario, where one variable experiences extreme gains while the other suffers extreme losses. See BaseCopulaRotation. If set to auto, applies best fitted rotation. Defaults to BaseCopulaRotation.R0.
  • rotation_: systematica.models.arbitrage_index.utils.BaseCopulaRotation: Best fitted rotation applied to the copula model, initialized to R0 (no rotation).
  • sample: Tuple[numpy.ndarray, numpy.ndarray]:
  • start: float: The starting value of the sequence. Must be greater than 0. Defaults to 0.001.
  • stop: float: The end value of the sequence. Must be less than 1. Defaults to 0.999.

Methods

density

Estimate the log probability density function for given ui and vi values. Parameters: Returns:

cumulative_density

Calculate cumulative density of the bivariate copula: P(U<=u,V<=v)P(U<=u, V<=v) Parameters: Returns:

arbitrage

Calculate the mispricing index for every time step in the trading period using the estimated copula. Mispricing indices are the conditional probabilities: P(U<uV=v) and P(V<vU=u).P(U < u | V = v) \text{ and } P(V < v | U = u). Parameters: Returns:

partial_derivative

Compute the h-function (partial derivative) for the bivariate copula, a.k.a. the mispricing index, for every time step in the trading period using the estimated copula. Parameters: Returns:

score

Compute the log-likelihood score of each sample (log-pdf) under the model.
u and v are bivariate inputs (u, v) where each row represents a bivariate observation. Both u and v must be in the interval [0, 1], having been transformed to uniform marginals.
Parameters: Returns:

probability

Probability density function (PDF).
u and v are bivariate inputs (u, v) where each row represents a bivariate observation. Both u and v must be in the interval [0, 1], having been transformed to uniform marginals.
Returns:

set_rotation

Set rotation. Parameters: Returns:

best_fit

Transform u and v with rotated functions. Handle model fitting and rotation of uniform marginals. Parameters: Returns:

criterion

Calculate the criterion value (e.g., aic) for the given copula model. Parameters: Returns: Raises:

tail_concentration

Compute the tail concentration function for a set of quantiles. The tail concentration function is defined as follows:
  • For quantiles q0.5q ≤ 0.5: C(q)=P(Uq,Vq)/qC(q) = P(U ≤ q, V ≤ q) / q
  • For quantiles q>0.5q > 0.5: C(q)=(12q+P(Uq,Vq))/(1q)C(q) = (1 - 2q + P(U ≤ q, V ≤ q)) / (1 - q)
where UU and VV are the pseudo-observations of the first and second variables, respectively. This function returns the concentration values for each qq provided. References:
  • “Quantitative Risk Management: Concepts, Techniques, and Tools”, McNeil, Frey, Embrechts (2005)
Parameters: Raises: Returns:

empirical_tail_concentration

Compute empirical tail concentration for the two variables in X. This function computes the concentration at each quantile provided. The tail concentration are estimated as:
  • Lower tail:
λL(q)=P(U2qU1q)\lambda_L(q) = P(U_2 ≤ q | U_1 ≤ q)
  • Upper tail:
λU(q)=P(U2qU1q)\lambda_U(q) = P(U_2 ≥ q | U_1 ≥ q) where U1U_1 and U2U_2 are the pseudo-observations. Parameters: Raises: Returns:

probability_density_matrix

Create probability density matrix. Parameters: Returns:

partial_derivative_matrix

Create partial derivative matrix. Parameters: Returns:

get_cross_tail_quantile_mask

Create a boolean mask to focus on tail regions of a probability density distribution. Compute the q-th quantile of the data. Masks values in 1 - alpha quantile range of the PDF values. See np.quantile for more information.
u and v are bivariate inputs (u, v) where each row represents a bivariate observation. In this context, u and v are evenly spaced numbers over [start, stop, num] interval.
Parameters: Returns:

get_cross_tail_triangle_mask

Create a boolean mask to focus on triangle regions of a probability density distribution.
u and v are bivariate inputs (u, v) where each row represents a bivariate observation. In this context, u and v are evenly spaced numbers over [start, stop, num] interval.
Parameters: Returns:

cross_tail_mask

Get cross-tail concentration mask. Parameters: Returns:

apply_cross_tail_concentration

Apply cross-tail concentration mask. Parameters: Returns:

plot_tail_concentration

Plot the tail concentration function. This method computes the tail concentration function at 100 evenly spaced quantile levels between 0.005 and 0.995. The plot displays the concentration values on the y-axis and the quantile levels on the x-axis. The tail concentration are estimated as:
  • Lower tail:
δL(q)=P(U2qU1q)\delta_L(q) = P(U_2 ≤ q | U_1 ≤ q)
  • Upper tail:
δU(q)=P(U2qU1q)\delta_U(q) = P(U_2 ≥ q | U_1 ≥ q) where U1U_1 and U2U_2 are the pseudo-observations of the first and second variables, respectively. Parameters: Returns:

plot_ecdf

Plot the empirical cumulative distribution function (ECDF) surface. Parameters: Returns:

plot_heatmap

Plot a 2D heatmap contour of the estimated probability density function (PDF). This method generates a grid over [0, 1]^2, computes the PDF, and displays a contour plot of the PDF. Contour levels are limited to the 97th quantile to avoid extreme densities. Parameters: Returns:

plot_surface

Plot a 3D surface of the estimated probability density function (PDF). This method generates a grid over [0, 1]^2, computes the PDF, and displays a 3D surface plot of the PDF using Plotly. Parameters: Returns:

plot_contour

Plot a 2D heatmap contour of the estimated probability density function (PDF). This method generates a grid over [0, 1]^2, computes the PDF, and displays a contour plot of the PDF. Contour levels are limited to the 97th quantile to avoid extreme densities. Parameters: Returns:

plot_ellipse

Plot an ellipse based on the covariance matrix of a 2D dataset. Parameters: Returns:

plot_density

Plot probability density matrix. Parameters: Returns: Raises: