Can any one tell me the code to import nifty data for last 10 days in python?
You can import Nifty data from NSEpy.
from nsepy import get_history
from datetime import datetime
# You can change the dates accordingly
start = datetime(2019, 7, 15)
end = datetime(2019, 7, 30)
data = get_history(symbol='NIFTY',start=start,end=end, index=True)
Thanks!
File "C:\Users\sauravku\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/sauravku/Desktop/untitled1.py", line 1, in <module>
from nsepy import get_history
ModuleNotFoundError: No module named 'nsepy'
You will have to first install nsepy using
!pip install nespy
in your IPython notebook
How to do it can you tell me the process?
Follow the following steps:
If you're using windows,
- Go to the start and search for Jupyter.
- Open your jupyter,create a new ipython notebook by clicking on 'New' on the upper right corner and create a python 3 notebook.
- For quick installation, you need to install nsepy by typing '!pip install nsepy' and run it either by clicking on the green triangle or by pressing F5.
- Once this is done, you could import nsepy and use it functions.
If you're using mac,
- Click on spotlight, type terminal to open terminal window.
- Type Jupyter to launch the Jupyter notebook. The notebook interface will appear in a new browser window.
- Open your jupyter,create a new ipython notebook by clicking on 'New' on the upper right corner and create a python 3 notebook
- For quick installation, you need to install nsepy by typing '!pip install nsepy' and run it either by shift+enter or click on run.
- Once this is done, you could import nsepy and use it functions
Now, follow the below steps in your IPython Notebook:
from nsepy import get_history
from datetime import datetime
# You can change the dates accordingly
start = datetime(2019, 7, 15)
end = datetime(2019, 7, 30)
data = get_history(symbol='NIFTY',start=start,end=end, index=True)