trd-utils 0.0.35__tar.gz → 0.0.36__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.35 → trd_utils-0.0.36}/PKG-INFO +1 -1
  2. {trd_utils-0.0.35 → trd_utils-0.0.36}/pyproject.toml +1 -1
  3. trd_utils-0.0.36/trd_utils/__init__.py +3 -0
  4. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/base_types.py +5 -0
  5. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/blofin/blofin_client.py +1 -0
  6. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/blofin/blofin_types.py +7 -2
  7. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/bx_ultra/bx_ultra_client.py +1 -0
  8. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/hyperliquid/hyperliquid_client.py +5 -1
  9. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/okx/okx_client.py +1 -0
  10. trd_utils-0.0.35/trd_utils/__init__.py +0 -3
  11. {trd_utils-0.0.35 → trd_utils-0.0.36}/LICENSE +0 -0
  12. {trd_utils-0.0.35 → trd_utils-0.0.36}/README.md +0 -0
  13. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/cipher/__init__.py +0 -0
  14. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/common_utils/float_utils.py +0 -0
  15. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/common_utils/wallet_utils.py +0 -0
  16. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/date_utils/__init__.py +0 -0
  17. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/date_utils/datetime_helpers.py +0 -0
  18. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/README.md +0 -0
  19. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/__init__.py +0 -0
  20. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/blofin/__init__.py +0 -0
  21. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/bx_ultra/__init__.py +0 -0
  22. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/bx_ultra/bx_types.py +0 -0
  23. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/bx_ultra/bx_utils.py +0 -0
  24. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/errors.py +0 -0
  25. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/exchange_base.py +0 -0
  26. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/hyperliquid/README.md +0 -0
  27. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/hyperliquid/__init__.py +0 -0
  28. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/hyperliquid/hyperliquid_types.py +0 -0
  29. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/okx/__init__.py +0 -0
  30. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/okx/okx_types.py +0 -0
  31. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/exchanges/price_fetcher.py +0 -0
  32. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/html_utils/__init__.py +0 -0
  33. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/html_utils/html_formats.py +0 -0
  34. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/tradingview/__init__.py +0 -0
  35. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/tradingview/tradingview_client.py +0 -0
  36. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/tradingview/tradingview_types.py +0 -0
  37. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/types_helper/__init__.py +0 -0
  38. {trd_utils-0.0.35 → trd_utils-0.0.36}/trd_utils/types_helper/base_model.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: trd_utils
3
- Version: 0.0.35
3
+ Version: 0.0.36
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.35"
3
+ version = "0.0.36"
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.36"
3
+
@@ -37,6 +37,11 @@ class UnifiedPositionInfo(BaseModel):
37
37
  # The base unit that the open-price is based on (e.g. USD, USDT, USDC)
38
38
  open_price_unit: str | None = None
39
39
 
40
+ # The initial amount of open_price_unit that the trader has put to open
41
+ # this position.
42
+ # Note that not all public APIs might provide this field.
43
+ initial_margin: Decimal | None = None
44
+
40
45
  # The last price of this pair on the target exchange.
41
46
  # not all exchanges support this yet, so use it with caution.
42
47
  last_price: Decimal | None = None
@@ -342,6 +342,7 @@ class BlofinClient(ExchangeBase):
342
342
  unified_pos.open_time = dt_from_ts(position.open_time)
343
343
  unified_pos.open_price = position.avg_open_price
344
344
  unified_pos.open_price_unit = position.symbol.split("-")[-1]
345
+ unified_pos.initial_margin = position.get_initial_margin()
345
346
  unified_result.positions.append(unified_pos)
346
347
 
347
348
  return unified_result
@@ -97,8 +97,8 @@ class CopyTraderSingleOrderInfo(BaseModel):
97
97
  symbol: str = None
98
98
  leverage: int = None
99
99
  order_side: str = None
100
- avg_open_price: str = None
101
- quantity: str = None
100
+ avg_open_price: Decimal = None
101
+ quantity: Decimal = None
102
102
  quantity_cont: Any = None
103
103
  open_time: int = None
104
104
  close_time: Any = None
@@ -146,6 +146,11 @@ class CopyTraderSingleOrderInfo(BaseModel):
146
146
  position_change_history: Any = None
147
147
  user_id: Any = None
148
148
 
149
+ def get_initial_margin(self) -> Decimal:
150
+ if not self.avg_open_price or not self.quantity or not self.leverage:
151
+ return None
152
+ return (self.avg_open_price * self.quantity) / self.leverage
153
+
149
154
 
150
155
  class CopyTraderOrderListResponse(BlofinApiResponse):
151
156
  data: list[CopyTraderSingleOrderInfo] = None
@@ -922,6 +922,7 @@ class BXUltraClient(ExchangeBase, IPriceFetcher):
922
922
  unified_pos.position_pair = position.symbol.replace("-", "/")
923
923
  unified_pos.open_time = None # TODO: do something for this?
924
924
  unified_pos.open_price = position.avg_price
925
+ unified_pos.initial_margin = position.margin
925
926
  unified_pos.open_price_unit = (
926
927
  position.valuation_coin_name or position.symbol.split("-")[-1]
927
928
  ) # TODO
@@ -1,4 +1,5 @@
1
1
 
2
+ from datetime import datetime
2
3
  from decimal import Decimal
3
4
  import json
4
5
  import logging
@@ -6,6 +7,8 @@ import httpx
6
7
 
7
8
  from pathlib import Path
8
9
 
10
+ import pytz
11
+
9
12
  from trd_utils.cipher import AESCipher
10
13
  from trd_utils.common_utils.wallet_utils import shorten_wallet_address
11
14
  from trd_utils.exchanges.base_types import UnifiedPositionInfo, UnifiedTraderInfo, UnifiedTraderPositions
@@ -163,9 +166,10 @@ class HyperLiquidClient(ExchangeBase):
163
166
  unified_pos.margin_mode = position.leverage.type
164
167
  unified_pos.position_leverage = Decimal(position.leverage.value)
165
168
  unified_pos.position_pair = f"{position.coin}/USDT"
166
- unified_pos.open_time = None # hyperliquid doesn't provide this...
169
+ unified_pos.open_time = datetime.now(pytz.UTC) # hyperliquid doesn't provide this...
167
170
  unified_pos.open_price = position.entry_px
168
171
  unified_pos.open_price_unit = "USDT"
172
+ unified_pos.initial_margin = position.margin_used
169
173
  unified_result.positions.append(unified_pos)
170
174
 
171
175
  return unified_result
@@ -186,6 +186,7 @@ class OkxClient(ExchangeBase):
186
186
  unified_pos.open_time = position.c_time
187
187
  unified_pos.open_price = position.avg_px
188
188
  unified_pos.open_price_unit = position.quote_ccy
189
+ unified_pos.initial_margin = position.margin
189
190
  unified_result.positions.append(unified_pos)
190
191
 
191
192
  return unified_result
@@ -1,3 +0,0 @@
1
-
2
- __version__ = "0.0.34"
3
-
File without changes
File without changes