JayLacoma commited on
Commit
d090fb9
·
verified ·
1 Parent(s): cb77ab1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -52,15 +52,19 @@ def stock_forecast(ticker, start_date, end_date):
52
  inputs=df,
53
  freq="D", # Daily frequency
54
  value_name="y",
55
- num_jobs=2,
56
  )
57
 
58
  # Combine actual and forecasted data for plotting
59
  combined_df = pd.concat([df, forecast_df], axis=0)
60
 
 
 
 
 
61
  # Create an interactive plot with Plotly
62
- fig = px.line(combined_df, x='ds', y=['y', 'timesfm'], labels={'value': 'Price', 'ds': 'Date'},
63
- title=f'{ticker} Stock Price Forecast')
64
 
65
  # Customize the plot for a dark theme
66
  fig.update_layout(
@@ -138,7 +142,7 @@ with gr.Blocks() as demo:
138
  with gr.Row():
139
  ticker_input = gr.Textbox(label="Enter Stock Ticker", value="AAPL")
140
  start_date_input = gr.Textbox(label="Enter Start Date (YYYY-MM-DD)", value="2022-01-01")
141
- end_date_input = gr.Textbox(label="Enter End Date (YYYY-MM-DD)", value="2026-01-01")
142
 
143
  submit_button = gr.Button("Enter")
144
  plot_output = gr.Plot()
 
52
  inputs=df,
53
  freq="D", # Daily frequency
54
  value_name="y",
55
+ num_jobs=-1,
56
  )
57
 
58
  # Combine actual and forecasted data for plotting
59
  combined_df = pd.concat([df, forecast_df], axis=0)
60
 
61
+ # Filter the last 90 days of data
62
+ last_90_days = combined_df['ds'].max() - pd.Timedelta(days=90)
63
+ filtered_df = combined_df[combined_df['ds'] >= last_90_days]
64
+
65
  # Create an interactive plot with Plotly
66
+ fig = px.line(filtered_df, x='ds', y=['y', 'timesfm'], labels={'value': 'Price', 'ds': 'Date'},
67
+ title=f'{ticker} Stock Price Forecast (Last 90 Days)')
68
 
69
  # Customize the plot for a dark theme
70
  fig.update_layout(
 
142
  with gr.Row():
143
  ticker_input = gr.Textbox(label="Enter Stock Ticker", value="AAPL")
144
  start_date_input = gr.Textbox(label="Enter Start Date (YYYY-MM-DD)", value="2022-01-01")
145
+ end_date_input = gr.Textbox(label="Enter End Date (YYYY-MM-DD)", value="2025-01-01")
146
 
147
  submit_button = gr.Button("Enter")
148
  plot_output = gr.Plot()