Navigation

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

    Working WebSocket Sample code to retrieve LTP - Python

    Python SDK
    7
    20
    752
    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.
    • D
      djdenish @James Bond last edited by djdenish

      @James-Bond

      def on_tick(ws, tick):
      for i in tick:
      for j, k in i.items():
      if j == 'ltp':
      print(j, k)
      else:
      pass

      If j is ltp and k is the value of ltp then Instead of just LTP, I want to print Open,Close,High,Low,Bid Price, Ask Price. Any idea how?

      S 1 Reply Last reply Reply Quote 0
      • L
        lavly @James Bond last edited by

        @James-Bond this code is giving following errorrs


        ReactorNotRestartable Traceback (most recent call last)
        <ipython-input-71-f3a22d8e176e> in <module>()
        21 ss.on_close = on_close
        22
        ---> 23 ss.connect( )

        3 frames
        /usr/local/lib/python3.7/dist-packages/twisted/internet/base.py in startRunning(self)
        841 raise error.ReactorAlreadyRunning()
        842 if self._startedBefore:
        --> 843 raise error.ReactorNotRestartable()
        844 self._started = True
        845 self._stopped = False

        ReactorNotRestartable:

        James Bond 1 Reply Last reply Reply Quote 0
        • S
          Surya 1 @djdenish last edited by

          @djdenish

          you can look at the key value and its corresponding explanation here

          https://smartapi.angelbroking.com/docs/WebSocket

          1 Reply Last reply Reply Quote 0
          • James Bond
            James Bond @lavly last edited by

            Hey @djdenish, did above code give you same error @lavly facing while you executes the code. ?

            “Bond. James Bond.”

            L D 2 Replies Last reply Reply Quote 0
            • L
              lavly @James Bond last edited by

              @James-Bond yes

              S 1 Reply Last reply Reply Quote 0
              • S
                Surya 1 @lavly last edited by

                @lavly what's your sdk version ??

                1 Reply Last reply Reply Quote 0
                • S
                  sudhakar last edited by

                  is there any way to get low, high , ltp and volumes, & market watch (best 5 bids & ask)?

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    Surya 1 @sudhakar last edited by

                    @sudhakar

                    @sudhakar said in Working WebSocket Sample code to retrieve LTP - Python:

                    is there any way to get low, high , ltp and volumes, &

                    this you get it in WebSocket..

                    @sudhakar said in Working WebSocket Sample code to retrieve LTP - Python:

                    market watch (best 5 bids & ask)

                    yes via api call.. rate limit is 1 call per seconds if I remember right..

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      sudhakar @Surya 1 last edited by

                      @rajanprabu , Can you help with any sample code , API guide is use less,it does not have anything.

                      A S 2 Replies Last reply Reply Quote 0
                      • A
                        admin @sudhakar last edited by

                        @sudhakar please provide us your contact details to assist you.

                        1 Reply Last reply Reply Quote 0
                        • S
                          Surya 1 @sudhakar last edited by

                          @sudhakar

                          @admin and team is very helpful and they will reach out to you.

                          @James-Bond has compiled some nice set of instructions and codes here which you can look

                          https://smartapi.angelbroking.com/topic/325/faq-smart-api/5

                          I will write a complete page with sample scripts sometime soon..

                          N 1 Reply Last reply Reply Quote 0
                          • D
                            djdenish @James Bond last edited by

                            @James-Bond
                            No I am not getting any error on code provided above.
                            Its working fine.

                            1 Reply Last reply Reply Quote 0
                            • N
                              neeluru @Surya 1 last edited by

                              @rajanprabu
                              Any idea on below error. Using google.colab

                              92cf3176-9985-4fd2-888a-b49740475963-image.png

                              S 1 Reply Last reply Reply Quote 0
                              • S
                                Surya 1 @neeluru last edited by

                                @neeluru

                                I don't use google colab so its difficult to comment. which versions of python sdk r u using ??

                                N 1 Reply Last reply Reply Quote 0
                                • N
                                  neeluru @Surya 1 last edited by

                                  @rajanprabu
                                  OK..

                                  Is code is correct one ?

                                  have used ss.connect() instead ws.connect(). Have changed it but no use at all

                                  S 1 Reply Last reply Reply Quote 0
                                  • S
                                    Surya 1 @neeluru last edited by

                                    @neeluru

                                    Please share which version of SDK you are using.. I can only check the code depending on that..

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