@@ -40,6 +40,7 @@ class StockUpdateThread(QThread):
4040
4141 def fetch_latest_data(self):
4242 current_price = self.get_current_stock_price()
43+ company_name = self.get_company_name() # Make sure this line is here
4344 nikkei_news = self.scrape_nikkei_news()
4445 yahoo_news = self.scrape_yahoo_finance_news()
4546 nikkei_sentiment = self.analyze_sentiment(nikkei_news)
@@ -49,6 +50,7 @@ class StockUpdateThread(QThread):
4950
5051 return {
5152 'current_price': current_price,
53+ 'company_name': company_name,
5254 'nikkei_sentiment': nikkei_sentiment,
5355 'yahoo_sentiment': yahoo_sentiment,
5456 'nikkei_news': nikkei_news,
@@ -119,6 +121,18 @@ class StockUpdateThread(QThread):
119121
120122 return sum(sentiments) / len(sentiments) if sentiments else None
121123
124+ def get_company_name(self):
125+ url = f"https://finance.yahoo.co.jp/quote/{self.stock_number}.T"
126+ response = requests.get(url)
127+ soup = BeautifulSoup(response.content, 'html.parser')
128+ title_tag = soup.find('title')
129+ if title_tag:
130+ title = title_tag.text.strip()
131+ company_name = title.split('【')[0].strip()
132+ return company_name
133+ else:
134+ return "Company name not found"
135+
122136 def get_stock_data(self):
123137 ticker = f"{self.stock_number}.T"
124138 end_date = datetime.now()
@@ -201,14 +215,16 @@ class MAGIStockAnalysis(QWidget):
201215 def initUI(self):
202216 self.setWindowTitle('MAGI Stock Analysis System')
203217 self.setGeometry(100, 100, 1200, 800)
204- self.setStyleSheet("background-color: black ; color: #00ff00;")
218+ self.setStyleSheet("background-color: #000000 ; color: #00ff00;")
205219
206220 main_layout = QVBoxLayout()
221+ main_layout.setSpacing(10)
222+ main_layout.setContentsMargins(10, 10, 10, 10)
207223
208224 # Header
209225 header = QLabel('MAGI Stock Analysis System')
210226 header.setAlignment(Qt.AlignmentFlag.AlignCenter)
211- header.setStyleSheet("font-size: 24px; color: #ff8c00;")
227+ header.setStyleSheet("font-size: 24px; color: #ff8c00; margin-bottom: 10px; ")
212228 main_layout.addWidget(header)
213229
214230 # Input section
@@ -219,37 +235,73 @@ class MAGIStockAnalysis(QWidget):
219235 self.price_input.setPlaceholderText("Purchase price (optional)")
220236 analyze_button = QPushButton("Analyze")
221237 analyze_button.clicked.connect(self.analyze_stock)
238+
239+ # Style for input fields
240+ input_style = """
241+ QLineEdit {
242+ background-color: #001a1a;
243+ color: #00ff00;
244+ border: 1px solid #00ff00;
245+ border-radius: 5px;
246+ padding: 5px;
247+ }
248+ """
249+ self.stock_input.setStyleSheet(input_style)
250+ self.price_input.setStyleSheet(input_style)
251+
252+ # Specific style for Analyze button with orange rectangle
253+ analyze_button.setStyleSheet("""
254+ QPushButton {
255+ background-color: #001a1a;
256+ color: #00ff00;
257+ border: 2px solid #ff8c00;
258+ border-radius: 5px;
259+ padding: 5px;
260+ }
261+ QPushButton:hover {
262+ background-color: #002a2a;
263+ }
264+ """)
265+
222266 input_layout.addWidget(self.stock_input)
223267 input_layout.addWidget(self.price_input)
224268 input_layout.addWidget(analyze_button)
225269 main_layout.addLayout(input_layout)
226270
227271 # MAGI components
228272 magi_layout = QHBoxLayout()
229- self.casper = self.create_magi_component("CASPER • 3")
230- self.balthasar = self.create_magi_component("BALTHASAR • 2")
273+ magi_layout.setSpacing(10)
231274 self.melchior = self.create_magi_component("MELCHIOR • 1")
232- magi_layout.addWidget( self.casper )
233- magi_layout.addWidget( self.balthasar )
275+ self.balthasar = self.create_magi_component("BALTHASAR • 2" )
276+ self.casper = self.create_magi_component("CASPER • 3" )
234277 magi_layout.addWidget(self.melchior)
235- main_layout.addLayout(magi_layout)
278+ magi_layout.addWidget(self.balthasar)
279+ magi_layout.addWidget(self.casper)
280+ main_layout.addLayout(magi_layout, stretch=1)
236281
237282 self.setLayout(main_layout)
238283
239284 def create_magi_component(self, title):
240285 component = QWidget()
241- component.setStyleSheet("border: 2px solid #ff8c00; background-color: #001a1a;")
242- layout = QVBoxLayout()
286+ component.setStyleSheet("""
287+ background-color: #001a1a;
288+ border: 2px solid #ff8c00;
289+ border-radius: 5px;
290+ """)
291+ layout = QVBoxLayout(component)
292+ layout.setContentsMargins(5, 5, 5, 5)
293+
243294 title_label = QLabel(title)
244295 title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
245- title_label.setStyleSheet("font-size: 18px; color: #ff8c00;")
296+ title_label.setStyleSheet("font-size: 18px; color: #ff8c00; background-color: transparent;")
297+
246298 content = QTextEdit()
247299 content.setReadOnly(True)
248- content.setStyleSheet("border: none; background-color: #001a1a ; color: #00ff00;")
249- content.setAlignment(Qt.AlignmentFlag.AlignCenter)
300+ content.setStyleSheet("border: none; background-color: transparent ; color: #00ff00;")
301+
250302 layout.addWidget(title_label)
251303 layout.addWidget(content)
252- component.setLayout(layout)
304+
253305 return component
254306
255307 def start_flicker(self, component):
@@ -302,6 +354,7 @@ class MAGIStockAnalysis(QWidget):
302354 def update_display(self, data, purchase_price):
303355 try:
304356 current_price = data['current_price']
357+ company_name = data['company_name']
305358 nikkei_sentiment = data['nikkei_sentiment']
306359 yahoo_sentiment = data['yahoo_sentiment']
307360 stock_data = data['stock_data']
@@ -316,6 +369,7 @@ class MAGIStockAnalysis(QWidget):
316369
317370 # Update CASPER
318371 casper_content = (
372+ f"Company: {company_name}\n\n"
319373 f"Nikkei Sentiment: {self.sentiment_to_text(nikkei_sentiment)}\n"
320374 f"Yahoo Sentiment: {self.sentiment_to_text(yahoo_sentiment)}\n"
321375 f"Overall Sentiment: {overall_sentiment_text}"
0 commit comments