unicex 0.8.1__tar.gz → 0.10.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unicex-0.8.1/unicex.egg-info → unicex-0.10.1}/PKG-INFO +5 -5
- {unicex-0.8.1 → unicex-0.10.1}/README.md +4 -4
- {unicex-0.8.1 → unicex-0.10.1}/pyproject.toml +1 -1
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_abc/__init__.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_base/websocket.py +26 -18
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/websocket_manager.py +6 -6
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/websocket_manager.py +10 -10
- unicex-0.10.1/unicex/gateio/websocket_manager.py +513 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/adapter.py +1 -1
- unicex-0.10.1/unicex/hyperliquid/websocket_manager.py +363 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PrivateAccountV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PrivateDealsV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PrivateOrdersV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicAggreBookTickerV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicAggreDealsV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicAggreDepthsV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicBookTickerBatchV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicBookTickerV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicDealsV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicFuture_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicIncreaseDepthsBatchV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicIncreaseDepthsV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicLimitDepthsV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicMiniTickerV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicMiniTickersV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PublicSpotKlineV3Api_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/PushDataV3ApiWrapper_pb2.py +0 -2
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/_spot_ws_proto/__init__.py +335 -332
- unicex-0.10.1/unicex/mexc/websocket_manager.py +456 -0
- unicex-0.10.1/unicex/okx/websocket_manager.py +743 -0
- {unicex-0.8.1 → unicex-0.10.1/unicex.egg-info}/PKG-INFO +5 -5
- {unicex-0.8.1 → unicex-0.10.1}/unicex.egg-info/SOURCES.txt +0 -1
- unicex-0.8.1/unicex/_abc/decoder.py +0 -18
- unicex-0.8.1/unicex/gateio/websocket_manager.py +0 -11
- unicex-0.8.1/unicex/hyperliquid/websocket_manager.py +0 -11
- unicex-0.8.1/unicex/mexc/websocket_manager.py +0 -11
- unicex-0.8.1/unicex/okx/websocket_manager.py +0 -11
- {unicex-0.8.1 → unicex-0.10.1}/LICENSE +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/setup.cfg +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_abc/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_abc/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_abc/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_base/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/_base/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/adapter.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/binance/websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/adapter.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bitget/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/adapter.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/bybit/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/enums.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/exceptions.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/extra.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/adapter.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/gateio/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/hyperliquid/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mapper.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/adapter.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/mexc/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/__init__.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/adapter.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/exchange_info.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/uni_client.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/uni_websocket_manager.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/okx/user_websocket.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/types.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex/utils.py +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex.egg-info/dependency_links.txt +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex.egg-info/requires.txt +0 -0
- {unicex-0.8.1 → unicex-0.10.1}/unicex.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unicex
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.1
|
|
4
4
|
Summary: Unified Crypto Exchange API
|
|
5
5
|
Author-email: LoveBloodAndDiamonds <ayazshakirzyanov27@gmail.com>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -58,10 +58,10 @@ Dynamic: license-file
|
|
|
58
58
|
| **Binance** | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
|
|
59
59
|
| **Bitget** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
60
60
|
| **Bybit** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
61
|
-
| **Gateio** | ✓ | ✓ |
|
|
62
|
-
| **Hyperliquid** | ✓ | ✓ |
|
|
63
|
-
| **Mexc** | ✓ | ✓ |
|
|
64
|
-
| **Okx** | ✓ | ✓ |
|
|
61
|
+
| **Gateio** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
62
|
+
| **Hyperliquid** | ✓ | ✓ | ✓ | ✓ | ✓ | | |
|
|
63
|
+
| **Mexc** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
64
|
+
| **Okx** | ✓ | ✓ | ✓ | | ✓ | | ✓ |
|
|
65
65
|
---
|
|
66
66
|
|
|
67
67
|
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
| **Binance** | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
|
|
10
10
|
| **Bitget** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
11
11
|
| **Bybit** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
12
|
-
| **Gateio** | ✓ | ✓ |
|
|
13
|
-
| **Hyperliquid** | ✓ | ✓ |
|
|
14
|
-
| **Mexc** | ✓ | ✓ |
|
|
15
|
-
| **Okx** | ✓ | ✓ |
|
|
12
|
+
| **Gateio** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
13
|
+
| **Hyperliquid** | ✓ | ✓ | ✓ | ✓ | ✓ | | |
|
|
14
|
+
| **Mexc** | ✓ | ✓ | ✓ | | ✓ | | |
|
|
15
|
+
| **Okx** | ✓ | ✓ | ✓ | | ✓ | | ✓ |
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
|
|
@@ -4,7 +4,7 @@ name = "unicex"
|
|
|
4
4
|
# • PATCH (x.y.Z) → увеличивается при багфиксе, который не ломает совместимость.
|
|
5
5
|
# • MINOR (x.Y.z) → увеличивается при добавлении новой функциональности, но без ломающих изменений (backward-compatible).
|
|
6
6
|
# • MAJOR (X.y.z) → увеличивается при изменениях, которые ломают обратную совместимость.
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.10.1"
|
|
8
8
|
|
|
9
9
|
description = "Unified Crypto Exchange API "
|
|
10
10
|
readme = "README.md"
|
|
@@ -4,10 +4,8 @@ __all__ = [
|
|
|
4
4
|
"IUniClient",
|
|
5
5
|
"IUniWebsocketManager",
|
|
6
6
|
"IExchangeInfo",
|
|
7
|
-
"IDecoder",
|
|
8
7
|
]
|
|
9
8
|
|
|
10
|
-
from .decoder import IDecoder
|
|
11
9
|
from .exchange_info import IExchangeInfo
|
|
12
10
|
from .uni_client import IUniClient
|
|
13
11
|
from .uni_websocket_manager import IUniWebsocketManager
|
|
@@ -3,7 +3,7 @@ __all__ = ["Websocket"]
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import time
|
|
5
5
|
from collections.abc import Awaitable, Callable
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import Any, Protocol
|
|
7
7
|
|
|
8
8
|
import orjson
|
|
9
9
|
import websockets
|
|
@@ -13,9 +13,6 @@ from websockets.asyncio.client import ClientConnection
|
|
|
13
13
|
from unicex.exceptions import QueueOverflowError
|
|
14
14
|
from unicex.types import LoggerLike
|
|
15
15
|
|
|
16
|
-
if TYPE_CHECKING:
|
|
17
|
-
from unicex._abc import IDecoder
|
|
18
|
-
|
|
19
16
|
|
|
20
17
|
class Websocket:
|
|
21
18
|
"""Базовый класс асинхронного вебсокета."""
|
|
@@ -23,10 +20,15 @@ class Websocket:
|
|
|
23
20
|
MAX_QUEUE_SIZE: int = 100
|
|
24
21
|
"""Максимальная длина очереди."""
|
|
25
22
|
|
|
23
|
+
class _DecoderProtocol(Protocol):
|
|
24
|
+
"""Протокол декодирования сообщений."""
|
|
25
|
+
|
|
26
|
+
def decode(self, message: Any) -> dict: ...
|
|
27
|
+
|
|
26
28
|
class _JsonDecoder:
|
|
27
|
-
"""
|
|
29
|
+
"""Протокол декодирования сообщений в формате JSON."""
|
|
28
30
|
|
|
29
|
-
def decode(self, message:
|
|
31
|
+
def decode(self, message: Any) -> dict:
|
|
30
32
|
return orjson.loads(message)
|
|
31
33
|
|
|
32
34
|
def __init__(
|
|
@@ -35,13 +37,13 @@ class Websocket:
|
|
|
35
37
|
url: str,
|
|
36
38
|
subscription_messages: list[dict] | list[str] | None = None,
|
|
37
39
|
ping_interval: int | float = 10,
|
|
38
|
-
ping_message: str | None = None,
|
|
39
|
-
pong_message: str | None = None,
|
|
40
|
+
ping_message: str | Callable | None = None,
|
|
41
|
+
pong_message: str | Callable | None = None,
|
|
40
42
|
no_message_reconnect_timeout: int | float | None = 60,
|
|
41
43
|
reconnect_timeout: int | float | None = 5,
|
|
42
44
|
worker_count: int = 2,
|
|
43
45
|
logger: LoggerLike | None = None,
|
|
44
|
-
decoder: type[
|
|
46
|
+
decoder: type[_DecoderProtocol] = _JsonDecoder,
|
|
45
47
|
**kwargs: Any, # Не дадим сломаться, если юзер передал ненужные аргументы
|
|
46
48
|
) -> None:
|
|
47
49
|
"""Инициализация вебсокета.
|
|
@@ -51,8 +53,8 @@ class Websocket:
|
|
|
51
53
|
url (`str`): URL вебсокета.
|
|
52
54
|
subscription_messages (`list[dict] | list[str] | None`): Сообщения для подписки после подключения.
|
|
53
55
|
ping_interval (`int | float`): Интервал отправки ping, сек.
|
|
54
|
-
ping_message (`str | None`): Сообщение для ping (если не указано — используется ping‑frame).
|
|
55
|
-
pong_message (`str | None`): Сообщение для pong (если не указано — используется pong‑frame).
|
|
56
|
+
ping_message (`str | Callable | None`): Сообщение для ping, или функция генерации ping (если не указано — используется ping‑frame).
|
|
57
|
+
pong_message (`str | Callable | None`): Сообщение для pong, или функция генерации pong (если не указано — используется pong‑frame).
|
|
56
58
|
no_message_reconnect_timeout (`int | float | None`): Таймаут ожидания без сообщений до рестарта, сек.
|
|
57
59
|
reconnect_timeout (`int | float | None`): Пауза перед переподключением, сек.
|
|
58
60
|
worker_count (`int`): Количество рабочих задач для обработки сообщений.
|
|
@@ -116,12 +118,13 @@ class Websocket:
|
|
|
116
118
|
|
|
117
119
|
# Цикл получения сообщений
|
|
118
120
|
while self._running:
|
|
119
|
-
message = await conn.recv(
|
|
121
|
+
message = await conn.recv()
|
|
120
122
|
await self._handle_message(message)
|
|
121
123
|
|
|
122
|
-
except websockets.exceptions.ConnectionClosed:
|
|
123
|
-
self._logger.error("Websocket connection was closed unexpectedly")
|
|
124
|
-
|
|
124
|
+
except websockets.exceptions.ConnectionClosed as e:
|
|
125
|
+
self._logger.error(f"Websocket connection was closed unexpectedly: {e}")
|
|
126
|
+
except Exception as e:
|
|
127
|
+
self._logger.error(f"Unexpected error in websosocket connection: {e}")
|
|
125
128
|
finally:
|
|
126
129
|
await asyncio.sleep(self._reconnect_timeout)
|
|
127
130
|
await self._after_disconnect()
|
|
@@ -133,7 +136,8 @@ class Websocket:
|
|
|
133
136
|
self._last_message_time = time.monotonic()
|
|
134
137
|
|
|
135
138
|
# Ложим сообщение в очередь, предварительно его сериализуя
|
|
136
|
-
|
|
139
|
+
decoded_message = self._decoder.decode(message)
|
|
140
|
+
await self._queue.put(decoded_message)
|
|
137
141
|
|
|
138
142
|
# Проверяем размер очереди сообщений и выбрасываем ошибку, если он превышает максимальный размер
|
|
139
143
|
self._check_queue_size()
|
|
@@ -213,8 +217,12 @@ class Websocket:
|
|
|
213
217
|
"""Периодически отправляет пользовательский ping."""
|
|
214
218
|
while self._running and self._ping_message:
|
|
215
219
|
try:
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
if isinstance(self._ping_message, Callable):
|
|
221
|
+
ping_message = self._ping_message()
|
|
222
|
+
else:
|
|
223
|
+
ping_message = self._ping_message
|
|
224
|
+
await conn.send(ping_message)
|
|
225
|
+
self._logger.debug(f"Sent ping message: {ping_message}")
|
|
218
226
|
except Exception as e:
|
|
219
227
|
self._logger.error(f"Error sending ping: {e}")
|
|
220
228
|
return
|
|
@@ -15,7 +15,7 @@ type CallbackType = Callable[[Any], Awaitable[None]]
|
|
|
15
15
|
class WebsocketManager:
|
|
16
16
|
"""Менеджер асинхронных вебсокетов для Bitget."""
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
_URL: str = "wss://ws.bitget.com/v2/ws/public"
|
|
19
19
|
"""Базовый URL для вебсокета."""
|
|
20
20
|
|
|
21
21
|
def __init__(self, client: Client | None = None, **ws_kwargs: Any) -> None:
|
|
@@ -91,7 +91,7 @@ class WebsocketManager:
|
|
|
91
91
|
)
|
|
92
92
|
return Websocket(
|
|
93
93
|
callback=callback,
|
|
94
|
-
url=self.
|
|
94
|
+
url=self._URL,
|
|
95
95
|
subscription_messages=subsription_messages,
|
|
96
96
|
**self._ws_kwargs,
|
|
97
97
|
)
|
|
@@ -124,7 +124,7 @@ class WebsocketManager:
|
|
|
124
124
|
)
|
|
125
125
|
return Websocket(
|
|
126
126
|
callback=callback,
|
|
127
|
-
url=self.
|
|
127
|
+
url=self._URL,
|
|
128
128
|
subscription_messages=subscription_messages,
|
|
129
129
|
**self._ws_kwargs,
|
|
130
130
|
)
|
|
@@ -160,7 +160,7 @@ class WebsocketManager:
|
|
|
160
160
|
)
|
|
161
161
|
return Websocket(
|
|
162
162
|
callback=callback,
|
|
163
|
-
url=self.
|
|
163
|
+
url=self._URL,
|
|
164
164
|
subscription_messages=subscription_messages,
|
|
165
165
|
**self._ws_kwargs,
|
|
166
166
|
)
|
|
@@ -195,7 +195,7 @@ class WebsocketManager:
|
|
|
195
195
|
)
|
|
196
196
|
return Websocket(
|
|
197
197
|
callback=callback,
|
|
198
|
-
url=self.
|
|
198
|
+
url=self._URL,
|
|
199
199
|
subscription_messages=subscription_messages,
|
|
200
200
|
**self._ws_kwargs,
|
|
201
201
|
)
|
|
@@ -226,7 +226,7 @@ class WebsocketManager:
|
|
|
226
226
|
)
|
|
227
227
|
return Websocket(
|
|
228
228
|
callback=callback,
|
|
229
|
-
url=self.
|
|
229
|
+
url=self._URL,
|
|
230
230
|
subscription_messages=subscription_messages,
|
|
231
231
|
**self._ws_kwargs,
|
|
232
232
|
)
|
|
@@ -15,19 +15,19 @@ type CallbackType = Callable[[Any], Awaitable[None]]
|
|
|
15
15
|
class WebsocketManager:
|
|
16
16
|
"""Менеджер асинхронных вебсокетов для Bybit."""
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
_SPOT_URL: str = "wss://stream.bybit.com/v5/public/spot"
|
|
19
19
|
"""Базовый URL для вебсокета на спот."""
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
_LINEAR_URL: str = "wss://stream.bybit.com/v5/public/linear"
|
|
22
22
|
"""Базовый URL для вебсокета на USDT/USDC перпетуалы и фьючерсы."""
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
_INVERSE_URL: str = "wss://stream.bybit.com/v5/public/inverse"
|
|
25
25
|
"""Базовый URL для вебсокета на инверсные контракты."""
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
_OPTION_URL: str = "wss://stream.bybit.com/v5/public/option"
|
|
28
28
|
"""Базовый URL для вебсокета на опционы."""
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
_PRIVATE_URL: str = "wss://stream.bybit.com/v5/private"
|
|
31
31
|
"""Базовый URL для приватных вебсокетов."""
|
|
32
32
|
|
|
33
33
|
def __init__(self, client: Client | None = None, **ws_kwargs: Any) -> None:
|
|
@@ -72,15 +72,15 @@ class WebsocketManager:
|
|
|
72
72
|
`str`: URL для вебсокета.
|
|
73
73
|
"""
|
|
74
74
|
if category == "spot":
|
|
75
|
-
return self.
|
|
75
|
+
return self._SPOT_URL
|
|
76
76
|
elif category == "linear":
|
|
77
|
-
return self.
|
|
77
|
+
return self._LINEAR_URL
|
|
78
78
|
elif category == "inverse":
|
|
79
|
-
return self.
|
|
79
|
+
return self._INVERSE_URL
|
|
80
80
|
elif category == "option":
|
|
81
|
-
return self.
|
|
81
|
+
return self._OPTION_URL
|
|
82
82
|
elif category == "private":
|
|
83
|
-
return self.
|
|
83
|
+
return self._PRIVATE_URL
|
|
84
84
|
else:
|
|
85
85
|
raise ValueError(f"Unsupported category: {category}")
|
|
86
86
|
|