Hi everyone, I am new to Zerodha and its API. My aim is to fetch live streaming market data (its depth/orderbook and ohlc values) for Nifty and BankNifty on 1 minute interval in python 2.7. After going through documentation, I found out about "quote" function which I think would solve my task to retrieve market data. After setting access token, I wrote the following line in python: kite.quote(exchange='NSE',tradingsymbol='NIFTY')
It displays the following error: Traceback (most recent call last): File "C:/Users/HP/PycharmProjects/AutomatedTrading/main.py", line 31, in kite.quote(exchange='NSE',tradingsymbol='NIFTY') File "C:\Users\HP\Miniconda2\lib\site-packages\kiteconnect\__init__.py", line 501, in quote return self._get("market.quote", {"exchange": exchange, "tradingsymbol": tradingsymbol}) File "C:\Users\HP\Miniconda2\lib\site-packages\kiteconnect\__init__.py", line 593, in _get return self._request(route, "GET", params) File "C:\Users\HP\Miniconda2\lib\site-packages\kiteconnect\__init__.py", line 684, in _request raise(exp(data["message"], code=r.status_code)) kiteconnect.exceptions.DataException: Exception fetching quote
Please help to fetch live streaming market data on 1 minute interval. Also, my kiteconnect version is 3.6.2. Thanks!!
Thanks for the response. 1. I passed parameters as below: kite.quote(['NSE:NIFTY']) Now, it says that function needs 3 arguments: TypeError: quote() takes exactly 3 arguments (2 given) What am I doing wrong here?
2. I need to get data in intervals of 1 minute. How to mention it in code?
Hi @zartimus and @tonystark, To upgrade to 3.7.0b5, I ran pip install kiteconnect --upgrade --pre. It threw exception shown below: Exception: Traceback (most recent call last): File "C:\Users\HP\Miniconda2\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "C:\Users\HP\Miniconda2\lib\site-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "C:\Users\HP\Miniconda2\lib\site-packages\pip\req\req_set.py", line 784, in install **kwargs File "C:\Users\HP\Miniconda2\lib\site-packages\pip\req\req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "C:\Users\HP\Miniconda2\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_f iles isolated=self.isolated, File "C:\Users\HP\Miniconda2\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files clobber(source, lib_dir, True) File "C:\Users\HP\Miniconda2\lib\site-packages\pip\wheel.py", line 323, in clobber shutil.copyfile(srcfile, destfile) File "C:\Users\HP\Miniconda2\lib\shutil.py", line 97, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 13] Permission denied: 'C:\\Users\\HP\\Miniconda2\\Lib\\site-packages\\_cffi_backend .pyd'
@Raunaak Please run your command prompt/ PS as administrator. If it does not work. Try running pip as a python module python -m pip install kiteconnect --upgrade --pre
I followed commands. version shows 3.6.2 when I run command pip show kiteconnect. version shows 3.7.05b when I run command python -m pip show kiteconnect. Now, I am not sure which version am I using?
After importing from kiteconnect import KiteConnect and setting keys, when I run kite.quote(['NSE:NIFTY']). It shows the same error TypeError: quote() takes exactly 3 arguments (2 given).
I followed the above commands. It throws the same exception as mentioned above. Before exception, cmd shows these lines: Found existing installation: cffi 1.10.0 Uninstalling cffi-1.10.0: Successfully uninstalled cffi-1.10.0 Rolling back uninstall of cffi
Hi @zartimus Thanks for the help. I think some files were being used by kite and hence upgrade was not possible. When I restarted my pc, update worked nicely!! There is one small issue. I am trying to fetch values for NIFTY futures using quote. I use the following code: data = kite.quote(['NFO:NIFTY28MARFUT']). I recieve an empty dictionary whereas if I use data = kite.quote(['NSE:INFY']), it gives useful data. Could you please guide me to correct instrument for nifty futures?
Hi @prakash.jj , you are absolutely right. 18 Mar gives useful data. But, as per my understanding, NIFTY futures expiry on the last Thursday of every month. And 29 Mar (Thursday) is a holiday. So, shouldn't trading symbol be NIFTY28MARFUT? I am assuming the appending date is the expiry date. What does 18 Mar signify?
It needs to be an array of exchange:tradingsymbol
Thanks for the response.
1. I passed parameters as below:
kite.quote(['NSE:NIFTY'])
Now, it says that function needs 3 arguments:
TypeError: quote() takes exactly 3 arguments (2 given)
What am I doing wrong here?
2. I need to get data in intervals of 1 minute. How to mention it in code?
pip show kiteconnect -> will show you the version number
https://github.com/zerodhatech/pykiteconnect/blob/kite3/kiteconnect/connect.py#L530-L543
is written in such a way that even if you pass instruments as a list or just arguments it should work
pip install kiteconnect --upgrade --pre
.You can create a thread that fetches data and then sleep for 60 seconds.
To upgrade to 3.7.0b5, I ran
pip install kiteconnect --upgrade --pre
.It threw exception shown below:
Exception:
Traceback (most recent call last):
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_f
iles
isolated=self.isolated,
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "C:\Users\HP\Miniconda2\lib\site-packages\pip\wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "C:\Users\HP\Miniconda2\lib\shutil.py", line 97, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'C:\\Users\\HP\\Miniconda2\\Lib\\site-packages\\_cffi_backend
.pyd'
How to go past it? Thanks.
If it does not work. Try running pip as a python module
python -m pip install kiteconnect --upgrade --pre
I followed commands. version shows 3.6.2 when I run command
pip show kiteconnect
. version shows 3.7.05b when I run commandpython -m pip show kiteconnect
. Now, I am not sure which version am I using?After importing
from kiteconnect import KiteConnect
and setting keys, when I runkite.quote(['NSE:NIFTY'])
.It shows the same error
TypeError: quote() takes exactly 3 arguments (2 given)
.Also pykiteconnect is tested against all versions of python and miniconda envs https://ci.appveyor.com/project/rainmattertech/pykiteconnect
Hope it works
I followed the above commands. It throws the same exception as mentioned above. Before exception, cmd shows these lines:
Found existing installation: cffi 1.10.0
Uninstalling cffi-1.10.0:
Successfully uninstalled cffi-1.10.0
Rolling back uninstall of cffi
I found a link on stackoverflow which may be help to solve this: https://stackoverflow.com/questions/45307110/pip-is-rolling-back-uninstall-of-setuptools
If I am unable to upgrade to 3.7.05, then also 3.6.2 should have quote function and I might be able to use it?
There is one small issue. I am trying to fetch values for NIFTY futures using quote. I use the following code:
data = kite.quote(['NFO:NIFTY28MARFUT'])
. I recieve an empty dictionary whereas if I usedata = kite.quote(['NSE:INFY'])
, it gives useful data. Could you please guide me to correct instrument for nifty futures?18 signifies the year of expiry.