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

After the upgrade to 2.2.1 I can only initialize indicators RSI and TSI but cannot add a new input using rsi().add() and tsi().add(). #134

Open
hysech opened this issue Apr 29, 2024 · 4 comments

Comments

@hysech
Copy link

hysech commented Apr 29, 2024

Hello Nardew,
sorry to disturb you. I used your older version of talipp at the same code without any issue. After the upgrade to 2.2.1 I can only initialize indicators RSI and TSI but cannot add a new input using rsi().add() and tsi().add().
Maybe the reason is in my using global variables gl.rsi, gl. tsi or other trik in Python, but I am stalling 2 weeks already. To go on in debugging I have to initialize rsi, tsi repeatedly and after a limit use
.purge_oldest which for some reason is working!?!? Of course repeating the initializations is very time consuming and downgrading to older version is the last step?
I tried to add type(R/TSI) to the declaration of the global var. but it did not help.

My config file with globals:

from talipp.indicators import TSI, RSI, EMA, SMA, Stoch
tsi1l = type(TSI) # TSI(13, 25, input_values = close_1ll)
#tsi1l.add() = TSI(13, 25, input_values = close_1ll).add()
rsi1l = type(RSI) # RSI(14, input_values = close_1ll)
#rsi1l.add() = RSI(14, input_values = close_1ll).add()
tsi2l = type(TSI) # TSI(13, 25, input_values = close_1ll)
rsi2l = type(RSI) # RSI(14, input_values = close_1ll)
tsi3l = type(TSI) # TSI(13, 25, input_values = close_1ll)
rsi3l = type(RSI) # RSI(14, input_values = close_1ll)

Code using talipp is of this type:

if len(gl.b1ldframe) < 50:
gl.close_1ll += [gl.b1l_close]
# logger.info(f'gl.close_1ll = {gl.close_1ll}')
gl.rsi1l = RSI(14, input_values=gl.close_1ll)
gl.tsi1l = TSI(13, 25, input_values=gl.close_1ll)
if gl.rsi1l[-1] != gl.rsi1l[-1]:
xlst = gl.b1l_bar + [0.0]
else:
xlst = gl.b1l_bar + [gl.rsi1l[-1]]
if gl.tsi1l[-1] != gl.tsi1l[-1]:
xlst = xlst + [0.0]
else:
xlst = xlst + [gl.tsi1l[-1]]

        #   lis1.extend([None])

else:

xlst = gl.b1l_bar + [gl.rsi1l.add(gl.b1l_bar[4])[-1]]
xlst += [gl.tsi1l.add(gl.b1l_bar[4])[-1]]
[logger.info](http://logger.info/)(f'xlst = {xlst}')
print('[RSI(14,).add(gl.b1l_bar[4])][-1]:')
print([RSI(14,).add(gl.b1l_bar[4])][-1])
gl.b1ldframe.loc[len(gl.b1ldframe.index)] = xlst
len1 = len(gl.b1ldframe)
[logger.info](http://logger.info/)(f'=3.len(gl.b1ldframe): {len1},')
[logger.info](http://logger.info/)(f'=3gl.b1ldframe.iloc[-1]:')
[logger.info](http://logger.info/)(f'{gl.b1ldframe.iloc[-1].tolist()}')
#################################################

RSI and TSI needs for my data(S&P2000, future) more than 30 bars to calculate a value, NaNs at start.
RSI, TSI values for 1st 50 bars.
When the second part of code is executed (see gl.rsi1l.add(gl.b1l_bar[4]), error message occurs:

File "name.py", line 394, in genbars
xlst = gl.b1l_bar + [gl.rsi1l.add(gl.b1l_bar[4])[-1]]
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
TypeError: 'NoneType' object is not subscriptable

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

Thank you very much in advance for your time and help.
With my regards,
Hynek Sechovsky

Neobsahuje žádné viry.[www.avast.com](https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail)

[email protected]. Stisknutím tabulátoru návrh vložíte.
Strana 1 z 2

@nardew
Copy link
Owner

nardew commented May 1, 2024

Hi @hysech ,
it's difficult to judge what is going wrong in your script. What is in gl.rsi1l and gl.b1l_bar at the line where it fails? Can you print those values in the line right before it?

Also when pasting a code, please enclose it between triple backticks to render it properly, otherwise it is not very readable.

@hysech
Copy link
Author

hysech commented May 14, 2024 via email

@hysech
Copy link
Author

hysech commented May 17, 2024 via email

@nardew
Copy link
Owner

nardew commented May 21, 2024

Hi @hysech , instantiating three independent RSI indicators should not be problematic in any way:

close = random.sample(range(1, 10000), 1000)

rsi1 = RSI(2, input_values=close)
rsi2 = RSI(3, input_values=close)
rsi3 = RSI(4, input_values=close)

print(rsi1[-1])
print(rsi2[-1])
print(rsi3[-1])

Output:

65.18165798725016
59.795855990107746
56.95817180954775

Some logging output I asked for above could help.

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