The purpose of this post is to list issue I found when utilizing the create_candlestick method. The _validate_ohlc method returns an Exception error when the low value is not lower/not the lowest value than the high, open, and close values ( “Oops! It looks like some of your low values are greater than the corresponding high, open, or close values”…). However, this does not allow for low value to be equivalent to the high, open, or close. I’m not sure if this is expected behavior. Because this validation fails, the create_candlestick method does not create the figure.
I would like to reach out and find out if this is a bug or if this is expected behavior. If it is expected, I would like to post to the community to hear comments.
validate_ohlc method should check if the low value is greater than one of the other values: https://github.com/plotly/plotly.py/blob/master/plotly/tools.py#L5018
If equal, you should still see the plot. Could you provide an example of when you’re seeing this message upon plotting your low value equal to one of the other values.
Hi Chelsea, thanks for the feedback. I was using the Candlestick Charting function to plot some financial data from a web based data source. There was actually an error in the data source, which is what lead me to find this issue. The issue was that a high and low were the exact same number. The validate ohlc function uses “>” to make sure that the low is the lowest value, and for the most part it should be the case. So, what was my experience running the candlestick function on the data that had certain day values as all the same value? Since I was running this from a Python script, the python script threw an error and I don’t think the script continued with the trace creation. Hopefully, this provides a bit more context about what happened.
Yes, it throws an error if the low > high, open, close
If it is equal or less than, no error will be thrown.
This is the intended behavior. The low value can be equal to the high, open or close value, but it cannot be higher. If you have an example where this is not the case, i.e. a low value that is equal to one of your other values it not working then please let me know.
Line 5018 on github uses ‘>’ symbol rather than ‘>=’. The low must be greater than the Open, High, and Close (this makes sense actually). Technically financial data should be all the same number for Open, High, Low, Close. However, what led me to this was an error in the data. It just so happened that I stumbled onto this because the High and the Low in a row was the same.
I created a simple test. The row had 10, 10, 10, 10 for Open, High, Low, Close - each respectively (Validate_ohlc threw an exception). I also did another test with 8, 10, 10, 9 for Open, High, Low, Close (this also cases the method to throw the same error, this makes sense to throw an error).
Error is in plotly/tools.py, line 5018, in create_candlestick, then in line 4984, in validate_ohlc, raise exceptions.PLotlyError("Oops! Looks’ like some of " - plotly. exceptions.PlotlyError: Oops! looks like some of your low values are greater than the corresponding high, open, or close values. Double check that your data is entered in O-H-L-C order.
Also, I will list the version information my environment is using. This has the possibility of being relevant to understanding the source of this issue. Plotly 1.12.9. installer pip. in a python 2.7.12 environment.
Using 2.7.11 this is not the case for me:
Feel free to post the code you’re running and an image of your error, but I cannot reproduce.
As I mentioned earlier, the error is called when the low value is GREATER THAN one of the other values. If it is less than or equal to the other values, it passes as demonstrated in my above example.