app = Dash(__name__)
app.layout = html.Div([
html.Div(id='live-update-nifty'),
html.Div(dash_table.DataTable(id="output-3",
columns=[
{"name": i, "id": i} for i in finish_butterfly().columns],
style_cell={'textAlign': 'center'},
style_header={'backgroundColor': 'rgb(30, 30, 30)','color': 'white'},
style_data={'backgroundColor': 'rgb(50, 50, 50)','color': 'white'},
style_data_conditional=[{
'if': {
'row_index': 5, # number | 'odd' | 'even'
'column_id': 'strike'
},
'backgroundColor': 'hotpink',
'color': 'white'
}])),
html.Div(dash_table.DataTable(id="output-2",
columns=[
{"name": i, "id": i} for i in finish_butterfly().columns],
style_cell={'textAlign': 'center'},
style_header={'backgroundColor': 'rgb(30, 30, 30)','color': 'white'},
style_data={'backgroundColor': 'rgb(50, 50, 50)','color': 'white'},
style_data_conditional=[{
'if': {
'row_index': 5, # number | 'odd' | 'even'
'column_id': 'strike'
},
'backgroundColor': 'hotpink',
'color': 'white'
}]),style={'display': 'inline-block',"padding": "20px"}),
html.Div(dash_table.DataTable(id="output-1",
columns=[
{"name": i, "id": i} for i in finish_butterfly().columns],
style_cell={'textAlign': 'center'},
style_header={'backgroundColor': 'rgb(30, 30, 30)','color': 'white'},
style_data={'backgroundColor': 'rgb(50, 50, 50)','color': 'white'},
style_data_conditional=[{
'if': {
'row_index': 5, # number | 'odd' | 'even'
'column_id': 'strike'
},
'backgroundColor': 'hotpink',
'color': 'white'
}]),style={'display': 'inline-block',"padding": "20px",'float': 'centre'}),
html.Div(dash_table.DataTable(id="output-4",
columns=[
{"name": i, "id": i} for i in oi().columns],
style_cell={'textAlign': 'center'}),style={'display': 'inline-block',"padding": "20px",'float': 'right'}),
dcc.Interval(
id='interval-component',
interval=1800, # in milliseconds
n_intervals=0),
dcc.Interval(
id='interval-component-2',
interval=2500, # in milliseconds
n_intervals=0)
])
@app.callback(Output('output-4', 'data'),Input('interval-component-2', 'n_intervals'))
def get_data(n):
return oi().to_dict('records')
@app.callback(Output('output-3', 'data'),Input('interval-component-2', 'n_intervals'))
def get_data(n):
return finish_butterfly().to_dict('records')
@app.callback(Output('output-2', 'data'),Input('interval-component', 'n_intervals'))
def get_data(n):
return finish_butterfly().to_dict('records')
@app.callback(Output('output-1', 'data'),Input('interval-component', 'n_intervals'))
def get_data(n):
return finish_butterfly().to_dict('records')
@app.callback(Output('live-update-nifty', 'children'),
Input('interval-component', 'n_intervals'))
def get_data_1(n):
return "NIFTY {}".format(datetime.now())
if __name__ == '__main__':
app.run_server()
nothing is updating … how do i update all tables according to their specific intervals