Hi,
I am using Card to have a deck of financial asset that is composed of a candlestick graph and the change on the last 24h.
I am able to do a comprehension list for building the layout of the card for each row. However I am not able to build the callback function in a way i just write one callback to populate the card because only the symbol of the financial asset changes not the graph themselve.
the callback is as follow but it is not working with the TypeError: update_graph() missing 1 required positional argument: âsymbolâ.:
for symbol in symbols:
@app.callback(
[Output('indicator-graph-{}'.format(symbol), 'figure')],
[Input('update', 'n_intervals')]
)
def update_graph(timer, symbol):
# dff_rv = dff.iloc[::-1]
day_start = candle_hourly[symbol][candle_hourly[symbol]['date'] == candle_hourly[symbol]['date'].min()]['close'].values[0]
day_end = candle_hourly[symbol][candle_hourly[symbol]['date'] == candle_hourly[symbol]['date'].max()]['close'].values[0]
# print(day_start)
# print(day_end)
fig = go.Figure(go.Indicator(
mode="delta",
value=day_end,
delta={'reference': day_start, 'relative': True, 'valueformat': '.2%'}))
fig.update_traces(delta_font={'size': 12})
fig.update_layout(height=30, width=70)
if day_end >= day_start:
fig.update_traces(delta_increasing_color='green')
elif day_end < day_start:
fig.update_traces(delta_decreasing_color='red')
return fig
What can I change to make it work? Is there a better way to write my callback?
Read about dynamics callback but not sure how it would work.