當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。