def future_max_apply_nb(close: tp.Array2d, window: int, wait: int = 1) -> tp.Array2d: """Get the maximum of the next period.""" out = generic_nb.rolling_max_nb(close[::-1], window, minp=window)[::-1] if wait > 0: return generic_nb.bshift_nb(out, wait) return out
def stoch_caching_nb(high_ts, low_ts, close_ts, k_windows, d_windows, d_ewms): """Caching function for `vectorbt.indicators.basic.Stochastic`.""" cache_dict = dict() for i in range(k_windows.shape[0]): h = hash(k_windows[i]) if h not in cache_dict: roll_min = generic_nb.rolling_min_nb(low_ts, k_windows[i]) roll_max = generic_nb.rolling_max_nb(high_ts, k_windows[i]) cache_dict[h] = roll_min, roll_max return cache_dict
def stoch_cache_nb(high, low, close, k_windows, d_windows, d_ewms, adjust): """Caching function for `vectorbt.indicators.basic.STOCH`.""" cache_dict = dict() for i in range(len(k_windows)): h = hash(k_windows[i]) if h not in cache_dict: roll_min = generic_nb.rolling_min_nb(low, k_windows[i]) roll_max = generic_nb.rolling_max_nb(high, k_windows[i]) cache_dict[h] = roll_min, roll_max return cache_dict
def stoch_cache_nb(high: tp.Array2d, low: tp.Array2d, close: tp.Array2d, k_windows: tp.List[int], d_windows: tp.List[int], d_ewms: tp.List[bool], adjust: bool) -> tp.Dict[int, tp.Tuple[tp.Array2d, tp.Array2d]]: """Caching function for `vectorbt.indicators.basic.STOCH`.""" cache_dict = dict() for i in range(len(k_windows)): h = hash(k_windows[i]) if h not in cache_dict: roll_min = generic_nb.rolling_min_nb(low, k_windows[i]) roll_max = generic_nb.rolling_max_nb(high, k_windows[i]) cache_dict[h] = roll_min, roll_max return cache_dict