You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The numpy function np.nanmax() attempts to determine the maximum value in an array, ignoring any nan values. The problem is that all the values in up_markers and down_markers are nan:
Adding the following to the code:
print("all([np.isnan(x) for x in up_plot['data']]) = ",end='')
print( all([np.isnan(x) forxinup_plot['data']]) )
print("all([np.isnan(x) for x in down_plot['data']]) = ",end='')
print( all([np.isnan(x) forxindown_plot['data']]) )
gives:
all([np.isnan(x) for x in up_plot['data']]) = True
all([np.isnan(x) for x in down_plot['data']]) = True
This is not a bug in mplfinance, but a problem of passing essentially no data as an addplot.
I could have mplfinance check for all nan, but I would still have it throw an exception, perhaps with a more explicit message as to what is wrong. (I definitely would not allow mplfinance to ignore the fact that the user has passed in no data for the addplots, as this could be even more confusing to the user when they don't see their addplots in the plot). That said, in situations like this (bad data) I have been reluctant to add more and more checks to mplfinance as it is already slow enough as it is. So for now, I mostly leave it up to the user to confirm that their data is valid.
The message (E ValueError: zero-size array to reduction operation maximum which has no identity) you are seeing is coming from numpy as a result of the line of code shown in the Traceback ... so this was not difficult to track down: I simply looked at the line of code and determined what in that line of code could possibly be a zero-size array
DanielGoldfarb
changed the title
Bug Report: zero-size array to reduction operation maximum which has no identity
mplfinance warn if user passes an empty data set.
Jan 5, 2024
Hi everyone I got this error while trying to achive a graph with signal markers...
if I add a scatter plot I get this error:
E ValueError: zero-size array to reduction operation maximum which has no identity
initially I thought to be my fault... but then I tried some examples out there and all behaves the same.
You can try executing those examples to see the error
https://code.luasoftware.com/tutorials/algo-trading/mplfinance-plot-marker-on-price-chart
The text was updated successfully, but these errors were encountered: