Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. greatworld
    3. Posts
    G
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by greatworld

    • RE: WebSocketV2 fetchData function response

      @Moderator_2
      Nothing is working neither

              setInterval(() => {
                  WebSocketV2response.on("tick", async (response) => {
                      console.log(response);
                  });
              }, 3000); 
      

      nor

              setTimeout(function () {
                  WebSocketV2response.on("tick", async (response) => {
                      console.log(response);
                  });
              }, 3000);
      

      It's receving data continuosly after 3 sec in both the cases ?

      posted in Bugs
      G
      greatworld
    • RE: WebSocketV2 fetchData function response

      @Moderator_2 said in WebSocketV2 fetchData function response:

      Hi @greatworld

      Action param on Websocket request represents zero to unsubscribe(feed stops) and one to subscribe(feed starts) the scripts.
      For some scripts, we may not notice any changes on the ticks since there wont be any trade occurring for it. We provide feeds continuously that is received from exchange end.
      If it is required to fetch data with latency time delay can be added. Kindly refer below
      Ref:
      https://masteringjs.io/tutorials/node/sleep

      Regards,
      SmartAPI team

      THANK YOU TEAM FOR YOUR SUPPORT

      posted in Bugs
      G
      greatworld
    • WebSocketV2 fetchData function response

      While fetching data using

      let json_req = {
      correlationID: "abcde12345",
      action: 1,
      mode: 3,
      exchangeType: data.exchanger === "NFO" ? 2 : 4,
      tokens: marketToken[data.index],
      };

      WebSocketV2response.fetchData(json_req);

      WebSocketV2response.on("tick", async (response) => {
      });

      when i provide 1 then i get data continuously but when i provide 0 then i receive pong as a data.

      I want to receive data once for single request or continuously after few seconds or minutes but while providing 1 it is giving me the same data continuously for what i have requested without any latency because of which i am unable to compute on present data , it's get changes so fast , computing on present data is not possible.

      How can i receive data with some latency so that i can computing on present value of data and again i request or by itself it sends data after few seconds or minutes it should fetch data using fetchData function ?

      THANK YOU

      posted in Bugs
      G
      greatworld
    • RE: USE OF ACTION

      @Moderator_2
      I mean when i provide 1 then i get data continuously but when i provide 0 then i receive pong as a data.

      I want to receive data once or few seconds later for what i have requested but while providing 1 it is giving me the same data continuously for what i have requested.

      How can i receive data with some latency so that i can computing on present value of data and again i request or by itself after few seconds or minutes it should fetch data using fetchData function ?

      THANK YOU

      posted in Bugs
      G
      greatworld
    • USE OF ACTION

      While fetching data using

      let json_req = {
      correlationID: "abcde12345",
      action: 0,
      mode: 3,
      exchangeType: data.exchanger === "NFO" ? 2 : 4,
      tokens: marketToken[data.index],
      };

      WebSocketV2response.fetchData(json_req);

      WebSocketV2response.on("tick", async (response) => {
      });

      code what's the use of action (i.e. 0 and 1) ?

      posted in Bugs
      G
      greatworld
    • API for fetching current data of market of any index

      I need an api endpoint which response with a current market data of any index like strike price , ltp , volume , volume change,oi , oi change and ....

      If you know how can i do that then please provide me the code to do it?

      posted in General Discussion
      G
      greatworld
    • FETCH AT THE MONEY STRIKE PRICE

      How can i fetch at the money strike price in node js.
      What is the API endpoint for current at the money strike of any index?

      Thank you

      posted in Bugs
      G
      greatworld
    • RE: Node JS WebSocketV2

      @Moderator_2
      "next": "14.1.3",
      I am using next js instead of node js to connect with WebSocketV2 directly from fronend.

      It got connected and worked very fine with all the function defined in WebSocketV2 leaving WebSocketV2.fetchData function in smartapi-javascript\lib\websocket2.0.js which is upload in your github repo https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js.

      In documentation it said to pass parameter like :
      {
      "correlationID": "abcde12345",
      "action": 1,
      "params": {
      "mode": 1,
      "tokenList": [
      {
      "exchangeType": 1,
      "tokens": [
      "10626",
      "5290"
      ]
      },
      {
      "exchangeType": 5,
      "tokens": [
      "234230",
      "234235",
      "234219"
      ]
      }
      ]
      }
      }

      but while retriving in WebSocketV2.fetchData function which is in line number 127 of https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js file is like

      const { correlationID, action, mode, exchangeType, tokens } = json_req;

      but i am passing data in different structure , so as to retrive the data i pass it has to be like :

      const { correlationID, action, params : {mode, tokenList :{exchangeType, tokens} }} = json_req;

      I request please provide the solution as soon as possible.
      Thank you

      posted in General Discussion
      G
      greatworld
    • RE: Node JS WebSocketV2

      @Moderator_2

      "next": "14.1.3",

      I am using next js instead of node js to conncect directly with WebSocketV2 from frontend and it's working fine for other functions define in WebSocketV2.

      The only problem I see is in fetchdata function defined in smartapi-javascript\lib\websocket2.0.js file which is upload in your github https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js

      The structure of sending the data to websocket2.0 is describe as
      {
      "correlationID": "abcde12345",
      "action": 1,
      "params": {
      "mode": 1,
      "tokenList": [
      {
      "exchangeType": 1,
      "tokens": [
      "10626",
      "5290"
      ]
      },
      {
      "exchangeType": 5,
      "tokens": [
      "234230",
      "234235",
      "234219"
      ]
      }
      ]
      }
      }
      whereas at receiving end of fetchData function which is
      const { correlationID, action, mode, exchangeType, tokens } = json_req;
      couldn't fetch request data because it is not in fromat of
      { correlationID, action, mode, exchangeType, tokens }

      It should be
      const {
      correlationID,
      action,
      params :
      {
      mode,
      tokenList :{
      exchangeType, tokens
      }
      }
      } = json_req;

      Please solve the issue as soon as possible.
      Thank you

      posted in General Discussion
      G
      greatworld
    • Node JS WebSocketV2

      while using fetchdata function from WebSocketV2

      code :
      web_socket.fetchData({
      correlationID: "abcde12345",
      action: 1,
      params: {
      mode: 1,
      tokenList: [
      {
      exchangeType: 1,
      tokens: ["10626", "5290"],
      },
      ],
      },
      });

      gives an error

      error :
      ⨯ node_modules\smartapi-javascript\lib\websocket2.0.js (137:0) @ WebSocketV2.fetchData
      ⨯ Error: Invalid Mode value passed
      at page (./src/app/page.jsx:63:16)
      null
      Error: Invalid Mode value passed
      at WebSocketV2.fetchData (webpack-internal:///(rsc)/./node_modules/smartapi-javascript/lib/websocket2.0.js:137:11)
      at eval (webpack-internal:///(rsc)/./node_modules/smartapi-javascript/lib/websocket2.0.js:52:14)
      at Array.map (<anonymous>)
      at WebSocket.onOpen (webpack-internal:///(rsc)/./node_modules/smartapi-javascript/lib/websocket2.0.js:51:20)
      at callListener (webpack-internal:///(rsc)/./node_modules/ws/lib/event-target.js:290:14)
      at WebSocket.onOpen (webpack-internal:///(rsc)/./node_modules/ws/lib/event-target.js:237:9)
      at WebSocket.emit (node:events:518:28)
      at WebSocket.setSocket (webpack-internal:///(rsc)/./node_modules/ws/lib/websocket.js:244:10)
      at ClientRequest.eval (webpack-internal:///(rsc)/./node_modules/ws/lib/websocket.js:1009:15)
      at ClientRequest.emit (node:events:518:28)
      at TLSSocket.socketOnData (node:_http_client:575:11)
      at TLSSocket.emit (node:events:518:28)
      at addChunk (node:internal/streams/readable:559:12)
      at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
      at Readable.push (node:internal/streams/readable:390:5)
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
      at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17)

      I think this error is due to the structure of passing parameter in fetchData function.

      posted in General Discussion
      G
      greatworld
    • Error due to fetchData function from WebSocketV2

      When i use fetchData function from WebSocketV2 instance then it gives the error that i have provided in photo

      code :
      web_socket.fetchData({
      correlationID: "abcde12345",
      action: 1,
      params: {
      mode: 1,
      tokenList: [
      {
      exchangeType: 1,
      tokens: ["10626", "5290"],
      },
      {
      exchangeType: 5,
      tokens: ["234230", "234235", "234219"],
      },
      ],
      },
      });
      Screenshot 2024-03-10 155613.png

      I think this error is due to the way it's fetching in websocket2.0.js file,
      it's fetch value as const { correlationID, action, mode, exchangeType, tokens } = json_req; but in documentation it is written as {
      "correlationID": "abcde12345",
      "action": 1,
      "params": {
      "mode": 1,
      "tokenList": [
      {
      "exchangeType": 1,
      "tokens": [
      "10626",
      "5290"
      ]
      },
      {
      "exchangeType": 5,
      "tokens": [
      "234230",
      "234235",
      "234219"
      ]
      }
      ]
      }
      }

      I request you please provide appropriate solution.

      posted in Bugs
      G
      greatworld