Skip to content

rolling module

Generic Numba-compiled functions for rolling and expanding windows.


alpha_from_com_nb function

alpha_from_com_nb(
    com
)

Get the smoothing factor alpha from a center of mass.


alpha_from_halflife_nb function

alpha_from_halflife_nb(
    halflife
)

Get the smoothing factor alpha from a half-life.


alpha_from_span_nb function

alpha_from_span_nb(
    span
)

Get the smoothing factor alpha from a span.


alpha_from_wilder_nb function

alpha_from_wilder_nb(
    period
)

Get the smoothing factor alpha from a Wilder's period.


ewm_mean_1d_nb function

ewm_mean_1d_nb(
    arr,
    span,
    minp=None,
    adjust=False
)

Compute exponential weighted moving average.

Uses ewm_mean_acc_nb() at each iteration.

Numba equivalent to pd.Series(arr).ewm(span=span, min_periods=minp, adjust=adjust).mean().

Adaptation of pd._libs.window.aggregations.window_aggregations.ewma with default arguments.

Note

In contrast to the Pandas implementation, minp is effective within span.


ewm_mean_acc_nb function

ewm_mean_acc_nb(
    in_state
)

Accumulator of ewm_mean_1d_nb().

Takes a state of type EWMMeanAIS and returns a state of type EWMMeanAOS.


ewm_mean_nb function

ewm_mean_nb(
    arr,
    span,
    minp=None,
    adjust=False
)

2-dim version of ewm_mean_1d_nb().


ewm_std_1d_nb function

ewm_std_1d_nb(
    arr,
    span,
    minp=None,
    adjust=False
)

Compute exponential weighted moving standard deviation.

Uses ewm_std_acc_nb() at each iteration.

Numba equivalent to pd.Series(arr).ewm(span=span, min_periods=minp).std().

Adaptation of pd._libs.window.aggregations.window_aggregations.ewmcov with default arguments.

Note

In contrast to the Pandas implementation, minp is effective within span.


ewm_std_acc_nb function

ewm_std_acc_nb(
    in_state
)

Accumulator of ewm_std_1d_nb().

Takes a state of type EWMStdAIS and returns a state of type EWMStdAOS.


ewm_std_nb function

ewm_std_nb(
    arr,
    span,
    minp=None,
    adjust=False
)

2-dim version of ewm_std_1d_nb().


expanding_max_1d_nb function

expanding_max_1d_nb(
    arr,
    minp=1
)

Compute expanding max.

Numba equivalent to pd.Series(arr).expanding(min_periods=minp).max().


expanding_max_nb function

expanding_max_nb(
    arr,
    minp=1
)

2-dim version of expanding_max_1d_nb().


expanding_min_1d_nb function

expanding_min_1d_nb(
    arr,
    minp=1
)

Compute expanding min.

Numba equivalent to pd.Series(arr).expanding(min_periods=minp).min().


expanding_min_nb function

expanding_min_nb(
    arr,
    minp=1
)

2-dim version of expanding_min_1d_nb().


ma_1d_nb function

ma_1d_nb(
    arr,
    window,
    wtype=0,
    minp=None,
    adjust=False
)

Compute a moving average based on the mode of the type WType.


ma_nb function

ma_nb(
    arr,
    window,
    wtype=0,
    minp=None,
    adjust=False
)

2-dim version of ma_1d_nb().


msd_1d_nb function

msd_1d_nb(
    arr,
    window,
    wtype=0,
    minp=None,
    adjust=False,
    ddof=0
)

Compute a moving standard deviation based on the mode of the type WType.


msd_nb function

msd_nb(
    arr,
    window,
    wtype=0,
    minp=None,
    adjust=False,
    ddof=0
)

2-dim version of msd_1d_nb().


rolling_all_1d_nb function

rolling_all_1d_nb(
    arr,
    window
)

Compute rolling all.


rolling_all_nb function

rolling_all_nb(
    arr,
    window
)

2-dim version of rolling_all_1d_nb().


rolling_any_1d_nb function

rolling_any_1d_nb(
    arr,
    window
)

Compute rolling any.


rolling_any_nb function

rolling_any_nb(
    arr,
    window
)

2-dim version of rolling_any_1d_nb().


rolling_argmax_1d_nb function

rolling_argmax_1d_nb(
    arr,
    window,
    minp=None,
    local=False
)

Compute rolling max index.


rolling_argmax_nb function

rolling_argmax_nb(
    arr,
    window,
    minp=None,
    local=False
)

2-dim version of rolling_argmax_1d_nb().


rolling_argmin_1d_nb function

rolling_argmin_1d_nb(
    arr,
    window,
    minp=None,
    local=False
)

Compute rolling min index.


rolling_argmin_nb function

rolling_argmin_nb(
    arr,
    window,
    minp=None,
    local=False
)

2-dim version of rolling_argmin_1d_nb().


rolling_corr_1d_nb function

rolling_corr_1d_nb(
    arr1,
    arr2,
    window,
    minp=None
)

Compute rolling correlation coefficient.

Numba equivalent to pd.Series(arr1).rolling(window, min_periods=minp).corr(arr2).


rolling_corr_acc_nb function

rolling_corr_acc_nb(
    in_state
)

Accumulator of rolling_corr_1d_nb().

Takes a state of type RollCorrAIS and returns a state of type RollCorrAOS.


rolling_corr_nb function

rolling_corr_nb(
    arr1,
    arr2,
    window,
    minp=None
)

2-dim version of rolling_corr_1d_nb().


rolling_cov_1d_nb function

rolling_cov_1d_nb(
    arr1,
    arr2,
    window,
    minp=None,
    ddof=0
)

Compute rolling covariance.

Numba equivalent to pd.Series(arr1).rolling(window, min_periods=minp).cov(arr2).


rolling_cov_acc_nb function

rolling_cov_acc_nb(
    in_state
)

Accumulator of rolling_cov_1d_nb().

Takes a state of type RollCovAIS and returns a state of type RollCovAOS.


rolling_cov_nb function

rolling_cov_nb(
    arr1,
    arr2,
    window,
    minp=None,
    ddof=0
)

2-dim version of rolling_cov_1d_nb().


rolling_max_1d_nb function

rolling_max_1d_nb(
    arr,
    window,
    minp=None
)

Compute rolling max.

Numba equivalent to pd.Series(arr).rolling(window, min_periods=minp).max().


rolling_max_nb function

rolling_max_nb(
    arr,
    window,
    minp=None
)

2-dim version of rolling_max_1d_nb().


rolling_mean_1d_nb function

rolling_mean_1d_nb(
    arr,
    window,
    minp=None
)

Compute rolling mean.

Uses rolling_mean_acc_nb() at each iteration.

Numba equivalent to pd.Series(arr).rolling(window, min_periods=minp).mean().


rolling_mean_acc_nb function

rolling_mean_acc_nb(
    in_state
)

Accumulator of rolling_mean_1d_nb().

Takes a state of type RollMeanAIS and returns a state of type RollMeanAOS.


rolling_mean_nb function

rolling_mean_nb(
    arr,
    window,
    minp=None
)

2-dim version of rolling_mean_1d_nb().


rolling_min_1d_nb function

rolling_min_1d_nb(
    arr,
    window,
    minp=None
)

Compute rolling min.

Numba equivalent to pd.Series(arr).rolling(window, min_periods=minp).min().


rolling_min_nb function

rolling_min_nb(
    arr,
    window,
    minp=None
)

2-dim version of rolling_min_1d_nb().


rolling_ols_1d_nb function

rolling_ols_1d_nb(
    arr1,
    arr2,
    window,
    minp=None
)

Compute rolling linear regression.


rolling_ols_acc_nb function

rolling_ols_acc_nb(
    in_state
)

Accumulator of rolling_ols_1d_nb().

Takes a state of type RollOLSAIS and returns a state of type RollOLSAOS.


rolling_ols_nb function

rolling_ols_nb(
    arr1,
    arr2,
    window,
    minp=None
)

2-dim version of rolling_ols_1d_nb().


rolling_pattern_similarity_1d_nb function

rolling_pattern_similarity_1d_nb(
    arr,
    pattern,
    window=None,
    max_window=None,
    row_select_prob=1.0,
    window_select_prob=1.0,
    interp_mode=3,
    rescale_mode=0,
    vmin=nan,
    vmax=nan,
    pmin=nan,
    pmax=nan,
    invert=False,
    error_type=0,
    distance_measure=0,
    max_error=nan,
    max_error_interp_mode=None,
    max_error_as_maxdist=False,
    max_error_strict=False,
    min_pct_change=nan,
    max_pct_change=nan,
    min_similarity=0.85,
    minp=None
)

Compute rolling pattern similarity.

Uses pattern_similarity_nb().


rolling_pattern_similarity_nb function

rolling_pattern_similarity_nb(
    arr,
    pattern,
    window=None,
    max_window=None,
    row_select_prob=1.0,
    window_select_prob=1.0,
    interp_mode=3,
    rescale_mode=0,
    vmin=nan,
    vmax=nan,
    pmin=nan,
    pmax=nan,
    invert=False,
    error_type=0,
    distance_measure=0,
    max_error=nan,
    max_error_interp_mode=None,
    max_error_as_maxdist=False,
    max_error_strict=False,
    min_pct_change=nan,
    max_pct_change=nan,
    min_similarity=0.85,
    minp=None
)

2-dim version of rolling_pattern_similarity_1d_nb().


rolling_prod_1d_nb function

rolling_prod_1d_nb(
    arr,
    window,
    minp=None
)

Compute rolling product.

Uses rolling_prod_acc_nb() at each iteration.

Numba equivalent to pd.Series(arr).rolling(window, min_periods=minp).apply(np.prod).


rolling_prod_acc_nb function

rolling_prod_acc_nb(
    in_state
)

Accumulator of rolling_prod_1d_nb().

Takes a state of type RollProdAIS and returns a state of type RollProdAOS.


rolling_prod_nb function

rolling_prod_nb(
    arr,
    window,
    minp=None
)

2-dim version of rolling_prod_1d_nb().


rolling_rank_1d_nb function

rolling_rank_1d_nb(
    arr,
    window,
    minp=None,
    pct=False
)

Rolling version of rank_1d_nb.


rolling_rank_nb function

rolling_rank_nb(
    arr,
    window,
    minp=None,
    pct=False
)

2-dim version of rolling_rank_1d_nb().


rolling_std_1d_nb function

rolling_std_1d_nb(
    arr,
    window,
    minp=None,
    ddof=0
)

Compute rolling standard deviation.

Uses rolling_std_acc_nb() at each iteration.

Numba equivalent to pd.Series(arr).rolling(window, min_periods=minp).std(ddof=ddof).


rolling_std_acc_nb function

rolling_std_acc_nb(
    in_state
)

Accumulator of rolling_std_1d_nb().

Takes a state of type RollStdAIS and returns a state of type RollStdAOS.


rolling_std_nb function

rolling_std_nb(
    arr,
    window,
    minp=None,
    ddof=0
)

2-dim version of rolling_std_1d_nb().


rolling_sum_1d_nb function

rolling_sum_1d_nb(
    arr,
    window,
    minp=None
)

Compute rolling sum.

Uses rolling_sum_acc_nb() at each iteration.

Numba equivalent to pd.Series(arr).rolling(window, min_periods=minp).sum().


rolling_sum_acc_nb function

rolling_sum_acc_nb(
    in_state
)

Accumulator of rolling_sum_1d_nb().

Takes a state of type RollSumAIS and returns a state of type RollSumAOS.


rolling_sum_nb function

rolling_sum_nb(
    arr,
    window,
    minp=None
)

2-dim version of rolling_sum_1d_nb().


rolling_zscore_1d_nb function

rolling_zscore_1d_nb(
    arr,
    window,
    minp=None,
    ddof=0
)

Compute rolling z-score.

Uses rolling_zscore_acc_nb() at each iteration.


rolling_zscore_acc_nb function

rolling_zscore_acc_nb(
    in_state
)

Accumulator of rolling_zscore_1d_nb().

Takes a state of type RollZScoreAIS and returns a state of type RollZScoreAOS.


rolling_zscore_nb function

rolling_zscore_nb(
    arr,
    window,
    minp=None,
    ddof=0
)

2-dim version of rolling_zscore_1d_nb().


vidya_1d_nb function

vidya_1d_nb(
    arr,
    window,
    minp=None
)

Compute VIDYA.

Uses vidya_acc_nb() at each iteration.


vidya_acc_nb function

vidya_acc_nb(
    in_state
)

Accumulator of vidya_1d_nb().

Takes a state of type VidyaAIS and returns a state of type VidyaAOS.


vidya_nb function

vidya_nb(
    arr,
    window,
    minp=None
)

2-dim version of vidya_1d_nb().


wm_mean_1d_nb function

wm_mean_1d_nb(
    arr,
    window,
    minp=None
)

Compute weighted moving average.

Uses wm_mean_acc_nb() at each iteration.


wm_mean_acc_nb function

wm_mean_acc_nb(
    in_state
)

Accumulator of wm_mean_1d_nb().

Takes a state of type WMMeanAIS and returns a state of type WMMeanAOS.


wm_mean_nb function

wm_mean_nb(
    arr,
    window,
    minp=None
)

2-dim version of wm_mean_1d_nb().


wwm_mean_1d_nb function

wwm_mean_1d_nb(
    arr,
    period,
    minp=None,
    adjust=False
)

Compute Wilder's exponential weighted moving average.


wwm_mean_nb function

wwm_mean_nb(
    arr,
    period,
    minp=None,
    adjust=False
)

2-dim version of wwm_mean_1d_nb().


wwm_std_1d_nb function

wwm_std_1d_nb(
    arr,
    period,
    minp=None,
    adjust=False
)

Compute Wilder's exponential weighted moving standard deviation.


wwm_std_nb function

wwm_std_nb(
    arr,
    period,
    minp=None,
    adjust=False
)

2-dim version of wwm_std_1d_nb().