From a76fa92d60e7feb55aa7dd7336019e886aa91f11 Mon Sep 17 00:00:00 2001 From: mohamedemad4 Date: Thu, 10 Sep 2020 11:25:05 +0200 Subject: [PATCH] minor comments and doc changes --- README.rst | 3 ++- docs/usage.rst | 5 +++-- tiingo/wsclient.py | 13 +++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 50b537b..fa7954d 100644 --- a/README.rst +++ b/README.rst @@ -144,7 +144,8 @@ Websocket support:: # Example response # msg = { - # "service":"iex" # An identifier telling you this is IEX data. The value returned by this will always be "iex". + # "service":"iex" # An identifier telling you this is IEX data. + # The value returned by this will correspond to the endpoint argument. # # # Will always return "A" meaning new price quotes. There are also H type Heartbeat msgs used to keep the connection alive # "messageType":"A" # A value telling you what kind of data packet this is from our IEX feed. diff --git a/docs/usage.rst b/docs/usage.rst index 138c485..408f572 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -70,8 +70,9 @@ Websocket support:: # Example response # msg = { - # "service":"iex" # An identifier telling you this is IEX data. The value returned by this will always be "iex". - # + # "service":"iex" # An identifier telling you this is IEX data. + # The value returned by this will correspond to the endpoint argument. + # # # Will always return "A" meaning new price quotes. There are also H type Heartbeat msgs used to keep the connection alive # "messageType":"A" # A value telling you what kind of data packet this is from our IEX feed. # diff --git a/tiingo/wsclient.py b/tiingo/wsclient.py index 2cb585c..c6ee667 100644 --- a/tiingo/wsclient.py +++ b/tiingo/wsclient.py @@ -1,5 +1,6 @@ import os import websocket +#to import the correct version of thread regardless of python version try: import thread except ImportError: @@ -42,7 +43,8 @@ class TiingoWebsocketClient: # Example response # msg = { - # "service":"iex" # An identifier telling you this is IEX data. The value returned by this will always be "iex". + # "service":"iex" # An identifier telling you this is IEX data. + # The value returned by this will correspond to the endpoint argument. # # # Will always return "A" meaning new price quotes. There are also H type Heartbeat msgs used to keep the connection alive # "messageType":"A" # A value telling you what kind of data packet this is from our IEX feed. @@ -85,13 +87,8 @@ class TiingoWebsocketClient: " via environment variable or config argument." "Notice that this config dict takes the API Key as authorization ") - try: - self.endpoint = endpoint - if not self.endpoint: - raise KeyError - if not (self.endpoint=="iex" or self.endpoint=="fx" or self.endpoint=="crypto"): - raise KeyError - except KeyError: + self.endpoint = endpoint + if not (self.endpoint=="iex" or self.endpoint=="fx" or self.endpoint=="crypto"): raise AttributeError("Endpoint must be defined as either (iex,fx,crypto) ") self.on_msg_cb = on_msg_cb