pschofield2 commited on
Commit
0bdd1c4
·
verified ·
1 Parent(s): a919a08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -312,7 +312,7 @@ def plot_price_chart(ticker: str):
312
 
313
  predicted_price = last_known_price * (1 + predicted_return)
314
 
315
- # Plot the data
316
  plt.figure(figsize=(10, 5))
317
  plt.plot(historical_dates, historical_prices, label='Historical Prices', marker='o')
318
  plt.axvline(x=last_known_date, color='gray', linestyle='--', label='Last Known Date')
@@ -321,6 +321,17 @@ def plot_price_chart(ticker: str):
321
  # Adding gap for 21 trading days (assuming 5 trading days per week)
322
  gap_dates = pd.date_range(start=last_known_date, periods=22, freq='B')[-1]
323
  plt.axvline(x=gap_dates, color='blue', linestyle='--', label='21 Trading Days Gap')
 
 
 
 
 
 
 
 
 
 
 
324
 
325
  plt.xlabel('Date')
326
  plt.ylabel('Price')
 
312
 
313
  predicted_price = last_known_price * (1 + predicted_return)
314
 
315
+ # Plot the data
316
  plt.figure(figsize=(10, 5))
317
  plt.plot(historical_dates, historical_prices, label='Historical Prices', marker='o')
318
  plt.axvline(x=last_known_date, color='gray', linestyle='--', label='Last Known Date')
 
321
  # Adding gap for 21 trading days (assuming 5 trading days per week)
322
  gap_dates = pd.date_range(start=last_known_date, periods=22, freq='B')[-1]
323
  plt.axvline(x=gap_dates, color='blue', linestyle='--', label='21 Trading Days Gap')
324
+
325
+ # Annotations
326
+ plt.annotate(f'Last Known Price: {last_known_price:.2f}',
327
+ xy=(last_known_date, last_known_price),
328
+ xytext=(last_known_date, last_known_price * 1.05),
329
+ arrowprops=dict(facecolor='black', arrowstyle='->'))
330
+
331
+ plt.annotate(f'Predicted Price: {predicted_price:.2f}\nPredicted Return: {predicted_return:.2%}',
332
+ xy=(predicted_date, predicted_price),
333
+ xytext=(predicted_date, predicted_price * 1.05),
334
+ arrowprops=dict(facecolor='red', arrowstyle='->'))
335
 
336
  plt.xlabel('Date')
337
  plt.ylabel('Price')