本文整理汇总了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)