☰
Login
Signup
Home
›
Python client
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.9K
All Categories
0
Incidents
156
Node JS client
40
Go client
793
.Net API client
380
Kite Publisher
537
.Net / VBA / Excel (3rd party)
457
Algorithms and Strategies
998
Java client
1.1K
API clients
404
PHP client
4K
Python client
347
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
General
In this Discussion
March 2017
Guhan
March 2017
sujith
Unable to place bracket order
Guhan
March 2017
in
Python client
order_id = kite.order_place(
tradingsymbol="INFY",
exchange="NSE",
quantity=1,
transaction_type="BUY",
order_type="LIMIT",
price=1505,
squareoff_value=2,
stoploss_value=2,
variety="bo",
validity="DAY",
product = "MIS"
)
above code gives me below error:
Traceback (most recent call last):
File "C:/Python27/codes/pandas/summa.py", line 28, in
product = "MIS"
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 286, in order_place
return self._post("orders.place", params)["order_id"]
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 467, in _post
return self._request(route, "POST", params)
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 554, in _request
raise(exp(data["message"], code=r.status_code))
TokenException: Invalid token
Tagged:
BO
Python Client
bracket orders
orders
sujith
March 2017
Hi
@Guhan
,
It seems like your session is expired. Try logging in again and place order.
Guhan
March 2017
@sujith
I tried again but it is not working.
>>> from kiteconnect import KiteConnect
>>> kite = KiteConnect(api_key =api_key)
>>> kite.set_access_token(access_token)
>>> kite.order_place(exchange = 'NSE', tradingsymbol = 'ASHOKLEY',
transaction_type = 'BUY', quantity = 1,
price = 105.05, product = 'MIS',
order_type = 'LIMIT', squareoff_value = 1,
stoploss_value = 1,trailing_stoploss = 1)#,variety ='bo',validity = 'DAY')
u'170317000454573'
>>> kite.order_place(exchange = 'NSE', tradingsymbol = 'ASHOKLEY',
transaction_type = 'BUY', quantity = 1,
price = 105.05, product = 'MIS',
order_type = 'LIMIT', squareoff_value = 1,
stoploss_value = 1,trailing_stoploss = 1,variety ='bo',validity = 'DAY')
Traceback (most recent call last):
File "", line 5, in
stoploss_value = 1,trailing_stoploss = 1,variety ='bo',validity = 'DAY')
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 286, in order_place
return self._post("orders.place", params)["order_id"]
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 467, in _post
return self._request(route, "POST", params)
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 554, in _request
raise(exp(data["message"], code=r.status_code))
TokenException: Invalid token
sujith
March 2017
@Guhan
,
Did you get new access token?
Guhan
March 2017
@sujith
, thanks it is working fine. Can't I have PI running along with my API
Guhan
March 2017
@sujith
I just wanna check how my coding works, because i see that whenever i log into PI my session gets expired
sujith
March 2017
@Guhan
,
Pi will create a new session every time you log in.
Please use Kite and make sure you don't log out of Kite, that will delete your Kite Connect session also.
Guhan
March 2017
@sujith
, oh ok, cheers
This discussion has been closed.
It seems like your session is expired. Try logging in again and place order.
>>> from kiteconnect import KiteConnect
>>> kite = KiteConnect(api_key =api_key)
>>> kite.set_access_token(access_token)
>>> kite.order_place(exchange = 'NSE', tradingsymbol = 'ASHOKLEY',
transaction_type = 'BUY', quantity = 1,
price = 105.05, product = 'MIS',
order_type = 'LIMIT', squareoff_value = 1,
stoploss_value = 1,trailing_stoploss = 1)#,variety ='bo',validity = 'DAY')
u'170317000454573'
>>> kite.order_place(exchange = 'NSE', tradingsymbol = 'ASHOKLEY',
transaction_type = 'BUY', quantity = 1,
price = 105.05, product = 'MIS',
order_type = 'LIMIT', squareoff_value = 1,
stoploss_value = 1,trailing_stoploss = 1,variety ='bo',validity = 'DAY')
Traceback (most recent call last):
File "", line 5, in
stoploss_value = 1,trailing_stoploss = 1,variety ='bo',validity = 'DAY')
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 286, in order_place
return self._post("orders.place", params)["order_id"]
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 467, in _post
return self._request(route, "POST", params)
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 554, in _request
raise(exp(data["message"], code=r.status_code))
TokenException: Invalid token
Did you get new access token?
Pi will create a new session every time you log in.
Please use Kite and make sure you don't log out of Kite, that will delete your Kite Connect session also.