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: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx-autodoc-typehints~=1.18.1
sphinx-autodoc-typehints~=1.19.2
websockets~=10.3
7 changes: 7 additions & 0 deletions docs/source/Getting-Started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ If it is a paginated :code:`list_*` response it's up to you to handle the "next_

.. literalinclude:: ../../examples/rest/raw-list.py

To provide your own JSON processing library (exposing loads/dumps functions) pass :code:`custom_json=my_module`:

.. literalinclude:: ../../examples/websocket/custom-json-get.py

WebSocket client usage
----------------------

Expand Down Expand Up @@ -80,3 +84,6 @@ To handle raw string or byte messages yourself pass :code:`raw=True`:

.. literalinclude:: ../../examples/websocket/raw.py

To provide your own JSON processing library (exposing loads/dumps functions) pass :code:`custom_json=my_module`:

.. literalinclude:: ../../examples/websocket/custom-json.py
9 changes: 9 additions & 0 deletions examples/rest/custom-json-get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from polygon import RESTClient

# type: ignore
import orjson

client = RESTClient(custom_json=orjson)

aggs = client.get_aggs("AAPL", 1, "day", "2022-04-04", "2022-04-04")
print(aggs)
16 changes: 16 additions & 0 deletions examples/websocket/custom-json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from polygon import WebSocketClient
from polygon.websocket.models import WebSocketMessage
from typing import List

# type: ignore
import orjson

c = WebSocketClient(subscriptions=["T.*"], custom_json=orjson)


def handle_msg(msgs: List[WebSocketMessage]):
for m in msgs:
print(m)


c.run(handle_msg)
Loading