It looks like you're new here. If you want to get involved, click one of these buttons!
modifying orders
for index, row in dfnew.iterrows():
try:
o = kite.order_modify(order_id=str(int(row['order_id'])),parent_order_id=None,trigger_price=row['sl_price_new'], variety='co' )
print str(int(row['order_id'])) + ' has been modified successfully.'
except Exception as e:
print (str(int(row['order_id'])), str(e))
#raise
placing CO
for index, row in orderlist.iterrows():
#find the last price
ltp = kite.quote(exchange="NSE",tradingsymbol=row['symbol'])
sl_price = myround(ltp['last_price'])
#now place orders
try:
order_id = kite.order_place(
tradingsymbol=row['symbol'],
exchange="NSE",
quantity= row['qty'],
transaction_type="SELL",
order_type="MARKET",
product="CO",
trigger_price = sl_price,
variety="co"
)
print 'placing order for ' + str(row['qty']) + ' ' + row['symbol'] + ' @' + str(ltp['last_price']) + ' with sl @' + str(sl_price) + ' : ' + kite.orders(order_id=str(order_id))[0]['status']
except Exception as e:
print ("placing order failed : ", str(e))
data = pd.DataFrame({"symbol" : row['symbol'] , "qty" : row['qty']/exec_count},index=[0])
dfailed = dfailed.append(data)
#raise
placing order for 229 APOLLOTYRE @151.35 with sl @152.55 : COMPLETE
placing order for 80 DLF @145.4 with sl @146.55 : COMPLETE
('placing order failed : ', 'OMS timed out')
placing order for 26 TATAMOTORS @447.4 with sl @451.0 : COMPLETE
Other than OMS Timed out I have encountered several other errors today. Surprisingly - the same order executed couple of seconds before through the same code.
Please see that the same order for SBI was successfull at 9:49:58 but failed at 9:51:33.
The order placement is done via same code.
Executed Code:
order_id = kite.order_place(exchange="NFO",tradingsymbol="BANKNIFTY16JUNFUT",transaction_type="BUY",quantity=30,price=17000,product="BO",order_type="LIMIT",validity="DAY", variety="bo", stoploss_value=170, squareoff_value=340)
Output:
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 264, in order_place
return self._post("orders.place", params)["order_id"]
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 443, in _post
return self._request(route, "POST", params)
File "C:\Python27\lib\site-packages\kiteconnect\__init__.py", line 495, in _request
raise ex.ClientNetworkException("Gateway timed out", code=504)
kiteconnect.exceptions.ClientNetworkException: Gateway timed out
It was working perfectly fine earlier today.
"OMS connection error" and "Gateway timed out" -- are they both related to OMS vendor? While the first error prevents any order through the second error actually lets the order put into the system which is extremely risky behavior.
Again getting OMS Connection Error starting from 10:04.