LinkLinkWu commited on
Commit
9966141
Β·
verified Β·
1 Parent(s): afa537c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -17
app.py CHANGED
@@ -21,10 +21,25 @@ st.markdown("""
21
  body {
22
  background-color: #ffffff;
23
  }
24
- h1 {
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  color: #002b45;
26
  font-family: 'Segoe UI', sans-serif;
27
- font-size: 18px;
 
 
28
  }
29
  .stTextInput > div > div > input,
30
  .stTextArea textarea {
@@ -46,50 +61,49 @@ st.markdown("""
46
  </style>
47
  """, unsafe_allow_html=True)
48
 
49
- # ----------- Header Section with Title Only -----------
50
  st.markdown("""
51
- <div style="margin-bottom: 1.5rem;">
52
- <h1 style="margin: 0;">πŸ“Š EquiPulse: Real-Time Stock News Sentiment</h1>
53
  </div>
54
  """, unsafe_allow_html=True)
55
 
56
-
57
- # ----------- Clean Description Section -----------
58
  st.markdown("""
59
- <div style='font-size:16px; line-height:1.6; color: #333333;'>
60
- Analyze financial sentiment from real-time news headlines related to your selected companies.
61
  </div>
62
  """, unsafe_allow_html=True)
63
 
64
  # ----------- Input Area -----------
65
- st.markdown("#### 🎯 Enter Your Target Company Tickers")
66
- free_text = st.text_area("Example: AAPL, NVDA, NKE", height=90)
67
 
 
68
  ner_pipeline = get_ner_pipeline()
69
  tickers = extract_org_entities(free_text, ner_pipeline)
70
 
71
  if tickers:
72
- st.markdown(f"βœ… **Identified Tickers:** `{', '.join(tickers)}`")
73
  else:
74
  tickers = []
75
 
76
  # ----------- Action Button -----------
77
- if st.button("Get News and Sentiment"):
78
  if not tickers:
79
- st.warning("⚠️ Please enter at least one recognizable company name.")
80
  else:
81
  sentiment_pipeline = get_sentiment_pipeline()
82
  progress_bar = st.progress(0)
83
  total_stocks = len(tickers)
84
 
85
  for idx, ticker in enumerate(tickers):
86
- st.markdown(f"---\n#### πŸ” Analyzing: `{ticker}`")
87
 
88
  news_list = fetch_news(ticker)
89
 
90
  if news_list:
91
  sentiments = [analyze_sentiment(news['title'], sentiment_pipeline) for news in news_list]
92
-
93
  pos_count = sentiments.count("Positive")
94
  neg_count = sentiments.count("Negative")
95
  total = len(sentiments)
@@ -109,7 +123,7 @@ if st.button("Get News and Sentiment"):
109
 
110
  st.success(f"πŸ“ˆ **Overall Sentiment for `{ticker}`: {overall}**")
111
  else:
112
- st.info(f"No recent news available for `{ticker}`.")
113
 
114
  progress_bar.progress((idx + 1) / total_stocks)
115
  time.sleep(0.1)
 
21
  body {
22
  background-color: #ffffff;
23
  }
24
+ .title-wrapper {
25
+ display: inline-block;
26
+ white-space: nowrap;
27
+ overflow-x: auto;
28
+ max-width: 100%;
29
+ }
30
+ .title-wrapper::-webkit-scrollbar {
31
+ height: 4px;
32
+ }
33
+ .title-wrapper::-webkit-scrollbar-thumb {
34
+ background-color: #ccc;
35
+ border-radius: 2px;
36
+ }
37
+ .main-title {
38
  color: #002b45;
39
  font-family: 'Segoe UI', sans-serif;
40
+ font-size: 26px;
41
+ font-weight: 600;
42
+ margin: 0;
43
  }
44
  .stTextInput > div > div > input,
45
  .stTextArea textarea {
 
61
  </style>
62
  """, unsafe_allow_html=True)
63
 
64
+ # ----------- Header Title (One-line, Scrollable if Long) -----------
65
  st.markdown("""
66
+ <div class="title-wrapper">
67
+ <h1 class="main-title">πŸ“Š EquiPulse: Real-Time Stock News Sentiment</h1>
68
  </div>
69
  """, unsafe_allow_html=True)
70
 
71
+ # ----------- Description Section -----------
 
72
  st.markdown("""
73
+ <div style='font-size:16px; line-height:1.6; color: #333333; margin-bottom: 1rem;'>
74
+ Analyze real-time financial sentiment from news headlines related to companies you're interested in.
75
  </div>
76
  """, unsafe_allow_html=True)
77
 
78
  # ----------- Input Area -----------
79
+ st.markdown("#### 🎯 Enter Company Tickers or Names")
80
+ free_text = st.text_area("Example: AAPL, NVIDIA, Tesla", height=90)
81
 
82
+ # ----------- Ticker Extraction -----------
83
  ner_pipeline = get_ner_pipeline()
84
  tickers = extract_org_entities(free_text, ner_pipeline)
85
 
86
  if tickers:
87
+ st.markdown(f"βœ… **Recognized Tickers:** `{', '.join(tickers)}`")
88
  else:
89
  tickers = []
90
 
91
  # ----------- Action Button -----------
92
+ if st.button("πŸ” Get News and Sentiment"):
93
  if not tickers:
94
+ st.warning("⚠️ Please enter at least one recognizable company name or ticker.")
95
  else:
96
  sentiment_pipeline = get_sentiment_pipeline()
97
  progress_bar = st.progress(0)
98
  total_stocks = len(tickers)
99
 
100
  for idx, ticker in enumerate(tickers):
101
+ st.markdown(f"---\n#### πŸ” Analyzing `{ticker}`")
102
 
103
  news_list = fetch_news(ticker)
104
 
105
  if news_list:
106
  sentiments = [analyze_sentiment(news['title'], sentiment_pipeline) for news in news_list]
 
107
  pos_count = sentiments.count("Positive")
108
  neg_count = sentiments.count("Negative")
109
  total = len(sentiments)
 
123
 
124
  st.success(f"πŸ“ˆ **Overall Sentiment for `{ticker}`: {overall}**")
125
  else:
126
+ st.info(f"No recent news found for `{ticker}`.")
127
 
128
  progress_bar.progress((idx + 1) / total_stocks)
129
  time.sleep(0.1)