unicex 0.17.2__tar.gz → 0.17.4__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.
Files changed (122) hide show
  1. {unicex-0.17.2/unicex.egg-info → unicex-0.17.4}/PKG-INFO +1 -1
  2. {unicex-0.17.2 → unicex-0.17.4}/pyproject.toml +1 -1
  3. {unicex-0.17.2 → unicex-0.17.4}/unicex/__init__.py +17 -0
  4. {unicex-0.17.2 → unicex-0.17.4}/unicex/extra.py +61 -0
  5. {unicex-0.17.2 → unicex-0.17.4/unicex.egg-info}/PKG-INFO +1 -1
  6. {unicex-0.17.2 → unicex-0.17.4}/LICENSE +0 -0
  7. {unicex-0.17.2 → unicex-0.17.4}/README.md +0 -0
  8. {unicex-0.17.2 → unicex-0.17.4}/setup.cfg +0 -0
  9. {unicex-0.17.2 → unicex-0.17.4}/unicex/_abc/__init__.py +0 -0
  10. {unicex-0.17.2 → unicex-0.17.4}/unicex/_abc/exchange_info.py +0 -0
  11. {unicex-0.17.2 → unicex-0.17.4}/unicex/_abc/uni_client.py +0 -0
  12. {unicex-0.17.2 → unicex-0.17.4}/unicex/_abc/uni_websocket_manager.py +0 -0
  13. {unicex-0.17.2 → unicex-0.17.4}/unicex/_base/__init__.py +0 -0
  14. {unicex-0.17.2 → unicex-0.17.4}/unicex/_base/client.py +0 -0
  15. {unicex-0.17.2 → unicex-0.17.4}/unicex/_base/websocket.py +0 -0
  16. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/__init__.py +0 -0
  17. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/adapter.py +0 -0
  18. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/client.py +0 -0
  19. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/exchange_info.py +0 -0
  20. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/uni_client.py +0 -0
  21. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/uni_websocket_manager.py +0 -0
  22. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/user_websocket.py +0 -0
  23. {unicex-0.17.2 → unicex-0.17.4}/unicex/aster/websocket_manager.py +0 -0
  24. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/__init__.py +0 -0
  25. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/adapter.py +0 -0
  26. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/client.py +0 -0
  27. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/exchange_info.py +0 -0
  28. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/uni_client.py +0 -0
  29. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/uni_websocket_manager.py +0 -0
  30. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/user_websocket.py +0 -0
  31. {unicex-0.17.2 → unicex-0.17.4}/unicex/binance/websocket_manager.py +0 -0
  32. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/__init__.py +0 -0
  33. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/adapter.py +0 -0
  34. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/client.py +0 -0
  35. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/exchange_info.py +0 -0
  36. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/uni_client.py +0 -0
  37. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/uni_websocket_manager.py +0 -0
  38. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/user_websocket.py +0 -0
  39. {unicex-0.17.2 → unicex-0.17.4}/unicex/bingx/websocket_manager.py +0 -0
  40. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/__init__.py +0 -0
  41. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/adapter.py +0 -0
  42. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/client.py +0 -0
  43. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/exchange_info.py +0 -0
  44. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/uni_client.py +0 -0
  45. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/uni_websocket_manager.py +0 -0
  46. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/user_websocket.py +0 -0
  47. {unicex-0.17.2 → unicex-0.17.4}/unicex/bitget/websocket_manager.py +0 -0
  48. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/__init__.py +0 -0
  49. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/adapter.py +0 -0
  50. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/client.py +0 -0
  51. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/exchange_info.py +0 -0
  52. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/uni_client.py +0 -0
  53. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/uni_websocket_manager.py +0 -0
  54. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/user_websocket.py +0 -0
  55. {unicex-0.17.2 → unicex-0.17.4}/unicex/bybit/websocket_manager.py +0 -0
  56. {unicex-0.17.2 → unicex-0.17.4}/unicex/enums.py +0 -0
  57. {unicex-0.17.2 → unicex-0.17.4}/unicex/exceptions.py +0 -0
  58. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/__init__.py +0 -0
  59. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/adapter.py +0 -0
  60. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/client.py +0 -0
  61. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/exchange_info.py +0 -0
  62. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/uni_client.py +0 -0
  63. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/uni_websocket_manager.py +0 -0
  64. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/user_websocket.py +0 -0
  65. {unicex-0.17.2 → unicex-0.17.4}/unicex/gate/websocket_manager.py +0 -0
  66. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/__init__.py +0 -0
  67. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/adapter.py +0 -0
  68. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/client.py +0 -0
  69. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/exchange_info.py +0 -0
  70. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/uni_client.py +0 -0
  71. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/uni_websocket_manager.py +0 -0
  72. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/user_websocket.py +0 -0
  73. {unicex-0.17.2 → unicex-0.17.4}/unicex/hyperliquid/websocket_manager.py +0 -0
  74. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/__init__.py +0 -0
  75. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/adapter.py +0 -0
  76. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/client.py +0 -0
  77. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/exchange_info.py +0 -0
  78. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/uni_client.py +0 -0
  79. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/uni_websocket_manager.py +0 -0
  80. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/user_websocket.py +0 -0
  81. {unicex-0.17.2 → unicex-0.17.4}/unicex/kucoin/websocket_manager.py +0 -0
  82. {unicex-0.17.2 → unicex-0.17.4}/unicex/mapper.py +0 -0
  83. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/__init__.py +0 -0
  84. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PrivateAccountV3Api_pb2.py +0 -0
  85. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PrivateDealsV3Api_pb2.py +0 -0
  86. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PrivateOrdersV3Api_pb2.py +0 -0
  87. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicAggreBookTickerV3Api_pb2.py +0 -0
  88. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicAggreDealsV3Api_pb2.py +0 -0
  89. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicAggreDepthsV3Api_pb2.py +0 -0
  90. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicBookTickerBatchV3Api_pb2.py +0 -0
  91. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicBookTickerV3Api_pb2.py +0 -0
  92. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicDealsV3Api_pb2.py +0 -0
  93. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicFuture_pb2.py +0 -0
  94. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicIncreaseDepthsBatchV3Api_pb2.py +0 -0
  95. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicIncreaseDepthsV3Api_pb2.py +0 -0
  96. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicLimitDepthsV3Api_pb2.py +0 -0
  97. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicMiniTickerV3Api_pb2.py +0 -0
  98. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicMiniTickersV3Api_pb2.py +0 -0
  99. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PublicSpotKlineV3Api_pb2.py +0 -0
  100. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/PushDataV3ApiWrapper_pb2.py +0 -0
  101. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/_spot_ws_proto/__init__.py +0 -0
  102. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/adapter.py +0 -0
  103. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/client.py +0 -0
  104. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/exchange_info.py +0 -0
  105. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/uni_client.py +0 -0
  106. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/uni_websocket_manager.py +0 -0
  107. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/user_websocket.py +0 -0
  108. {unicex-0.17.2 → unicex-0.17.4}/unicex/mexc/websocket_manager.py +0 -0
  109. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/__init__.py +0 -0
  110. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/adapter.py +0 -0
  111. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/client.py +0 -0
  112. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/exchange_info.py +0 -0
  113. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/uni_client.py +0 -0
  114. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/uni_websocket_manager.py +0 -0
  115. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/user_websocket.py +0 -0
  116. {unicex-0.17.2 → unicex-0.17.4}/unicex/okx/websocket_manager.py +0 -0
  117. {unicex-0.17.2 → unicex-0.17.4}/unicex/types.py +0 -0
  118. {unicex-0.17.2 → unicex-0.17.4}/unicex/utils.py +0 -0
  119. {unicex-0.17.2 → unicex-0.17.4}/unicex.egg-info/SOURCES.txt +0 -0
  120. {unicex-0.17.2 → unicex-0.17.4}/unicex.egg-info/dependency_links.txt +0 -0
  121. {unicex-0.17.2 → unicex-0.17.4}/unicex.egg-info/requires.txt +0 -0
  122. {unicex-0.17.2 → unicex-0.17.4}/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.17.2
3
+ Version: 0.17.4
4
4
  Summary: Unified Crypto Exchange API
5
5
  Author-email: LoveBloodAndDiamonds <ayazshakirzyanov27@gmail.com>
6
6
  License: BSD 3-Clause License
@@ -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.17.2"
7
+ version = "0.17.4"
8
8
 
9
9
  description = "Unified Crypto Exchange API "
10
10
  readme = "README.md"
@@ -31,6 +31,13 @@ __all__ = [
31
31
  # Base clients and websockets
32
32
  "Websocket",
33
33
  "BaseClient",
34
+ # Aster
35
+ "AsterClient",
36
+ "AsterUniClient",
37
+ "AsterUniWebsocketManager",
38
+ "AsterUserWebsocket",
39
+ "AsterWebsocketManager",
40
+ "AsterExchangeInfo",
34
41
  # Binance
35
42
  "BinanceClient",
36
43
  "BinanceUniClient",
@@ -123,6 +130,14 @@ from .types import (
123
130
 
124
131
  # exchanges
125
132
 
133
+ from .aster import (
134
+ Client as AsterClient,
135
+ UniClient as AsterUniClient,
136
+ UniWebsocketManager as AsterUniWebsocketManager,
137
+ UserWebsocket as AsterUserWebsocket,
138
+ WebsocketManager as AsterWebsocketManager,
139
+ ExchangeInfo as AsterExchangeInfo,
140
+ )
126
141
  from .binance import (
127
142
  Client as BinanceClient,
128
143
  UniClient as BinanceUniClient,
@@ -208,6 +223,7 @@ from .bingx import (
208
223
  async def load_exchanges_info() -> list:
209
224
  """Единожды загружает информацию о тикерах на всех биржах."""
210
225
  return await asyncio.gather(
226
+ AsterExchangeInfo.load_exchange_info(),
211
227
  BinanceExchangeInfo.load_exchange_info(),
212
228
  BitgetExchangeInfo.load_exchange_info(),
213
229
  BybitExchangeInfo.load_exchange_info(),
@@ -223,6 +239,7 @@ async def load_exchanges_info() -> list:
223
239
  async def start_exchanges_info(parse_interval_seconds: int = 60 * 60) -> Awaitable:
224
240
  """Запускает цикл обновления информации о тикерах на всех биржах."""
225
241
  return asyncio.gather(
242
+ AsterExchangeInfo.start(parse_interval_seconds),
226
243
  BinanceExchangeInfo.start(parse_interval_seconds),
227
244
  BitgetExchangeInfo.start(parse_interval_seconds),
228
245
  BybitExchangeInfo.start(parse_interval_seconds),
@@ -13,6 +13,7 @@ __all__ = [
13
13
  ]
14
14
 
15
15
  import time
16
+ from collections import defaultdict
16
17
  from typing import Literal
17
18
 
18
19
  from .enums import Exchange, MarketType
@@ -93,6 +94,66 @@ class TimeoutTracker[T]:
93
94
  self._blocked_items[item] = time.time() + duration
94
95
 
95
96
 
97
+ class SignalCounter[T]:
98
+ """Класс, который считает количество сигналов за отведенный интервал."""
99
+
100
+ def __init__(self, window_sec: int = 86400) -> None:
101
+ """Инициализация класса SignalCounter."""
102
+ self._window_sec = window_sec
103
+ self._signals: dict[T, list[float]] = defaultdict(list)
104
+
105
+ def is_within_limit(self, item: T, limit: int) -> bool:
106
+ """Проверяет, что количество сигналов НЕ превышает допустимый лимит.
107
+
108
+ Лимит считается превышенным, если количество сигналов
109
+ равно или больше limit.
110
+
111
+ Параметры:
112
+ item (T): Объект (сигнал), для которого проверяется количество срабатываний.
113
+ limit (int): Максимально допустимое количество сигналов.
114
+
115
+ Возвращает:
116
+ bool:
117
+ True — если количество сигналов строго меньше limit
118
+ (лимит не превышен).
119
+ False — если количество сигналов равно или больше limit
120
+ (лимит считается превышенным).
121
+
122
+ """
123
+ return self.get(item) < limit
124
+
125
+ def get(self, item: T) -> int:
126
+ """Возвращает количество сигналов за интервал.
127
+
128
+ Параметры:
129
+ item (T): Сигнал.
130
+
131
+ Возвращает:
132
+ int: Количество сигналов за интервал.
133
+
134
+ """
135
+ timestamp = time.time()
136
+ threshold = timestamp - self._window_sec
137
+ self._signals[item] = [t for t in self._signals[item] if t > threshold]
138
+ return len(self._signals[item])
139
+
140
+ def add(self, item: T) -> int:
141
+ """Добавляет сигнал и возвращает количество сигналов за интервал.
142
+
143
+ Параметры:
144
+ item (T): Сигнал.
145
+
146
+ Возвращает:
147
+ int: Количество сигналов за интервал.
148
+
149
+ """
150
+ timestamp = time.time()
151
+ self._signals[item].append(timestamp)
152
+ threshold = timestamp - self._window_sec
153
+ self._signals[item] = [t for t in self._signals[item] if t > threshold]
154
+ return len(self._signals[item])
155
+
156
+
96
157
  def normalize_ticker(raw_ticker: str) -> str:
97
158
  """Нормализует тикер и возвращает базовую валюту (например, `BTC`).
98
159
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unicex
3
- Version: 0.17.2
3
+ Version: 0.17.4
4
4
  Summary: Unified Crypto Exchange API
5
5
  Author-email: LoveBloodAndDiamonds <ayazshakirzyanov27@gmail.com>
6
6
  License: BSD 3-Clause License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes