本文整理匯總了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)