Abhisesh7 commited on
Commit
fc3b29d
·
verified ·
1 Parent(s): 0387dd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -151,3 +151,38 @@ def plot_stock_data(ticker, start_date, end_date):
151
 
152
  plt.show()
153
  return plt.gcf() # Return the current figure object
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
  plt.show()
153
  return plt.gcf() # Return the current figure object
154
+ import matplotlib.pyplot as plt
155
+ import pandas as pd
156
+
157
+ def plot_stock_data(ticker, start_date, end_date):
158
+ # Fetch stock data and make predictions...
159
+ stock_data = fetch_data(ticker, start_date, end_date)
160
+
161
+ # Example future dates (change this according to your actual future date range logic)
162
+ future_dates = pd.date_range(end_date, periods=90, freq='D') # Generates 90 future dates
163
+ future_prices = model_predict(stock_data) # Generates 89 future prices (example)
164
+
165
+ # Ensure both future_dates and future_prices have the same length
166
+ min_length = min(len(future_dates), len(future_prices))
167
+ future_dates = future_dates[:min_length]
168
+ future_prices = future_prices[:min_length]
169
+
170
+ # Plot historical stock data
171
+ plt.figure(figsize=(10, 5))
172
+ plt.plot(stock_data.index, stock_data['Close'], label="Historical Prices")
173
+
174
+ # Plot future predicted prices
175
+ plt.plot(future_dates, future_prices, label="Predicted Future Prices", linestyle='--')
176
+
177
+ # Add labels and title
178
+ plt.xlabel("Date")
179
+ plt.ylabel("Stock Price")
180
+ plt.title(f"{ticker} Stock Price Prediction")
181
+ plt.legend()
182
+ plt.grid(True)
183
+
184
+ # Show the plot
185
+ plt.show()
186
+
187
+ return plt.gcf() # Return the current figure object for Gradio to display
188
+