niyaa commited on
Commit
c953136
·
1 Parent(s): f20226d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -20,17 +20,21 @@ start_date = st.sidebar.date_input("Start date", datetime.date(2019, 1, 1))
20
  end_date = st.sidebar.date_input("End date", datetime.date(2023, 9, 30))
21
 
22
  # User input for the stock ticker symbol
23
- tickerSymbol = "^NSEI"
24
 
25
  if tickerSymbol:
26
  tickerData = yf.Ticker(tickerSymbol) # Get ticker data
27
  tickerDf = tickerData.history(period='1d', start=start_date, end=end_date) # Get the historical prices for this ticker
28
 
29
- string_name = tickerData.info['longName']
30
  st.header('**%s**' % string_name)
31
 
32
- string_summary = tickerData.info['longBusinessSummary']
33
- st.info(string_summary)
 
 
 
 
34
 
35
  # Ticker data
36
  st.header('**Ticker data**')
@@ -44,5 +48,3 @@ if tickerSymbol:
44
  st.plotly_chart(fig)
45
  else:
46
  st.warning("Please enter a valid Stock Ticker Symbol.")
47
-
48
- # You can remove the code for displaying the S&P 500 company symbols and information
 
20
  end_date = st.sidebar.date_input("End date", datetime.date(2023, 9, 30))
21
 
22
  # User input for the stock ticker symbol
23
+ tickerSymbol = st.sidebar.text_input('Enter Stock Ticker Symbol')
24
 
25
  if tickerSymbol:
26
  tickerData = yf.Ticker(tickerSymbol) # Get ticker data
27
  tickerDf = tickerData.history(period='1d', start=start_date, end=end_date) # Get the historical prices for this ticker
28
 
29
+ string_name = tickerData.info.get('longName', 'Company Name Not Available')
30
  st.header('**%s**' % string_name)
31
 
32
+ # Try to get the business summary, handle KeyError if not available
33
+ try:
34
+ string_summary = tickerData.info['longBusinessSummary']
35
+ st.info(string_summary)
36
+ except KeyError:
37
+ st.warning("Business summary not available for this company.")
38
 
39
  # Ticker data
40
  st.header('**Ticker data**')
 
48
  st.plotly_chart(fig)
49
  else:
50
  st.warning("Please enter a valid Stock Ticker Symbol.")