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

RSI fills in wrong values #119

Closed
palmbook opened this issue Jan 18, 2020 · 2 comments
Closed

RSI fills in wrong values #119

palmbook opened this issue Jan 18, 2020 · 2 comments

Comments

@palmbook
Copy link

I am not sure if this behavior is intended. I called RSI n=14 and noticed that the first 14 rows were also filled in, even though I explicitly passed fillna=False. The values seem to be weird as well.

open high low close volume rsi

536.5 | 542.0 | 535.6 | 536.2 | 152 | 100.000000
536.0 | 537.2 | 536.0 | 536.1 | 53 | 0.000000
537.0 | 538.5 | 537.0 | 538.5 | 75 | 96.275072
536.8 | 536.8 | 535.6 | 535.7 | 81 | 43.571072
536.5 | 542.0 | 536.5 | 541.0 | 109 | 73.331230
541.0 | 543.9 | 540.6 | 543.3 | 68 | 78.604622
544.2 | 545.5 | 542.6 | 543.4 | 320 | 78.800895
543.8 | 544.6 | 543.5 | 543.7 | 195 | 79.411107
541.0 | 541.0 | 534.5 | 535.5 | 176 | 42.987527
533.7 | 533.9 | 525.0 | 530.3 | 445 | 32.733976
532.0 | 533.4 | 530.8 | 531.0 | 254 | 34.982219
523.0 | 523.0 | 518.5 | 518.5 | 519 | 21.294872
514.0 | 519.1 | 514.0 | 518.0 | 133 | 20.941906
516.8 | 516.8 | 504.2 | 505.1 | 122 | 14.338522
505.0 | 507.5 | 502.0 | 507.0 | 194 | 18.418793
508.0 | 509.4 | 496.1 | 496.1 | 182 | 14.230916
493.0 | 493.0 | 487.6 | 488.4 | 352 | 12.132334
498.0 | 501.0 | 492.7 | 497.0 | 156 | 25.369679
498.4 | 499.5 | 493.0 | 497.1 | 79 | 25.510204
495.0 | 496.8 | 491.3 | 491.4 | 97 | 22.867122

I understand that ta calculates RSI as ema of average gain over ema of average loss; but the first 3-4 values still seem very off.

@vladim0105
Copy link

IIRC, the first 14 rows are "supposed" to be weird. This is due to RSI using the past 14 days to calculate the current RSI value, but what happens if it does not know what happened the last 14 days? This is probably why you are getting weird values for the 14 first days, you can even see that the values are getting less weird the more days RSI has.

One solution would be to just calculate the RSI and then remove the first 14 rows from your dataset.

@bukosabino
Copy link
Owner

Hi @palmbook ,

I have updated the library fixing this bug. You need to update the last library version (0.5.25).

pip install -U ta

or

pip install ta==0.5.25

Let me know if you have any problems.

Best,
Dario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants