trd-utils 0.0.34__py3-none-any.whl → 0.0.35__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.

Potentially problematic release.


This version of trd-utils might be problematic. Click here for more details.

@@ -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
@@ -51,16 +51,19 @@ class BlofinClient(ExchangeBase):
51
51
  fav_letter: str = "^",
52
52
  read_session_file: bool = True,
53
53
  sessions_dir: str = "sessions",
54
+ use_http1: bool = False,
55
+ use_http2: bool = True,
54
56
  ):
55
57
  self.httpx_client = httpx.AsyncClient(
56
58
  verify=http_verify,
57
- http2=True,
58
- http1=False,
59
+ http1=use_http1,
60
+ http2=use_http2,
59
61
  )
60
62
  self.account_name = account_name
61
63
  self._fav_letter = fav_letter
62
64
  self.sessions_dir = sessions_dir
63
-
65
+ self.exchange_name = "blofin"
66
+
64
67
  super().__init__()
65
68
 
66
69
  if read_session_file:
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: trd_utils
3
- Version: 0.0.34
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
@@ -4,34 +4,34 @@ trd_utils/common_utils/float_utils.py,sha256=aYPwJ005LmrRhXAngojwvdDdtRgeb1FfR6h
4
4
  trd_utils/common_utils/wallet_utils.py,sha256=OX9q2fymP0VfIWTRIRBP8W33cfyjLXimxMgPOsZe-3g,727
5
5
  trd_utils/date_utils/__init__.py,sha256=Erg_E1TfKWNpiuZFm_NXRjCwoRMfxpPS2-mJK6V4lFM,77
6
6
  trd_utils/date_utils/datetime_helpers.py,sha256=euIJBr-6PfJzLScOC9xVXd8Re_Gw5CSBPwtHX9_Il4A,596
7
- trd_utils/exchanges/README.md,sha256=UwkpsfcoLCJaMvJe4yBsFkDpf8P6DOLYhtybb6xWMLc,6738
7
+ trd_utils/exchanges/README.md,sha256=8egE4IPUQ3_UtiGP6GaCg50xq_dp43aGY_X1lKcO6ok,6812
8
8
  trd_utils/exchanges/__init__.py,sha256=sZRyp24q0KyMYASshAfsP-AfvsCADTYqqefxiRulPKE,484
9
9
  trd_utils/exchanges/base_types.py,sha256=NGykHGyY97mcc4gqxa0RLNElro0y3cQsdSCM1XAtIz8,3625
10
10
  trd_utils/exchanges/blofin/__init__.py,sha256=X4r9o4Nyjla4UeOBG8lrgtnGYO2aErFMKaJ7yQrFasE,76
11
- trd_utils/exchanges/blofin/blofin_client.py,sha256=UMPxgGtAiImEjNbAQ3cDqu0Tw9BtKndcj92_2S55HEY,12904
11
+ trd_utils/exchanges/blofin/blofin_client.py,sha256=j3E9fdz06x3T4fA0SmS0PxopE4qNc1kSuj2UxGazodQ,13008
12
12
  trd_utils/exchanges/blofin/blofin_types.py,sha256=ZlHX1ClYTd2pDRTQIlZYyBu5ReGpMgxXxKASsPeBQug,4090
13
13
  trd_utils/exchanges/bx_ultra/__init__.py,sha256=8Ssy-eOemQR32Nv1-FoPHm87nRqRO4Fm2PU5GHEFKfQ,80
14
14
  trd_utils/exchanges/bx_ultra/bx_types.py,sha256=hRe8DfF3sdXlMdk-knwWx4XpZUp1rITpXPnUDtiy93o,34715
15
- trd_utils/exchanges/bx_ultra/bx_ultra_client.py,sha256=Wdfg34goiMeJEGd5T-thouXEC_2Gacs8ixiSJ0rcojg,34726
15
+ trd_utils/exchanges/bx_ultra/bx_ultra_client.py,sha256=MKL2nKMjWy_aIFQKtY62gwODISEfAsGnD58SElUx6Q8,34977
16
16
  trd_utils/exchanges/bx_ultra/bx_utils.py,sha256=PwapomwDW33arVmKIDj6cL-aP0ptu4BYy_lOCqSAPOo,1392
17
17
  trd_utils/exchanges/errors.py,sha256=P_NTuc389XL7rFegomP59BydWmHv8ckiGyNU-_l5qNQ,167
18
- trd_utils/exchanges/exchange_base.py,sha256=wJV966YYw6BQnB7hr9Cgy3a4FHg8_jyWeaidJgzCA7Q,7772
18
+ trd_utils/exchanges/exchange_base.py,sha256=Zn5y4bymK53ENVLjYnQadS61SZKs8BGoZ4jfsY4GOcE,7835
19
19
  trd_utils/exchanges/hyperliquid/README.md,sha256=-qaxmDt_9NTus2xRuzyFGkKgYDWgWk7ufHVTSkyn3t4,105
20
20
  trd_utils/exchanges/hyperliquid/__init__.py,sha256=QhwGRcneGFHREM-MMdYpbcx-aWdsWsu2WznHzx7LaUM,92
21
- trd_utils/exchanges/hyperliquid/hyperliquid_client.py,sha256=FOOEDY1wOvyDlUcnSHf0Vp-8KNK2_AkI6Z7h3lls3Co,6832
21
+ trd_utils/exchanges/hyperliquid/hyperliquid_client.py,sha256=-aBtgTjXJyI9n4kmDQIlm4Ip00SAwgURJ-ztZxuCRTM,6875
22
22
  trd_utils/exchanges/hyperliquid/hyperliquid_types.py,sha256=MiGG5fRU7wHqOMtCzQXD1fwwbeUK1HEcQwW5rl-9D4c,2678
23
23
  trd_utils/exchanges/okx/__init__.py,sha256=OjVpvcwB9mrCTofLt14JRHV2-fMAzGz9-YkJAMwl6dM,67
24
- trd_utils/exchanges/okx/okx_client.py,sha256=lUf507ovd4D3fI7Z3Iy1fGvxNJWdm4wTcdzTCkMw13U,7146
24
+ trd_utils/exchanges/okx/okx_client.py,sha256=zrWGs8H8oU_ZrP-nY5g5p3iaIZUJs_oozFa0HExS6EU,7181
25
25
  trd_utils/exchanges/okx/okx_types.py,sha256=IkFOfgivcvvIw950jyGHAVfFFGbGqfZcYGfZLWfNLvc,5013
26
- trd_utils/exchanges/price_fetcher.py,sha256=Jjrlnis-9fFOYR-7T8T0Dkzi63gSN7gSLkehjbbldEg,1074
26
+ trd_utils/exchanges/price_fetcher.py,sha256=YHLkM6sCvHGFS_4t188Sl3DczqrarK-1ivGwZEVsom4,1320
27
27
  trd_utils/html_utils/__init__.py,sha256=1WWs8C7JszRjTkmzIRLHpxWECHur_DrulTPGIeX88oM,426
28
28
  trd_utils/html_utils/html_formats.py,sha256=unKsvOiiDmYTTaM0DYZEUNLEUzWQKKrqASJXvY54kvU,2299
29
29
  trd_utils/tradingview/__init__.py,sha256=H0QYb-O5qvy7qC3yswtlcSWLmeBnaS6oJ3JtjvmaV_Y,154
30
30
  trd_utils/tradingview/tradingview_client.py,sha256=g_eWYaCRQAL8Kvd-r6AnAdbH7Jha6C_GAyCuxh-RQUU,3917
31
31
  trd_utils/tradingview/tradingview_types.py,sha256=z21MXPVdWHAduEl3gSeMIRhxtBN9yK-jPYHfZSMIbSA,6144
32
32
  trd_utils/types_helper/__init__.py,sha256=lLbUiW1jUV1gjzTMFLthwkvF0hwauH-F_J2JZq--1U0,67
33
- trd_utils/types_helper/base_model.py,sha256=Q2KK0r4UXP9PlWeIl6nxdAeCGB5InU5IkTNGAfJasfM,11808
34
- trd_utils-0.0.34.dist-info/LICENSE,sha256=J1EP2xt87RjjmsTV1jTjHDQMLIM9FjdwEftTpw8hyv4,1067
35
- trd_utils-0.0.34.dist-info/METADATA,sha256=H9rMPrA7U_x3IGEHWivudi9ixFtXr9bKvDqarQgM8SM,1179
36
- trd_utils-0.0.34.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
37
- trd_utils-0.0.34.dist-info/RECORD,,
33
+ trd_utils/types_helper/base_model.py,sha256=dknzoq6iAUOb0n_yhI5mU3So-F_8d5ykGk3EbrERLnM,11763
34
+ trd_utils-0.0.35.dist-info/LICENSE,sha256=J1EP2xt87RjjmsTV1jTjHDQMLIM9FjdwEftTpw8hyv4,1067
35
+ trd_utils-0.0.35.dist-info/METADATA,sha256=h6uD6uuSfYbor9unNO36-sxv4uxdpdhCKBIqJfNeygM,1179
36
+ trd_utils-0.0.35.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
37
+ trd_utils-0.0.35.dist-info/RECORD,,