当前位置: 首页>>代码示例>>Python>>正文


Python talib.MACDEXT属性代码示例

本文整理汇总了Python中talib.MACDEXT属性的典型用法代码示例。如果您正苦于以下问题:Python talib.MACDEXT属性的具体用法?Python talib.MACDEXT怎么用?Python talib.MACDEXT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在talib的用法示例。


在下文中一共展示了talib.MACDEXT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MACDEXT

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MACDEXT [as 别名]
def MACDEXT(Series, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0):
    macd, macdsignal, macdhist = talib.MACDEXT(
        Series.values, fastperiod, fastmatype, slowperiod, slowmatype, signalperiod, signalmatype)
    return pd.Series(macd, index=Series.index), pd.Series(macdsignal, index=Series.index), pd.Series(macdhist, index=Series.index) 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:6,代码来源:talib_series.py

示例2: macdext

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MACDEXT [as 别名]
def macdext(candles: np.ndarray, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9,
            signalmatype=0, source_type="close", sequential=False) -> MACDEXT:
    """
    MACDEXT - MACD with controllable MA type

    :param candles: np.ndarray
    :param fastperiod: int - default: 12
    :param fastmatype: int - default: 0
    :param slow_period: int - default: 26
    :param slowmatype: int - default: 0
    :param signal_period: int - default: 9
    :param signalmatype: int - default: 0
    :param source_type: str - default: "close"
    :param sequential: bool - default: False

    :return: MACDEXT(macd, signal, hist)
    """
    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    source = get_candle_source(candles, source_type=source_type)
    macd, macdsignal, macdhist = talib.MACDEXT(source, fastperiod=fastperiod, fastmatype=fastmatype,
                                               slowperiod=slowperiod, slowmatype=slowmatype,
                                               signalperiod=signalperiod, signalmatype=signalmatype)

    if sequential:
        return MACDEXT(macd, macdsignal, macdhist)
    else:
        return MACDEXT(macd[-1], macdsignal[-1], macdhist[-1]) 
开发者ID:jesse-ai,项目名称:jesse,代码行数:31,代码来源:macdext.py

示例3: MACDEXT

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MACDEXT [as 别名]
def MACDEXT(data, **kwargs):
    _check_talib_presence()
    prices = _extract_series(data)
    return talib.MACDEXT(prices, **kwargs) 
开发者ID:ranaroussi,项目名称:qtpylib,代码行数:6,代码来源:talib_indicators.py

示例4: __recountMacd

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MACDEXT [as 别名]
def __recountMacd(self):
        """
        Macd计算方法:
        12日EMA的计算:EMA12 = 前一日EMA12 X 11/13 + 今日收盘 X 2/13
        26日EMA的计算:EMA26 = 前一日EMA26 X 25/27 + 今日收盘 X 2/27
        差离值(DIF)的计算: DIF = EMA12 - EMA26,即为talib-MACD返回值macd
        根据差离值计算其9日的EMA,即离差平均值,是所求的DEA值。
        今日DEA = (前一日DEA X 8/10 + 今日DIF X 2/10),即为talib-MACD返回值signal
        DIF与它自己的移动平均之间差距的大小一般BAR=(DIF-DEA)*2,即为MACD柱状图。
        但是talib中MACD的计算是bar = (dif-dea)*1
        """

        if self.inputMacdFastPeriodLen <= EMPTY_INT: return
        if self.inputMacdSlowPeriodLen <= EMPTY_INT: return
        if self.inputMacdSignalPeriodLen <= EMPTY_INT: return

        maxLen = max(self.inputMacdFastPeriodLen,self.inputMacdSlowPeriodLen)+self.inputMacdSignalPeriodLen+1

        #maxLen = maxLen * 3             # 注:数据长度需要足够,才能准确。测试过,3倍长度才可以与国内的文华等软件一致

        if len(self.lineBar) < maxLen:
            self.debugCtaLog(u'数据未充分,当前Bar数据数量:{0},计算MACD需要:{1}'.format(len(self.lineBar), maxLen))
            return

        if self.mode == self.TICK_MODE:
            listClose =[x.close for x in self.lineBar[-maxLen:-1]]
        else:
            listClose =[x.close for x in self.lineBar[-maxLen-1:]]

        dif, dea, macd = ta.MACD(np.array(listClose, dtype=float), fastperiod=self.inputMacdFastPeriodLen,
                       slowperiod=self.inputMacdSlowPeriodLen, signalperiod=self.inputMacdSignalPeriodLen)

        #dif, dea, macd = ta.MACDEXT(np.array(listClose, dtype=float),
        #                            fastperiod=self.inputMacdFastPeriodLen, fastmatype=1,
        #                            slowperiod=self.inputMacdSlowPeriodLen, slowmatype=1,
        #                            signalperiod=self.inputMacdSignalPeriodLen, signalmatype=1)

        if len(self.lineDif) > maxLen:
            del self.lineDif[0]
        self.lineDif.append(dif[-1])

        if len(self.lineDea) > maxLen:
            del self.lineDea[0]
        self.lineDea.append(dea[-1])

        if len(self.lineMacd) > maxLen:
            del self.lineMacd[0]
        self.lineMacd.append(macd[-1]*2)            # 国内一般是2倍 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:50,代码来源:ctaLineBar.py

示例5: add_MACDEXT

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MACDEXT [as 别名]
def add_MACDEXT(self, fastperiod=12, fastmatype=0,
                slowperiod=26, slowmatype=0,
                signalperiod=9, signalmatype=0,
                types=['line', 'line', 'histogram'],
                colors=['primary', 'tertiary', 'fill'],
                **kwargs):
    """Moving Average Convergence Divergence with Controllable MA Type.

    Note that the first argument of types and colors refers to MACD,
    the second argument refers to MACD signal line and the third argument
    refers to MACD histogram.

    """
    if not self.has_close:
        raise Exception()

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

    if 'type' in kwargs:
        types = [kwargs['type']] * 3
    if 'color' in kwargs:
        colors = [kwargs['color']] * 3

    name = 'MACDEXT({},{},{})'.format(str(fastperiod),
                                      str(slowperiod),
                                      str(signalperiod))
    macd = name
    smacd = name + '[Sign]'
    hmacd = name + '[Hist]'
    self.sec[macd] = dict(type=types[0], color=colors[0])
    self.sec[smacd] = dict(type=types[1], color=colors[1], on=macd)
    self.sec[hmacd] = dict(type=types[2], color=colors[2], on=macd)
    (self.ind[macd],
     self.ind[smacd],
     self.ind[hmacd]) = talib.MACDEXT(self.df[self.cl].values,
                                      fastperiod, fastmatype,
                                      slowperiod, slowmatype,
                                      signalperiod, signalmatype) 
开发者ID:plotly,项目名称:dash-technical-charting,代码行数:44,代码来源:ta.py


注:本文中的talib.MACDEXT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。