# collect the candlestick data from Binance
binance = ccxt.binanceusdm()
trading_pair = 'BTC/USDT'
candles = binance.fetch_ohlcv(trading_pair, '1m')
dates = []
open_data = []
high_data = []
low_data = []
close_data = []
# format the data to match the charting library
for candle in candles:
dates.append(datetime.fromtimestamp(candle[0] / 1000.0).strftime('%Y-%m-%d %H:%M:%S.%f'))
open_data.append(candle[1])
high_data.append(candle[2])
low_data.append(candle[3])
close_data.append(candle[4])
# The latest status of the bar
Candleูupdate = [dates[-1], open_data[-1], high_data[-1], low_data[-1], close_data[-1]]
fig = go.Figure(data=[go.Candlestick(x=dates,
open=open_data, high=high_data,
low=low_data, close=close_data)])
fig.show()
The part where the diagram is drawn is how the data should be updated without a new diagram being drawn (because I used the while loop and new diagrams were created), only a new candlestick is created!