Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Need assistance on web Socket call

    NodeJS SDK
    0
    6
    115
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      AravindAnbalagan last edited by AravindAnbalagan

      Hello @admin

      Yesterday onwards websocket.tickerUsage() stopped working, I request you to share any references for the same using java.
      Any help is appreciated!

      String strWatchListScript = "mcx_fo|243301";
      String task = "sfi";
      examples.tickerUsage(clientID, feedToken, strWatchListScript, task);

      Sample Response :

      subscribe() called!
      ticker data: [{"msg":"cn","task":"cn","ak":"nk"}]
      ticker data: [{"msg":"bh","task":"bh","ak":"nk"}]
      ticker data: [{"msg":"hb","task":"hb","ak":"nk"}]

      Thanks

      T 1 Reply Last reply Reply Quote 0
      • T
        techsharad @AravindAnbalagan last edited by

        @AravindAnbalagan yes it not working, and can't find any solution yet.

        punit 1 Reply Last reply Reply Quote 0
        • punit
          punit @techsharad last edited by

          @techsharad websocket is migrated to new endpoint. unfortunately no wrapper available for that in java. only python was released by AB.

          A 1 Reply Last reply Reply Quote 0
          • A
            admin @punit last edited by admin

            HI @AravindAnbalagan @techsharad @Ashok

            I wanted to share an example code in Java for working with Websocket 2.0 and the SmartStreamTicker class. This code can be used as a reference only and is not an official release. You can find the code on GitHub at https://github.com/angel-one/smartapi-java/pull/1/files

            Please note that this code is provided as a sample only and is not an official release. It is not officially supported and should be used with caution.

            This is just to give you an idea of the best practices for running a websocket, including parsing logic, and can be used as a reference only

            Please let me know if you have any questions or concerns.

            A D 2 Replies Last reply Reply Quote 0
            • A
              AravindAnbalagan @admin last edited by

              @admin Thank you

              1 Reply Last reply Reply Quote 0
              • D
                DMoney @admin last edited by

                @admin This is really awesome! Saves lot of time.
                Just one difference I found. The prices received are multiplied by 100 and user has to divide it by 100 to get right price.

                Is it correct implementation or some bug.
                I dont understand the reason to do so.

                @Override
                public void onQuoteArrival(Quote quote) {
                ZonedDateTime exchangeTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(quote.getExchangeFeedTimeEpochMillis()), TZ_IST);
                String data = String.format("token: %s"
                + " sequenceNumber: %d"
                + " ltp: %.2f"
                + " open: %.2f"
                + " high: %.2f"
                + " low: %.2f"
                + " close: %.2f"
                + " exchangeTime: %s"
                + " exchangeToClientLatency: %s",
                quote.getToken().toString(),
                quote.getSequenceNumber(),
                (quote.getLastTradedPrice() / 100.0),
                (quote.getOpenPrice() / 100.0),
                (quote.getHighPrice() / 100.0),
                (quote.getLowPrice() / 100.0),
                (quote.getClosePrice() / 100.0),
                exchangeTime,
                Instant.now().toEpochMilli() - quote.getExchangeFeedTimeEpochMillis());
                System.out.println(data);
                }

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post