unicex 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
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/extra.py +49 -0
- {unicex-0.4.0.dist-info → unicex-0.5.0.dist-info}/METADATA +1 -1
- {unicex-0.4.0.dist-info → unicex-0.5.0.dist-info}/RECORD +6 -6
- {unicex-0.4.0.dist-info → unicex-0.5.0.dist-info}/WHEEL +0 -0
- {unicex-0.4.0.dist-info → unicex-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {unicex-0.4.0.dist-info → unicex-0.5.0.dist-info}/top_level.txt +0 -0
unicex/extra.py
CHANGED
|
@@ -7,9 +7,11 @@ __all__ = [
|
|
|
7
7
|
"generate_ex_link",
|
|
8
8
|
"generate_tv_link",
|
|
9
9
|
"generate_cg_link",
|
|
10
|
+
"make_humanreadable",
|
|
10
11
|
]
|
|
11
12
|
|
|
12
13
|
import time
|
|
14
|
+
from typing import Literal
|
|
13
15
|
|
|
14
16
|
from .enums import Exchange, MarketType
|
|
15
17
|
from .exceptions import NotSupported
|
|
@@ -205,3 +207,50 @@ def generate_cg_link(exchange: Exchange, market_type: MarketType, symbol: str) -
|
|
|
205
207
|
return f"{base_url}/SPOT_{exchange.upper()}_{symbol.replace('USDT', '-USDT')}"
|
|
206
208
|
# Для остальных бирж ссылки нет → возвращаем заглушку
|
|
207
209
|
return base_url
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def make_humanreadable(value: float, locale: Literal["ru", "en"] = "ru") -> str:
|
|
213
|
+
"""Функция превращает большие числа в удобочитаемый вид.
|
|
214
|
+
|
|
215
|
+
Принимает:
|
|
216
|
+
value (float): число для преобразования
|
|
217
|
+
locale (Literal["ru", "en"]): язык для форматирования числа
|
|
218
|
+
|
|
219
|
+
Возвращает:
|
|
220
|
+
str: Человеческое представление числа
|
|
221
|
+
"""
|
|
222
|
+
suffixes = {
|
|
223
|
+
"ru": {
|
|
224
|
+
1_000: "тыс.",
|
|
225
|
+
1_000_000: "млн.",
|
|
226
|
+
1_000_000_000: "млрд.",
|
|
227
|
+
1_000_000_000_000: "трлн.",
|
|
228
|
+
1_000_000_000_000_000: "квдрлн.",
|
|
229
|
+
1_000_000_000_000_000_000: "квнтлн.",
|
|
230
|
+
},
|
|
231
|
+
"en": {
|
|
232
|
+
1_000: "K",
|
|
233
|
+
1_000_000: "M",
|
|
234
|
+
1_000_000_000: "B",
|
|
235
|
+
1_000_000_000_000: "T",
|
|
236
|
+
1_000_000_000_000_000: "Qa", # Quadrillion
|
|
237
|
+
1_000_000_000_000_000_000: "Qi", # Quintillion
|
|
238
|
+
},
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
selected_suffixes = suffixes[locale]
|
|
242
|
+
|
|
243
|
+
for divisor in sorted(selected_suffixes.keys(), reverse=True):
|
|
244
|
+
if abs(value) >= divisor:
|
|
245
|
+
number = value / divisor
|
|
246
|
+
if locale == "ru":
|
|
247
|
+
return (
|
|
248
|
+
f"{number:,.2f}".replace(",", " ").replace(".", ",")
|
|
249
|
+
+ f" {selected_suffixes[divisor]}"
|
|
250
|
+
)
|
|
251
|
+
return f"{number:,.2f} {selected_suffixes[divisor]}"
|
|
252
|
+
|
|
253
|
+
# Форматирование "малых" чисел
|
|
254
|
+
if locale == "ru":
|
|
255
|
+
return f"{value:,.2f}".replace(",", " ").replace(".", ",")
|
|
256
|
+
return f"{value:,.2f}"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
unicex/__init__.py,sha256=YcTqQ92p6EZXAn3dQqpORHVqzHVZf5u5oxQ3TLv4yzA,6645
|
|
2
2
|
unicex/enums.py,sha256=fEdvOdr35E0m8AFInZxaM1fh5CMsEORwNO6fM3svjuU,9124
|
|
3
3
|
unicex/exceptions.py,sha256=r-xZzX78VuxVnI5pe99AM8FIiGcdIUDcF5CaTkQ4NE0,2213
|
|
4
|
-
unicex/extra.py,sha256=
|
|
4
|
+
unicex/extra.py,sha256=fy_SS5vXtMIu9i_NdiD-XFHOnT0QC6PApHUGj6SrmPU,10376
|
|
5
5
|
unicex/mapper.py,sha256=hqgDVibYIIyUlVjq0A3R3sHiwDjC4k72ats3ca_JMB4,4928
|
|
6
6
|
unicex/types.py,sha256=QW0AEak5rPmiFwmRtAfO19Yaj2pkGfmLHzS81V2hMEI,2871
|
|
7
7
|
unicex/utils.py,sha256=dwU1VYuP2xcMpzaETtNQerL1V8Y_JH8H8EsLJ__-M4s,8050
|
|
@@ -116,8 +116,8 @@ unicex/xt/uni_client.py,sha256=Boi13Lsbik3p5WOzb4_gspZMrD8pM5Y8W8Gjtk61TXI,6353
|
|
|
116
116
|
unicex/xt/uni_websocket_manager.py,sha256=_mwIZuY9AEtRvYlUy9yxBHdNyDYUDKhaN0P3SZuLRFA,9325
|
|
117
117
|
unicex/xt/user_websocket.py,sha256=7OX1O5dIw9X3iXDBP9eT3xOyd1-xbjrQytKqZUSxdTc,125
|
|
118
118
|
unicex/xt/websocket_manager.py,sha256=iQZIucT5PbPt27yeukcsR2ufMQGf9gvMJG9aAliG5Ws,266
|
|
119
|
-
unicex-0.
|
|
120
|
-
unicex-0.
|
|
121
|
-
unicex-0.
|
|
122
|
-
unicex-0.
|
|
123
|
-
unicex-0.
|
|
119
|
+
unicex-0.5.0.dist-info/licenses/LICENSE,sha256=lNNK4Vqak9cXm6qVJLhbqS7iR_BMj6k7fd7XQ6l1k54,1507
|
|
120
|
+
unicex-0.5.0.dist-info/METADATA,sha256=WgBjx9bF-ZhFi-GBzfBq6BaVNLzulT_pUFAEIpfsTqc,8149
|
|
121
|
+
unicex-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
122
|
+
unicex-0.5.0.dist-info/top_level.txt,sha256=_7rar-0OENIg4KRy6cgjWiebFYAJhjKEcMggAocGWG4,7
|
|
123
|
+
unicex-0.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|