Update app.py
Browse files
app.py
CHANGED
@@ -18,67 +18,35 @@ st.set_page_config(
|
|
18 |
# ----------- Custom Styling -----------
|
19 |
st.markdown("""
|
20 |
<style>
|
21 |
-
body {
|
22 |
-
background-color: #ffffff;
|
23 |
-
}
|
24 |
/* Title styling */
|
25 |
-
.main-title
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
color: #002b45;
|
30 |
-
margin-bottom: 1.2rem;
|
31 |
-
white-space: nowrap;
|
32 |
-
overflow-x: auto;
|
33 |
-
}
|
34 |
-
.main-title::-webkit-scrollbar {
|
35 |
-
height: 4px;
|
36 |
-
}
|
37 |
-
.main-title::-webkit-scrollbar-thumb {
|
38 |
-
background-color: #ccc;
|
39 |
-
border-radius: 2px;
|
40 |
-
}
|
41 |
/* Input + Button styling */
|
42 |
.stTextInput > div > div > input,
|
43 |
-
.stTextArea textarea
|
44 |
-
|
45 |
-
|
46 |
-
.stButton>button
|
47 |
-
|
48 |
-
color: white;
|
49 |
-
font-size: 16px;
|
50 |
-
padding: 0.4rem 1rem;
|
51 |
-
border-radius: 6px;
|
52 |
-
}
|
53 |
-
.stButton>button:hover {
|
54 |
-
background-color: #004b78;
|
55 |
-
}
|
56 |
-
.stMarkdown {
|
57 |
-
font-size: 16px;
|
58 |
-
}
|
59 |
</style>
|
60 |
""", unsafe_allow_html=True)
|
61 |
|
62 |
# ----------- Header Title (Centered + Bold + Large + Professional) -----------
|
63 |
st.markdown("""
|
64 |
<style>
|
65 |
-
.centered-title {
|
66 |
-
|
67 |
-
|
68 |
-
font-weight: 800;
|
69 |
-
font-family: 'Segoe UI', sans-serif;
|
70 |
-
color: #002b45;
|
71 |
-
margin-top: 20px;
|
72 |
-
margin-bottom: 20px;
|
73 |
-
}
|
74 |
</style>
|
75 |
<div class="centered-title">π EquiPulse: Stock Sentiment Tracker</div>
|
76 |
""", unsafe_allow_html=True)
|
77 |
|
78 |
-
|
79 |
# ----------- Description Section -----------
|
80 |
st.markdown("""
|
81 |
-
<div style='font-size:16px; line-height:1.6; color
|
82 |
Analyze real-time financial sentiment from news headlines related to companies you're interested in.
|
83 |
</div>
|
84 |
""", unsafe_allow_html=True)
|
@@ -111,10 +79,16 @@ if st.button("π Get News and Sentiment"):
|
|
111 |
news_list = fetch_news(ticker)
|
112 |
|
113 |
if news_list:
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
pos_count = sentiments.count("Positive")
|
116 |
neg_count = sentiments.count("Negative")
|
117 |
-
total
|
118 |
pos_ratio = pos_count / total if total else 0
|
119 |
neg_ratio = neg_count / total if total else 0
|
120 |
|
@@ -129,7 +103,7 @@ if st.button("π Get News and Sentiment"):
|
|
129 |
# Display news
|
130 |
st.markdown(f"**π° Top News for `{ticker}`:**")
|
131 |
for i, news in enumerate(news_list[:3]):
|
132 |
-
st.markdown(f"{i+1}. [{news['title']}]({news['link']}) β **{sentiments[i]}**")
|
133 |
|
134 |
st.success(f"π **Overall Sentiment for `{ticker}`: {overall}**")
|
135 |
else:
|
|
|
18 |
# ----------- Custom Styling -----------
|
19 |
st.markdown("""
|
20 |
<style>
|
21 |
+
body { background-color: #ffffff; }
|
|
|
|
|
22 |
/* Title styling */
|
23 |
+
.main-title { font-size: 32px; font-weight: 700; font-family: 'Segoe UI', sans-serif;
|
24 |
+
color: #002b45; margin-bottom: 1.2rem; white-space: nowrap; overflow-x: auto; }
|
25 |
+
.main-title::-webkit-scrollbar { height: 4px; }
|
26 |
+
.main-title::-webkit-scrollbar-thumb { background-color: #ccc; border-radius: 2px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/* Input + Button styling */
|
28 |
.stTextInput > div > div > input,
|
29 |
+
.stTextArea textarea { font-size: 16px; }
|
30 |
+
.stButton > button { background-color: #002b45; color: white; font-size: 16px;
|
31 |
+
padding: 0.4rem 1rem; border-radius: 6px; }
|
32 |
+
.stButton > button:hover { background-color: #004b78; }
|
33 |
+
.stMarkdown { font-size: 16px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
</style>
|
35 |
""", unsafe_allow_html=True)
|
36 |
|
37 |
# ----------- Header Title (Centered + Bold + Large + Professional) -----------
|
38 |
st.markdown("""
|
39 |
<style>
|
40 |
+
.centered-title { text-align: center; font-size: 36px; font-weight: 800;
|
41 |
+
font-family: 'Segoe UI', sans-serif; color: #002b45;
|
42 |
+
margin-top: 20px; margin-bottom: 20px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
</style>
|
44 |
<div class="centered-title">π EquiPulse: Stock Sentiment Tracker</div>
|
45 |
""", unsafe_allow_html=True)
|
46 |
|
|
|
47 |
# ----------- Description Section -----------
|
48 |
st.markdown("""
|
49 |
+
<div style='font-size:16px; line-height:1.6; color:#333; margin-bottom:1rem;'>
|
50 |
Analyze real-time financial sentiment from news headlines related to companies you're interested in.
|
51 |
</div>
|
52 |
""", unsafe_allow_html=True)
|
|
|
79 |
news_list = fetch_news(ticker)
|
80 |
|
81 |
if news_list:
|
82 |
+
# ------------------------------------------------------
|
83 |
+
sentiments = [
|
84 |
+
analyze_sentiment(news["title"], pipe=sentiment_pipeline)
|
85 |
+
for news in news_list
|
86 |
+
]
|
87 |
+
# ------------------------------------------------------
|
88 |
+
|
89 |
pos_count = sentiments.count("Positive")
|
90 |
neg_count = sentiments.count("Negative")
|
91 |
+
total = len(sentiments)
|
92 |
pos_ratio = pos_count / total if total else 0
|
93 |
neg_ratio = neg_count / total if total else 0
|
94 |
|
|
|
103 |
# Display news
|
104 |
st.markdown(f"**π° Top News for `{ticker}`:**")
|
105 |
for i, news in enumerate(news_list[:3]):
|
106 |
+
st.markdown(f"{i + 1}. [{news['title']}]({news['link']}) β **{sentiments[i]}**")
|
107 |
|
108 |
st.success(f"π **Overall Sentiment for `{ticker}`: {overall}**")
|
109 |
else:
|