Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,20 +62,38 @@ col1, col2 = st.columns([1, 3])
|
|
62 |
|
63 |
with col1:
|
64 |
st.subheader("Stock Overview")
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
with col2:
|
69 |
st.subheader("Stock Details")
|
70 |
ticker_symbol = st.selectbox('Select a stock for details', options=sp500_list)
|
71 |
if ticker_symbol:
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
st.
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
|
81 |
|
|
|
62 |
|
63 |
with col1:
|
64 |
st.subheader("Stock Overview")
|
65 |
+
# Adjust styling approach here
|
66 |
+
def color_combined_score(value):
|
67 |
+
"""Colors the combined score cell based on its value."""
|
68 |
+
if value > 0:
|
69 |
+
color = 'green'
|
70 |
+
elif value < 0:
|
71 |
+
color = 'red'
|
72 |
+
else:
|
73 |
+
color = 'none'
|
74 |
+
return f'background-color: {color};'
|
75 |
+
|
76 |
+
# Apply the styling function to the 'Combined Score' column only
|
77 |
+
styled_scores_df = scores_df_sorted.style.applymap(color_combined_score, subset=['Combined Score'])
|
78 |
+
st.dataframe(styled_scores_df)
|
79 |
|
80 |
with col2:
|
81 |
st.subheader("Stock Details")
|
82 |
ticker_symbol = st.selectbox('Select a stock for details', options=sp500_list)
|
83 |
if ticker_symbol:
|
84 |
+
with st.spinner(f'Fetching data for {ticker_symbol}...'):
|
85 |
+
stock_data, info = fetch_stock_data(ticker_symbol)
|
86 |
+
comparison, _ = compare_to_index(stock_data, sp500_averages)
|
87 |
+
|
88 |
+
# Display the company name and its ticker symbol
|
89 |
+
st.markdown(f"**{info.get('longName', 'N/A')}** ({ticker_symbol})")
|
90 |
+
|
91 |
+
# Display the company's business summary
|
92 |
+
st.write(info.get('longBusinessSummary', 'Description not available.'))
|
93 |
+
|
94 |
+
# Display each financial ratio and its comparison result
|
95 |
+
for ratio, status in comparison.items():
|
96 |
+
st.text(f"{ratio}: {status}")
|
97 |
|
98 |
|
99 |
|