本文整理匯總了Python中talib.CCI屬性的典型用法代碼示例。如果您正苦於以下問題:Python talib.CCI屬性的具體用法?Python talib.CCI怎麽用?Python talib.CCI使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類talib
的用法示例。
在下文中一共展示了talib.CCI屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_CCI
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def add_CCI(self, timeperiod=14,
type='line', color='secondary', **kwargs):
"""Channel Commodity Index."""
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:
type = kwargs['kind']
name = 'CCI({})'.format(str(timeperiod))
self.sec[name] = dict(type=type, color=color)
self.ind[name] = talib.CCI(self.df[self.hi].values,
self.df[self.lo].values,
self.df[self.cl].values,
timeperiod)
示例2: cci
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def cci(candles: np.ndarray, period=14, sequential=False) -> Union[float, np.ndarray]:
"""
CCI - Commodity Channel Index
:param candles: np.ndarray
:param period: int - default=14
:param sequential: bool - default=False
:return: float | np.ndarray
"""
if not sequential and len(candles) > 240:
candles = candles[-240:]
res = talib.CCI(candles[:, 3], candles[:, 4], candles[:, 2], timeperiod=period)
if sequential:
return res
else:
return None if np.isnan(res[-1]) else res[-1]
示例3: CCI
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def CCI(self, period: int, bars: list):
"""
Return CCI (Commodity Chanel Index) for n bars close price.
CCI = (Typical Price − MA) / 0.015 * Mean Deviation
where:
Typical Price = ∑P((H + L + C) / 3))
P = number of bars (period)
MA = Moving Average = (∑P Typical Price) / P
Mean Deviation=(∑P | Typical Price - MA |) / P
"""
self.check_bars_type(bars)
cci = ta.CCI(
bars['high'], bars['low'], bars['close'], timeperiod=period)
return cci
示例4: CCI
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def CCI(DataFrame, N=14):
res = talib.CCI(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)
return pd.DataFrame({'CCI': res}, index=DataFrame.index)
示例5: TA_CCI
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def TA_CCI(high:np.ndarray,
low:np.ndarray,
close:np.ndarray,
timeperiod:int=14) -> np.ndarray:
"""
名稱:平均趨向指數的趨向指數
簡介:使用CCI指標,指標判斷CCI趨勢。
CCI - Commodity Channel Index
"""
real = talib.CCI(high,
low,
close,
timeperiod=timeperiod)
delta = np.r_[np.nan, np.diff(real)]
return np.c_[real, delta]
示例6: cci
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def cci(self, sym, frequency, period=14):
if not self.kbars_ready(sym, frequency):
return []
highs = self.high(sym, frequency)
lows = self.low(sym, frequency)
closes = self.close(sym, frequency)
cci = ta.CCI(highs, lows, closes, timeperiod=period)
return cci
示例7: cci
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def cci(self, n, array=False):
"""
Commodity Channel Index (CCI).
"""
result = talib.CCI(self.high, self.low, self.close, n)
if array:
return result
return result[-1]
示例8: cci
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def cci(self, n, array=False):
"""CCI指標"""
result = talib.CCI(self.high, self.low, self.close, n)
if array:
return result
return result[-1]
# ----------------------------------------------------------------------
示例9: CCI
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def CCI(frame, n=14, high_col='high', low_col='low', close_col='close'):
return _frame_to_series(frame, [high_col, low_col, close_col], talib.CCI, n)
示例10: test_cci
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def test_cci(self):
result = pandas_ta.cci(self.high, self.low, self.close)
self.assertIsInstance(result, Series)
self.assertEqual(result.name, 'CCI_14_0.015')
try:
expected = tal.CCI(self.high, self.low, 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)
示例11: CCI
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def CCI(data, **kwargs):
_check_talib_presence()
_, phigh, plow, pclose, _ = _extract_ohlc(data)
return talib.CCI(phigh, plow, pclose, **kwargs)
示例12: __recountCci
# 需要導入模塊: import talib [as 別名]
# 或者: from talib import CCI [as 別名]
def __recountCci(self):
"""CCI計算
順勢指標又叫CCI指標,CCI指標是美國股市技術分析 家唐納德·藍伯特(Donald Lambert)於20世紀80年代提出的,專門測量股價、外匯或者貴金屬交易
是否已超出常態分布範圍。屬於超買超賣類指標中較特殊的一種。波動於正無窮大和負無窮大之間。但是,又不需要以0為中軸線,這一點也和波動於正無窮大
和負無窮大的指標不同。
它最早是用於期貨市場的判斷,後運用於股票市場的研判,並被廣泛使用。與大多數單一利用股票的收盤價、開盤價、最高價或最低價而發明出的各種技術分析
指標不同,CCI指標是根據統計學原理,引進價格與固定期間的股價平均區間的偏離程度的概念,強調股價平均絕對偏差在股市技術分析中的重要性,是一種比
較獨特的技術指標。
它與其他超買超賣型指標又有自己比較獨特之處。象KDJ、W%R等大多數超買超賣型指標都有“0-100”上下界限,因此,它們對待一般常態行情的研判比較適用
,而對於那些短期內暴漲暴跌的股票的價格走勢時,就可能會發生指標鈍化的現象。而CCI指標卻是波動於正無窮大到負無窮大之間,因此不會出現指標鈍化現
象,這樣就有利於投資者更好地研判行情,特別是那些短期內暴漲暴跌的非常態行情。
http://baike.baidu.com/view/53690.htm?fromtitle=CCI%E6%8C%87%E6%A0%87&fromid=4316895&type=syn
"""
if self.inputCciLen <= 0:
return
# 1、lineBar滿足長度才執行計算
if len(self.lineBar) < self.inputCciLen+2:
self.debugCtaLog(u'數據未充分,當前Bar數據數量:{0},計算CCI需要:{1}'.
format(len(self.lineBar), self.inputCciLen + 2))
return
# 計算第1根RSI曲線
# 3、inputCc1Len(包含當前周期)
if self.mode == self.TICK_MODE:
listClose = [x.close for x in self.lineBar[-self.inputCciLen - 2:-1]]
listHigh = [x.high for x in self.lineBar[-self.inputCciLen - 2:-1]]
listLow = [x.low for x in self.lineBar[-self.inputCciLen - 2:-1]]
idx = 2
else:
listClose = [x.close for x in self.lineBar[-self.inputCciLen-1:]]
listHigh = [x.high for x in self.lineBar[-self.inputCciLen - 1:]]
listLow = [x.low for x in self.lineBar[-self.inputCciLen - 1:]]
idx = 1
barCci = ta.CCI(high=np.array(listHigh, dtype=float), low=np.array(listLow, dtype=float),
close=np.array(listClose, dtype=float), timeperiod=self.inputCciLen)[-1]
barCci = round(float(barCci), 3)
l = len(self.lineCci)
if l > self.inputCciLen*8:
del self.lineCci[0]
self.lineCci.append(barCci)