GTT order failed. Invalid `order_type`.

vivekvs
Getting the error " GTT order failed. Invalid `order_type`. " when GTT is fired , which is placed by kite connect api . this is the function i used to place it

Please note level is a price



PlaceGttOrderForThisPrice(stockPpItem,level){


let ob={};

ob.params={};

ob.accessToken=this.accessToken;

ob.params.tradingsymbol=stockPpItem.tradingsymbol;
ob.params.exchange=stockPpItem.exchange;
ob.params.trigger_values=[level];
ob.params.last_price=stockPpItem.last_price;


let order={};
order.transaction_type='BUY'
order.quantity=1
order.product='CNC';
order.order_type='LIMIT';
order.price=level;

ob.params.orders=[order]

let url="/api/PlaceGTT";
axios.post(url,ob).then(r=>console.log(r,'response'))


}
  • tonystark
    From your code snippet let url="/api/PlaceGTT"; this API root is not part of Kite Connect. If there is an interface between above code and Kite Connect, check what is actually being sent to Kite Connect APIs.
  • vivekvs
    Dear @tonystark

    This is the node js code of the api you are referring to . Kindly help

    app.post('/api/PlaceGTT', async (req,res) => {

    let params=req.body.params;
    let accessToken=req.body.accessToken;


    try {
    var kc = new KiteConnect({
    api_key: api_key,
    access_token: accessToken
    });
    params.trigger_type=kc.GTT_TYPE_SINGLE;



    let out=await kc.placeGTT(params);

    res.send(out);
    return;

    } catch (error) {
    console.log(error,'this error')
    }
  • vivekvs
    kindly reply
  • rakeshr
    await kc.placeGTT(**params**);
    You have not mentioned the params fields in your code snippet. Go through the placeGTT params example code here.
  • vivekvs
    hi. bro this is the param i pass from front end


    {"tradingsymbol":"AARTIIND","exchange":"NSE","trigger_values":[482.4],"last_price":511.75}


    then from back end i

    set

    params.trigger_type=kc.GTT_TYPE_SINGLE;

    Kindly help in solving this
  • sujith
    Can you enable debug logs and send us the exact params that is being sent in the request? Make sure to remove the app and client specific information.
  • vivekvs
    {"tradingsymbol":"AARTIIND","exchange":"NSE","trigger_values":[482.4],"last_price":511.75} AND params.trigger_type=kc.GTT_TYPE_SINGLE; where kc is the object
  • sujith
    @vivekvs,
    We can't help you with the details about what you are sending. Can you please give us the request logs?
  • vivekvs
    bro what is request log
  • rakeshr
    Enable debug=True in the kiteConnect object initialization, and paste those logs here.
Sign In or Register to comment.