Placing GTT OCO Orders for Bank Nifty is failing with error "Invalid condition params"

sankalpdayal5
I am using Python API v3

Here is my code which uses `kite.place_gtt()` for placing GTT Orders -

instrument = {'tradingsymbol': 'BANKNIFTY2341339900PE', 'exchange': 'NFO', 'instrument_token': 12484866,
'product': 'NRML', 'quantity': -50, 'overnight_quantity': -50, 'multiplier': 1,
'average_price': 17.875, 'close_price': 16.1, 'last_price': 6.9, 'value': 893.75,
'pnl': 548.75, 'm2m': 460.0000000000001, 'unrealised': 548.75, 'realised': 0,
'buy_quantity': 0, 'buy_price': 0, 'buy_value': 0, 'buy_m2m': 0, 'sell_quantity': 50,
'sell_price': 17.875, 'sell_value': 893.75, 'sell_m2m': 805.0000000000001,
'day_buy_quantity': 0, 'day_buy_price': 0, 'day_buy_value': 0, 'day_sell_quantity': 0,
'day_sell_price': 0, 'day_sell_value': 0}

symbol = instrument['tradingsymbol']
quantity = instrument['quantity']
ltp = instrument['last_price']
target = ltp * 0.5
sl = ltp * 1.5
trigger_type = kite.GTT_TYPE_OCO
exchange = instrument['exchange']
orders = [
{
"transaction_type": "SELL",
"quantity": quantity,
"price": target,
"order_type": kite.ORDER_TYPE_LIMIT,
"product": symbol,
},
{
"transaction_type": "SELL",
"quantity": quantity,
"price": sl,
"order_type": kite.ORDER_TYPE_LIMIT,
"product": symbol,
}
]
trigger_values = [{"index": 0, "value": str(target)}, {"index": 1, "value": str(sl)}]

# Place GTT order
order_id = kite.place_gtt(trigger_type=trigger_type, tradingsymbol=symbol, exchange=exchange,
trigger_values=trigger_values, last_price=ltp, orders=orders)




Line 894 of connect.py has the response "r".
Code for getting the response in connect.py file

try:
r = self.reqsession.request(method,
url,
json=params if (method in ["POST", "PUT"] and is_json) else None,
data=params if (method in ["POST", "PUT"] and not is_json) else None,
params=query_params,
headers=headers,
verify=not self.disable_ssl,
allow_redirects=True,
timeout=self.timeout,
proxies=self.proxies)
# Any requests lib related exceptions are raised here - https://requests.readthedocs.io/en/latest/api/#exceptions
except Exception as e:
raise e


After the above code runs, it is containing the below error in the response received.
'{"status":"error","message":"Invalid condition params.","data":null,"error_type":"InputException"}'

Sign In or Register to comment.