arbitragelab.copula_approach.vine_copula_partner_selection_utils
Utils for implementing partner selection approaches for vine copulas.
Module Contents
Functions
|
Returns ranked quantiles from returns. |
|
Function returns Sector and Sub sector information for all tickers in quadruple. |
|
Helper function for traditional approach to partner selection. |
|
Helper function for extended approach to partner selection. |
|
Helper function for geometric approach to partner selection. |
|
Helper function to calculate chi-squared test statistic based on p-dimensional Nelsen copulas. |
Calculates 2**d x 2**d dimensional covariance matrix. Since the matrix is symmetric, only the integrals |
|
|
Calculates T_(d,n) as seen in proposition 3.3. Each of the 2**d rows in the array are appended to output and |
|
Function returns form of respective variable after partial differentiation in the copula density function. |
|
Calculates Integrand for covariance matrix calculation. |
- get_quantiles_data(col: pandas.Series)
Returns ranked quantiles from returns.
- Parameters:
col – (pd.Series) Returns data for a single stock.
- Returns:
Ranked returns from quantiles.
- get_sector_data(quadruple: list, constituents: pandas.DataFrame)
Function returns Sector and Sub sector information for all tickers in quadruple.
- Parameters:
quadruple – (list) List of four tickers.
constituents – (pd.DataFrame) Dataframe consisting of sector data for all tickers in universe.
- Returns:
Data corresponding to the quadruple.
- get_sum_correlations_vectorized(data_subset: pandas.DataFrame, all_possible_combinations: numpy.array) tuple
Helper function for traditional approach to partner selection.
Calculates sum of pairwise correlations between all stocks in each quadruple. Returns the quadruple with the largest sum.
- Parameters:
data_subset – (pd.DataFrame) Dataset storing correlations data.
all_possible_combinations – (np.array) Array of indices of 19600 quadruples.
- Returns:
(tuple) Final quadruple, corresponding measure.
- multivariate_rho_vectorized(data_subset: pandas.DataFrame, all_possible_combinations: numpy.array) tuple
Helper function for extended approach to partner selection.
Calculates 3 proposed estimators for high dimensional generalization for Spearman’s rho. These implementations are present in Multivariate extensions of Spearman’s rho and related statistics. (2007) by Schmid, F., Schmidt, R.
Returns the quadruple with the largest measure.
- Parameters:
data_subset – (pd.DataFrame) Dataset storing ranked returns data.
all_possible_combinations – (np.array) Array of indices of 19600 quadruples.
- Returns:
(tuple) Final quadruple, corresponding measure.
- diagonal_measure_vectorized(data_subset: pandas.DataFrame, all_possible_combinations: numpy.array) tuple
Helper function for geometric approach to partner selection.
Calculates the sum of Euclidean distances from the relative ranks to the (hyper-)diagonal in four dimensional space for each quadruple of a target stock. Returns the quadruple with the smallest measure.
- Parameters:
data_subset – (pd.DataFrame) Dataset storing ranked returns data.
all_possible_combinations – (np.array) Array of indices of 19600 quadruples.
- Returns:
(tuple) Final quadruple, corresponding measure
- extremal_measure(u: pandas.DataFrame, co_variance_matrix: numpy.array)
Helper function to calculate chi-squared test statistic based on p-dimensional Nelsen copulas.
Specifically, proposition 3.3 from Mangold (2015) is implemented for 4 dimensions.
- Parameters:
u – (pd.DataFrame) Ranked returns of stocks in quadruple.
co_variance_matrix – (np.array) Covariance matrix.
- Returns:
(float) Test statistic.
- get_co_variance_matrix(d: int)
Calculates 2**d x 2**d dimensional covariance matrix. Since the matrix is symmetric, only the integrals in the upper triangle are calculated. The remaining values are filled from the transpose.
- Parameters:
d – (int) Number of stocks.
- t_calc(u)
Calculates T_(d,n) as seen in proposition 3.3. Each of the 2**d rows in the array are appended to output and returned as numpy array.
- Parameters:
u – (pd.DataFrame) Ranked returns of stocks in quadruple.
- Returns:
(np.array) Array of Shape (2**d, n).
- variable_form(t: numpy.array, value: int)
Function returns form of respective variable after partial differentiation in the copula density function. All variables in the density function are in one of two forms.
- Parameters:
t – (np.array) Variable.
value – (int) Flag denoting equation form of variable.
- Returns:
(float) Differentiation result.
- variance_integral_func(*args)
Calculates Integrand for covariance matrix calculation.
- Parameters:
args – (list) Given parameters.
- Returns:
(float) Integrand value.