KITE API Error Exchange missing

Vishesh
Vishesh edited April 2019 in API clients
header is {'X-Kite-Version': '3', 'Authorization': 'token xxx:yyy'}
payload is {'tradingsymbol': 'RELIANCE', 'stoploss': 10.0, 'order_type': 'MARKET', 'exchange': 'NSE', 'price': 1382.0, 'quantity': 10, 'product': 'co', 'transaction_type': 'BUY'}

API response is
{"status":"error","message":"Missing or empty field `exchange`","data":null,"error_type":"InputException"}

can someone assist with what is the reason for this error?

(API/ Token have been blanked out on purpose)
  • sujith
    Are you sending the params as the form body or json?
  • Vishesh
    r = requests.post(url, data=json.dumps(payload), headers=headers)
  • sujith
    You seem to be sending data as json. You can check out the documentation here. You need to make a form request.
  • Vishesh
    ok.. just did the form request...

    {'X-Kite-Version': '3', 'Authorization': 'token xxx:yyy'} {'variety': 'co', 'tradingsymbol': 'RELIANCE', 'order_type': 'MARKET', 'stop_loss': 1399.0, 'exchange': 'NSE', 'price': 1409.0, 'quantity': 1, 'product': 'MIS', 'transaction_type': 'BUY'}
    {"status":"success","data":{"order_id":"190502001276122"}}

    kite return message is: The stop loss trigger price is beyond the allowed range of 9.9%. Try a price within the range.

    please guide on what I am missing.
  • Vishesh
    I've tried replacing the stop loss to an absolute value too... same error .

    {'X-Kite-Version': '3', 'Authorization': 'token xxx:yyy} {'variety': 'co', 'tradingsymbol': 'RELIANCE', 'order_type': 'MARKET', 'stop_loss': 10.0, 'exchange': 'NSE', 'price': 1409.0, 'quantity': 1, 'product': 'MIS', 'transaction_type': 'BUY'}
    {"status":"success","data":{"order_id":"ZZZZ"}}

    The stop loss trigger price is beyond the allowed range of 9.9%. Try a price within the range.
  • sujith
    The stop-loss value is an absolute value in case of cover order.
  • Vishesh
    I've tried replacing the stop loss to an absolute value too... same error .

    {'X-Kite-Version': '3', 'Authorization': 'token xxx:yyy} {'variety': 'co', 'tradingsymbol': 'RELIANCE', 'order_type': 'MARKET', 'stop_loss': 10.0, 'exchange': 'NSE', 'price': 1409.0, 'quantity': 1, 'product': 'MIS', 'transaction_type': 'BUY'}
    {"status":"success","data":{"order_id":"ZZZZ"}}

    The stop loss trigger price is beyond the allowed range of 9.9%. Try a price within the range.
  • Vishesh
    in the previous comment... stoploss is 10
  • sujith
    It means the user is trying to give a stop-loss beyond the permitted range for the cover order. You can check the permitted range here. This is a instruments margin link.
  • Vishesh
    Thanks...

    I just retried

    {'X-Kite-Version': '3', 'Authorization': 'token xxx:yyy'}

    {'variety': 'co', 'tradingsymbol': 'RELIANCE', 'order_type': 'MARKET', 'stop_loss': 9.0, 'exchange': 'NSE', 'price': 1405.35, 'quantity': 1, 'product': 'MIS', 'transaction_type': 'BUY'}
    {"status":"success","data":{"order_id":"190502001512486"}}

    same error.
  • Vishesh
    in the instruments marking link given above... the numbers are in % or absolute terms?

    for ex:
    {"margin": 0, "co_lower": 5.5, "mis_multiplier": 12.5, "tradingsymbol": "RELIANCE", "co_upper": 10.0, "nrml_margin": 0, "mis_margin": 8.0},

    5.5 /12.5/10/8 = are absolute or percentages?
  • rakeshr
    @Vishesh
    Your query is answered in this thread.You need to send trigger_price not stoploss value.
  • Vishesh
    I think I am missing out on some parameters here... since, even after changing the stoploss to 4.0 - order it not getting thru.. getting same error.
  • Vishesh
    @rakeshr : I have 2 threads... one is for python client... and other is for Kite API/ HTTP. So... not sure if both treads need to be merged.
  • Vishesh
    I just posted this..

    {'X-Kite-Version': '3', 'Authorization': 'token xxx:yyy'} {'trigger_price': 1410.3, 'variety': 'co', 'tradingsymbol': 'RELIANCE', 'order_type': 'MARKET', 'exchange': 'NSE', 'price': 1405.35, 'quantity': 1, 'product': 'MIS', 'transaction_type': 'BUY'}
    {"status":"success","data":{"order_id":"190502001614482"}}

    rejected with same error... what am I missing?
  • sujith
    Can you paste the rejection message here for this order?
  • Vishesh
    The stop loss trigger price is beyond the allowed range of 9.9%. Try a price within the range.
  • rakeshr
    @Vishesh
    I have 2 threads... one is for python client... and other is for Kite API/ HTTP
    Order params remains same in both the request(python client and kite API/HTTP).You need to send trigger_price not stop loss value for CO order.
  • Vishesh
    Vishesh edited May 2019
    @rakeshr : yes... I've tried trigger_price too - getting the same error.. that I've pasted above per Sujith's request.
  • themohammedfaisal
    @Vishesh - The order is getting rejected because the trigger price for the 2nd leg sell order is higher than the LTP. Try entering the trigger price for the stop-loss order lower than LTP and the order will work fine.
  • Vishesh
    Vishesh edited May 2019
    You guys rock! thanks for all the help. @rakeshr , @sujith , @themohammedfaisal
This discussion has been closed.