You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@kishoretarun As of now this code won't support that feature. You can try this code to find "NIFTY BANK".
If you want stock name in nsetool library change these lines in get_fno_lot_sizes method.
(underlying_code, _, name) = [x.strip() for x in line.split(',')[0:3]]
res_dict[underlying_code] = int(name)
Save this in stock.py file and run python stock.py.
import six
import re
from http.cookiejar import CookieJar
from urllib.request import build_opener, HTTPCookieProcessor, Request
from pprint import pprint # just for neatness of display
headers = {
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Host': 'www1.nseindia.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0',
'X-Requested-With': 'XMLHttpRequest'
}
fno_lot_size_url = "https://www1.nseindia.com/content/fo/fo_mktlots.csv"
req = Request(fno_lot_size_url, None, headers, None, True)
cj = CookieJar()
opener = build_opener(HTTPCookieProcessor(cj))
res = opener.open(req)
strings = res.read().decode('latin-1')
fbuffer = six.StringIO(strings)
res_dict = {}
for line in fbuffer.read().split('\n'):
if line != '' and re.search(',', line) and (line.casefold().find('symbol') == -1):
(underlying_code, _, name) = [x.strip() for x in line.split(',')[0:3]]
res_dict[underlying_code] = int(name)
pprint(res_dict)
how to get lot size of stocks with original stock name, instead of some other symbol...
for example- It is returing "banknifty" with its lot size.. but the original stock symbol is "NIFTY BANK"
is their any way to filter this out?
The text was updated successfully, but these errors were encountered: