html.Div([ html.P([html.Strong('Test for dialog')]), sd_material_ui.Dialog([ html.H3('Sample Dialog'), html.Div(html.Button('Close Dialog'), id='closer') ], id='output2'), html.Div(id='input2', children=[ html.Button(children='Open the dialog') ]), ]), spacer, html.Div([ html.P([html.Strong('Sample FontIcon')]), sd_material_ui.FontIcon(id='fonticon', iconName='insert_emoticon'), ]), spacer, html.Div([ html.P([html.Strong('Test for toggle switch')]), sd_material_ui.Toggle( id='toggle-input', label='Johnny?', toggled=False, ), html.P(id='toggle-output', children=['Flame off']), ]), spacer,
zDepth=5, circle=True, style=dict( height=100, width=100, margin=20, textAlign='center', display='inline-block', ), ), spacer, sd_material_ui.Paper( children=[ sd_material_ui.FontIcon( className='material-icons', iconName='help', color='green', ) ], zDepth=4, rounded=False, style=dict( height=100, width=100, margin=20, textAlign='center', display='inline-block', ), ), spacer,
def predict_stocks_decision_daily(json_data, figure): """ Callback to get stock data from the hidden div and perform RL to predict the optimal decision to make. """ # Parse json_res = json.loads(json_data) series = json_res["Time Series (Daily)"] days = [day for day in series] closing = [float(series[day]["4. close"]) for day in days] # Get the last 100 days stock prices model_input = closing[:100] model_input = [float(numeric_string) for numeric_string in model_input] model_input = np.reshape(model_input, (1, 1, 100)) # Load model json_file = open('models/dqn_model.json', 'r') loaded_model_json = json_file.read() json_file.close() loaded_model = model_from_json(loaded_model_json) # load weights into new model loaded_model.load_weights("models/dqn_weights.h5") # Run model decisions = loaded_model.predict(model_input) # Reset for future model predictions K.clear_session() # Render output if np.argmax(decisions) == 0: # Stay return sd_material_ui.Paper( children=[ sd_material_ui.FontIcon(className='material-icons', iconName='trending_flat', hoverColor="#1125ff"), html.P('The Deep Q Network advices to ignore this stock') ], zDepth=2, rounded=True, style=dict(height=150, width=150, margin=20, textAlign='center', display='inline-block'), ), elif (np.argmax(decisions) == 1): # Buy return sd_material_ui.Paper( children=[ sd_material_ui.FontIcon(className='material-icons', iconName='trending_up', hoverColor="#56fc0a"), html.P('The Deep Q Network advices to invest in this stock') ], zDepth=2, rounded=True, style=dict(height=150, width=150, margin=20, textAlign='center', display='inline-block'), ), else: # Sell return sd_material_ui.Paper( children=[ sd_material_ui.FontIcon(className='material-icons', iconName='trending_down', hoverColor="#fc000c"), html.P('The Deep Q Network advices to sell this stock') ], zDepth=2, rounded=True, style=dict(height=150, width=150, margin=20, textAlign='center', display='inline-block'), ),