I have subscribed to historical data api and I am trying to calculate RSI value for list of stock at EOD. I wrote the below piece of code to calculate RSI value.
def RSI(df, base, period , script_name,xls_row): """ Function to compute Relative Strength Index (RSI)
Args : df : Pandas DataFrame which contains ['date', 'open', 'high', 'low', 'close', 'volume'] columns base : String indicating the column name from which the MACD needs to be computed from (Default Close) period : Integer indicates the period of computation in terms of number of candles
Returns : df : Pandas DataFrame with new columns added for Relative Strength Index (RSI_$period) """
I checked for few stocks and below is my observation: For "ABBOTINDIA" period: 14 , interval = "day" and RSI is calucalted on "close" price. RSI from kite app = 39.72 on 18/11/2020 closing basis RSI calculated from above formula = 28.29 on 18/11/2020. Please let me know the formula which I am using above is correct for calculating RSI?
Maybe you can look at this thread.
This is the best method to calculate rsi
This method will give you RSI values which matches TRADINGVIEW RSI values.