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

trd_utils/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
 
2
- __version__ = "0.0.46"
2
+ __version__ = "0.0.48"
3
3
 
@@ -209,7 +209,8 @@ class OkxClient(ExchangeBase):
209
209
  unified_info.trader_id = account_info.unique_name or uid
210
210
  unified_info.trader_name = account_info.en_nick_name or account_info.nick_name
211
211
  unified_info.trader_url = f"{BASE_PROFILE_URL}{uid}"
212
- unified_info.win_rate = overview.win_rate
212
+ if overview:
213
+ unified_info.win_rate = overview.win_rate
213
214
 
214
215
  return unified_info
215
216
 
@@ -13,7 +13,7 @@ from trd_utils.date_utils.datetime_helpers import dt_from_ts, dt_to_ts
13
13
  from trd_utils.html_utils.html_formats import camel_to_snake
14
14
  from trd_utils.types_helper.model_config import ModelConfig
15
15
  from trd_utils.types_helper.ultra_list import convert_to_ultra_list
16
- from trd_utils.types_helper.utils import AbstractModel, get_my_field_types
16
+ from trd_utils.types_helper.utils import AbstractModel, get_my_field_types, is_type_optional
17
17
 
18
18
  # Whether to use ultra-list instead of normal python list or not.
19
19
  # This might be convenient in some cases, but it is not recommended
@@ -199,7 +199,7 @@ class BaseModel(AbstractModel):
199
199
 
200
200
  expected_type_args = get_type_args(expected_type)
201
201
  expected_type_name = getattr(expected_type, "__name__", None)
202
- is_optional_type = expected_type_name == "Optional"
202
+ is_optional_type = is_type_optional(expected_type)
203
203
  is_dict_type = expected_type_name == "dict"
204
204
  # maybe in the future we can have some other usages for is_optional_type
205
205
  # variable or something like that.
@@ -278,9 +278,16 @@ class BaseModel(AbstractModel):
278
278
  # raise ValueError(f"Missing required field: {field}")
279
279
 
280
280
  @classmethod
281
- def deserialize(cls, json_data: Union[str, dict]):
281
+ def deserialize(
282
+ cls,
283
+ json_data: Union[str, dict],
284
+ parse_float=Decimal,
285
+ ):
282
286
  if isinstance(json_data, str):
283
- data = json.loads(json_data)
287
+ data = json.loads(
288
+ json_data,
289
+ parse_float=parse_float,
290
+ )
284
291
  else:
285
292
  data = json_data
286
293
  return cls(**data)
@@ -5,6 +5,18 @@ from typing import (
5
5
  class AbstractModel:
6
6
  pass
7
7
 
8
+ def is_type_optional(target: type) -> bool:
9
+ if getattr(target, "__name__", None) == "Optional":
10
+ # e.g: my_field: Optional[str] = None
11
+ return True
12
+
13
+ target_args = getattr(target, "__args__", None)
14
+ if target_args and len(target_args) > 1 and target_args[1] is type(None):
15
+ # e.g: my_field: Decimal | None = None
16
+ return True
17
+
18
+ return False
19
+
8
20
  def get_real_attr(cls, attr_name):
9
21
  if cls is None:
10
22
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: trd_utils
3
- Version: 0.0.46
3
+ Version: 0.0.48
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,4 +1,4 @@
1
- trd_utils/__init__.py,sha256=wLcWARA4_ZeM1KZ-X6E-axb1IuqweiU-ZE_9aEEk83k,25
1
+ trd_utils/__init__.py,sha256=F6nqO7h9gFbxijcrf5rruAh2gbKqWBYRYodKJG82pGA,25
2
2
  trd_utils/cipher/__init__.py,sha256=V05KNuzQwCic-ihMVHlC8sENaJGc3I8MCb4pg4849X8,1765
3
3
  trd_utils/common_utils/float_utils.py,sha256=aYPwJ005LmrRhXAngojwvdDdtRgeb1FfR6hKeQ5ndMU,470
4
4
  trd_utils/common_utils/wallet_utils.py,sha256=OX9q2fymP0VfIWTRIRBP8W33cfyjLXimxMgPOsZe-3g,727
@@ -21,7 +21,7 @@ trd_utils/exchanges/hyperliquid/__init__.py,sha256=QhwGRcneGFHREM-MMdYpbcx-aWdsW
21
21
  trd_utils/exchanges/hyperliquid/hyperliquid_client.py,sha256=rc1TPtyMo9K1udISVwfWGN51Di783QbNiAFcPBmgpcY,7239
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=P_DnIBk0086XJSXuSNDRc6woayiJmPEC5avbgDZsFt4,7409
24
+ trd_utils/exchanges/okx/okx_client.py,sha256=uKgH7u052yvPIEQcr_GaZiAXjl1w9U4eFXFh1lUGr6g,7434
25
25
  trd_utils/exchanges/okx/okx_types.py,sha256=IkFOfgivcvvIw950jyGHAVfFFGbGqfZcYGfZLWfNLvc,5013
26
26
  trd_utils/exchanges/price_fetcher.py,sha256=YHLkM6sCvHGFS_4t188Sl3DczqrarK-1ivGwZEVsom4,1320
27
27
  trd_utils/html_utils/__init__.py,sha256=1WWs8C7JszRjTkmzIRLHpxWECHur_DrulTPGIeX88oM,426
@@ -30,12 +30,12 @@ trd_utils/tradingview/__init__.py,sha256=H0QYb-O5qvy7qC3yswtlcSWLmeBnaS6oJ3Jtjvm
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=cVm7Pbvuow4zS9vvH4cI9TQjRjPf_d1JE15zXb6dG40,188
33
- trd_utils/types_helper/base_model.py,sha256=5y_QHYiNu57IxYtyFpPUNA3HI9Jywryl8cyxbM5jQcI,11066
33
+ trd_utils/types_helper/base_model.py,sha256=A1AGScpvnpxdf_sCD4PLc6bbd6MSeOEUQ-FoEuU7PaQ,11207
34
34
  trd_utils/types_helper/decorators.py,sha256=ziQGDKV0RnhMG6gBPAz244Ug3j6ayr0iKXeucAdnXB8,527
35
35
  trd_utils/types_helper/model_config.py,sha256=uvyhdGHQZ1A_I5RUbCgzlDk6MxWL6RLV8r0cdVi6nBk,60
36
36
  trd_utils/types_helper/ultra_list.py,sha256=01WQSkx0G7lD9O9XcXccexniNwyuQ9LwVOeixxr4tWQ,1178
37
- trd_utils/types_helper/utils.py,sha256=Xq4SZG4NkkGzJyOBs9huAvzl2YcCZ7ZRjfOHol3o-Kc,569
38
- trd_utils-0.0.46.dist-info/LICENSE,sha256=J1EP2xt87RjjmsTV1jTjHDQMLIM9FjdwEftTpw8hyv4,1067
39
- trd_utils-0.0.46.dist-info/METADATA,sha256=TOK9FOBw1qYtyRKUTH3lOJsa2ZqpmQVm_hDDRTE4iEI,1179
40
- trd_utils-0.0.46.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
41
- trd_utils-0.0.46.dist-info/RECORD,,
37
+ trd_utils/types_helper/utils.py,sha256=hJzxI6D1ZSmv4y4wLrv-QW5AvrDU4BARXJmLpB-CTEI,960
38
+ trd_utils-0.0.48.dist-info/LICENSE,sha256=J1EP2xt87RjjmsTV1jTjHDQMLIM9FjdwEftTpw8hyv4,1067
39
+ trd_utils-0.0.48.dist-info/METADATA,sha256=GKHCGk74bb8OZ7UVLSV9hte6gaNQm9rb67mHJz0wxns,1179
40
+ trd_utils-0.0.48.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
41
+ trd_utils-0.0.48.dist-info/RECORD,,