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


Python talib.RSI属性代码示例

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


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

示例1: onInit

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def onInit(self):
        """初始化策略(必须由用户继承实现)"""
        self.writeCtaLog(u'%s策略初始化' %self.name)
    
        # 初始化RSI入场阈值
        self.rsiBuy = 50 + self.rsiEntry
        self.rsiSell = 50 - self.rsiEntry

        # 载入历史数据,并采用回放计算的方式初始化策略数值
        initData = self.loadBar(self.initDays)
        for bar in initData:
            self.onBar(bar)

        self.putEvent()

    #---------------------------------------------------------------------- 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:strategyAtrRsi.py

示例2: rsi

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def rsi(candles: np.ndarray, period=14, source_type="close", sequential=False) -> Union[float, np.ndarray]:
    """
    RSI - Relative Strength Index

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

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

示例3: TA_MACD

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def TA_MACD(prices:np.ndarray, 
            fastperiod:int=12, 
            slowperiod:int=26, 
            signalperiod:int=9) -> np.ndarray:
    '''
    参数设置:
        fastperiod = 12
        slowperiod = 26
        signalperiod = 9

    返回: macd - dif, signal - dea, hist * 2 - bar, delta
    '''
    macd, signal, hist = talib.MACD(prices, 
                                    fastperiod=fastperiod, 
                                    slowperiod=slowperiod, 
                                    signalperiod=signalperiod)
    hist = (macd - signal) * 2
    delta = np.r_[np.nan, np.diff(hist)]
    return np.c_[macd, signal, hist, delta]


# 定义RSI函数 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:24,代码来源:talib_numpy.py

示例4: isBuy

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def isBuy(context, analysis):
    # Bullish SMA Crossover
    if (getLast(analysis, 'sma_test') == 1):
        # Bullish MACD
        if (getLast(analysis, 'macd_test') == 1):
            return True

    # # Bullish Stochastics
    # if(getLast(analysis, 'stoch_over_sold') == 1):
    #     return True

    # # Bullish RSI
    # if(getLast(analysis, 'rsi_over_sold') == 1):
    #     return True

    return False 
开发者ID:enigmampc,项目名称:catalyst,代码行数:18,代码来源:talib_simple.py

示例5: isSell

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def isSell(context, analysis):
    # Bearish SMA Crossover
    if (getLast(analysis, 'sma_test') == 0):
        # Bearish MACD
        if (getLast(analysis, 'macd_test') == 0):
            return True

    # # Bearish Stochastics
    # if(getLast(analysis, 'stoch_over_bought') == 0):
    #     return True

    # # Bearish RSI
    # if(getLast(analysis, 'rsi_over_bought') == 0):
    #     return True

    return False 
开发者ID:enigmampc,项目名称:catalyst,代码行数:18,代码来源:talib_simple.py

示例6: annotate_data

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def annotate_data(self, feed, timeframe):
        # Get SMAs
        for k, v in six.iteritems(self.sma_intervals):
            feed[k] = talib.SMA(feed['closeMid'].values, v)

        # Get MACD
        # NOTE: talib.MACD() returns (macd, signal, hist)
        feed['macd'], _, feed['macd_hist'] = talib.MACD(
            feed['closeMid'].values,
            fastperiod=12,
            slowperiod=26,
            signalperiod=9
        )

        # Get RSI
        feed['rsi'] = talib.RSI(feed['closeMid'].values)
        return feed 
开发者ID:jmelett,项目名称:pyfx,代码行数:19,代码来源:new_strategy.py

示例7: TA_RSI

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def TA_RSI(prices:np.ndarray, 
           timeperiod:int=12) -> np.ndarray:
    '''
    参数设置:
        timeperiod = 12

    返回: ma
    '''
    rsi = talib.RSI(prices, timeperiod=timeperiod)
    delta = np.r_[np.nan, np.diff(rsi)]
    return np.c_[rsi, delta]


# 定义RSI函数 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:16,代码来源:talib_numpy.py

示例8: rsi

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def rsi(self, sym, frequency, *args, **kwargs):
        if not self.kbars_ready(sym, frequency):
            return []

        highs = self.high(sym, frequency)
        lows = self.low(sym, frequency)
        closes = self.close(sym, frequency)

        avg_prices = (highs + lows + closes) / 3.0

        return ta.RSI(avg_prices, *args, **kwargs) 
开发者ID:myquant,项目名称:strategy,代码行数:13,代码来源:ta_indicator_mixin.py

示例9: __str__

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def __str__(self):
        return 'RSI(data=%s, period=%s)' %(self.data, self.period) 
开发者ID:edouardpoitras,项目名称:NowTrade,代码行数:4,代码来源:technical_indicator.py

示例10: results

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def results(self, data_frame):
        try:
            data_frame[self.value] = talib.RSI(data_frame[self.data].values, timeperiod=self.period)
        except KeyError:
            data_frame[self.value] = np.nan 
开发者ID:edouardpoitras,项目名称:NowTrade,代码行数:7,代码来源:technical_indicator.py

示例11: technical_indicators_df

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def technical_indicators_df(self, daily_data):
        """
        Assemble a dataframe of technical indicator series for a single stock
        """
        o = daily_data['Open'].values
        c = daily_data['Close'].values
        h = daily_data['High'].values
        l = daily_data['Low'].values
        v = daily_data['Volume'].astype(float).values
        # define the technical analysis matrix

        # Most data series are normalized by their series' mean
        ta = pd.DataFrame()
        ta['MA5'] = tb.MA(c, timeperiod=5) / tb.MA(c, timeperiod=5).mean()
        ta['MA10'] = tb.MA(c, timeperiod=10) / tb.MA(c, timeperiod=10).mean()
        ta['MA20'] = tb.MA(c, timeperiod=20) / tb.MA(c, timeperiod=20).mean()
        ta['MA60'] = tb.MA(c, timeperiod=60) / tb.MA(c, timeperiod=60).mean()
        ta['MA120'] = tb.MA(c, timeperiod=120) / tb.MA(c, timeperiod=120).mean()
        ta['MA5'] = tb.MA(v, timeperiod=5) / tb.MA(v, timeperiod=5).mean()
        ta['MA10'] = tb.MA(v, timeperiod=10) / tb.MA(v, timeperiod=10).mean()
        ta['MA20'] = tb.MA(v, timeperiod=20) / tb.MA(v, timeperiod=20).mean()
        ta['ADX'] = tb.ADX(h, l, c, timeperiod=14) / tb.ADX(h, l, c, timeperiod=14).mean()
        ta['ADXR'] = tb.ADXR(h, l, c, timeperiod=14) / tb.ADXR(h, l, c, timeperiod=14).mean()
        ta['MACD'] = tb.MACD(c, fastperiod=12, slowperiod=26, signalperiod=9)[0] / \
                     tb.MACD(c, fastperiod=12, slowperiod=26, signalperiod=9)[0].mean()
        ta['RSI'] = tb.RSI(c, timeperiod=14) / tb.RSI(c, timeperiod=14).mean()
        ta['BBANDS_U'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[0] / \
                         tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[0].mean()
        ta['BBANDS_M'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1] / \
                         tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1].mean()
        ta['BBANDS_L'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2] / \
                         tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2].mean()
        ta['AD'] = tb.AD(h, l, c, v) / tb.AD(h, l, c, v).mean()
        ta['ATR'] = tb.ATR(h, l, c, timeperiod=14) / tb.ATR(h, l, c, timeperiod=14).mean()
        ta['HT_DC'] = tb.HT_DCPERIOD(c) / tb.HT_DCPERIOD(c).mean()
        ta["High/Open"] = h / o
        ta["Low/Open"] = l / o
        ta["Close/Open"] = c / o

        self.ta = ta 
开发者ID:jiewwantan,项目名称:StarTrader,代码行数:42,代码来源:data_preprocessing.py

示例12: add_RSI

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def add_RSI(self, timeperiod=14,
            type='line', color='secondary', **kwargs):
    """Relative Strength Index."""

    if not self.has_close:
        raise Exception()

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

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

示例13: calculate_cmi_indicator

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def calculate_cmi_indicator(df):  # RSI

    cmi_period = 30
    cmi_ma_period = 10
    roc = df['close'].diff(cmi_period)
    h1 = ta.MAX(df['high'], cmi_period) - ta.MIN(df['low'], cmi_period)
    cmi = abs(roc / h1) * 100
    cmi_ma = ta.MA(cmi, cmi_ma_period)  # rolling.
    return cmi_ma 
开发者ID:ramoslin02,项目名称:51bitqunt,代码行数:11,代码来源:technical_indicators.py

示例14: rsi

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def rsi(self, n, array=False):
        """
        Relative Strenght Index (RSI).
        """
        result = talib.RSI(self.close, n)
        if array:
            return result
        return result[-1] 
开发者ID:ramoslin02,项目名称:51bitqunt,代码行数:10,代码来源:array_manager.py

示例15: rsi

# 需要导入模块: import talib [as 别名]
# 或者: from talib import RSI [as 别名]
def rsi(close, period=14):
    return talib.RSI(close, period) 
开发者ID:noda-sin,项目名称:ebisu,代码行数:4,代码来源:__init__.py


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