Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 =
|
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
|
30 |
st.header('**%s**' % string_name)
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
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.")
|
|
|
|