Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VectorBT vs TA-Lib | RSI discrepancies #745

Open
danigarod opened this issue Aug 29, 2024 · 1 comment
Open

VectorBT vs TA-Lib | RSI discrepancies #745

danigarod opened this issue Aug 29, 2024 · 1 comment

Comments

@danigarod
Copy link

Hi there.
I am trying to understand how VectorBT calculates the RSI indicator. I have the following code to compare VectorBT RSI values againts talib:

import vectorbt as vbt
import talib as ta
import pandas as pd
import yfinance as yf

symbol ='SPY'
data = yf.download(symbol)
data = data.dropna()

##################################

RSI Check

##################################
rsi_1 = ta.RSI(data.Close, 3)
rsi_1 = pd.Series(rsi_1, name="rsi_1")

rsi_2= vbt.RSI.run(data.Close, 3, ewm=True).rsi
rsi_2 = pd.Series(rsi_2, name="rsi_2")

merged = pd.merge(rsi_1, rsi_2, on='Date', how='outer')

merged.head(50)
And these are the results:

rsi_1 rsi_2

Date

1993-01-29 NaN NaN

1993-02-01 NaN NaN

1993-02-02 NaN NaN

1993-02-03 100.000000 100.000000

1993-02-04 100.000000 100.000000

1993-02-05 94.267516 89.333333

1993-02-08 94.267516 89.333333

1993-02-09 41.168289 16.962025

1993-02-10 49.672814 37.284895

1993-02-11 71.387503 76.885130

1993-02-12 35.392258 25.761511

1993-02-16 10.184007 4.813165

I am trying to dig into VectorBT code but it is hard to follow. Anyone has already looked into this before?

Thanks a lot!

@danigarod danigarod changed the title VectorBT vs TA-Lib | RSI dircrepancies VectorBT vs TA-Lib | RSI discrepancies Aug 29, 2024
@polakowo
Copy link
Owner

Duplicate of #471

@polakowo polakowo marked this as a duplicate of #471 Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants