Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,10 @@ from sklearn.linear_model import LinearRegression
|
|
7 |
|
8 |
# Function to fetch data
|
9 |
def fetch_data(ticker, start_date, end_date):
|
|
|
|
|
|
|
|
|
10 |
stock_data = yf.download(ticker, start=start_date, end=end_date)
|
11 |
return stock_data
|
12 |
|
@@ -62,11 +66,11 @@ def stock_prediction_interface(ticker, start_date, end_date):
|
|
62 |
# Gradio app UI
|
63 |
ticker_list = ['AAPL', 'GOOGL', 'MSFT', 'AMZN', 'TSLA', 'META', 'NFLX', 'NVDA', 'BABA', 'INTC']
|
64 |
|
65 |
-
#
|
66 |
with gr.Blocks() as demo:
|
67 |
ticker_input = gr.components.Dropdown(choices=ticker_list, label="Stock Ticker")
|
68 |
-
start_date_input = gr.components.
|
69 |
-
end_date_input = gr.components.
|
70 |
|
71 |
output_text = gr.components.Textbox(label="Prediction Results")
|
72 |
output_plot = gr.components.Plot(label="Stock Price Plot")
|
|
|
7 |
|
8 |
# Function to fetch data
|
9 |
def fetch_data(ticker, start_date, end_date):
|
10 |
+
# Convert input dates from strings to pandas datetime
|
11 |
+
start_date = pd.to_datetime(start_date)
|
12 |
+
end_date = pd.to_datetime(end_date)
|
13 |
+
|
14 |
stock_data = yf.download(ticker, start=start_date, end=end_date)
|
15 |
return stock_data
|
16 |
|
|
|
66 |
# Gradio app UI
|
67 |
ticker_list = ['AAPL', 'GOOGL', 'MSFT', 'AMZN', 'TSLA', 'META', 'NFLX', 'NVDA', 'BABA', 'INTC']
|
68 |
|
69 |
+
# Use Textbox for date input since Gradio doesn't have a Date component anymore
|
70 |
with gr.Blocks() as demo:
|
71 |
ticker_input = gr.components.Dropdown(choices=ticker_list, label="Stock Ticker")
|
72 |
+
start_date_input = gr.components.Textbox(label="Start Date (YYYY-MM-DD)", placeholder="e.g. 2023-01-01")
|
73 |
+
end_date_input = gr.components.Textbox(label="End Date (YYYY-MM-DD)", placeholder="e.g. 2023-12-31")
|
74 |
|
75 |
output_text = gr.components.Textbox(label="Prediction Results")
|
76 |
output_plot = gr.components.Plot(label="Stock Price Plot")
|