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


Python talib.MOM属性代码示例

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


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

示例1: acosc

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def acosc(candles: np.ndarray, sequential=False) -> AC:
    """
    Acceleration / Deceleration Oscillator (AC)

    :param candles: np.ndarray
    :param sequential: bool - default=False

    :return: AC(osc, change)
    """
    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    med = talib.MEDPRICE(candles[:, 3], candles[:, 4])
    ao = talib.SMA(med, 5) - talib.SMA(med, 34)

    res = ao - talib.SMA(ao, 5)
    mom = talib.MOM(res, timeperiod=1)

    if sequential:
        return AC(res, mom)
    else:
        return AC(res[-1], mom[-1]) 
开发者ID:jesse-ai,项目名称:jesse,代码行数:24,代码来源:acosc.py

示例2: ao

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def ao(candles: np.ndarray, sequential=False) -> AO:
    """
    Awesome Oscillator

    :param candles: np.ndarray
    :param sequential: bool - default=False

    :return: AO(osc, change)
    """
    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    med = talib.MEDPRICE(candles[:, 3], candles[:, 4])
    res = talib.SMA(med, 5) - talib.SMA(med, 34)

    mom = talib.MOM(res, timeperiod=1)

    if sequential:
        return AO(res, mom)
    else:
        return AO(res[-1], mom[-1]) 
开发者ID:jesse-ai,项目名称:jesse,代码行数:23,代码来源:ao.py

示例3: tsi

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def tsi(candles: np.ndarray, long_period=25, short_period=13, source_type="close", sequential=False) -> Union[
    float, np.ndarray]:
    """
     True strength index (TSI)

    :param candles: np.ndarray
    :param long_period: int - default: 25
    :param short_period: int - default: 13
    :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)
    r = 100 * (talib.EMA((talib.EMA(talib.MOM(source, 1), long_period)), short_period)) / (
        talib.EMA((talib.EMA(np.absolute(talib.MOM(source, 1)), long_period)), short_period))

    return r if sequential else r[-1] 
开发者ID:jesse-ai,项目名称:jesse,代码行数:23,代码来源:tsi.py

示例4: mom

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def mom(candles: np.ndarray, period=10, source_type="close", sequential=False) -> Union[float, np.ndarray]:
    """
    MOM - Momentum

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

    if sequential:
        return res
    else:
        return None if np.isnan(res[-1]) else res[-1] 
开发者ID:jesse-ai,项目名称:jesse,代码行数:23,代码来源:mom.py

示例5: momentum

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def momentum(obs, period=14):
    prices = obs.xs('open', level=1, axis=1).astype(np.float64)
    # mean_volume = obs.xs('volume', level=1, axis=1).astype(np.float64).apply(lambda x: safe_div(x[-period:-1].sum(),
    #                                                                     x[-int(2 * period):-period].sum()), raw=True)
    mom = prices.apply(ta.MOM, timeperiod=period, raw=True).fillna(0.0)
    return 1 + safe_div(mom, prices.iloc[-period])# * mean_volume 
开发者ID:naripok,项目名称:cryptotrader,代码行数:8,代码来源:apriori.py

示例6: mom

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def mom(self, sym, frequency, period=5):
        if not self.kbars_ready(sym, frequency):
            return []

        closes = self.close(sym, frequency)

        mom = ta.MOM(closes, timeperiod=period)
        return mom 
开发者ID:myquant,项目名称:strategy,代码行数:10,代码来源:ta_indicator_mixin.py

示例7: test_indicator_MOM

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def test_indicator_MOM(self):
        n = 3
        price = 'Close'
        result = MOM(df, n)
        isinstance(result, pd.DataFrame)
        expected = talib.MOM(df[price].values, timeperiod=n)
        np.testing.assert_almost_equal(result.values, expected) 
开发者ID:femtotrader,项目名称:pandas_talib,代码行数:9,代码来源:test_pandas_talib.py

示例8: add_MOM

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def add_MOM(self, timeperiod=10,
            type='line', color='secondary', **kwargs):
    """Momentum Indicator."""

    if not self.has_close:
        raise Exception()

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

    name = 'MOM({})'.format(str(timeperiod))
    self.sec[name] = dict(type=type, color=color)
    self.ind[name] = talib.MOM(self.df[self.cl].values,
                               timeperiod) 
开发者ID:plotly,项目名称:dash-technical-charting,代码行数:17,代码来源:ta.py

示例9: gatorosc

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def gatorosc(candles: np.ndarray, source_type="close", sequential=False) -> GATOR:
    """
    Gator Oscillator by Bill M. Williams

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

    :return: GATOR(upper, lower, upper_change, lower_change)
    """

    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    source = get_candle_source(candles, source_type=source_type)

    jaw = shift(numpy_ewma(source, 13), 8)
    teeth = shift(numpy_ewma(source, 8), 5)
    lips = shift(numpy_ewma(source, 5), 3)

    upper = np.abs(jaw - teeth)
    lower = -np.abs(teeth - lips)

    upper_change = talib.MOM(upper, timeperiod=1)
    lower_change = -talib.MOM(lower, timeperiod=1)

    if sequential:
        return GATOR(upper, lower, upper_change, lower_change)
    else:
        return GATOR(upper[-1], lower[-1], upper_change[-1], lower_change[-1])


# preallocate empty array and assign slice by chrisaycock 
开发者ID:jesse-ai,项目名称:jesse,代码行数:35,代码来源:gatorosc.py

示例10: test_mom

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def test_mom():
    '''test TA.MOM'''

    mom = TA.MOM(ohlc, 15)
    talib_mom = talib.MOM(ohlc['close'], 15)

    assert round(talib_mom[-1], 5) == round(mom.values[-1], 5) 
开发者ID:peerchemist,项目名称:finta,代码行数:9,代码来源:test_reg.py

示例11: MOM

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def MOM(series, n=10):
    return _series_to_series(series, talib.MOM, n) 
开发者ID:bpsmith,项目名称:tia,代码行数:4,代码来源:talib_wrapper.py

示例12: test_mom

# 需要导入模块: import talib [as 别名]
# 或者: from talib import MOM [as 别名]
def test_mom(self):
        result = pandas_ta.mom(self.close)
        self.assertIsInstance(result, Series)
        self.assertEqual(result.name, 'MOM_10')

        try:
            expected = tal.MOM(self.close)
            pdt.assert_series_equal(result, expected, check_names=False)
        except AssertionError as ae:
            try:
                corr = pandas_ta.utils.df_error_analysis(result, expected, col=CORRELATION)
                self.assertGreater(corr, CORRELATION_THRESHOLD)
            except Exception as ex:
                error_analysis(result, CORRELATION, ex) 
开发者ID:twopirllc,项目名称:pandas-ta,代码行数:16,代码来源:test_indicator_momentum.py

示例13: MOM

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


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