Created
September 6, 2019 04:52
-
-
Save jsrimr/0c5da0cd3637a148d6c02f58c79a5eb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fnRSI(m_Df, m_N=15): | |
m_Df = m_Df.c | |
U = np.where(m_Df.diff(1) > 0, m_Df.diff(1), 0) | |
D = np.where(m_Df.diff(1) < 0, m_Df.diff(1) *(-1), 0) | |
AU = pd.DataFrame(U).rolling( window=m_N, min_periods=m_N).mean() | |
AD = pd.DataFrame(D).rolling( window=m_N, min_periods=m_N).mean() | |
RSI = AU.div(AD+AU)[0].mean() | |
return RSI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment