This commit is contained in:
Kevin Johnson
2022-04-14 12:07:14 -07:00
parent e84160c74a
commit 44b0bd83fc
+3 -3
View File
@@ -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: