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: meta.yaml
+75-34Lines changed: 75 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,6 @@ about:
74
74
in a easy, fast, flexible, robust and fully-featured way.
75
75
description: |
76
76
[](https://shop.lucit.services)
### [Create a multiplex websocket connection](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.create_stream) to Binance with a [`stream_buffer`](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/wiki/%60stream_buffer%60) with just 3 lines of code:
124
+
### [Create a multiplex websocket connection](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.create_stream) to Binance with a [`stream_buffer`](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/wiki/%60stream_buffer%60) with just 3 lines of code
126
125
127
126
```
128
127
from unicorn_binance_websocket_api import BinanceWebSocketApiManager
### Or with a [callback function](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html?highlight=process_stream_data#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.create_stream) just do:
142
+
### Or with a [callback function](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html?highlight=process_stream_data#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.create_stream) just do
143
+
143
144
```
144
145
from unicorn_binance_websocket_api import BinanceWebSocketApiManager
145
146
@@ -154,8 +155,10 @@ about:
154
155
process_stream_data=process_new_receives)
155
156
```
156
157
157
-
### Or await the webstream data in an asyncio task:
158
+
### Or await the webstream data in an asyncio coroutine
159
+
158
160
This is the recommended method for processing data from web streams.
161
+
159
162
```
160
163
from unicorn_binance_websocket_api import BinanceWebSocketApiManager
### [Subscribe](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.subscribe_to_stream) / [unsubscribe](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.unsubscribe_from_stream) new markets and channels:
203
+
## [Subscribe](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.subscribe_to_stream) / [unsubscribe](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.manager.BinanceWebSocketApiManager.unsubscribe_from_stream) new markets and channels
### [Place orders](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.api.BinanceWebSocketApiApi.create_order), [cancel orders](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.api.BinanceWebSocketApiApi.cancel_order) or [send other requests](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#module-unicorn_binance_websocket_api.api) via WebSocket:
217
+
### [Place orders](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.api.BinanceWebSocketApiApi.create_order), [cancel orders](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn_binance_websocket_api.api.BinanceWebSocketApiApi.cancel_order) or [send other requests](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#module-unicorn_binance_websocket_api.api) via WebSocket
218
+
214
219
```
215
220
from unicorn_binance_websocket_api import BinanceWebSocketApiManager
216
221
217
-
218
-
def process_api_responses(stream_data):
219
-
print(str(stream_data))
220
-
221
-
222
222
api_key = "YOUR_BINANCE_API_KEY"
223
223
api_secret = "YOUR_BINANCE_API_SECRET"
224
224
225
+
async def process_api_responses(stream_id=None):
226
+
while ubwa.is_stop_request(stream_id=stream_id) is False:
227
+
data = await ubwa.get_stream_data_from_asyncio_queue(stream_id=stream_id)
print(f"Waiting 5 seconds and then stop the stream ...")
291
+
time.sleep(5)
292
+
```
293
+
294
+
## More?
295
+
296
+
[Discover even more possibilities](https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html), [use this script](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/blob/master/example_stream_everything.py)
297
+
to stream everything from "binance.com" or try our [examples](#examples)!
0 commit comments