Add reload symbols button

This commit is contained in:
George 2024-09-30 11:53:53 -07:00
parent 16c74c4aa5
commit 1ba9698fa9

View File

@ -679,8 +679,8 @@ if __name__ == "__main__":
# App layout # App layout
app.layout = [ app.layout = [
html.Div([ html.Div([
# html.Button('Reset', id="reset-button", n_clicks=0, html.Button('Reload Syms', id="reload-button", n_clicks=0,
# style={'font-size': '12px', 'width': '140px', 'display': 'inline-block', 'margin-bottom': '10px', 'margin-right': '5px', 'height':'36px', 'verticalAlign': 'top'}), style={'font-size': '12px', 'width': '140px', 'display': 'inline-block', 'margin-bottom': '10px', 'margin-right': '5px', 'height':'36px', 'verticalAlign': 'top'}),
html.Div([ html.Div([
dcc.Dropdown(symbols, symbols[0], id='symbols_dropdown_list',), dcc.Dropdown(symbols, symbols[0], id='symbols_dropdown_list',),
], style={'width': '140px', 'text-align': 'center'}), ], style={'width': '140px', 'text-align': 'center'}),
@ -735,16 +735,16 @@ if __name__ == "__main__":
return False, "Pause", True return False, "Pause", True
return no_update return no_update
# # reset button callback # reload button callback
# @callback(Output('interval-component', 'n_intervals'), @callback(Output('symbols_dropdown_list', 'options'),
# Output("start-button", "children"), Input("reload-button", "n_clicks"),)
# Output('symbols_dropdown_list', 'disabled'),
# Input("reset-button", "n_clicks"),)
# def reset_cycle(n): def reload_syms(n):
# if n: if n:
# return 0, "Pause", False watchlist = get_watchlist()
# return no_update symbols = watchlist.index.values.tolist()
return symbols
return no_update
# interval callback # interval callback
@callback(Output('symbols_dropdown_list', 'value'), @callback(Output('symbols_dropdown_list', 'value'),
@ -767,7 +767,6 @@ if __name__ == "__main__":
# Input(component_id='signal', component_property='data'), # Input(component_id='signal', component_property='data'),
) )
# def update_graph(col_chosen, syms):
def update_graph(col_chosen): def update_graph(col_chosen):
if not col_chosen: if not col_chosen:
raise PreventUpdate raise PreventUpdate
@ -830,21 +829,15 @@ if __name__ == "__main__":
x=rsi.index, x=rsi.index,
y=['_RSI', '_VoRSI'], y=['_RSI', '_VoRSI'],
) )
# fig.add_traces(price_line.data + volume_line.data, rows=1, cols=1, secondary_ys=[False, False, False, False, False, False, True])
fig.add_traces(price_line.data + volume_line.data, rows=1, cols=1, secondary_ys=[True, True, True, True, True, True, False]) fig.add_traces(price_line.data + volume_line.data, rows=1, cols=1, secondary_ys=[True, True, True, True, True, True, False])
fig.add_traces(macd_line.data + macd_hist_pos.data + macd_hist_neg.data, rows=2, cols=1) fig.add_traces(macd_line.data + macd_hist_pos.data + macd_hist_neg.data, rows=2, cols=1)
# fig.add_traces(macd_line.data, rows=2, cols=1)
fig.add_traces(rsi_line.data, rows=3, cols=1) fig.add_traces(rsi_line.data, rows=3, cols=1)
# fig.update_traces(marker_color = 'rgba(0,0,250,0.5)', # fig.update_traces(marker_color = 'rgba(0,0,250,0.5)',
# marker_line_width = 0, # marker_line_width = 0,
# selector=dict(type="bar"), # selector=dict(type="bar"),
# )
# fig.update_layout(bargap=0, bargroupgap=0)
# fig.layout.xaxis.title="Time"
fig.layout.yaxis.title="Volume" fig.layout.yaxis.title="Volume"
# fig.layout.yaxis.type="log"
fig.layout.yaxis2.title="Price ($)" fig.layout.yaxis2.title="Price ($)"
fig.layout.yaxis2.type="log" fig.layout.yaxis2.type="log"
fig.layout.yaxis3.title="MACD" fig.layout.yaxis3.title="MACD"
@ -855,10 +848,8 @@ if __name__ == "__main__":
margin=dict(l=30, r=20, t=50, b=20), margin=dict(l=30, r=20, t=50, b=20),
) )
# fig.update_layout(showlegend=False) # fig.update_layout(showlegend=False)
# fig.update_layout(margin=dict(l=30, r=20, t=50, b=20))
return fig return fig
# return fig, syms.index(col_chosen)
serve(app.server, host="0.0.0.0", port=8050, threads=7) serve(app.server, host="0.0.0.0", port=8050, threads=7)
# app.run(debug=True) # app.run(debug=True)