Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/Getting-Started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,5 @@ Websocket client usage

asyncio.run(client.connect(handle_msg))

.. note::
Raises :code:`AuthError` if invalid API key is provided.
25 changes: 25 additions & 0 deletions docs/source/WebSocket-Enums.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. _websocket_enums_header:

WebSocket Enums
==============================

==============================================================
Feed
==============================================================
.. autoclass:: polygon.websocket.models.Feed
:members:
:undoc-members:

==============================================================
Market
==============================================================
.. autoclass:: polygon.websocket.models.Market
:members:
:undoc-members:

==============================================================
EventType
==============================================================
.. autoclass:: polygon.websocket.models.EventType
:members:
:undoc-members:
4 changes: 2 additions & 2 deletions docs/source/WebSockets.rst → docs/source/WebSocket.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _websockets_header:
.. _websocket_header:

WebSockets
WebSocket
==========

===========
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ This documentation is for the Python client only. For details about the response

Getting-Started
Aggs
WebSockets
WebSocket
Snapshot
Quotes
Reference
Trades
vX
Models
Enums

WebSocket-Enums

Indices and tables
==================
Expand Down
2 changes: 1 addition & 1 deletion polygon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .rest import RESTClient
from .websocket import WebSocketClient
from .websocket import WebSocketClient, AuthError
8 changes: 6 additions & 2 deletions polygon/websocket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
env_key = "POLYGON_API_KEY"


class AuthError(Exception):
pass


class WebSocketClient:
def __init__(
self,
Expand Down Expand Up @@ -71,6 +75,7 @@ async def connect(

:param processor: The callback to process messages.
:param close_timeout: How long to wait for handshake when calling .close.
:raises AuthError: If invalid API key is supplied.
"""
reconnects = 0
isasync = inspect.iscoroutinefunction(processor)
Expand Down Expand Up @@ -98,8 +103,7 @@ async def connect(
if self.verbose:
print("authed:", auth_msg)
if auth_msg_parsed[0]["status"] == "auth_failed":
print(auth_msg_parsed[0]["message"])
return
raise AuthError(auth_msg_parsed[0]["message"])
while True:
if self.schedule_resub:
if self.verbose:
Expand Down