Skip to content

nb module¶

Numba-compiled functions.

Provides an arsenal of Numba-compiled functions that are used by indicator classes. These only accept NumPy arrays and other Numba-compatible types.

Note

vectorbt treats matrices as first-class citizens and expects input arrays to be 2-dim, unless function has suffix _1d or is meant to be input to another function. Data is processed along index (axis 0).

All functions passed as argument should be Numba-compiled.


atr_apply_nb function¶

atr_apply_nb(
    high,
    low,
    close,
    window,
    ewm,
    adjust,
    tr,
    cache_dict
)

Apply function for ATR.


atr_cache_nb function¶

atr_cache_nb(
    high,
    low,
    close,
    windows,
    ewms,
    adjust
)

Caching function for ATR.


bb_apply_nb function¶

bb_apply_nb(
    close,
    window,
    ewm,
    alpha,
    adjust,
    ddof,
    ma_cache_dict,
    mstd_cache_dict
)

Apply function for BBANDS.


bb_cache_nb function¶

bb_cache_nb(
    close,
    windows,
    ewms,
    alphas,
    adjust,
    ddof
)

Caching function for BBANDS.


ma_apply_nb function¶

ma_apply_nb(
    close,
    window,
    ewm,
    adjust,
    cache_dict
)

Apply function for MA.


ma_cache_nb function¶

ma_cache_nb(
    close,
    windows,
    ewms,
    adjust
)

Caching function for MA.


ma_nb function¶

ma_nb(
    a,
    window,
    ewm,
    adjust=False
)

Compute simple or exponential moving average (ewm=True).


macd_apply_nb function¶

macd_apply_nb(
    close,
    fast_window,
    slow_window,
    signal_window,
    macd_ewm,
    signal_ewm,
    adjust,
    cache_dict
)

Apply function for MACD.


macd_cache_nb function¶

macd_cache_nb(
    close,
    fast_windows,
    slow_windows,
    signal_windows,
    macd_ewms,
    signal_ewms,
    adjust
)

Caching function for MACD.


mstd_apply_nb function¶

mstd_apply_nb(
    close,
    window,
    ewm,
    adjust,
    ddof,
    cache_dict
)

Apply function for MSTD.


mstd_cache_nb function¶

mstd_cache_nb(
    close,
    windows,
    ewms,
    adjust,
    ddof
)

Caching function for MSTD.


mstd_nb function¶

mstd_nb(
    a,
    window,
    ewm,
    adjust=False,
    ddof=0
)

Compute simple or exponential moving STD (ewm=True).

With ewm=True, ddof=0 uses population variance, while ddof=1 applies the unbiased weighted correction.


obv_custom_nb function¶

obv_custom_nb(
    close,
    volume_ts
)

Custom calculation function for OBV.

Start with the first bar's volume. Add volume when the close rises, subtract it when the close falls, and leave OBV unchanged for equal finite closes.

Compare each close with the immediately previous bar. A NaN close breaks the comparison chain, so the next finite close adds its full volume.


rsi_apply_nb function¶

rsi_apply_nb(
    close,
    window,
    ewm,
    adjust,
    cache_dict
)

Apply function for RSI.


rsi_cache_nb function¶

rsi_cache_nb(
    close,
    windows,
    ewms,
    adjust
)

Caching function for RSI.


stoch_apply_nb function¶

stoch_apply_nb(
    high,
    low,
    close,
    k_window,
    d_window,
    d_ewm,
    adjust,
    cache_dict
)

Apply function for STOCH.


stoch_cache_nb function¶

stoch_cache_nb(
    high,
    low,
    close,
    k_windows,
    d_windows,
    d_ewms,
    adjust
)

Caching function for STOCH.


true_range_nb function¶

true_range_nb(
    high,
    low,
    close
)

Calculate true range.