Open pratham-darooka opened 6 months ago
Temporarily using dhan.co for getting lot sizes until this is fixed.
from memoization import cached import jmespath, requests, json @cached(ttl=30 24 3600) def get_lot_sizes_dhan(): res = requests.post("https://open-web-scanx.dhan.co/scanx/allfut", json=json.loads('{"Data":{"Seg":2,"Instrument":"FUT","Count":200,"Page_no":1,"ExpCode":-1}}'), headers={ "content-type": "application/json; charset=UTF-8" }, cookies={}, auth=(), ) lots = jmespath.search("data.list[*].[sym, fo_dt[0].lot_type]", res.json()) result = {x[0]:int(x[1].split()[0]) for x in lots} return result
Thanks @aeron7
url="https://archives.nseindia.com/content/fo/fo_mktlots.csv" not able to find the new location of this url, did anyone found it or temporary have old csv which can work as a temporary solution.
@mirajgodha you can use this:
lot_size = nsepython.nse_quote(symbol=<symbol>)['stocks'][i]['marketDeptOrderBook']['tradeInfo']['marketLot’]
cc: @aeron7
I would suggest to take a look at NSE Circulars dated March 15th here at https://nsearchives.nseindia.com/content/circulars/FAOP61157.pdf
It is the problem of NSE and users (us) -- not the authors' -- not that he would care anyway. You will have to use the forums in general. NSE website should ideally have resorted to 404 code but they hook you and make you think something is wrong with your code. thankfully! circulars give you more information.
Not that you are on your own here, but I would suggest to take a look at the other API methods available in the nsepython library and see if you can deduce the lot size from there and see if you could provide a working patch for the same? hope that is constructive. Please feel free to revert.
Temporarily using dhan.co for getting lot sizes until this is fixed.
from memoization import cached import jmespath, requests, json @cached(ttl=30 24 3600) def get_lot_sizes_dhan(): res = requests.post("https://open-web-scanx.dhan.co/scanx/allfut", json=json.loads('{"Data":{"Seg":2,"Instrument":"FUT","Count":200,"Page_no":1,"ExpCode":-1}}'), headers={ "content-type": "application/json; charset=UTF-8" }, cookies={}, auth=(), ) lots = jmespath.search("data.list[*].[sym, fo_dt[0].lot_type]", res.json()) result = {x[0]:int(x[1].split()[0]) for x in lots} return result
thanks @mdtanveer this is cool as an alternative .. infact, I was debugging dhan get fno lot size webpage but this seems to be what is needed.
I think we all most possibly agree that we could prefer something from the original source, i.e., NSE website itself. So, perhaps exploring more on the NSE website and looking up for any REST urls could be useful and then backtracking the same into library update would be awesome.
File .venv/lib/python3.12/site-packages/nsepython/rahu.py", line 484, in nse_get_fno_lot_sizes (code, name) = [x.strip() for x in line.split(',')[1:3]] ^^^^^^^^^^^^ ValueError: not enough values to unpack (expected 2, got 1)
Seems like the problem is in the url:
url="https://archives.nseindia.com/content/fo/fo_mktlots.csv"
Throws 404. Perhaps need a new URL?