From a2895834f948172f5911ba1080969e1930325215 Mon Sep 17 00:00:00 2001 From: "Christopher J. Mobley" Date: Sun, 10 Apr 2022 21:42:52 -0400 Subject: [PATCH 1/3] Fixed r=True case for linreg when Ta-Lib is installed. Closes Issue 510. --- pandas_ta/overlap/linreg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas_ta/overlap/linreg.py b/pandas_ta/overlap/linreg.py index c939cdb..3fb9b38 100644 --- a/pandas_ta/overlap/linreg.py +++ b/pandas_ta/overlap/linreg.py @@ -65,7 +65,7 @@ def linreg( # Calculate np_close = close.values - if Imports["talib"] and mode_tal: + if Imports["talib"] and mode_tal and not r: from talib import LINEARREG, LINEARREG_ANGLE, LINEARREG_INTERCEPT, LINEARREG_SLOPE, TSF if tsf: linreg = TSF(close, timeperiod=length) From e84160c74aa5687872d95d022b953542de9309ed Mon Sep 17 00:00:00 2001 From: "Christopher J. Mobley" Date: Sun, 10 Apr 2022 21:44:51 -0400 Subject: [PATCH 2/3] Fixed order of coefficients in cg. Closes Issue 507. --- pandas_ta/momentum/cg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas_ta/momentum/cg.py b/pandas_ta/momentum/cg.py index 6c49885..175ac24 100644 --- a/pandas_ta/momentum/cg.py +++ b/pandas_ta/momentum/cg.py @@ -38,7 +38,7 @@ def cg( offset = v_offset(offset) # Calculate - coefficients = [length - i for i in range(0, length)] + coefficients = list(range(1, length + 1)) numerator = -close.rolling(length).apply(weights(coefficients), raw=True) cg = numerator / close.rolling(length).sum() From 44b0bd83fc0ce2f97da3c24439fecf9e4bbff81a Mon Sep 17 00:00:00 2001 From: Kevin Johnson Date: Thu, 14 Apr 2022 12:07:14 -0700 Subject: [PATCH 3/3] ENH cg --- pandas_ta/momentum/cg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas_ta/momentum/cg.py b/pandas_ta/momentum/cg.py index 175ac24..1379aa0 100644 --- a/pandas_ta/momentum/cg.py +++ b/pandas_ta/momentum/cg.py @@ -38,9 +38,9 @@ def cg( offset = v_offset(offset) # Calculate - coefficients = list(range(1, length + 1)) - numerator = -close.rolling(length).apply(weights(coefficients), raw=True) - cg = numerator / close.rolling(length).sum() + coefficients = range(1, length + 1) + numerator = close.rolling(length).apply(weights(coefficients), raw=True) + cg = -numerator / close.rolling(length).sum() # Offset if offset != 0: