Python talib.CORREL Examples
The following are 4
code examples of talib.CORREL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
talib
, or try the search function
.
Example #1
Source File: correl.py From jesse with MIT License | 6 votes |
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]
Example #2
Source File: ta_indicator_mixin.py From strategy with Apache License 2.0 | 5 votes |
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)
Example #3
Source File: talib_wrapper.py From tia with BSD 3-Clause "New" or "Revised" License | 5 votes |
def CORREL(frame, col0, col1, n=30): return _frame_to_series(frame, [col0, col1], talib.CORREL, n)
Example #4
Source File: talib_indicators.py From qtpylib with Apache License 2.0 | 5 votes |
def CORREL(data, **kwargs): _check_talib_presence() _, phigh, plow, _, _ = _extract_ohlc(data) return talib.CORREL(phigh, plow, **kwargs)