Update stock notifications with company names and new schedule times
Add full company names to stock price notifications displayed alongside tickers. Update scheduled message times from hourly to three specific times: market open (9:30 AM ET), noon (12:00 PM ET), and market close (4:00 PM ET). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,15 @@ class FinnhubAPI(StockAPIBase):
|
||||
Dictionary with stock data or None if unavailable
|
||||
"""
|
||||
try:
|
||||
# Get company name from company profile
|
||||
company_name = None
|
||||
try:
|
||||
profile = self.client.company_profile2(symbol=ticker)
|
||||
company_name = profile.get('name') or ticker.upper()
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not fetch company name for {ticker}: {e}")
|
||||
company_name = ticker.upper()
|
||||
|
||||
# Get current quote data
|
||||
quote = self.client.quote(ticker)
|
||||
|
||||
@@ -56,6 +65,7 @@ class FinnhubAPI(StockAPIBase):
|
||||
|
||||
return {
|
||||
'ticker': ticker.upper(),
|
||||
'company_name': company_name,
|
||||
'current_price': round(current_price, 2),
|
||||
'previous_close': round(previous_close, 2),
|
||||
'change_dollar': round(change_dollar, 2),
|
||||
|
||||
@@ -23,6 +23,15 @@ class YahooFinanceAPI(StockAPIBase):
|
||||
try:
|
||||
stock = yf.Ticker(ticker)
|
||||
|
||||
# Get company name from info
|
||||
company_name = None
|
||||
try:
|
||||
info = stock.info
|
||||
company_name = info.get('longName') or info.get('shortName') or ticker.upper()
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not fetch company name for {ticker}: {e}")
|
||||
company_name = ticker.upper()
|
||||
|
||||
# Use history() method instead of info to avoid rate limiting
|
||||
# Get last 2 days of data to calculate change
|
||||
hist = stock.history(period="2d")
|
||||
@@ -48,6 +57,7 @@ class YahooFinanceAPI(StockAPIBase):
|
||||
|
||||
return {
|
||||
'ticker': ticker.upper(),
|
||||
'company_name': company_name,
|
||||
'current_price': round(current_price, 2),
|
||||
'previous_close': round(previous_close, 2),
|
||||
'change_dollar': round(change_dollar, 2),
|
||||
|
||||
Reference in New Issue
Block a user