Khanmx99 commited on
Commit
e7084d7
·
verified ·
1 Parent(s): dcf0230

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -87,16 +87,18 @@ if st.button("Analyze"):
87
  # Moving Averages and Bollinger Bands
88
  st.subheader("Volatility Analysis")
89
  ma_20, upper_band, lower_band = calculate_bollinger_bands(stock_data)
90
- plt.figure(figsize=(10, 5))
91
- plt.plot(stock_data['Close'], label="Close Price")
92
- plt.plot(ma_20, label="20-Day Moving Average", linestyle='--')
93
- plt.plot(upper_band, label="Upper Bollinger Band", linestyle='--')
94
- plt.plot(lower_band, label="Lower Bollinger Band", linestyle='--')
95
- plt.legend()
96
- plt.title(f"{ticker} Price with Bollinger Bands")
97
- plt.xlabel("Date")
98
- plt.ylabel("Price")
99
- st.pyplot()
 
 
100
 
101
  # Fetch and Analyze News
102
  st.subheader("Latest News and Sentiment Analysis")
 
87
  # Moving Averages and Bollinger Bands
88
  st.subheader("Volatility Analysis")
89
  ma_20, upper_band, lower_band = calculate_bollinger_bands(stock_data)
90
+
91
+ # Create a figure for Bollinger Bands
92
+ fig, ax = plt.subplots(figsize=(10, 5))
93
+ ax.plot(stock_data['Close'], label="Close Price")
94
+ ax.plot(ma_20, label="20-Day Moving Average", linestyle='--')
95
+ ax.plot(upper_band, label="Upper Bollinger Band", linestyle='--')
96
+ ax.plot(lower_band, label="Lower Bollinger Band", linestyle='--')
97
+ ax.legend()
98
+ ax.set_title(f"{ticker} Price with Bollinger Bands")
99
+ ax.set_xlabel("Date")
100
+ ax.set_ylabel("Price")
101
+ st.pyplot(fig)
102
 
103
  # Fetch and Analyze News
104
  st.subheader("Latest News and Sentiment Analysis")