So this confuses me a bit. The state is the graph and figure and the interval is the trigger.
How is the state actually forcing an extension to the trace instead of reloading the trace/graph?
I have mimicked the callback but I get an error.
TypeError: update_graph_scatter() takes 0 positional arguments but 2 were given
127.0.0.1 - - [20/Oct/2018 18:49:36] “POST /_dash-update-component HTTP/1.1” 200 -
exchange_tickers = {
‘Binance’: [‘XRP/USDT’],
‘Bittrex’: [u’XRP/USDT’],
‘Kraken’: [u’XRP/USD’],
‘Poloniex’: [u’USDT_XRP’]
}
exchanges = [‘Kraken’, ‘Binance’, ‘Bittrex’]
exchanges = [dict(label=str(exchange), value=str(exchange)) for exchange in exchanges]
PullValues = bf()
AppendedValue = PullValues.Kraken()
NewDateTimes = AppendedValue.index
NewclosePrice = AppendedValue[‘close’]
app = dash.Dash(name)
app.layout = html.Div([
html.Div([
html.H1(
‘Trade Pair - Exchange’,
style={‘padding-top’:‘20’, ‘text-align’:‘center’}
),
html.Div([
html.Label(‘Exchange:’),
dcc.Dropdown(
id=‘dropdown_exchange’,
options=[{‘label’: k, ‘value’: k} for k in exchange_tickers.keys()],
value=‘Kraken’,
)
], style={
‘width’: ‘300’,
‘display’: ‘inline-block’,
‘padding-left’: ‘50’
}),
html.Div([
html.Label(‘Select ticker:’),
dcc.Dropdown(
id=‘dropdown_ticker’,
options=tickers,
value=‘XRP’,
)
], style={
‘width’:‘300’,
‘display’:‘inline-block’,
‘padding-left’:‘50’
}),
html.Div([
html.Label('Amount To Leverage:'),
dcc.Input(
id='amount_leverage',
placeholder='50',
type='text',
value='50',
)
], style={
'width':'300',
'display':'inline-block',
'padding-left':'50'
})
]),
html.Div([
dcc.Graph(id='initial-graph', animate=True,
figure={
'data': [
{'x': NewDateTimes, 'y': NewclosePrice, 'type': 'line', 'name': 'LINE XRP-USD'},
],
'layout': {
'title': '4 HOUR - XRP-USD - KRAKEN', # TITLE AT TOP OF CHART
'legend': {'x': 'XRPUSD'}
}
}),
dcc.Interval(id='graph-update', interval=20000)
]),
])
@app.callback(dash.dependencies.Output(‘dropdown_ticker’, ‘options’), [dash.dependencies.Input(‘dropdown_exchange’, ‘value’)])
def update_trading_pair(selected_exchange):
return [{‘label’: i, ‘value’: i} for i in exchange_tickers[selected_exchange]]
@app.callback(dash.dependencies.Output(‘dropdown_ticker’, ‘value’), [dash.dependencies.Input(‘dropdown_ticker’, ‘options’)])
def update_trading_pair(exchange_tickers):
return exchange_tickers[0][‘value’]
#@app.callback(Output(‘initial-graph’, ‘figure’), events=[Event(‘graph-update’, ‘interval’)])
@app.callback(Output(‘initial-graph’, ‘figure’), [dash.dependencies.Input(‘graph-update’, ‘interval’)], [dash.dependencies.State(‘initial-graph’, ‘figure’)])
def update_graph_scatter():
####### CANDLESTICK GRAPH GRAPH ####################
PullValues = bf()
AppendedValue = PullValues.Kraken()
NewDateTimes = AppendedValue.index
trace = Candlestick(
x=NewDateTimes,
open=AppendedValue['open'],
high=AppendedValue['high'],
low=AppendedValue['low'],
close=AppendedValue['close'],
showlegend=False,
name='XRP/USD',
legendgroup='XRP/USD',
increasing=dict(line=dict(color=colorscale[3])),
decreasing=dict(line=dict(color=colorscale[5]))
)
layout = Layout(
height=480,
margin={'l': 50, 'r': 30, 'b': 50, 't': 50},
legend={'x': 0, 'y': 1, 'xanchor': 'left'},
xaxis={'rangeslider': {'visible': False}}
)
return Figure(data=[trace], layout=layout)