GTT placing error

vivekvs
self._getGTTPayload = function (params) {
if (params.trigger_type !== self.GTT_TYPE_OCO && params.trigger_type !== self.GTT_TYPE_SINGLE) {
throw new Error("Invalid `params.trigger_type`")
}


i think this should be if (params.trigger_type !== self.GTT_TYPE_OCO || params.trigger_type !== self.GTT_TYPE_SINGLE) {

line number 1057.. Kindly rectify
  • SRIJAN
    SRIJAN edited August 2022
    There is no error in the KiteConnect Node JS client.

    You should learn basic programming(logical operators) first before doing algo trading.
    Otherwise,you would write such posts and mislead other users.


    You should learn about 'AND' operator(&& in Node JS) and 'OR' operator(|| in Node JS) .

    The 'AND' operator only returns true when both of its operands are true,while the 'OR' operator will return true even if one of the operands is true.

    https://github.com/zerodha/kiteconnectjs/blob/7d94fb87794e6819bfbd2e914e5b1b68ad0862dd/lib/connect.js#L1068


    Basically,if you use ||,it will throw an error even if the trigger_type is one of the accepted values.

    Using && will only throw an error when the trigger_type is none of the accepted values.
  • vivekvs
    i agreed that sorry for the mistake . however i am geeting this error


    Error: Invalid `params.trigger_type`
    at KiteConnect.self._getGTTPayload (/home/vivek/findependence/findiserver/node_modules/kiteconnect/lib/connect.js:1027:19)
    at KiteConnect.self.placeGTT (/home/vivek/findependence/findiserver/node_modules/kiteconnect/lib/connect.js:1074:28)
    at /home/vivek/findependence/findiserver/server.js:659:20
    at Layer.handle [as handle_request] (/home/vivek/findependence/findiserver/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/vivek/findependence/findiserver/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/home/vivek/findependence/findiserver/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/home/vivek/findependence/findiserver/node_modules/express/lib/router/layer.js:95:5)
    at /home/vivek/findependence/findiserver/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/home/vivek/findependence/findiserver/node_modules/express/lib/router/index.js:346:12)
    at next (/home/vivek/findependence/findiserver/node_modules/express/lib/router/index.js:280:10)
    at /home/vivek/findependence/findiserver/node_modules/body-parser/lib/read.js:137:5
    at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
    at invokeCallback (/home/vivek/findependence/findiserver/node_modules/raw-body/index.js:231:16)
    at done (/home/vivek/findependence/findiserver/node_modules/raw-body/index.js:220:7)
    at IncomingMessage.onEnd (/home/vivek/findependence/findiserver/node_modules/raw-body/index.js:280:7)
    at IncomingMessage.emit (node:events:539:35) this error






    i have set the like this

    params.trigger_type='self.GTT_TYPE_SINGLE'; before passing it to kc.placeGTT(params)
  • SRIJAN
    SRIJAN edited August 2022
    It should be kc.GTT_TYPE_SINGLE. Here,'kc' is the current initialised KiteConnect object.
    And, don't use quotes around that.

    Please read the documentation properly:

    https://github.com/zerodha/kiteconnectjs/blob/7d94fb87794e6819bfbd2e914e5b1b68ad0862dd/examples/connect.js#L375
Sign In or Register to comment.