def generate_main_window( self, data_table_columns: List[Dict[str, str]] ) -> html.Div: return html.Div( children=[ html.Div( [ html.Div( sd_material_ui.RaisedButton( id=self.id_button_options, label="Options" ), style={"display": "inline-block"}, ), html.Div( sd_material_ui.RaisedButton( id=self.id_button_update, label="Update Graphs" ), style={ "display": "inline-block", "margin-left": "15px", }, ), ], style={"margin-bottom": "5px"}, ), core.Loading( id=self.id_loader_graph, children=[ sd_material_ui.Paper([core.Graph(id=self.id_plot)]) ], ), core.Loading( id=self.id_loader_data_table, children=[ sd_material_ui.Paper( [ dash_table.DataTable( id=self.id_data_table, columns=data_table_columns, data=self.df_func().to_dict("records"), page_size=50, sort_action="native", sort_mode="multi", export_format="csv", ) ] ) ], type="circle", ), ] )
def hide_graph(clicked: int, timestamp, data, content): if timestamp is None: raise PreventUpdate xs = data.get('lastXs') ys = data.get('lastYs') if len(xs) > 1: x_prev = xs[-2] y_prev = ys[-2] x = xs[-1] y = ys[-1] else: x_prev = y_prev = x = y = None KNOB = sd_material_ui.Paper(zDepth=1, style=dict(height=625, width=750), children=[ html.Div([ daq.Knob(label="Gradient Ranges", value=7, size=500, color={ "gradient": True, "ranges": { "red": [0, 5], "yellow": [5, 9], "green": [9, 10] } }, style=dict( position='relative', top='25px', left='0px')) ]) ]), if x_prev != x or y_prev != y: # Moved return content else: if content is None or content == []: return KNOB elif content: return []
spacer, # Test SDSubheader sd_material_ui.Subheader(children=['This is a subheader']), spacer, sd_material_ui.Subheader(children=['This is a subheader with an inset'], inset=True), spacer, # Test SDPaper sd_material_ui.Paper( 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,
]), sd_material_ui.Divider(), html.Div([ spacer, ]), html.Div([ html.Div([ html.Div([ html.P([html.Strong('Test for Collapse Transition and Paper/Card')]), sd_material_ui.CollapseTransition(id='transition-collapse', visible=True, children=[ sd_material_ui.Paper([ html.H3('Paper Title'), sd_material_ui.Card([ html.P('Card Text') ]), ]) ]), sd_material_ui.Toggle(id='transition-input', toggled=True, label='Show element?'), ]), spacer, html.Div([ html.P([html.Strong('Test for Fade Transition')]), sd_material_ui.FadeTransition(id='transition-fade', visible=True, children=[ sd_material_ui.Card([ html.P('Card Text') ]), ]),
style={ "fontSize": 20, "fontFamily": "sans serif", "textAlign": "center", "padding": 30, }, ), html.Br(), html.Div( sd.Paper( html.Div( id="object_threshold", style={ "fontSize": 20, "fontWeight": "bold" }, ), style={ "padding": 50, "background-color": "rgb(222,222,222)", }, ), style={ "width": "45%", "display": "inline-block", "textAlign": "center", }, ), html.Div( sd.Paper( html.Div(
handle='.handle', children=[ html.Div([ sd_material_ui.Paper(children=[ sd_material_ui.IconButton( id='button1', iconClassName='fas fa-grip-lines', iconStyle={ 'color': 'grey', 'width': 50, 'height': 50, 'position': 'relative', 'top': '2px', 'left': '-12px' }, tooltip='Drag Me', touch=True, tooltipPosition='bottom-right') ], zDepth=3, circle=True, style=dict( height=50, width=50, textAlign='center', position='relative', display='inline-block', top='25px', left='-25px')) ], className='handle no-print'), dash_table.DataTable(
children=sd_material_ui.Paper([ daq.BooleanSwitch(label='Simple Moving Average', id='0', on=False, labelPosition='right'), daq.BooleanSwitch(label='Exponential Moving Average', id='1', on=False, labelPosition='right'), daq.BooleanSwitch(label='Weighted Moving Average', id='2', on=False, labelPosition='right'), daq.BooleanSwitch(label='Double Exponential Moving Average', id='3', on=False, labelPosition='right'), daq.BooleanSwitch(label='Triple Exponential Moving Average', id='4', on=False, labelPosition='right'), daq.BooleanSwitch(label='Triangular Moving Average', id='5', on=False, labelPosition='right'), daq.BooleanSwitch(label='Kaufman Adaptive Moving Average', id='6', on=False, labelPosition='right'), daq.BooleanSwitch(label='MESA Adaptive Moving Average', id='7', on=False, labelPosition='right'), daq.BooleanSwitch(label='Triple Exponential Moving Average', id='8', on=False, labelPosition='right'), daq.BooleanSwitch(label='Moving Average Convergence/Divergence', id='9', on=False, labelPosition='right'), # {'daq.BooleanSwitch(label'='', id='', on=False, labelPosition='right'), MACDEXT daq.BooleanSwitch(label='Stochastic Oscillator Values', id='10', on=False, labelPosition='right'), # {'daq.BooleanSwitch(label'='', id='', on=False, labelPosition='right'), STOCHF daq.BooleanSwitch(label='Relative Strength Index', id='11', on=False, labelPosition='right'), daq.BooleanSwitch(label='Stochastic Relative Strength Index', id='12', on=False, labelPosition='right'), daq.BooleanSwitch(label='Williams %R Values', id='13', on=False, labelPosition='right'), daq.BooleanSwitch(label='Average Directional Movement Index', id='14', on=False, labelPosition='right'), daq.BooleanSwitch(label='Absolute Price Oscillator Values', id='15', on=False, labelPosition='right'), daq.BooleanSwitch(label='Percentage Price Oscillator Values', id='16', on=False, labelPosition='right'), daq.BooleanSwitch(label='Momentum Values', id='17', on=False, labelPosition='right'), daq.BooleanSwitch(label='Balance of Power Values', id='18', on=False, labelPosition='right'), daq.BooleanSwitch(label='Commodity Channel Index', id='19', on=False, labelPosition='right'), daq.BooleanSwitch(label='Chande Momentum Oscillator Values', id='20', on=False, labelPosition='right'), # {'daq.BooleanSwitch(label'='Rate of Change Values', id='', on=False, labelPosition='right'), # Save as default indicator daq.BooleanSwitch(label='AROON Values', id='21', on=False, labelPosition='right'), daq.BooleanSwitch(label='AROON OScillator Values', id='22', on=False, labelPosition='right'), daq.BooleanSwitch(label='Money Flow Index', id='23', on=False, labelPosition='right'), # {'daq.BooleanSwitch(label'='', id='', on=False, labelPosition='right'), TRIX daq.BooleanSwitch(label='Ultimate Oscillator Values', id='24', on=False, labelPosition='right'), daq.BooleanSwitch(label='Directional Movement Index', id='25', on=False, labelPosition='right'), daq.BooleanSwitch(label='Minus Directional Indicator Values', id='26', on=False, labelPosition='right'), daq.BooleanSwitch(label='Plus Directional Indicator Values', id='27', on=False, labelPosition='right'), daq.BooleanSwitch(label='Minus Directional Movement Values', id='28', on=False, labelPosition='right'), daq.BooleanSwitch(label='Plus Directional Movement Values', id='29', on=False, labelPosition='right'), # {'daq.BooleanSwitch(label'='', id='', on=False, labelPosition='right'), # BBands by default daq.BooleanSwitch(label='Midpoint Values', id='30', on=False, labelPosition='right'), daq.BooleanSwitch(label='Midprice Values', id='31', on=False, labelPosition='right'), daq.BooleanSwitch(label='Parabolic SAR Values', id='32', on=False, labelPosition='right'), daq.BooleanSwitch(label='True Range Values', id='33', on=False, labelPosition='right'), daq.BooleanSwitch(label='Average True Range Values', id='34', on=False, labelPosition='right'), daq.BooleanSwitch(label='Normalized Average True Range Values', id='35', on=False, labelPosition='right'), daq.BooleanSwitch(label='Chaikin A/D Line Values', id='36', on=False, labelPosition='right'), daq.BooleanSwitch(label='Chaikin A/D Oscialltor Values', id='37', on=False, labelPosition='right'), daq.BooleanSwitch(label='On-balance Volume Values', id='38', on=False, labelPosition='right'), daq.BooleanSwitch(label='Hilbert Transform', id='39', on=False, labelPosition='right'), daq.BooleanSwitch(label='Hilbert Transform: Sine Wave', id='40', on=False, labelPosition='right'), daq.BooleanSwitch(label='Hilbert Transform: Trend vs Cycle', id='41', on=False, labelPosition='right'), daq.BooleanSwitch(label='Hilbert Transform: Dominant Cycle Period', id='42', on=False, labelPosition='right'), daq.BooleanSwitch(label='Hilbert Transform: Dominant Cycle Phase', id='43', on=False, labelPosition='right'), daq.BooleanSwitch(label='Hilbert Transform: Phasor Components', id='44', on=False, labelPosition='right'), ])),
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'), ),