当前位置: 首页>>代码示例>>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;未经允许,请勿转载。