def repeat(df, s, on: str, repeat: int) -> ReturnType: result = df.exec(on)[s] if repeat == 1: return result, repeat return rolling_calc(result, repeat, np.all, False, 1), repeat
def increase(df, s, on: str, repeat: int, direction: int) -> ReturnType: period = repeat + 1 current = NEGATIVE_INFINITY if direction == 1 else POSITIVE_INFINITY compare = partial(check_increase, direction, current) return rolling_calc(df.exec(on)[s], period, compare, False), period
def calc_ma( array: np.ndarray, period: int ) -> np.ndarray: """Calculates N-period Simple Moving Average """ return rolling_calc(array, period, np.mean)
def boll_band(upper: bool, df, s, period, times, column) -> ReturnType: """Gets the upper band or the lower band of bolinger bands Args: upper (bool): Get the upper band if True else the lower band """ prices = df[column][s].to_numpy() ma = df.exec(f'ma:{period},{column}')[s] mstd = rolling_calc(prices, period, np.std) if upper: return np.add(ma, np.multiply(times, mstd)), period else: return np.subtract(ma, np.multiply(times, mstd)), period
def hhv(df, s, period, column) -> ReturnType: """Gets HHV (Highest of High Value) """ return rolling_calc(df.get_column(column)[s].to_numpy(), period, max), period
def llv(df, s, period, column) -> ReturnType: """Gets LLV (Lowest of Low Value) """ return rolling_calc(df.get_column(column)[s].to_numpy(), period, min), period