You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/account-streamer.rst
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,9 @@
1
1
Account Streamer
2
2
================
3
3
4
+
Basic usage
5
+
-----------
6
+
4
7
The account streamer is used to track account-level updates, such as order fills, watchlist updates and quote alerts.
5
8
Typically, you'll want a separate task running for the account streamer, which can then notify your application about important events.
6
9
@@ -35,3 +38,24 @@ Probably the most important information the account streamer handles is order fi
35
38
36
39
asyncfor order in streamer.listen(PlacedOrder):
37
40
print(order)
41
+
42
+
Retry callback
43
+
--------------
44
+
45
+
The account streamer has a special "callback" function which can be used to execute arbitrary code whenever the websocket reconnects. This is useful for re-subscribing to whatever alerts you wanted to subscribe to initially (in fact, you can probably use the same function/code you use when initializing the connection).
46
+
The callback function should look something like this:
The requirements are that the first parameter be the `AlertStreamer` instance, and the function should be asynchronous. Other than that, you have the flexibility to decide what arguments you want to use.
54
+
This callback can then be used when creating the streamer:
55
+
56
+
.. code-block:: python
57
+
58
+
asyncwith AlertStreamer(session, reconnect_fn=callback, reconnect_args=(arg1, arg2)) as streamer:
59
+
# ...
60
+
61
+
The reconnection uses `websockets`' exponential backoff algorithm, which can be configured through environment variables `here <https://websockets.readthedocs.io/en/14.1/reference/variables.html>`_.
The data streamer has a special "callback" function which can be used to execute arbitrary code whenever the websocket reconnects. This is useful for re-subscribing to whatever events you wanted to subscribe to initially (in fact, you can probably use the same function/code you use when initializing the connection).
154
+
The callback function should look something like this:
The requirements are that the first parameter be the `DXLinkStreamer` instance, and the function should be asynchronous. Other than that, you have the flexibility to decide what arguments you want to use.
162
+
This callback can then be used when creating the streamer:
163
+
164
+
.. code-block:: python
165
+
166
+
asyncwith DXLinkStreamer(session, reconnect_fn=callback, reconnect_args=(arg1, arg2)) as streamer:
167
+
# ...
168
+
169
+
The reconnection uses `websockets`' exponential backoff algorithm, which can be configured through environment variables `here <https://websockets.readthedocs.io/en/14.1/reference/variables.html>`_.
0 commit comments