Exemple #1
0
 def ewm_std(self, span, minp=0, adjust=True, ddof=1):  # pragma: no cover
     return self.wrap(
         nb.ewm_std_nb(self.to_2d_array(),
                       span,
                       minp=minp,
                       adjust=adjust,
                       ddof=ddof))
Exemple #2
0
 def ewm_std(self, span, minp=0, adjust=True, ddof=1):  # pragma: no cover
     """See `vectorbt.generic.nb.ewm_std_nb`."""
     return self.wrap(
         nb.ewm_std_nb(self.to_2d_array(),
                       span,
                       minp=minp,
                       adjust=adjust,
                       ddof=ddof))
Exemple #3
0
def mstd_nb(a, window, ewm, adjust=False, ddof=0):
    """Compute simple or exponential moving STD (`ewm=True`)."""
    if ewm:
        return generic_nb.ewm_std_nb(a,
                                     window,
                                     minp=window,
                                     adjust=adjust,
                                     ddof=ddof)
    return generic_nb.rolling_std_nb(a, window, minp=window, ddof=ddof)
Exemple #4
0
def future_std_apply_nb(close, window, ewm, wait=1, adjust=False, ddof=0):
    """Get the standard deviation of the next period."""
    if ewm:
        out = generic_nb.ewm_std_nb(close[::-1], window, minp=window, adjust=adjust, ddof=ddof)[::-1]
    else:
        out = generic_nb.rolling_std_nb(close[::-1], window, minp=window, ddof=ddof)[::-1]
    if wait > 0:
        return generic_nb.bshift_nb(out, wait)
    return out
Exemple #5
0
def mstd_caching_nb(ts, windows, ewms):
    """Caching function for `vectorbt.indicators.basic.MSTD`."""
    cache_dict = dict()
    for i in range(windows.shape[0]):
        h = hash((windows[i], ewms[i]))
        if h not in cache_dict:
            if ewms[i]:
                mstd = generic_nb.ewm_std_nb(ts, windows[i])
            else:
                mstd = generic_nb.rolling_std_nb(ts, windows[i])
            cache_dict[h] = mstd
    return cache_dict
Exemple #6
0
def mstd_nb(a: tp.Array2d,
            window: int,
            ewm: int,
            adjust: bool = False,
            ddof: int = 0) -> tp.Array2d:
    """Compute simple or exponential moving STD (`ewm=True`)."""
    if ewm:
        return generic_nb.ewm_std_nb(a,
                                     window,
                                     minp=window,
                                     adjust=adjust,
                                     ddof=ddof)
    return generic_nb.rolling_std_nb(a, window, minp=window, ddof=ddof)
Exemple #7
0
def future_std_apply_nb(close: tp.Array2d,
                        window: int,
                        ewm: bool,
                        wait: int = 1,
                        adjust: bool = False,
                        ddof: int = 0) -> tp.Array2d:
    """Get the standard deviation of the next period."""
    if ewm:
        out = generic_nb.ewm_std_nb(close[::-1],
                                    window,
                                    minp=window,
                                    adjust=adjust,
                                    ddof=ddof)[::-1]
    else:
        out = generic_nb.rolling_std_nb(close[::-1],
                                        window,
                                        minp=window,
                                        ddof=ddof)[::-1]
    if wait > 0:
        return generic_nb.bshift_nb(out, wait)
    return out