Kr08 commited on
Commit
8b5f94a
·
verified ·
1 Parent(s): 7c2d39c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -7,7 +7,7 @@ demo = gr.Blocks()
7
 
8
  with demo:
9
  d1 = gr.Dropdown(index_options, label='Please select Index...', info='Will be adding more indices later on', interactive=True)
10
- d2 = gr.Dropdown([], label='Please Select Stock from your selected index', interactive=True)
11
  d3 = gr.Dropdown(time_intervals, label='Select Time Interval', value='1d', interactive=True)
12
  d4 = gr.Radio(['Line Graph', 'Candlestick Graph'], label='Select Graph Type', value='Line Graph', interactive=True)
13
  d5 = gr.Dropdown(['ARIMA', 'Prophet', 'LSTM'], label='Select Forecasting Method', value='ARIMA', interactive=True)
@@ -18,11 +18,15 @@ with demo:
18
  inputs = [d1, d2, d3, d4, d5]
19
  outputs = [out_graph, out_fundamentals]
20
 
21
- d1.input(get_stocks_from_index, d1, d2)
22
- d2.input(get_stock_graph_and_info, inputs, outputs)
23
- d3.input(get_stock_graph_and_info, inputs, outputs)
24
- d4.input(get_stock_graph_and_info, inputs, outputs)
25
- d5.input(get_stock_graph_and_info, inputs, outputs)
 
 
 
 
26
 
27
  if __name__ == "__main__":
28
  demo.launch()
 
7
 
8
  with demo:
9
  d1 = gr.Dropdown(index_options, label='Please select Index...', info='Will be adding more indices later on', interactive=True)
10
+ d2 = gr.Dropdown(label='Please Select Stock from your selected index', interactive=True)
11
  d3 = gr.Dropdown(time_intervals, label='Select Time Interval', value='1d', interactive=True)
12
  d4 = gr.Radio(['Line Graph', 'Candlestick Graph'], label='Select Graph Type', value='Line Graph', interactive=True)
13
  d5 = gr.Dropdown(['ARIMA', 'Prophet', 'LSTM'], label='Select Forecasting Method', value='ARIMA', interactive=True)
 
18
  inputs = [d1, d2, d3, d4, d5]
19
  outputs = [out_graph, out_fundamentals]
20
 
21
+ def update_stock_options(index):
22
+ stocks = get_stocks_from_index(index)
23
+ return gr.Dropdown(choices=stocks)
24
+
25
+ d1.change(update_stock_options, d1, d2)
26
+ d2.change(get_stock_graph_and_info, inputs, outputs)
27
+ d3.change(get_stock_graph_and_info, inputs, outputs)
28
+ d4.change(get_stock_graph_and_info, inputs, outputs)
29
+ d5.change(get_stock_graph_and_info, inputs, outputs)
30
 
31
  if __name__ == "__main__":
32
  demo.launch()