arbitragelab.hedge_ratios.linear

The module implements OLS (Ordinary Least Squares) and TLS (Total Least Squares) hedge ratio calculations.

Module Contents

Functions

get_ols_hedge_ratio(→ Tuple[dict, pandas.DataFrame, ...)

Get OLS hedge ratio: y = beta*X.

get_tls_hedge_ratio(→ Tuple[dict, pandas.DataFrame, ...)

Get Total Least Squares (TLS) hedge ratio using Orthogonal Regression.

get_ols_hedge_ratio(price_data: pandas.DataFrame, dependent_variable: str, add_constant: bool = False) Tuple[dict, pandas.DataFrame, pandas.Series, pandas.Series]

Get OLS hedge ratio: y = beta*X.

Parameters:
  • price_data – (pd.DataFrame) Data Frame with security prices.

  • dependent_variable – (str) Column name which represents the dependent variable (y).

  • add_constant – (bool) Boolean flag to add constant in regression setting.

Returns:

(Tuple) Hedge ratios, X, and y and OLS fit residuals.

get_tls_hedge_ratio(price_data: pandas.DataFrame, dependent_variable: str, add_constant: bool = False) Tuple[dict, pandas.DataFrame, pandas.Series, pandas.Series]

Get Total Least Squares (TLS) hedge ratio using Orthogonal Regression.

Parameters:
  • price_data – (pd.DataFrame) Data Frame with security prices.

  • dependent_variable – (str) Column name which represents the dependent variable (y).

  • add_constant – (bool) Boolean flag to add constant in regression setting.

Returns:

(Tuple) Hedge ratios dict, X, and y and fit residuals.