unexpected error: '>' not supported between instances of 'function' and 'float'
Hi when i starting live this error came out…
I believe it is from this line:
if ann> 0.53 and ind2>ind3 and ind1>60 and (ind1-ind4)/ind4 >0 :
return -1
elif ann< 0.47 and ind2<ind3 and ind1<40 and (ind1-ind4)/ind4 <0 :
return 1
else:
return 0
Where ann is the function,how do I correct this?
Here is the link to full codes : ann
The object 'ann' is a function in your code. As the error message says, comapring a function and a number is not meaningful. You probably mean the return value of the function. In that case, you have to use a function call. So instead of ann > 0.53, you should use ann() > 0.53. Also make sure the return value of ann is a number and not an array.
Thank you for the reply…,
…have done what you have corrected Sir, however, another error messages popped :
File "user_algp.py", line 213 in ann
Name error: global name 'data' is not defined:
Do we need to predefine the data object…or we have to import it somewhere?
you are using the data object for data.history call in the function 'ann'. You must pass 'data' as an argument to that function. So define it as def ann(data) and call it as ann(data). Also, the you are calling ann from signal_function. You need pass on the data object there too. Read more about function, function calls and function arguments in Python to understand.
Hi Prodipta…
…Thank you for the fast reply…I have followed your guide…Here are the new codes corrctions ann2…
However now it saying "
File "user_algo.py", line 215, in signal_function AttributeError: 'dict' object has no attribute 'history'. (you can check at line 82 from the link) ....where should we put the functions data.history()? Is it : 1. under initialize() by creating an object for it. 2. under handle_data() ....because I'm seeing no issue when it is put under the function 'generate_signals' Thank you Sir...your help has been really helpful...