pvyas96 commited on
Commit
8da5022
·
verified ·
1 Parent(s): d200ddb

Update src/utils.py

Browse files
Files changed (1) hide show
  1. src/utils.py +18 -3
src/utils.py CHANGED
@@ -366,7 +366,22 @@ def get_global_indices():
366
 
367
  @st.cache_data(ttl=900)
368
  def get_market_news():
 
 
 
 
 
369
  try:
370
- ticker = yf.Ticker("^NSEI")
371
- return ticker.news
372
- except: return []
 
 
 
 
 
 
 
 
 
 
 
366
 
367
  @st.cache_data(ttl=900)
368
  def get_market_news():
369
+ """
370
+ Fetch latest market news.
371
+ Note: We use RELIANCE.NS as a proxy because ^NSEI (Index)
372
+ news feed is often empty or broken in yfinance.
373
+ """
374
  try:
375
+ # Primary Source: Reliance Industries (Major market mover)
376
+ ticker = yf.Ticker("RELIANCE.NS")
377
+ news = ticker.news
378
+
379
+ # Fallback Source: TCS if Reliance returns nothing
380
+ if not news:
381
+ ticker = yf.Ticker("TCS.NS")
382
+ news = ticker.news
383
+
384
+ return news
385
+ except Exception as e:
386
+ print(f"News error: {e}")
387
+ return []