unicex 0.13.11__py3-none-any.whl → 0.13.13__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/binance/client.py CHANGED
@@ -38,7 +38,6 @@ class Client(BaseClient):
38
38
  method: RequestMethod,
39
39
  signed: bool,
40
40
  params: dict[str, Any] | None,
41
- data: dict[str, Any] | None,
42
41
  ) -> tuple[dict[str, Any], dict[str, Any] | None]:
43
42
  """Подготавливает payload и заголовки для запроса.
44
43
 
@@ -46,13 +45,12 @@ class Client(BaseClient):
46
45
  - добавляет подпись и все обязательные параметры в заголовки
47
46
 
48
47
  Если signed=False:
49
- - возвращает только отфильтрованные params/data.
48
+ - возвращает только отфильтрованные params.
50
49
 
51
50
  Параметры:
52
51
  method (`RequestMethod`): Метод запроса.
53
52
  signed (`bool`): Нужно ли подписывать запрос.
54
53
  params (`dict | None`): Параметры для query string.
55
- data (`dict | None`): Параметры для тела запроса.
56
54
 
57
55
  Возвращает:
58
56
  tuple:
@@ -61,16 +59,18 @@ class Client(BaseClient):
61
59
  """
62
60
  # Фильтруем параметры от None значений
63
61
  params = filter_params(params) if params else {}
64
- data = filter_params(data) if data else {}
62
+
63
+ # Получаем заголовки для запроса
64
+ headers = self._get_headers(method)
65
65
 
66
66
  if not signed:
67
- return {"params": params, "data": data}, None
67
+ return {"params": params}, headers
68
68
 
69
69
  if not self.is_authorized():
70
70
  raise NotAuthorized("Api key and api secret is required to private endpoints")
71
71
 
72
72
  # Объединяем все параметры в payload
73
- payload = {**params, **data}
73
+ payload = {**params}
74
74
  payload["timestamp"] = int(time.time() * 1000)
75
75
  payload["recvWindow"] = self._RECV_WINDOW
76
76
 
@@ -82,7 +82,6 @@ class Client(BaseClient):
82
82
  "hex",
83
83
  )
84
84
 
85
- headers = self._get_headers(method)
86
85
  return payload, headers
87
86
 
88
87
  async def _make_request(
@@ -92,13 +91,12 @@ class Client(BaseClient):
92
91
  signed: bool = False,
93
92
  *,
94
93
  params: dict[str, Any] | None = None,
95
- data: dict[str, Any] | None = None,
96
94
  ) -> Any:
97
95
  """Выполняет HTTP-запрос к эндпоинтам Binance API.
98
96
 
99
97
  Если signed=True, формируется подпись для приватных endpoint'ов:
100
- - Если переданы params — подпись добавляется в параметры запроса.
101
- - Если передан data — подпись добавляется в тело запроса.
98
+ - Если метод запроса "GET" — подпись добавляется в параметры запроса.
99
+ - Если метод запроса "POST" | "PUT" | "DELETE" — подпись добавляется в тело запроса.
102
100
 
103
101
  Если signed=False, запрос отправляется как публичный.
104
102
 
@@ -107,22 +105,15 @@ class Client(BaseClient):
107
105
  url (`str`): Полный URL эндпоинта Binance API.
108
106
  signed (`bool`): Нужно ли подписывать запрос.
109
107
  params (`dict | None`): Query-параметры.
110
- data (`dict | None`): Тело запроса.
111
108
 
112
109
  Возвращает:
113
110
  `dict`: Ответ в формате JSON.
114
111
  """
115
- payload, headers = self._prepare_payload(
116
- method=method, signed=signed, params=params, data=data
117
- )
112
+ payload, headers = self._prepare_payload(method=method, signed=signed, params=params)
118
113
 
119
114
  if not signed:
120
115
  return await super()._make_request(method=method, url=url, **payload)
121
116
 
122
- if data:
123
- return await super()._make_request(
124
- method=method, url=url, data=payload, headers=headers
125
- )
126
117
  return await super()._make_request(method=method, url=url, params=payload, headers=headers)
127
118
 
128
119
  async def request(
@@ -391,7 +382,7 @@ class Client(BaseClient):
391
382
  https://developers.binance.com/docs/binance-spot-api-docs/rest-api/spot-trading-endpoints#new-order-trade
392
383
  """
393
384
  url = self._BASE_SPOT_URL + "/api/v3/order"
394
- data = {
385
+ params = {
395
386
  "symbol": symbol,
396
387
  "side": side,
397
388
  "type": type,
@@ -406,8 +397,8 @@ class Client(BaseClient):
406
397
  "selfTradePreventionMode": self_trade_prevention_mode,
407
398
  }
408
399
 
409
- # return await self._make_request("POST", url, True, data=data)
410
- return await self._make_request("POST", url, True, params=data)
400
+ # return await self._make_request("POST", url, True, params=params)
401
+ return await self._make_request("POST", url, True, params=params)
411
402
 
412
403
  async def order_test(
413
404
  self,
@@ -429,7 +420,7 @@ class Client(BaseClient):
429
420
  https://developers.binance.com/docs/binance-spot-api-docs/rest-api/spot-trading-endpoints#test-new-order-trade
430
421
  """
431
422
  url = self._BASE_SPOT_URL + "/api/v3/order/test"
432
- data = {
423
+ params = {
433
424
  "symbol": symbol,
434
425
  "side": side,
435
426
  "type": type,
@@ -444,7 +435,7 @@ class Client(BaseClient):
444
435
  "selfTradePreventionMode": self_trade_prevention_mode,
445
436
  }
446
437
 
447
- return await self._make_request("POST", url, True, data=data)
438
+ return await self._make_request("POST", url, True, params=params)
448
439
 
449
440
  async def order_cancel(
450
441
  self,
@@ -458,14 +449,14 @@ class Client(BaseClient):
458
449
  https://developers.binance.com/docs/binance-spot-api-docs/rest-api/spot-trading-endpoints#cancel-order-trade
459
450
  """
460
451
  url = self._BASE_SPOT_URL + "/api/v3/order"
461
- data = {
452
+ params = {
462
453
  "symbol": symbol,
463
454
  "orderId": order_id,
464
455
  "origClientOrderId": orig_client_order_id,
465
456
  "newClientOrderId": new_client_order_id,
466
457
  }
467
458
 
468
- return await self._make_request("DELETE", url, True, data=data)
459
+ return await self._make_request("DELETE", url, True, params=params)
469
460
 
470
461
  async def orders_cancel_all(self, symbol: str) -> list[dict]:
471
462
  """Отмена всех активных ордеров по символу.
@@ -473,9 +464,9 @@ class Client(BaseClient):
473
464
  https://developers.binance.com/docs/binance-spot-api-docs/rest-api/spot-trading-endpoints#cancel-all-open-orders-on-a-symbol-trade
474
465
  """
475
466
  url = self._BASE_SPOT_URL + "/api/v3/openOrders"
476
- data = {"symbol": symbol}
467
+ params = {"symbol": symbol}
477
468
 
478
- return await self._make_request("DELETE", url, True, data=data)
469
+ return await self._make_request("DELETE", url, True, params=params)
479
470
 
480
471
  async def orders_open(self, symbol: str | None = None) -> list[dict]:
481
472
  """Получение всех активных ордеров.
@@ -523,7 +514,7 @@ class Client(BaseClient):
523
514
  """
524
515
  url = self._BASE_SPOT_URL + "/api/v3/orderList/oco"
525
516
 
526
- data = {
517
+ params = {
527
518
  "symbol": symbol,
528
519
  "side": side,
529
520
  "quantity": quantity,
@@ -553,7 +544,7 @@ class Client(BaseClient):
553
544
  "selfTradePreventionMode": self_trade_prevention_mode,
554
545
  }
555
546
 
556
- return await self._make_request("POST", url, True, params=data)
547
+ return await self._make_request("POST", url, True, params=params)
557
548
 
558
549
  async def oco_order_cancel(
559
550
  self,
@@ -567,14 +558,14 @@ class Client(BaseClient):
567
558
  https://developers.binance.com/docs/binance-spot-api-docs/rest-api/spot-trading-endpoints#cancel-oco-trade
568
559
  """
569
560
  url = self._BASE_SPOT_URL + "/api/v3/orderList"
570
- data = {
561
+ params = {
571
562
  "symbol": symbol,
572
563
  "orderListId": order_list_id,
573
564
  "listClientOrderId": list_client_order_id,
574
565
  "newClientOrderId": new_client_order_id,
575
566
  }
576
567
 
577
- return await self._make_request("DELETE", url, True, data=data)
568
+ return await self._make_request("DELETE", url, True, params=params)
578
569
 
579
570
  async def oco_order_get(
580
571
  self, order_list_id: int | None = None, orig_client_order_id: str | None = None
@@ -1115,9 +1106,9 @@ class Client(BaseClient):
1115
1106
  https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Change-Multi-Assets-Mode
1116
1107
  """
1117
1108
  url = self._BASE_FUTURES_URL + "/fapi/v1/multiAssetsMargin"
1118
- data = {"multiAssetsMargin": multi_assets_margin}
1109
+ params = {"multiAssetsMargin": multi_assets_margin}
1119
1110
 
1120
- return await self._make_request("POST", url, True, data=data)
1111
+ return await self._make_request("POST", url, True, params=params)
1121
1112
 
1122
1113
  async def futures_multi_asset_mode_get(self) -> dict:
1123
1114
  """Получение режима мультиактивной маржи.
@@ -1156,7 +1147,7 @@ class Client(BaseClient):
1156
1147
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
1157
1148
  """
1158
1149
  url = self._BASE_FUTURES_URL + "/fapi/v1/order"
1159
- data = {
1150
+ params = {
1160
1151
  "symbol": symbol,
1161
1152
  "side": side,
1162
1153
  "type": type,
@@ -1177,7 +1168,7 @@ class Client(BaseClient):
1177
1168
  "goodTillDate": good_till_date,
1178
1169
  }
1179
1170
 
1180
- return await self._make_request("POST", url, True, data=data)
1171
+ return await self._make_request("POST", url, True, params=params)
1181
1172
 
1182
1173
  async def futures_order_modify(
1183
1174
  self,
@@ -1194,7 +1185,7 @@ class Client(BaseClient):
1194
1185
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
1195
1186
  """
1196
1187
  url = self._BASE_FUTURES_URL + "/fapi/v1/order"
1197
- data = {
1188
+ params = {
1198
1189
  "orderId": order_id,
1199
1190
  "origClientOrderId": orig_client_order_id,
1200
1191
  "symbol": symbol,
@@ -1204,7 +1195,7 @@ class Client(BaseClient):
1204
1195
  "priceMatch": price_match,
1205
1196
  }
1206
1197
 
1207
- return await self._make_request("PUT", url, True, data=data)
1198
+ return await self._make_request("PUT", url, True, params=params)
1208
1199
 
1209
1200
  async def futures_order_get(
1210
1201
  self,
@@ -1264,9 +1255,9 @@ class Client(BaseClient):
1264
1255
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-All-Open-Orders
1265
1256
  """
1266
1257
  url = self._BASE_FUTURES_URL + "/fapi/v1/allOpenOrders"
1267
- data = {"symbol": symbol}
1258
+ params = {"symbol": symbol}
1268
1259
 
1269
- return await self._make_request("DELETE", url, True, data=data)
1260
+ return await self._make_request("DELETE", url, True, params=params)
1270
1261
 
1271
1262
  async def futures_countdown_cancel_all(
1272
1263
  self,
@@ -1278,12 +1269,12 @@ class Client(BaseClient):
1278
1269
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Auto-Cancel-All-Open-Orders
1279
1270
  """
1280
1271
  url = self._BASE_FUTURES_URL + "/fapi/v1/countdownCancelAll"
1281
- data = {
1272
+ params = {
1282
1273
  "symbol": symbol,
1283
1274
  "countdownTime": countdown_time,
1284
1275
  }
1285
1276
 
1286
- return await self._make_request("POST", url, True, data=data)
1277
+ return await self._make_request("POST", url, True, params=params)
1287
1278
 
1288
1279
  async def futures_position_info(self, symbol: str | None = None) -> list[dict]:
1289
1280
  """Получение информации о позициях на фьючерсах.
@@ -1347,9 +1338,9 @@ class Client(BaseClient):
1347
1338
  https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Change-Initial-Leverage
1348
1339
  """
1349
1340
  url = self._BASE_FUTURES_URL + "/fapi/v1/leverage"
1350
- data = {"symbol": symbol, "leverage": leverage}
1341
+ params = {"symbol": symbol, "leverage": leverage}
1351
1342
 
1352
- return await self._make_request("POST", url, True, data=data)
1343
+ return await self._make_request("POST", url, True, params=params)
1353
1344
 
1354
1345
  async def futures_margin_type_change(self, symbol: str, margin_type: str) -> dict:
1355
1346
  """Изменение типа маржи на фьючерсах.
@@ -1357,9 +1348,9 @@ class Client(BaseClient):
1357
1348
  https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Change-Margin-Type
1358
1349
  """
1359
1350
  url = self._BASE_FUTURES_URL + "/fapi/v1/marginType"
1360
- data = {"symbol": symbol, "marginType": margin_type}
1351
+ params = {"symbol": symbol, "marginType": margin_type}
1361
1352
 
1362
- return await self._make_request("POST", url, True, data=data)
1353
+ return await self._make_request("POST", url, True, params=params)
1363
1354
 
1364
1355
  async def futures_position_margin_modify(
1365
1356
  self,
@@ -1373,14 +1364,14 @@ class Client(BaseClient):
1373
1364
  https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Modify-Isolated-Position-Margin
1374
1365
  """
1375
1366
  url = self._BASE_FUTURES_URL + "/fapi/v1/positionMargin"
1376
- data = {
1367
+ params = {
1377
1368
  "symbol": symbol,
1378
1369
  "positionSide": position_side,
1379
1370
  "amount": amount,
1380
1371
  "type": type,
1381
1372
  }
1382
1373
 
1383
- return await self._make_request("POST", url, True, data=data)
1374
+ return await self._make_request("POST", url, True, params=params)
1384
1375
 
1385
1376
  async def futures_position_margin_history(
1386
1377
  self,
@@ -1465,13 +1456,13 @@ class Client(BaseClient):
1465
1456
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Order
1466
1457
  """
1467
1458
  url = self._BASE_FUTURES_URL + "/fapi/v1/order"
1468
- data = {
1459
+ params = {
1469
1460
  "symbol": symbol,
1470
1461
  "orderId": order_id,
1471
1462
  "origClientOrderId": orig_client_order_id,
1472
1463
  }
1473
1464
 
1474
- return await self._make_request("DELETE", url, data=data)
1465
+ return await self._make_request("DELETE", url, params=params)
1475
1466
 
1476
1467
  async def futures_batch_orders_create(self, orders: list[dict]) -> list[dict]:
1477
1468
  """Создание множественных ордеров одновременно на фьючерсах.
@@ -1479,9 +1470,9 @@ class Client(BaseClient):
1479
1470
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Place-Multiple-Orders
1480
1471
  """
1481
1472
  url = self._BASE_FUTURES_URL + "/fapi/v1/batchOrders"
1482
- data = {"batchOrders": json.dumps(orders)} # Нужен особый дамп
1473
+ params = {"batchOrders": json.dumps(orders)} # Нужен особый дамп
1483
1474
 
1484
- return await self._make_request("POST", url, signed=True, data=data)
1475
+ return await self._make_request("POST", url, signed=True, params=params)
1485
1476
 
1486
1477
  async def futures_batch_orders_cancel(
1487
1478
  self,
@@ -1494,17 +1485,17 @@ class Client(BaseClient):
1494
1485
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Multiple-Orders
1495
1486
  """
1496
1487
  url = self._BASE_FUTURES_URL + "/fapi/v1/batchOrders"
1497
- data = {"symbol": symbol}
1488
+ params = {"symbol": symbol}
1498
1489
 
1499
1490
  if order_id_list:
1500
- data["orderIdList"] = json.dumps(order_id_list) # Нужен особый дамп
1491
+ params["orderIdList"] = json.dumps(order_id_list) # Нужен особый дамп
1501
1492
 
1502
1493
  if orig_client_order_id_list:
1503
- data["origClientOrderIdList"] = json.dumps( # Нужен особый дамп
1494
+ params["origClientOrderIdList"] = json.dumps( # Нужен особый дамп
1504
1495
  orig_client_order_id_list
1505
1496
  )
1506
1497
 
1507
- return await self._make_request("DELETE", url, signed=True, data=data)
1498
+ return await self._make_request("DELETE", url, signed=True, params=params)
1508
1499
 
1509
1500
  # topic: user data streams
1510
1501
 
unicex/gate/adapter.py CHANGED
@@ -115,14 +115,14 @@ class Adapter:
115
115
  KlineDict(
116
116
  s=symbol,
117
117
  t=int(kline[0]),
118
- o=float(kline[1]),
119
- h=float(kline[2]),
120
- l=float(kline[3]),
121
- c=float(kline[4]),
122
- v=float(kline[5]),
123
- q=float(kline[6]),
118
+ o=float(kline[5]),
119
+ h=float(kline[3]),
120
+ l=float(kline[4]),
121
+ c=float(kline[2]),
122
+ v=float(kline[6]),
123
+ q=float(kline[1]),
124
124
  T=None,
125
- x=None,
125
+ x=kline[7] == "true",
126
126
  )
127
127
  for kline in sorted(
128
128
  raw_data,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unicex
3
- Version: 0.13.11
3
+ Version: 0.13.13
4
4
  Summary: Unified Crypto Exchange API
5
5
  Author-email: LoveBloodAndDiamonds <ayazshakirzyanov27@gmail.com>
6
6
  License: BSD 3-Clause License
@@ -14,7 +14,7 @@ unicex/_base/client.py,sha256=asIIQLZlRwwmUDvxveSv7aCvth54iiSRJdz19bxGorI,8904
14
14
  unicex/_base/websocket.py,sha256=haSV3dSgkT352n8knpLm_iI4ZlUGWWKFCB3k5Ua2esU,12542
15
15
  unicex/binance/__init__.py,sha256=sDk4ZjakRdpFMaMSpOCfqjf6ZPfAS9tlrt4WlDHtDkw,932
16
16
  unicex/binance/adapter.py,sha256=JbUFyjnDAFtyuYYrh90YeOvQOZQ6faim0nWS6U0NxXw,8799
17
- unicex/binance/client.py,sha256=Yz1XgcdHh7AfKIGLwClRxSbveJRZ82p9qi--cHalzws,62565
17
+ unicex/binance/client.py,sha256=H_6xq3ahD55EPR_lBYak-7Gd0_bqbIJUf7TXm43ZI3A,62298
18
18
  unicex/binance/exchange_info.py,sha256=LNDkgBC5HB3JxtIBi39puqDg6LIVWqIWjT-6akDxtMs,2437
19
19
  unicex/binance/uni_client.py,sha256=W4yxiU0kkJKPJjimhv4KAWreuEBwt7GgrWXefcw5BEA,8365
20
20
  unicex/binance/uni_websocket_manager.py,sha256=HYHs6PYOTxBqN31AuOzbzs6o4oLBsZPMccqbjJiMu_4,8696
@@ -37,7 +37,7 @@ unicex/bybit/uni_websocket_manager.py,sha256=OpnvWD0xZ8T_By0HZCSg3jWoZqScRATAsku
37
37
  unicex/bybit/user_websocket.py,sha256=IGGEnwyWs5jOppgK_R7SisBDvsiF1_piTswBrdQOgDg,128
38
38
  unicex/bybit/websocket_manager.py,sha256=ePHvngoqoVPr6p-BayoEGhCuRK-cJ69CAPzF94qTalQ,15404
39
39
  unicex/gate/__init__.py,sha256=dsKvhQhDcw4_w0S4c9IjKkCoOg4DCUtSecEUOlfstug,929
40
- unicex/gate/adapter.py,sha256=PE5lXQORAKLhzFZBtxcarNIt2xEcDrPrphxWS0k0wEk,6842
40
+ unicex/gate/adapter.py,sha256=Kr04kfz7Dl1GF2QXHFnuhkc5GaYvEss1Q10ajkm_8Jg,6856
41
41
  unicex/gate/client.py,sha256=bhWkYBn5B4JKpLRfQERTVzisiCSg7mMi6mM0kh4Hes4,53760
42
42
  unicex/gate/exchange_info.py,sha256=ANzfe4mqxtLnj2TBJJxoc31KUosvxdApp1_xYrRNQDs,2300
43
43
  unicex/gate/uni_client.py,sha256=zJrxzWqp0g4hYV0kUKQRfWxMHcWoAnhgB4B5t_MfOng,9644
@@ -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.11.dist-info/licenses/LICENSE,sha256=lNNK4Vqak9cXm6qVJLhbqS7iR_BMj6k7fd7XQ6l1k54,1507
90
- unicex-0.13.11.dist-info/METADATA,sha256=Qj324r8nIh6ZlcVXw3nVN2Ad4AiMm03NujNZN7eUKzk,11753
91
- unicex-0.13.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
- unicex-0.13.11.dist-info/top_level.txt,sha256=_7rar-0OENIg4KRy6cgjWiebFYAJhjKEcMggAocGWG4,7
93
- unicex-0.13.11.dist-info/RECORD,,
89
+ unicex-0.13.13.dist-info/licenses/LICENSE,sha256=lNNK4Vqak9cXm6qVJLhbqS7iR_BMj6k7fd7XQ6l1k54,1507
90
+ unicex-0.13.13.dist-info/METADATA,sha256=CIX3EuOngPQGcHho08jh9aYgcCafAfIvCz9epQVRUS4,11753
91
+ unicex-0.13.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
+ unicex-0.13.13.dist-info/top_level.txt,sha256=_7rar-0OENIg4KRy6cgjWiebFYAJhjKEcMggAocGWG4,7
93
+ unicex-0.13.13.dist-info/RECORD,,