Johan713 commited on
Commit
e7461b0
·
verified ·
1 Parent(s): 3318a9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -11
app.py CHANGED
@@ -573,15 +573,23 @@ def explore_data():
573
  """)
574
 
575
  fig = go.Figure()
576
- fig.add_trace(go.Scatter(x=data.index, y=data['Close'], mode='lines', name='Close'))
577
-
578
- fig.update_layout(title=f"{company_name} Stock Price History",
579
- xaxis_title="Date",
580
- yaxis_title="Price",
581
- hovermode="x unified",
582
- template="plotly_dark")
583
- st.plotly_chart(fig, use_container_width=True)
584
-
 
 
 
 
 
 
 
 
585
  with tab2:
586
  st.markdown("""
587
  ### OHLC (Open-High-Low-Close) Chart
@@ -756,8 +764,14 @@ def explore_data():
756
  st.metric("Avg Daily Return", f"{returns.mean():.2f}%")
757
  st.metric("Return Volatility", f"{returns.std():.2f}%")
758
 
759
- else:
760
- st.error("Failed to fetch data. Please try again.")
 
 
 
 
 
 
761
  except Exception as e:
762
  st.error(f"An error occurred: {str(e)}. Please try a different time period or check your internet connection.")
763
 
 
573
  """)
574
 
575
  fig = go.Figure()
576
+ fig.add_trace(go.Scatter(x=data.index, y=data['Open'], mode='lines', name='Open'))
577
+ fig.add_trace(go.Scatter(x=data.index, y=data['High'], mode='lines', name='High'))
578
+ fig.add_trace(go.Scatter(x=data.index, y=data['Low'], mode='lines', name='Low'))
579
+ fig.add_trace(go.Scatter(x=data.index, y=data['Close'], mode='lines', name='Close'))
580
+
581
+ # Add rolling mean and standard deviation
582
+ data['Rolling_Mean'] = data['Close'].rolling(window=20).mean()
583
+ data['Rolling_Std'] = data['Close'].rolling(window=20).std()
584
+ fig.add_trace(go.Scatter(x=data.index, y=data['Rolling_Mean'], mode='lines', name='20-day Rolling Mean', line=dict(dash='dash')))
585
+ fig.add_trace(go.Scatter(x=data.index, y=data['Rolling_Std'], mode='lines', name='20-day Rolling Std', line=dict(dash='dot')))
586
+
587
+ fig.update_layout(title=f"{company_name} Stock Price History",
588
+ xaxis_title="Date",
589
+ yaxis_title="Price",
590
+ hovermode="x unified",
591
+ template="plotly_dark")
592
+ st.plotly_chart(fig, use_container_width=True)
593
  with tab2:
594
  st.markdown("""
595
  ### OHLC (Open-High-Low-Close) Chart
 
764
  st.metric("Avg Daily Return", f"{returns.mean():.2f}%")
765
  st.metric("Return Volatility", f"{returns.std():.2f}%")
766
 
767
+ # Display news
768
+ st.subheader("Latest News")
769
+ news = fetch_news(company_name)
770
+ for item in news:
771
+ st.markdown(f"[{item['title']}]({item['link']}) ({item['pubDate']})")
772
+ else:
773
+ st.error("Failed to fetch data. Please try again.")
774
+
775
  except Exception as e:
776
  st.error(f"An error occurred: {str(e)}. Please try a different time period or check your internet connection.")
777