awt_quant.utils

Module Contents

awt_quant.utils.hurst(ts, lag)[source]

Calculates the Hurst Exponent for a given time series.

The Hurst Exponent is a measure of long-term memory in a time series: - Near 0.5: Random series. - Near 0: Mean reverting. - Near 1: Trending.

Parameters:
  • ts (array-like) – Time series data.

  • lag (int) – Maximum lag to compute.

Returns:

Hurst exponent value.

Return type:

float

awt_quant.utils.hurst(ts, lag)[source]

Returns the Hurst Exponent of the time series vector ts The Hurst Exponent is a statistical measure used to classify time series and infer the level of difficulty in predicting and choosing an appropriate model for the series at hand. The Hurst exponent is used as a measure of long-term memory of time series. It relates to the autocorrelations of the time series, and the rate at which these decrease as the lag between pairs of values increases.

Value near 0.5 indicates a random series. Value near 0 indicates a mean reverting series. Value near 1 indicates a trending series.

awt_quant.utils.financial_calendar_days_before(date_str, T, calendar_name='NYSE')[source]

Gets the T-th market day occurring before a given date.

Parameters:
  • date_str (str) – End date in ‘YYYY-MM-DD’ format.

  • T (int) – Number of market days to go back.

  • calendar_name (str) – Market calendar name (default: ‘NYSE’).

Returns:

Computed start date in ‘YYYY-MM-DD’ format.

Return type:

str

awt_quant.utils.plot_correlogram(x, lags=None, title=None)[source]

Plots the correlogram for a given time series.

The output consists of: - Time series plot. - Q-Q plot. - Autocorrelation Function (ACF). - Partial Autocorrelation Function (PACF).

Parameters:
  • x (pd.Series) – Time series data.

  • lags (int, optional) – Number of lags in ACF/PACF.

  • title (str, optional) – Plot title.