I was a regular user of NSEpy, it’s a great library, but recently I observed that while it worked fine on my local machine, it was not able to fetch any data when used from cloud. I tried AWS, Google colab and GCP but this behaviour looked consistent.
If you ping
www1.nseindia.com from your local machine, it shows IP address -
22.214.171.124, But if you ping from your virtual machine, it shows IP address -
126.96.36.199. So NSE is redirecting traffic from cloud to another ip and apparently it is not returning any results on http request.
Jugaad Data as per documentation.
Here’s a small snippet of code showing how to fetch data -
from jugaad_data import JugaadData from datetime import date z = JugaadData() z.base_url = "https://188.8.131.52" z.ssl_verify = False j = JugaadData() symbol = "RELIANCE" index = "NIFTY 50" from_date = date(2019,1,3) to_date = date(2020,1,10) stock_df = j.stock_history(symbol, from_date, to_date) index_df = j.index_history(index, from_date, to_date)
You will get an SSL warning, but at least it works for now.