Display has gone blank and flashing today
romancerny opened this issue · 9 comments
pi@raspberrypi:~ $ python3 ~/zero-btc-screen/main.py
Traceback (most recent call last):
File "/home/pi/zero-btc-screen/main.py", line 60, in
main()
File "/home/pi/zero-btc-screen/main.py", line 46, in main
data_sink.update_observers(prices)
File "/home/pi/zero-btc-screen/presentation/observer.py", line 18, in update_observers
observer.update(data)
File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 54, in update
self.form_image(data, self.screen_draw)
File "/home/pi/zero-btc-screen/presentation/screens/epd2in13v2.py", line 41, in form_image
Plot.candle(prices, size=(SCREEN_WIDTH - 45, 93), position=(41, 0), draw=screen_draw)
File "/home/pi/zero-btc-screen/data/plot.py", line 61, in candle
for i in range(data_offset, len(data), windows_per_candle):
ValueError: range() arg 3 must not be zero
I have tried re-flashing the whole system and re-installing all dependencies, but the issue still persists.
Please advise.
Prior to today, it worked all well without any issues on refresh rate 1 min, 5 min and 15 min
Not sure what happened, must be a bug in the code with the dataset. I see the array for "data" is coming back 0 length. But its an array of arrays. (I'm not familiar with this code). Must be the dataset changed?
I notice if i change to line instead of candle, its working for me.
Edit: Looks like the floor division is coming back zero for windows_per_candle.
Okay,
To fix:
Update the data/plot.py, the candle static method:
def candle(data, size=(100, 100), position=(0, 0), draw=None, fill_neg="#000000", fill_pos=None):
width = size[0]
height = size[1]
candle_width = 9
space = 1
windows_per_candle = 1
data_offset = 0
num_of_candles = width // (candle_width + space)
leftover_space = width % (candle_width + space)
if num_of_candles < len(data):
windows_per_candle = len(data) // num_of_candles
data_offset = len(data) % num_of_candles
candle_data = []
for i in range(data_offset, len(data), windows_per_candle):
if windows_per_candle > 1:
window = data[i:i + windows_per_candle - 1]
open = window[0][0]
close = window[len(window) - 1][3]
high = max([i[1] for i in window])
low = min([i[2] for i in window])
else:
open = data[i][0]
close = data[i][3]
high = data[i][1]
low = data[i][2]
candle_data.append((open, high, low, close))
all_values = [item for sublist in candle_data for item in sublist]
There seems to be an issue with the data returned by the API, to be precise the last data frame is dated GMT: Sunday, January 23, 2022 3:29:59 AM. If this continues we just need to use another data source, I see that v3 works just fine, though has per-minute data.
Thanks, guys for the quick response. Hopefully, the data provider will sort that out soon.
It would be nice to have that caught and display a message on the display
Yeah seeing my graph slowly disappear, definitely no data coming anymore.
Hi everyone, mine doesn't work anymore either.
I also had a similar issue few months ago.
Yep, the Coindesk stopped returning data in their API call. Could we have an alternative data source? e.g. Coingecko?
https://api.coingecko.com/api/v3/coins/bitcoin/ohlc?vs_currency=usd&days=1
As the API is up and running again, I don't think there is a need of migrating to a new one. If, however, it becomes unstable, the one above could be a viable option.
sounds good. Thanks