def update_graph(selected_row, temp_data, n1, n2): global long_num global short_num t = pd.DataFrame() if n1 > long_num: long_num = long_num + 1 temp_data = t.from_records(temp_data) temp = temp_data.iloc[selected_row[0]].to_dict() temp['Long_Short_Flag'] = 1 print(temp) stmanager.add_option(temp) df = stmanager.get_options() print('current strategy: ', df) return df.to_json(orient="split") elif n2 > short_num: short_num = short_num + 1 temp_data = t.from_records(temp_data) temp = temp_data.iloc[selected_row[0]].to_dict() temp['Long_Short_Flag'] = -1 print(temp) stmanager.add_option(temp) df = stmanager.get_options() print('current strategy: ', df) return df.to_json(orient="split") else: df = stmanager.get_options() return df.to_json(orient="split")
def clear_strategy_callback(n): if n > 0: stmanager.clear_options() df = stmanager.get_options() print(df) return df.to_json(orient="split")
"padding": "8", "marginTop": "5", "backgroundColor": "white", "border": "1px solid #C8D4E3", "borderRadius": "3px", 'margin-left': '40px', 'margin-right': '40px' }, ), ]), modal(), html.Div(pd.DataFrame().to_json(orient="split"), id='data_container', style={'display': 'none'}), html.Div( stmanager.get_options().to_json(orient="split"), id="options_df", style={"display": "none"}, ), # Tab content html.Div(id="tab_content", className="row", style={"margin": "2% 3%"}), ], className="row", style={"margin": "0%"}, ) @app.callback(Output("tab_content", "children"), [Input("tabs", "value")]) def render_content(tab): if tab == "basics_tab":