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