Jitendra12421 commited on
Commit
f32b8de
·
verified ·
1 Parent(s): 933a006

Update get_market_cap_tier to use ScreenerScraper

Browse files
Files changed (1) hide show
  1. forecaster_cli.py +7 -10
forecaster_cli.py CHANGED
@@ -96,20 +96,17 @@ def fetch_live_features(ticker):
96
  return None
97
 
98
  def get_market_cap_tier(ticker):
99
- print(f"[{ticker}] Resolving market cap classification from NSE servers...")
100
  try:
101
- ua = {'User-Agent': 'Mozilla/5.0'}
102
- large = pd.read_csv(TIERS["Large"], storage_options=ua)['Symbol'].tolist()
103
- if ticker in large: return "Large"
104
-
105
- mid = pd.read_csv(TIERS["Mid"], storage_options=ua)['Symbol'].tolist()
106
- if ticker in mid: return "Mid"
107
 
108
- small = pd.read_csv(TIERS["Small"], storage_options=ua)['Symbol'].tolist()
109
- if ticker in small: return "Small"
 
110
 
111
  except Exception as e:
112
- print(f"Warning: Could not fetch NSE lists ({e}). Defaulting to Small Cap.")
113
 
114
  return "Small" # Default to small cap model for everything else
115
 
 
96
  return None
97
 
98
  def get_market_cap_tier(ticker):
99
+ print(f"[{ticker}] Resolving market cap classification via Screener...")
100
  try:
101
+ scraper = ScreenerScraper()
102
+ cap_class = scraper.get_cap_info(ticker)['market_cap_class']
 
 
 
 
103
 
104
+ if "Large" in cap_class: return "Large"
105
+ if "Mid" in cap_class: return "Mid"
106
+ if "Small" in cap_class: return "Small"
107
 
108
  except Exception as e:
109
+ print(f"Warning: Could not fetch market cap ({e}). Defaulting to Small.")
110
 
111
  return "Small" # Default to small cap model for everything else
112