예제 #1
0
파일: nb.py 프로젝트: vroomzel/vectorbt
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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