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


Python talib.STOCHF属性代码示例

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


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

示例1: STOCHF

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def STOCHF(DataFrame, fastk_period=5, fastd_period=3, fastd_matype=0):
    fastk, fastd = talib.STOCHF(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values,
                               fastk_period, fastd_period, fastd_matype)
    return pd.DataFrame({'STOCHF_FASTK': fastk, 'STOCHF_FASTD': fastd}, index=DataFrame.index) 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:6,代码来源:talib_indicators.py

示例2: __str__

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

示例3: results

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def results(self, data_frame):
        try:
            fastk, fastd = talib.STOCHF(data_frame['%s_High' %self.symbol].values,
                                        data_frame['%s_Low' %self.symbol].values,
                                        data_frame['%s_Close' %self.symbol].values,
                                        self.fast_k_period, self.fast_d_period,
                                        self.fast_d_ma_type)
            data_frame[self.fastk] = fastk
            data_frame[self.fastd] = fastd
        except KeyError:
            data_frame[self.fastk] = np.nan
            data_frame[self.fastd] = np.nan 
开发者ID:edouardpoitras,项目名称:NowTrade,代码行数:14,代码来源:technical_indicator.py

示例4: add_STOCHF

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def add_STOCHF(self, fastk_period=5, fastd_period=3, fastd_matype=0,
               types=['line', 'line'],
               colors=['primary', 'tertiary'],
               **kwargs):
    """Fast Stochastic Oscillator.

    Note that the first argument of types and colors refers to Fast Stoch %K,
    while second argument refers to Fast Stoch %D
    (signal line of %K obtained by MA).

    """
    if not (self.has_high and self.has_low and 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']] * 2
    if 'color' in kwargs:
        colors = [kwargs['color']] * 2

    name = 'STOCHF({},{})'.format(str(fastk_period),
                                  str(fastd_period))
    fastk = name + r'[%k]'
    fastd = name + r'[%d]'
    self.sec[fastk] = dict(type=types[0], color=colors[0])
    self.sec[fastd] = dict(type=types[1], color=colors[1], on=fastk)
    self.ind[fastk], self.ind[fastd] = talib.STOCHF(self.df[self.hi].values,
                                                    self.df[self.lo].values,
                                                    self.df[self.cl].values,
                                                    fastk_period, fastd_period,
                                                    fastd_matype) 
开发者ID:plotly,项目名称:dash-technical-charting,代码行数:38,代码来源:ta.py

示例5: stochf

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def stochf(candles: np.ndarray, fastk_period=5, fastd_period=3, fastd_matype=0, sequential=False) -> StochasticFast:
    """
    Stochastic Fast

    :param candles: np.ndarray
    :param fastk_period: int - default=5
    :param fastd_period: int - default=3
    :param fastd_matype: int - default=0
    :param sequential: bool - default=False

    :return: StochasticFast(k, d)
    """
    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    k, d = talib.STOCHF(
        candles[:, 3],
        candles[:, 4],
        candles[:, 2],
        fastk_period=fastk_period,
        fastd_period=fastd_period,
        fastd_matype=fastd_matype
    )

    if sequential:
        return StochasticFast(k, d)
    else:
        return StochasticFast(k[-1], d[-1]) 
开发者ID:jesse-ai,项目名称:jesse,代码行数:30,代码来源:stochf.py

示例6: STOCHF

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def STOCHF(frame, fastk=5, fastd=3, fastd_matype=0, high_col='high', low_col='low', close_col='close'):
    return _frame_to_frame(frame, [high_col, low_col, close_col], ['FAST_K', 'FAST_D'], talib.STOCHF, fastk, fastd,
                           fastd_matype) 
开发者ID:bpsmith,项目名称:tia,代码行数:5,代码来源:talib_wrapper.py

示例7: test_stoch

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def test_stoch(self):
        result = pandas_ta.stoch(self.high, self.low, self.close, fast_k=14, slow_k=14, slow_d=14)
        self.assertIsInstance(result, DataFrame)
        self.assertEqual(result.name, 'STOCH_14_14_14')
        self.assertEqual(len(result.columns), 4)

        result = pandas_ta.stoch(self.high, self.low, self.close)
        self.assertIsInstance(result, DataFrame)
        self.assertEqual(result.name, 'STOCH_14_5_3')

        try:
            tal_stochf = tal.STOCHF(self.high, self.low, self.close)
            tal_stoch = tal.STOCH(self.high, self.low, self.close)
            tal_stochdf = DataFrame({'STOCHF_14': tal_stochf[0], 'STOCHF_3': tal_stochf[1], 'STOCH_5': tal_stoch[0], 'STOCH_3': tal_stoch[1]})
            pdt.assert_frame_equal(result, tal_stochdf)
        except AssertionError as ae:
            try:
                stochfk_corr = pandas_ta.utils.df_error_analysis(result.iloc[:,0], tal_stochdf.iloc[:,0], col=CORRELATION)
                self.assertGreater(stochfk_corr, CORRELATION_THRESHOLD)
            except Exception as ex:
                error_analysis(result.iloc[:,0], CORRELATION, ex)

            try:
                stochfd_corr = pandas_ta.utils.df_error_analysis(result.iloc[:,1], tal_stochdf.iloc[:,1], col=CORRELATION)
                self.assertGreater(stochfd_corr, CORRELATION_THRESHOLD)
            except Exception as ex:
                error_analysis(result.iloc[:,1], CORRELATION, ex, newline=False)

            try:
                stochsk_corr = pandas_ta.utils.df_error_analysis(result.iloc[:,2], tal_stochdf.iloc[:,2], col=CORRELATION)
                self.assertGreater(stochsk_corr, CORRELATION_THRESHOLD)
            except Exception as ex:
                error_analysis(result.iloc[:,2], CORRELATION, ex, newline=False)

            try:
                stochsd_corr = pandas_ta.utils.df_error_analysis(result.iloc[:,3], tal_stochdf.iloc[:,3], col=CORRELATION)
                self.assertGreater(stochsd_corr, CORRELATION_THRESHOLD)
            except Exception as ex:
                error_analysis(result.iloc[:,3], CORRELATION, ex, newline=False) 
开发者ID:twopirllc,项目名称:pandas-ta,代码行数:41,代码来源:test_indicator_momentum.py

示例8: STOCHF

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

示例9: test_fso_expected_with_talib

# 需要导入模块: import talib [as 别名]
# 或者: from talib import STOCHF [as 别名]
def test_fso_expected_with_talib(self, seed):
        """
        Test the output that is returned from the fast stochastic oscillator
        is the same as that from the ta-lib STOCHF function.
        """
        window_length = 14
        nassets = 6
        rng = np.random.RandomState(seed=seed)

        input_size = (window_length, nassets)

        # values from 9 to 12
        closes = 9.0 + (rng.random_sample(input_size) * 3.0)

        # Values from 13 to 15
        highs = 13.0 + (rng.random_sample(input_size) * 2.0)

        # Values from 6 to 8.
        lows = 6.0 + (rng.random_sample(input_size) * 2.0)

        expected_out_k = []
        for i in range(nassets):
            fastk, fastd = talib.STOCHF(
                high=highs[:, i],
                low=lows[:, i],
                close=closes[:, i],
                fastk_period=window_length,
                fastd_period=1,
            )

            expected_out_k.append(fastk[-1])
        expected_out_k = np.array(expected_out_k)

        today = pd.Timestamp('2015')
        out = np.empty(shape=(nassets,), dtype=np.float)
        assets = np.arange(nassets, dtype=np.float)

        fso = FastStochasticOscillator()
        fso.compute(
            today, assets, out, closes, lows, highs
        )

        assert_equal(out, expected_out_k, array_decimal=6) 
开发者ID:enigmampc,项目名称:catalyst,代码行数:45,代码来源:test_technical.py


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