how to calculate JDK Rs Ratio from a brazilian stock using yahoofinance

Viewed 1559

I'm trying to calculate JDK - RS Ratio using python, however it seems it is not working well.

These are some articles that i've found on the internet, concerning JDK RS Ratio:

https://quant.stackexchange.com/questions/17963/how-to-calculate-the-jdk-rs-ratio

https://marginstone.com/how-to-create-a-relative-rotation-graph-on-excel/

https://github.com/vlaranjo/Vasconomics_Materials/blob/master/Articles/RRG/Relative_Rotation_Graphs.ipynb

This is my python code, using Taurus (TASA4) stock and Ibovespa (benchmark - ^BVSP) as an example:

df_tasa = pdr.get_data_yahoo(['^BVSP', 'TASA4.SA'], start_date, end_date)['Adj Close'].pct_change().dropna().reset_index()
df_tasa['price_relative'] = (df_tasa.iloc[:,2] / df_tasa.iloc[:,1]) * 100
df_tasa['price_relative_roll10_mean'] = df_tasa.price_relative.rolling(10).mean()
df_tasa['price_relative_roll10_std'] = df_tasa.price_relative.rolling(10).std() + 1
df_tasa['Jdk_rs_ratio'] = 100 + ((df_tasa.price_relative - df_tasa.price_relative_roll10_mean) / df_tasa.price_relative_roll10_std)
df_tasa['Jdk_rs_ratio'] = df_tasa['Jdk_rs_ratio'].round(2)
df_tasa.dropna(inplace=True)
df_tasa.tail()

The above code has returned the following table: enter image description here

However, it's seems that my python code has some error because when i compared python daframe with RRG Software, i've saw that Taurus (TASA4) JDK Rs Ratio has ranged between 96 and 98.

enter image description here

The above beind said, could you please help me correctly calculate JDK RS Ratio?

Thanks in advance

1 Answers

Why did you add 1 in this line

df_tasa.price_relative.rolling(10).std() + 1

I think you should standardize as 100 + (value-mean)/SD

Related