Skip to content

Commit 89d3cf6

Browse files
committedSep 23, 2024·
fix issues with endpoint response for returning nse tickers list
1 parent 8a4a63b commit 89d3cf6

File tree

3 files changed

+74
-56
lines changed

3 files changed

+74
-56
lines changed
 

‎fin_maestro_kin/modules/data_toolkit/nse/nse_operations.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,28 @@ def get_pcr(self, symbol: str = Query(..., title="Symbol", description="Stock sy
776776

777777
def nse_equity_tickers(self):
778778
try:
779-
symbols = pd.read_csv('https://archives.nseindia.com/content/equities/EQUITY_L.csv')
780-
tickers = symbols['SYMBOL'].tolist()
781-
return tickers
779+
headers = {
780+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
781+
}
782+
783+
indices = ['NIFTY 50', 'NIFTY NEXT 50', 'NIFTY 500', 'NIFTY MIDSMALLCAP 400']
784+
base_url = 'https://www.nseindia.com/api/equity-stockIndices?index='
785+
786+
tickers = []
787+
788+
for index in indices:
789+
url = base_url + index.replace(' ', '%20')
790+
response = requests.get(url, headers=headers)
791+
response.raise_for_status()
792+
data = response.json()
793+
794+
for stock in data['data']:
795+
tickers.append(stock['symbol'])
796+
797+
return list(set(tickers))
798+
782799
except Exception as e:
783-
return f"Error fetching equity tickers: {e}"
800+
raise HTTPException(status_code=500, detail=f"Error fetching equity tickers: {e}")
784801

785802
def get_nse_equity_tickers(self):
786803
return {"equity_tickers": self.nse_equity_tickers()}

‎poetry.lock

+51-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[tool.poetry]
22
name = "fin-maestro-kin"
3-
version = "0.3.2"
3+
version = "0.3.3"
44
description = "Seamless Finance: Docker Deployed APIs for Smart Investments."
55
authors = ["DEV_FINWIZ <devjuneja43@gmail.com>"]
66
license = "MIT"
77
readme = "README.md"
88

99
[tool.poetry.dependencies]
1010
python = "^3.9"
11-
fastapi = "^0.109.0"
11+
fastapi = "^0.114.0"
1212
uvicorn = "^0.25.0"
1313
pydantic = "^2.5.3"
1414
requests = "^2.31.0"

0 commit comments

Comments
 (0)
Please sign in to comment.