當前位置: 首頁>>代碼示例>>Python>>正文


Python talib.KAMA屬性代碼示例

本文整理匯總了Python中talib.KAMA屬性的典型用法代碼示例。如果您正苦於以下問題:Python talib.KAMA屬性的具體用法?Python talib.KAMA怎麽用?Python talib.KAMA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在talib的用法示例。


在下文中一共展示了talib.KAMA屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getKamas

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def getKamas(df, mas, dropna=True):
        """
            獲取周期內的考夫曼均價
            @mas: [5, 10, 20, 30, 60, ...]
        """
        if df is None:
            return pd.DataFrame([])

        means = {}
        names = []
        for ma in mas:
            mean = talib.KAMA(df['close'].values, ma)
            name = 'kama%s'%ma
            
            means[name] = mean
            names.append(name)

        df = pd.DataFrame(means, index=df.index, columns=names)

        return df.dropna() if dropna else df 
開發者ID:moyuanz,項目名稱:DevilYuan,代碼行數:22,代碼來源:DyStockDataUtility.py

示例2: kama

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def kama(candles: np.ndarray, period=30, source_type="close", sequential=False) -> Union[float, np.ndarray]:
    """
    KAMA - Kaufman Adaptive Moving Average

    :param candles: np.ndarray
    :param period: int - default: 30
    :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 = talib.KAMA(source, timeperiod=period)

    return res if sequential else res[-1] 
開發者ID:jesse-ai,項目名稱:jesse,代碼行數:20,代碼來源:kama.py

示例3: TA_KAMA

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def TA_KAMA(close, timeperiod=30):
    """
    請直接用 talib.KAMA(close, timeperiod)
    KAMA - Kaufman Adaptive Moving Average
    """
    real = talib.KAMA(close, timeperiod=timeperiod)
    return np.c_[real] 
開發者ID:QUANTAXIS,項目名稱:QUANTAXIS,代碼行數:9,代碼來源:talib_numpy.py

示例4: KAMA

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def KAMA(Series, timeperiod=30):
    res = talib.KAMA(Series.values, timeperiod)
    return pd.Series(res, index=Series.index) 
開發者ID:QUANTAXIS,項目名稱:QUANTAXIS,代碼行數:5,代碼來源:talib_series.py

示例5: KAMA

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def KAMA(data, **kwargs):
    _check_talib_presence()
    prices = _extract_series(data)
    return talib.KAMA(prices, **kwargs) 
開發者ID:ranaroussi,項目名稱:qtpylib,代碼行數:6,代碼來源:talib_indicators.py

示例6: predict

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def predict(self, obs):
        """
        Performs prediction given environment observation
        """
        prices = obs.xs('open', level=1, axis=1).astype(np.float64)
        mu = prices.apply(tl.KAMA, timeperiod=self.window, raw=True).iloc[-1].values

        price_relative = np.append(safe_div(mu, prices.iloc[-1].values) - 1, [0.0])

        return price_relative 
開發者ID:naripok,項目名稱:cryptotrader,代碼行數:12,代碼來源:apriori.py

示例7: add_KAMA

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def add_KAMA(self, timeperiod=20,
             type='line', color='secondary', **kwargs):
    """Kaufmann Adaptive Moving Average."""

    if not self.has_close:
        raise Exception()

    utils.kwargs_check(kwargs, VALID_TA_KWARGS)
    if 'kind' in kwargs:
        type = kwargs['kind']

    name = 'KAMA({})'.format(str(timeperiod))
    self.pri[name] = dict(type=type, color=color)
    self.ind[name] = talib.KAMA(self.df[self.cl].values,
                                timeperiod) 
開發者ID:plotly,項目名稱:dash-technical-charting,代碼行數:17,代碼來源:ta.py

示例8: test_kama

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def test_kama():
    '''test TA.KAMA'''

    ma = TA.KAMA(ohlc, period=30)
    talib_ma = talib.KAMA(ohlc['close'], timeperiod=30)

    # assert round(talib_ma[-1], 5) == round(ma.values[-1], 5)
    # assert 1519.60321 == 1524.26954
    pass  # close enough 
開發者ID:peerchemist,項目名稱:finta,代碼行數:11,代碼來源:test_reg.py

示例9: KAMA

# 需要導入模塊: import talib [as 別名]
# 或者: from talib import KAMA [as 別名]
def KAMA(series, n=30):
    """Kaufman Adaptive Moving Average"""
    return _series_to_series(series, talib.KAMA, n) 
開發者ID:bpsmith,項目名稱:tia,代碼行數:5,代碼來源:talib_wrapper.py


注:本文中的talib.KAMA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。