本文整理汇总了Python中talib.CORREL属性的典型用法代码示例。如果您正苦于以下问题:Python talib.CORREL属性的具体用法?Python talib.CORREL怎么用?Python talib.CORREL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类talib
的用法示例。
在下文中一共展示了talib.CORREL属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: correl
# 需要导入模块: import talib [as 别名]
# 或者: from talib import CORREL [as 别名]
def correl(candles: np.ndarray, period=5, sequential=False) -> Union[float, np.ndarray]:
"""
CORREL - Pearson's Correlation Coefficient (r)
:param candles: np.ndarray
:param period: int - default: 5
:param sequential: bool - default=False
:return: float | np.ndarray
"""
if not sequential and len(candles) > 240:
candles = candles[-240:]
res = talib.CORREL(candles[:, 3], candles[:, 4], timeperiod=period)
if sequential:
return res
else:
return None if np.isnan(res[-1]) else res[-1]
示例2: cor
# 需要导入模块: import talib [as 别名]
# 或者: from talib import CORREL [as 别名]
def cor(self, sym1, sym2, frequency, period=10):
if not self.kbars_ready(sym1, frequency) or not self.kbars_ready(sym2, frequency):
return []
close1 = self.close(sym1, frequency)
close2 = self.close(sym2, frequency)
roc1 = ta.ROC(close1, timeperiod=period)
roc2 = ta.ROC(close2, timeperiod=period)
return ta.CORREL(roc1, roc2, timeperiod=period)
示例3: CORREL
# 需要导入模块: import talib [as 别名]
# 或者: from talib import CORREL [as 别名]
def CORREL(frame, col0, col1, n=30):
return _frame_to_series(frame, [col0, col1], talib.CORREL, n)
示例4: CORREL
# 需要导入模块: import talib [as 别名]
# 或者: from talib import CORREL [as 别名]
def CORREL(data, **kwargs):
_check_talib_presence()
_, phigh, plow, _, _ = _extract_ohlc(data)
return talib.CORREL(phigh, plow, **kwargs)