I have two random variables
rows, cols = 3, 2
and I want to make 3x2 table to show and update some charts inside each field
how can I do that?I can just add them with two for loops as static charts but I need to update them with not equal timeperiods and I cant!
Its my static minimal code for it but its not working too!! :):
from datetime import datetime
from time import sleep
import ccxt
import dash
import pandas as pd
from dash import dcc, html
from dash.dependencies import Input, Output
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import configparser
import numpy as np
###########################################################################
def load_df(exchange, market, tf, limit):
ohlcv = None
while ohlcv is None:
try:
ohlcv = exchange.fetch_ohlcv(symbol=market, timeframe=tf, limit=limit)
except Exception as e:
# raise
print(e)
sleep(1)
df = pd.DataFrame(ohlcv, columns=['Date', 'Open', 'High', 'Low', 'Close', 'Volume'])
df['Date'] = [datetime.fromtimestamp(float(time) / 1000) for time in df['Date']]
df.index = pd.DatetimeIndex(df['Date'])
# df = heikin_ashi(df)
return df
###########################################################################
# Load Config
config = configparser.ConfigParser()
config.read('./config.ini')
config_file_uri = config['DEFAULT']['configfile']
config.read(config_file_uri)
###########################################################################
exchanges = list(ccxt.exchanges)
print(exchanges)
markets = {}
timeframes = {}
widget_chart = {}
listbox_exchange = {}
listbox_market = {}
listbox_timeframe = {}
listbox_type = {}
spinbox_limit = {}
button_maximize = {}
###########################################################################
app = dash.Dash(__name__)
###########################################################################
output = []
for row in range(int(config['DEFAULT']['rows'])):
for col in range(int(config['DEFAULT']['cols'])):
# Load Panel Configuration
section = f"{row}x{col}"
pconf = config[section]
exchange = getattr(ccxt, pconf['exchange'])({'enableRateLimit': True})
# exchange.set_sandbox_mode(True)
limit = int(pconf['limit'])
chart_type = pconf['type']
market = pconf['market']
timeframe = pconf['timeframe']
df = load_df(exchange, market=market, tf=timeframe, limit=limit)
output.append(
html.Div(
children=[
dcc.Input(id='row'+section,type="number", value=row,disabled=True),
dcc.Input(id='col'+section,type="number", value=col,disabled=True),
dcc.Input(id='exchange'+section,type="text", value=pconf['exchange']),
dcc.Input(id='limit'+section,type="number", value=limit),
dcc.Input(id='chart_type'+section,type="text", value=chart_type),
dcc.Input(id='market'+section,type="text", value=market),
dcc.Input(id='timeframe'+section,type="text", value=timeframe),
dcc.Graph(id='chart'+section,figure={'data': [
go.Candlestick(
x=df['Date'],
open=df['Open'],
high=df['High'],
low=df['Low'],
close=df['Close']
)
]}),
dcc.Interval(
id='interval-component'+section,
interval=1 * 1000 * 6, # in milliseconds
n_intervals=0
)
]
)
)
###########################################################################
# Fill Exchanges Data
if pconf['exchange'] not in markets:
markets[pconf['exchange']] = list(exchange.load_markets())
# print(pconf['exchange'], markets[pconf['exchange']])
if pconf['exchange'] not in timeframes:
timeframes[pconf['exchange']] = list(exchange.timeframes)
# print(pconf['exchange'], timeframes[pconf['exchange']])
app.layout = html.Div(children=output)
if __name__ == '__main__':
app.run_server(debug=True)