File size: 1,722 Bytes
31ac823
7057428
5b5151c
 
 
31ac823
 
2e2dfb4
31ac823
 
8b5f94a
31ac823
 
 
7057428
 
 
 
2e2dfb4
5b5151c
 
2e79a3d
7057428
5b5151c
2e79a3d
8b5f94a
 
 
 
 
 
 
 
 
7057428
 
2e2dfb4
5b5151c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr
from datetime import date, timedelta
from config import index_options, time_intervals, START_DATE, END_DATE, FORECAST_PERIOD
from data_fetcher import get_stocks_from_index
from stock_analysis import get_stock_graph_and_info

demo = gr.Blocks()

with demo:
    d1 = gr.Dropdown(index_options, label='Please select Index...', info='Will be adding more indices later on', interactive=True)
    d2 = gr.Dropdown(label='Please Select Stock from your selected index', interactive=True)
    d3 = gr.Dropdown(time_intervals, label='Select Time Interval', value='1d', interactive=True)
    d4 = gr.Radio(['Line Graph', 'Candlestick Graph'], label='Select Graph Type', value='Line Graph', interactive=True)
    d5 = gr.Dropdown(['ARIMA', 'Prophet', 'LSTM'], label='Select Forecasting Method', value='ARIMA', interactive=True)
    
    # New date inputs
    date_start = gr.Date(label="Start Date", value=START_DATE)
    date_end = gr.Date(label="End Date", value=END_DATE)

    out_graph = gr.Plot()
    out_fundamentals = gr.DataFrame()

    inputs = [d1, d2, d3, d4, d5, date_start, date_end]
    outputs = [out_graph, out_fundamentals]

    def update_stock_options(index):
        stocks = get_stocks_from_index(index)
        return gr.Dropdown(choices=stocks)

    d1.change(update_stock_options, d1, d2)
    d2.change(get_stock_graph_and_info, inputs, outputs)
    d3.change(get_stock_graph_and_info, inputs, outputs)
    d4.change(get_stock_graph_and_info, inputs, outputs)
    d5.change(get_stock_graph_and_info, inputs, outputs)
    date_start.change(get_stock_graph_and_info, inputs, outputs)
    date_end.change(get_stock_graph_and_info, inputs, outputs)

if __name__ == "__main__":
    demo.launch()