trd-utils 0.0.33__tar.gz → 0.0.35__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.
Potentially problematic release.
This version of trd-utils might be problematic. Click here for more details.
- {trd_utils-0.0.33 → trd_utils-0.0.35}/PKG-INFO +1 -1
- {trd_utils-0.0.33 → trd_utils-0.0.35}/pyproject.toml +1 -1
- trd_utils-0.0.35/trd_utils/__init__.py +3 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/README.md +4 -2
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/blofin/blofin_client.py +18 -3
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/bx_ultra_client.py +9 -1
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/exchange_base.py +3 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/hyperliquid_client.py +1 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/okx/okx_client.py +1 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/price_fetcher.py +11 -1
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/types_helper/base_model.py +0 -1
- trd_utils-0.0.33/trd_utils/__init__.py +0 -3
- {trd_utils-0.0.33 → trd_utils-0.0.35}/LICENSE +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/README.md +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/cipher/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/common_utils/float_utils.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/common_utils/wallet_utils.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/date_utils/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/date_utils/datetime_helpers.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/base_types.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/blofin/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/blofin/blofin_types.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/bx_types.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/bx_utils.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/errors.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/README.md +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/hyperliquid_types.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/okx/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/okx/okx_types.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/html_utils/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/html_utils/html_formats.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/tradingview/__init__.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/tradingview/tradingview_client.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/tradingview/tradingview_types.py +0 -0
- {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/types_helper/__init__.py +0 -0
|
@@ -48,11 +48,13 @@ class MyExchangeClient(ExchangeBase):
|
|
|
48
48
|
fav_letter: str = "^",
|
|
49
49
|
read_session_file: bool = True,
|
|
50
50
|
sessions_dir: str = "sessions",
|
|
51
|
+
use_http1: bool = False,
|
|
52
|
+
use_http2: bool = True,
|
|
51
53
|
):
|
|
52
54
|
self.httpx_client = httpx.AsyncClient(
|
|
53
55
|
verify=http_verify,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
http1=use_http1,
|
|
57
|
+
http2=use_http2,
|
|
56
58
|
)
|
|
57
59
|
self.account_name = account_name
|
|
58
60
|
self._fav_letter = fav_letter
|
|
@@ -23,6 +23,7 @@ from trd_utils.exchanges.blofin.blofin_types import (
|
|
|
23
23
|
ShareConfigResponse,
|
|
24
24
|
)
|
|
25
25
|
from trd_utils.cipher import AESCipher
|
|
26
|
+
from trd_utils.exchanges.errors import ExchangeError
|
|
26
27
|
from trd_utils.exchanges.exchange_base import ExchangeBase
|
|
27
28
|
|
|
28
29
|
|
|
@@ -50,16 +51,19 @@ class BlofinClient(ExchangeBase):
|
|
|
50
51
|
fav_letter: str = "^",
|
|
51
52
|
read_session_file: bool = True,
|
|
52
53
|
sessions_dir: str = "sessions",
|
|
54
|
+
use_http1: bool = False,
|
|
55
|
+
use_http2: bool = True,
|
|
53
56
|
):
|
|
54
57
|
self.httpx_client = httpx.AsyncClient(
|
|
55
58
|
verify=http_verify,
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
http1=use_http1,
|
|
60
|
+
http2=use_http2,
|
|
58
61
|
)
|
|
59
62
|
self.account_name = account_name
|
|
60
63
|
self._fav_letter = fav_letter
|
|
61
64
|
self.sessions_dir = sessions_dir
|
|
62
|
-
|
|
65
|
+
self.exchange_name = "blofin"
|
|
66
|
+
|
|
63
67
|
super().__init__()
|
|
64
68
|
|
|
65
69
|
if read_session_file:
|
|
@@ -141,6 +145,17 @@ class BlofinClient(ExchangeBase):
|
|
|
141
145
|
from_param=current_id_from,
|
|
142
146
|
limit_param=chunk_limit,
|
|
143
147
|
)
|
|
148
|
+
if current_result.code != 200:
|
|
149
|
+
if current_result.msg:
|
|
150
|
+
raise ExchangeError(
|
|
151
|
+
f"blofin get_copy_trader_all_order_list: {current_result.msg}; "
|
|
152
|
+
f"code: {current_result.code}"
|
|
153
|
+
)
|
|
154
|
+
raise ExchangeError(
|
|
155
|
+
"blofin get_copy_trader_all_order_list: unknown error; "
|
|
156
|
+
f"code: {current_result.code}"
|
|
157
|
+
)
|
|
158
|
+
|
|
144
159
|
if not isinstance(current_result, CopyTraderOrderListResponse):
|
|
145
160
|
raise ValueError(
|
|
146
161
|
"get_copy_trader_order_list returned invalid value of "
|
|
@@ -114,9 +114,13 @@ class BXUltraClient(ExchangeBase, IPriceFetcher):
|
|
|
114
114
|
http_verify: bool = True,
|
|
115
115
|
fav_letter: str = "^",
|
|
116
116
|
sessions_dir: str = "sessions",
|
|
117
|
+
use_http1: bool = False,
|
|
118
|
+
use_http2: bool = True,
|
|
117
119
|
):
|
|
118
120
|
self.httpx_client = httpx.AsyncClient(
|
|
119
|
-
verify=http_verify,
|
|
121
|
+
verify=http_verify,
|
|
122
|
+
http1=use_http1,
|
|
123
|
+
http2=use_http2,
|
|
120
124
|
)
|
|
121
125
|
self.account_name = account_name
|
|
122
126
|
self.platform_id = platform_id
|
|
@@ -124,6 +128,7 @@ class BXUltraClient(ExchangeBase, IPriceFetcher):
|
|
|
124
128
|
self.app_version = app_version
|
|
125
129
|
self._fav_letter = fav_letter
|
|
126
130
|
self.sessions_dir = sessions_dir
|
|
131
|
+
self.exchange_name = "\u0062ing\u0078"
|
|
127
132
|
|
|
128
133
|
super().__init__()
|
|
129
134
|
self.read_from_session_file(
|
|
@@ -301,6 +306,8 @@ class BXUltraClient(ExchangeBase, IPriceFetcher):
|
|
|
301
306
|
await self._do_price_ws(
|
|
302
307
|
url=url,
|
|
303
308
|
)
|
|
309
|
+
except asyncio.CancelledError:
|
|
310
|
+
return
|
|
304
311
|
except Exception as ex:
|
|
305
312
|
err_str = f"{ex}"
|
|
306
313
|
if err_str.find("Event loop is closed") != -1:
|
|
@@ -308,6 +315,7 @@ class BXUltraClient(ExchangeBase, IPriceFetcher):
|
|
|
308
315
|
return
|
|
309
316
|
|
|
310
317
|
logger.warning(f"error at _do_price_ws: {err_str}")
|
|
318
|
+
await asyncio.sleep(1)
|
|
311
319
|
|
|
312
320
|
async def _do_price_ws(self, url: str):
|
|
313
321
|
async with websockets.connect(url, ping_interval=None) as ws:
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
from datetime import datetime
|
|
3
4
|
from decimal import Decimal
|
|
5
|
+
|
|
6
|
+
import pytz
|
|
4
7
|
from trd_utils.types_helper import BaseModel
|
|
5
8
|
|
|
6
9
|
|
|
@@ -20,6 +23,13 @@ class MinimalCandleInfo(BaseModel):
|
|
|
20
23
|
# volume in the second part of the pair (e.g. USDT).
|
|
21
24
|
quote_volume: Decimal = None
|
|
22
25
|
|
|
26
|
+
# The time this candle info was retrieved.
|
|
27
|
+
fetched_at: datetime = None
|
|
28
|
+
|
|
29
|
+
def __init__(self, **kwargs):
|
|
30
|
+
super().__init__(**kwargs)
|
|
31
|
+
self.fetched_at = datetime.now(tz=pytz.UTC)
|
|
32
|
+
|
|
23
33
|
|
|
24
34
|
class IPriceFetcher:
|
|
25
35
|
"""
|
|
@@ -35,4 +45,4 @@ class IPriceFetcher:
|
|
|
35
45
|
pass
|
|
36
46
|
|
|
37
47
|
async def get_last_candle(self, pair: str) -> MinimalCandleInfo:
|
|
38
|
-
pass
|
|
48
|
+
pass
|
|
@@ -212,7 +212,6 @@ def convert_to_ultra_list(value: Any) -> UltraList:
|
|
|
212
212
|
class BaseModel:
|
|
213
213
|
def __init__(self, **kwargs):
|
|
214
214
|
annotations = get_my_field_types(self)
|
|
215
|
-
# annotations = self.__annotations__
|
|
216
215
|
for key, value in kwargs.items():
|
|
217
216
|
corrected_key = key
|
|
218
217
|
if key not in annotations:
|
|
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
|