Navigation

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

    Python Streaming Tick Data Problem.

    Python SDK
    8
    21
    334
    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.
    • J
      jiwan1986 @shenoytech last edited by

      @dorje @bhaveshjain I am having the same issue. Actually the values printed on the terminal is not from on_ticks() method. It is simple string that is being printed because in the webSocket.py file, there is print() function which only prints the data but it doesn't send any data to the client so we can't parse it. And also the API closes connection after 10 minutes and giving error code of 1000.

      S A H 3 Replies Last reply Reply Quote 0
      • S
        shenoytech @jiwan1986 last edited by

        @rjbanna ok..that i never thought silly of me thats why i was confused even when i was not using print function it was printing the streaming data. @admin and @bhaveshjain it is really bad that you advertising it as a free API but i think for full operation it will take some time, so at least give us time frame for full launch of the service.

        M J 2 Replies Last reply Reply Quote 0
        • M
          Manoj P A @shenoytech last edited by

          @dorje I agree with you, they are doing kind of testing from our side by claiming free API. 😀

          K 1 Reply Last reply Reply Quote 0
          • J
            jiwan1986 @shenoytech last edited by

            @dorje I have modified the webSocket.py file code so it is now returning the parsable response and you can get data from it. Below is the code if you are interested and don't want to wait for the development team to fix it. You just need to replace _parse_text_message() function from env/lib/python3/site-packages/smartapi/webSocket.py file with below code. This will return dict.

            def _parse_text_message(self, payload):
                    """Parse text message."""
                    # Decode unicode data
                    if not six.PY2 and type(payload) == bytes:
                        payload = payload.decode("utf-8")
                        data = base64.b64decode(payload)
            
                    try:
                        data = bytes((zlib.decompress(data)).decode("utf-8"), 'utf-8')
                        data = json.loads(data.decode('utf8').replace("'", '"'))
                        data = json.loads(json.dumps(data, indent=4, sort_keys=True))
                    except ValueError:
                        return
            
                    self.on_ticks(self, data)
            
            S 1 Reply Last reply Reply Quote 0
            • S
              shenoytech @jiwan1986 last edited by

              @rjbanna said in Python Streaming Tick Data Problem.:

              data = bytes((zlib.decompress(data)).decode("utf-8"), 'utf-8')

              thankyou @rjbanna now it is working 🙂

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

                @rjbanna Our development team should fix web socket disconnection issue by tomorrow. If it is fixed during the day, I'll share an update here.

                K 1 Reply Last reply Reply Quote 0
                • K
                  krunal96 @Manoj P A last edited by

                  Hi @kaleps , @dorje

                  As these APIs are in Beta Release. & A Beta phase generally begins when the software is feature complete but likely to contain a number of known or unknown bugs. So we are likely to identify some known/unknown bugs.☺

                  1 Reply Last reply Reply Quote 0
                  • K
                    krunal96 @admin last edited by

                    Hi @admin ,

                    Any update regarding this issue?

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

                      @vishant @dorje @mihirk Please check now. We have resolved web socket connection issue.

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

                        @vishant @dorje @mihirk Please share your feedback.

                        K S 2 Replies Last reply Reply Quote 0
                        • K
                          krunal96 @admin last edited by

                          Hi @admin ,

                          Tried WebSocket connection but got disconnected to socket after 5 minutes.
                          Below is the error which I got in my NodeJS SDK.

                          close:: CloseEvent {target: WebSocket, type: 'close', wasClean: true, reason: '', code: 1000}
                          arg1: CloseEvent {target: WebSocket, type: 'close', wasClean: true, reason: '', code: 1000}
                          code: 1000
                          reason: ''
                          target: WebSocket {_events: {…}, _eventsCount: 4, _maxListeners: undefined, _binaryType: 'nodebuffer', _closeCode: 1000}
                          _binaryType: 'nodebuffer'
                          _bufferedAmount: 0
                          _closeCode: 1000
                          _closeFrameReceived: true
                          _closeFrameSent: true
                          _closeMessage: ''
                          _closeTimer: Timeout {_called: false, _idleTimeout: -1, _idlePrev: null, _idleNext: null, _idleStart: 317581}
                          _events: {open: ƒ, message: ƒ, error: ƒ, close: ƒ}
                          _eventsCount: 4
                          _extensions: {permessage-deflate: PerMessageDeflate}
                          _isServer: false
                          _maxListeners: undefined
                          _protocol: ''
                          _readyState: 3
                          _receiver: Receiver {_writableState: WritableState, writable: false, _events: {…}, _eventsCount: 0, _maxListeners: undefined}
                          _redirects: 0
                          _req: null
                          _sender: Sender {_extensions: {…}, _socket: TLSSocket, _firstFragment: true, _compress: false, _bufferedBytes: 0}
                          _socket: TLSSocket {_tlsOptions: {…}, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true}
                          _url: 'wss://omnefeeds.angelbroking.com/NestHtml5Mobile/socket/stream'
                          get binaryType: ƒ binaryType() {\n    return this._binaryType;\n  }
                          set binaryType: ƒ binaryType(type) {\n    if (!BINARY_TYPES.includes(type)) return;\n\n    this._binaryType = type;\n\n    //\n    // Allow to change `binaryType` on the fly.\n    //\n    if (this._receiver) this._receiver._binaryType = type;\n  }
                          get bufferedAmount: ƒ bufferedAmount() {\n    if (!this._socket) return this._bufferedAmount;\n\n    return this._socket._writableState.length + this._sender._bufferedBytes;\n  }
                          get extensions: ƒ extensions() {\n    return Object.keys(this._extensions).join();\n  }
                          get onclose: ƒ get() {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        if (listeners[i]._listener) return listeners[i]._listener;\n      }\n\n      return undefined;\n    }
                          set onclose: ƒ set(listener) {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        //\n        // Remove only the listeners added via `addEventListener`.\n        //\n        if (listeners[i]._listener) this.removeListener(method, listeners[i]);\n      }\n      this.addEventListener(method, listener);\n    }
                          get onerror: ƒ get() {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        if (listeners[i]._listener) return listeners[i]._listener;\n      }\n\n      return undefined;\n    }
                          set onerror: ƒ set(listener) {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        //\n        // Remove only the listeners added via `addEventListener`.\n        //\n        if (listeners[i]._listener) this.removeListener(method, listeners[i]);\n      }\n      this.addEventListener(method, listener);\n    }
                          get onmessage: ƒ get() {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        if (listeners[i]._listener) return listeners[i]._listener;\n      }\n\n      return undefined;\n    }
                          set onmessage: ƒ set(listener) {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        //\n        // Remove only the listeners added via `addEventListener`.\n        //\n        if (listeners[i]._listener) this.removeListener(method, listeners[i]);\n      }\n      this.addEventListener(method, listener);\n    }
                          get onopen: ƒ get() {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        if (listeners[i]._listener) return listeners[i]._listener;\n      }\n\n      return undefined;\n    }
                          set onopen: ƒ set(listener) {\n      const listeners = this.listeners(method);\n      for (let i = 0; i < listeners.length; i++) {\n        //\n        // Remove only the listeners added via `addEventListener`.\n        //\n        if (listeners[i]._listener) this.removeListener(method, listeners[i]);\n      }\n      this.addEventListener(method, listener);\n    }
                          get protocol: ƒ protocol() {\n    return this._protocol;\n  }
                          get readyState: ƒ readyState() {\n    return this._readyState;\n  }
                          get url: ƒ url() {\n    return this._url;\n  }
                          __proto__: EventEmitter
                          type: 'close'
                          wasClean: true
                          __proto__: Event
                          
                          1 Reply Last reply Reply Quote 0
                          • J
                            jiwan1986 last edited by

                            @admin I'm still facing the websocket disconnection issue after 10 minutes for Python SDK

                            1 Reply Last reply Reply Quote 0
                            • S
                              shenoytech @admin last edited by

                              @admin hi admin now it working fine.

                              1 Reply Last reply Reply Quote 0
                              • H
                                hisameer @jiwan1986 last edited by

                                @rjbanna Ohh.. that was the reason, no wonder I was not able to save data in list or anything.

                                1 Reply Last reply Reply Quote 0
                                • G
                                  gondalapradeep @shenoytech last edited by

                                  @dorje Can i get this code please, I have been trying alot, but only getting above three lines and not feed..

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