MAINT rsi refactor

This commit is contained in:
Kevin Johnson
2020-07-25 11:30:00 -07:00
parent 40594c49d1
commit 93c898a005
2 changed files with 364 additions and 365 deletions
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, concat
from pandas_ta.overlap import rma
from pandas_ta.utils import get_drift, get_offset, verify_series, signals
def rsi(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
@@ -18,10 +19,10 @@ def rsi(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
positive[positive < 0] = 0 # Make negatives 0 for the postive series
negative[negative > 0] = 0 # Make postives 0 for the negative series
positive_avg = positive.ewm(com=length, adjust=False).mean()
negative_avg = negative.ewm(com=length, adjust=False).mean().abs()
positive_avg = rma(positive, length=length)
negative_avg = rma(negative, length=length)
rsi = scalar * positive_avg / (positive_avg + negative_avg)
rsi = scalar * positive_avg / (positive_avg + negative_avg.abs())
# Offset
if offset != 0: