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.

Files changed (38) hide show
  1. {trd_utils-0.0.33 → trd_utils-0.0.35}/PKG-INFO +1 -1
  2. {trd_utils-0.0.33 → trd_utils-0.0.35}/pyproject.toml +1 -1
  3. trd_utils-0.0.35/trd_utils/__init__.py +3 -0
  4. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/README.md +4 -2
  5. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/blofin/blofin_client.py +18 -3
  6. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/bx_ultra_client.py +9 -1
  7. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/exchange_base.py +3 -0
  8. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/hyperliquid_client.py +1 -0
  9. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/okx/okx_client.py +1 -0
  10. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/price_fetcher.py +11 -1
  11. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/types_helper/base_model.py +0 -1
  12. trd_utils-0.0.33/trd_utils/__init__.py +0 -3
  13. {trd_utils-0.0.33 → trd_utils-0.0.35}/LICENSE +0 -0
  14. {trd_utils-0.0.33 → trd_utils-0.0.35}/README.md +0 -0
  15. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/cipher/__init__.py +0 -0
  16. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/common_utils/float_utils.py +0 -0
  17. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/common_utils/wallet_utils.py +0 -0
  18. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/date_utils/__init__.py +0 -0
  19. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/date_utils/datetime_helpers.py +0 -0
  20. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/__init__.py +0 -0
  21. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/base_types.py +0 -0
  22. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/blofin/__init__.py +0 -0
  23. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/blofin/blofin_types.py +0 -0
  24. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/__init__.py +0 -0
  25. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/bx_types.py +0 -0
  26. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/bx_ultra/bx_utils.py +0 -0
  27. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/errors.py +0 -0
  28. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/README.md +0 -0
  29. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/__init__.py +0 -0
  30. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/hyperliquid/hyperliquid_types.py +0 -0
  31. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/okx/__init__.py +0 -0
  32. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/exchanges/okx/okx_types.py +0 -0
  33. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/html_utils/__init__.py +0 -0
  34. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/html_utils/html_formats.py +0 -0
  35. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/tradingview/__init__.py +0 -0
  36. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/tradingview/tradingview_client.py +0 -0
  37. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/tradingview/tradingview_types.py +0 -0
  38. {trd_utils-0.0.33 → trd_utils-0.0.35}/trd_utils/types_helper/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: trd_utils
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: Common Basic Utils for Python3. By ALiwoto.
5
5
  Keywords: utils,trd_utils,basic-utils,common-utils
6
6
  Author: ALiwoto
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "trd_utils"
3
- version = "0.0.33"
3
+ version = "0.0.35"
4
4
  description = "Common Basic Utils for Python3. By ALiwoto."
5
5
  authors = ["ALiwoto <aminnimaj@gmail.com>"]
6
6
  packages = [
@@ -0,0 +1,3 @@
1
+
2
+ __version__ = "0.0.34"
3
+
@@ -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
- http2=True,
55
- http1=False,
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
- http2=True,
57
- http1=False,
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, http2=True, http1=False
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:
@@ -52,6 +52,9 @@ class ExchangeBase(ABC):
52
52
  install_channel: str = "officialAPK"
53
53
  channel_header: str = "officialAPK"
54
54
 
55
+ # The name of the exchange.
56
+ exchange_name: str = None
57
+
55
58
  jwt_manager: JWTManager = None
56
59
 
57
60
  _fav_letter: str = "^"
@@ -46,6 +46,7 @@ class HyperLiquidClient(ExchangeBase):
46
46
  self.account_name = account_name
47
47
  self._fav_letter = fav_letter
48
48
  self.sessions_dir = sessions_dir
49
+ self.exchange_name = "hyperliquid"
49
50
 
50
51
  super().__init__()
51
52
 
@@ -54,6 +54,7 @@ class OkxClient(ExchangeBase):
54
54
  self.account_name = account_name
55
55
  self._fav_letter = fav_letter
56
56
  self.sessions_dir = sessions_dir
57
+ self.exchange_name = "okx"
57
58
 
58
59
  super().__init__()
59
60
 
@@ -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:
@@ -1,3 +0,0 @@
1
-
2
- __version__ = "0.0.33"
3
-
File without changes
File without changes