예제 #1
0
파일: dpo.py 프로젝트: noenfugler/jesse-1
def dpo(candles: np.ndarray, period: int = 5, source_type: str = "close", sequential: bool = False) -> Union[
    float, np.ndarray]:
    """
    DPO - Detrended Price Oscillator

    :param candles: np.ndarray
    :param period: int - default: 5
    :param source_type: str - default: "close"
    :param sequential: bool - default=False

    :return: float | np.ndarray
    """
    candles = slice_candles(candles, sequential)

    source = get_candle_source(candles, source_type=source_type)
    res = ti.dpo(np.ascontiguousarray(source), period=period)

    return same_length(candles, res) if sequential else res[-1]
예제 #2
0
def dpo(candles: np.ndarray,
        period: int = 5,
        source_type: str = "close",
        sequential: bool = False) -> Union[float, np.ndarray]:
    """
    DPO - Detrended Price Oscillator

    :param candles: np.ndarray
    :param period: int - default: 5
    :param source_type: str - default: "close"
    :param sequential: bool - default=False

    :return: float | np.ndarray
    """
    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    source = get_candle_source(candles, source_type=source_type)
    res = ti.dpo(np.ascontiguousarray(source), period=period)

    return np.concatenate(
        (np.full((candles.shape[0] - res.shape[0]), np.nan),
         res), axis=0) if sequential else res[-1]
예제 #3
0
    def compute(self, data_dict):
        close = data_dict.get('close')

        return ti.dpo(close, self.per)