unicex 0.13.7__py3-none-any.whl → 0.13.8__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.
unicex/bybit/client.py CHANGED
@@ -7,7 +7,7 @@ from typing import Any, Literal
7
7
  from unicex._base import BaseClient
8
8
  from unicex.exceptions import NotAuthorized
9
9
  from unicex.types import RequestMethod
10
- from unicex.utils import filter_params, generate_hmac_sha256_signature
10
+ from unicex.utils import dict_to_query_string, filter_params, generate_hmac_sha256_signature
11
11
 
12
12
 
13
13
  class Client(BaseClient):
@@ -35,7 +35,7 @@ class Client(BaseClient):
35
35
  headers["X-BAPI-TIMESTAMP"] = timestamp
36
36
  return headers
37
37
 
38
- def _generate_signature(self, timestamp: str, payload: dict) -> str:
38
+ def _generate_signature(self, timestamp: str, payload: dict, method: RequestMethod) -> str:
39
39
  """Генерация подписи.
40
40
 
41
41
  Источник: https://github.com/bybit-exchange/api-usage-examples/blob/master/V5_demo/api_demo/Encryption_HMAC.py
@@ -44,9 +44,16 @@ class Client(BaseClient):
44
44
  if not self.is_authorized():
45
45
  raise NotAuthorized("Api key and api secret is required to private endpoints")
46
46
 
47
- dumped_payload = json.dumps(payload)
48
- prepared_query_string = timestamp + self._api_key + self._RECV_WINDOW + dumped_payload # type: ignore[attrDefined]
49
- return generate_hmac_sha256_signature(self._api_secret, prepared_query_string) # type: ignore[attrDefined]
47
+ if method == "POST":
48
+ # timestamp+api_key+recv_window+jsonBodyString
49
+ dumped_payload = json.dumps(payload)
50
+ prepared_query_string = timestamp + self._api_key + self._RECV_WINDOW + dumped_payload # type: ignore[attrDefined]
51
+ return generate_hmac_sha256_signature(self._api_secret, prepared_query_string) # type: ignore[attrDefined]
52
+ else:
53
+ # timestamp+api_key+recv_window+queryString
54
+ query_string = dict_to_query_string(payload)
55
+ prepared_query_string = timestamp + self._api_key + self._RECV_WINDOW + query_string # type: ignore[attrDefined]
56
+ return generate_hmac_sha256_signature(self._api_secret, prepared_query_string) # type: ignore[attrDefined]
50
57
 
51
58
  async def _make_request(
52
59
  self,
@@ -94,7 +101,7 @@ class Client(BaseClient):
94
101
  payload = params
95
102
 
96
103
  # Генерируем строку для подписи
97
- signature = self._generate_signature(timestamp, payload)
104
+ signature = self._generate_signature(timestamp, payload, method)
98
105
 
99
106
  # Генерируем заголовки (вкл. в себя подпись и апи ключ)
100
107
  headers = self._get_headers(timestamp, signature)
@@ -110,7 +117,7 @@ class Client(BaseClient):
110
117
  return await super()._make_request(
111
118
  method=method,
112
119
  url=url,
113
- params=payload,
120
+ params=params,
114
121
  headers=headers,
115
122
  )
116
123
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unicex
3
- Version: 0.13.7
3
+ Version: 0.13.8
4
4
  Summary: Unified Crypto Exchange API
5
5
  Author-email: LoveBloodAndDiamonds <ayazshakirzyanov27@gmail.com>
6
6
  License: BSD 3-Clause License
@@ -30,7 +30,7 @@ unicex/bitget/user_websocket.py,sha256=tlkv7Rmsw_FSfCJnEMOK_9jRsXRk2Ah_slqG8C-uh
30
30
  unicex/bitget/websocket_manager.py,sha256=2OhH2gKy2gN03oYeCFvf3_l6RA29dDOvpajGhbXI9Zw,9886
31
31
  unicex/bybit/__init__.py,sha256=SrMBh6K5zUt4JheWUpNUYNb1NCDr2ujTFv4IDguaGZI,926
32
32
  unicex/bybit/adapter.py,sha256=U6QP2eGefZqfXq7H4P1G9M23HieAjmylb5FnrHISn5s,8147
33
- unicex/bybit/client.py,sha256=U1mCcF-Mg2spiKlp0ucIA-kDOisYLO0edRS6XC16iNo,61014
33
+ unicex/bybit/client.py,sha256=csOCEl1FhJLuCGd012TLgPvA83QDATDfx2Nu0gEQyx0,61539
34
34
  unicex/bybit/exchange_info.py,sha256=6DySi-61kyU1Wpfp7G-5Zu7G1bFfcR4qo2oO5d0YutI,2200
35
35
  unicex/bybit/uni_client.py,sha256=0wmIRRgofuJXWvZMB1gHwuIEfoWuPhLJXthmK1f9w40,8382
36
36
  unicex/bybit/uni_websocket_manager.py,sha256=OpnvWD0xZ8T_By0HZCSg3jWoZqScRATAsku4IIBqhlw,10252
@@ -86,8 +86,8 @@ unicex/okx/uni_client.py,sha256=E_Wod0JSGt1K6k1mAIWnOv350pELbv-nic7g1KgOuos,8694
86
86
  unicex/okx/uni_websocket_manager.py,sha256=b4f_QjA64DJmENQdIGb5IOVc7kvit7KMCdWeCmRbxGY,9326
87
87
  unicex/okx/user_websocket.py,sha256=8c9kpm-xVa729pW93OKUGLHaE9MY0uzEpjIgNIFRF80,126
88
88
  unicex/okx/websocket_manager.py,sha256=wROXTUDqKzOE-wDnCtXso_MC4SzfPuPols5aPg_Z3y4,26027
89
- unicex-0.13.7.dist-info/licenses/LICENSE,sha256=lNNK4Vqak9cXm6qVJLhbqS7iR_BMj6k7fd7XQ6l1k54,1507
90
- unicex-0.13.7.dist-info/METADATA,sha256=s1fo3iBF1O5boIO2BF86NNvOXdhp0BAMoPO-JyzjqQA,11752
91
- unicex-0.13.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
- unicex-0.13.7.dist-info/top_level.txt,sha256=_7rar-0OENIg4KRy6cgjWiebFYAJhjKEcMggAocGWG4,7
93
- unicex-0.13.7.dist-info/RECORD,,
89
+ unicex-0.13.8.dist-info/licenses/LICENSE,sha256=lNNK4Vqak9cXm6qVJLhbqS7iR_BMj6k7fd7XQ6l1k54,1507
90
+ unicex-0.13.8.dist-info/METADATA,sha256=ZepMPOyW75HQ047NKM52g79J2V1nF5Bt8lK50rN2I-U,11752
91
+ unicex-0.13.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
+ unicex-0.13.8.dist-info/top_level.txt,sha256=_7rar-0OENIg4KRy6cgjWiebFYAJhjKEcMggAocGWG4,7
93
+ unicex-0.13.8.dist-info/RECORD,,