ccxt 4.3.55__py2.py3-none-any.whl → 4.3.57__py2.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 ccxt might be problematic. Click here for more details.

ccxt/gate.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -99,6 +99,8 @@ class gate(Exchange, ImplicitAPI):
99
99
  'borrowIsolatedMargin': True,
100
100
  'cancelAllOrders': True,
101
101
  'cancelOrder': True,
102
+ 'cancelOrders': True,
103
+ 'cancelOrdersForSymbols': True,
102
104
  'createMarketBuyOrderWithCost': True,
103
105
  'createMarketOrder': True,
104
106
  'createMarketOrderWithCost': False,
@@ -640,6 +642,7 @@ class gate(Exchange, ImplicitAPI):
640
642
  'createOrder': {
641
643
  'expiration': 86400, # for conditional orders
642
644
  },
645
+ 'createMarketBuyOrderRequiresPrice': True,
643
646
  'networks': {
644
647
  'AVAXC': 'AVAX_C',
645
648
  'BEP20': 'BSC',
@@ -4183,6 +4186,8 @@ class gate(Exchange, ImplicitAPI):
4183
4186
  # "message": "Not enough balance"
4184
4187
  # }
4185
4188
  #
4189
+ # {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
4190
+ #
4186
4191
  succeeded = self.safe_bool(order, 'succeeded', True)
4187
4192
  if not succeeded:
4188
4193
  # cancelOrders response
@@ -4190,6 +4195,7 @@ class gate(Exchange, ImplicitAPI):
4190
4195
  'clientOrderId': self.safe_string(order, 'text'),
4191
4196
  'info': order,
4192
4197
  'status': 'rejected',
4198
+ 'id': self.safe_string(order, 'id'),
4193
4199
  })
4194
4200
  put = self.safe_value_2(order, 'put', 'initial', {})
4195
4201
  trigger = self.safe_value(order, 'trigger', {})
@@ -4725,6 +4731,81 @@ class gate(Exchange, ImplicitAPI):
4725
4731
  #
4726
4732
  return self.parse_order(response, market)
4727
4733
 
4734
+ def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
4735
+ """
4736
+ cancel multiple orders
4737
+ :see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
4738
+ :see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list-2
4739
+ :param str[] ids: order ids
4740
+ :param str symbol: unified symbol of the market the order was made in
4741
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4742
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4743
+ """
4744
+ self.load_markets()
4745
+ market = None
4746
+ if symbol is not None:
4747
+ market = self.market(symbol)
4748
+ type = None
4749
+ defaultSettle = 'usdt' if (market is None) else market['settle']
4750
+ settle = self.safe_string_lower(params, 'settle', defaultSettle)
4751
+ type, params = self.handle_market_type_and_params('cancelOrders', market, params)
4752
+ isSpot = (type == 'spot')
4753
+ if isSpot and (symbol is None):
4754
+ raise ArgumentsRequired(self.id + ' cancelOrders requires a symbol argument for spot markets')
4755
+ if isSpot:
4756
+ ordersRequests = []
4757
+ for i in range(0, len(ids)):
4758
+ id = ids[i]
4759
+ orderItem: dict = {
4760
+ 'id': id,
4761
+ 'symbol': symbol,
4762
+ }
4763
+ ordersRequests.append(orderItem)
4764
+ return self.cancel_orders_for_symbols(ordersRequests, params)
4765
+ request = {
4766
+ 'settle': settle,
4767
+ }
4768
+ finalList = [request] # hacky but needs to be done here
4769
+ for i in range(0, len(ids)):
4770
+ finalList.append(ids[i])
4771
+ response = self.privateFuturesPostSettleBatchCancelOrders(finalList)
4772
+ return self.parse_orders(response)
4773
+
4774
+ def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
4775
+ """
4776
+ cancel multiple orders for multiple symbols
4777
+ :see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
4778
+ :param str[] ids: order ids
4779
+ :param str symbol: unified symbol of the market the order was made in
4780
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4781
+ :param str[] [params.clientOrderIds]: client order ids
4782
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4783
+ """
4784
+ self.load_markets()
4785
+ ordersRequests = []
4786
+ for i in range(0, len(orders)):
4787
+ order = orders[i]
4788
+ symbol = self.safe_string(order, 'symbol')
4789
+ market = self.market(symbol)
4790
+ if not market['spot']:
4791
+ raise NotSupported(self.id + ' cancelOrdersForSymbols() supports only spot markets')
4792
+ id = self.safe_string(order, 'id')
4793
+ orderItem: dict = {
4794
+ 'id': id,
4795
+ 'currency_pair': market['id'],
4796
+ }
4797
+ ordersRequests.append(orderItem)
4798
+ response = self.privateSpotPostCancelBatchOrders(ordersRequests)
4799
+ #
4800
+ # [
4801
+ # {
4802
+ # "currency_pair": "BTC_USDT",
4803
+ # "id": "123456"
4804
+ # }
4805
+ # ]
4806
+ #
4807
+ return self.parse_orders(response)
4808
+
4728
4809
  def cancel_all_orders(self, symbol: Str = None, params={}):
4729
4810
  """
4730
4811
  cancel all open orders
@@ -5651,7 +5732,20 @@ class gate(Exchange, ImplicitAPI):
5651
5732
  authentication = api[0] # public, private
5652
5733
  type = api[1] # spot, margin, future, delivery
5653
5734
  query = self.omit(params, self.extract_params(path))
5654
- if isinstance(params, list):
5735
+ containsSettle = path.find('settle') > -1
5736
+ if containsSettle and path.endswith('batch_cancel_orders'): # weird check to prevent $settle in php and converting {settle} to array(settle)
5737
+ # special case where we need to extract the settle from the path
5738
+ # but the body is an array of strings
5739
+ settle = self.safe_dict(params, 0)
5740
+ path = self.implode_params(path, settle)
5741
+ # remove the first element from params
5742
+ newParams = []
5743
+ anyParams = params
5744
+ for i in range(1, len(anyParams)):
5745
+ newParams.append(params[i])
5746
+ params = newParams
5747
+ query = newParams
5748
+ elif isinstance(params, list):
5655
5749
  # endpoints like createOrders use an array instead of an object
5656
5750
  # so we infer the settle from one of the elements
5657
5751
  # they have to be all the same so relying on the first one is fine
@@ -7010,6 +7104,7 @@ class gate(Exchange, ImplicitAPI):
7010
7104
  # {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: Trigger.rule"}
7011
7105
  # {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: trigger.expiration invalid range"}
7012
7106
  # {"label": "INVALID_ARGUMENT", "detail": "invalid size"}
7107
+ # {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
7013
7108
  #
7014
7109
  label = self.safe_string(response, 'label')
7015
7110
  if label is not None:
ccxt/htx.py CHANGED
@@ -5521,7 +5521,62 @@ class htx(Exchange, ImplicitAPI):
5521
5521
  # "ts": 1604367997451
5522
5522
  # }
5523
5523
  #
5524
- return response
5524
+ data = self.safe_dict(response, 'data')
5525
+ return self.parse_cancel_orders(data)
5526
+
5527
+ def parse_cancel_orders(self, orders):
5528
+ #
5529
+ # {
5530
+ # "success": [
5531
+ # "5983466"
5532
+ # ],
5533
+ # "failed": [
5534
+ # {
5535
+ # "err-msg": "Incorrect order state",
5536
+ # "order-state": 7,
5537
+ # "order-id": "",
5538
+ # "err-code": "order-orderstate-error",
5539
+ # "client-order-id": "first"
5540
+ # },
5541
+ # ...
5542
+ # ]
5543
+ # }
5544
+ #
5545
+ # {
5546
+ # "errors": [
5547
+ # {
5548
+ # "order_id": "769206471845261312",
5549
+ # "err_code": 1061,
5550
+ # "err_msg": "This order doesnt exist."
5551
+ # }
5552
+ # ],
5553
+ # "successes": "1258075374411399168,1258075393254871040"
5554
+ # }
5555
+ #
5556
+ successes = self.safe_string(orders, 'successes')
5557
+ success = None
5558
+ if successes is not None:
5559
+ success = successes.split(',')
5560
+ else:
5561
+ success = self.safe_list(orders, 'success', [])
5562
+ failed = self.safe_list_2(orders, 'errors', 'failed', [])
5563
+ result = []
5564
+ for i in range(0, len(success)):
5565
+ order = success[i]
5566
+ result.append(self.safe_order({
5567
+ 'info': order,
5568
+ 'id': order,
5569
+ 'status': 'canceled',
5570
+ }))
5571
+ for i in range(0, len(failed)):
5572
+ order = failed[i]
5573
+ result.append(self.safe_order({
5574
+ 'info': order,
5575
+ 'id': self.safe_string_2(order, 'order-id', 'order_id'),
5576
+ 'status': 'failed',
5577
+ 'clientOrderId': self.safe_string(order, 'client-order-id'),
5578
+ }))
5579
+ return result
5525
5580
 
5526
5581
  def cancel_all_orders(self, symbol: Str = None, params={}):
5527
5582
  """
@@ -5558,6 +5613,22 @@ class htx(Exchange, ImplicitAPI):
5558
5613
  if symbol is not None:
5559
5614
  request['symbol'] = market['id']
5560
5615
  response = self.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(self.extend(request, params))
5616
+ #
5617
+ # {
5618
+ # "code": 200,
5619
+ # "data": {
5620
+ # "success-count": 2,
5621
+ # "failed-count": 0,
5622
+ # "next-id": 5454600
5623
+ # }
5624
+ # }
5625
+ #
5626
+ data = self.safe_dict(response, 'data')
5627
+ return [
5628
+ self.safe_order({
5629
+ 'info': data,
5630
+ }),
5631
+ ]
5561
5632
  else:
5562
5633
  if symbol is None:
5563
5634
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
@@ -5611,30 +5682,18 @@ class htx(Exchange, ImplicitAPI):
5611
5682
  response = self.contractPrivatePostApiV1ContractCancelall(self.extend(request, params))
5612
5683
  else:
5613
5684
  raise NotSupported(self.id + ' cancelAllOrders() does not support ' + marketType + ' markets')
5614
- #
5615
- # spot
5616
- #
5617
- # {
5618
- # "code": 200,
5619
- # "data": {
5620
- # "success-count": 2,
5621
- # "failed-count": 0,
5622
- # "next-id": 5454600
5623
- # }
5624
- # }
5625
- #
5626
- # future and swap
5627
- #
5628
- # {
5629
- # "status": "ok",
5630
- # "data": {
5631
- # "errors": [],
5632
- # "successes": "1104754904426696704"
5633
- # },
5634
- # "ts": "1683435723755"
5635
- # }
5636
- #
5637
- return response
5685
+ #
5686
+ # {
5687
+ # "status": "ok",
5688
+ # "data": {
5689
+ # "errors": [],
5690
+ # "successes": "1104754904426696704"
5691
+ # },
5692
+ # "ts": "1683435723755"
5693
+ # }
5694
+ #
5695
+ data = self.safe_dict(response, 'data')
5696
+ return self.parse_cancel_orders(data)
5638
5697
 
5639
5698
  def cancel_all_orders_after(self, timeout: Int, params={}):
5640
5699
  """
ccxt/huobijp.py CHANGED
@@ -1468,7 +1468,61 @@ class huobijp(Exchange, ImplicitAPI):
1468
1468
  # }
1469
1469
  # }
1470
1470
  #
1471
- return response
1471
+ return self.parse_cancel_orders(response)
1472
+
1473
+ def parse_cancel_orders(self, orders):
1474
+ #
1475
+ # {
1476
+ # "success": [
1477
+ # "5983466"
1478
+ # ],
1479
+ # "failed": [
1480
+ # {
1481
+ # "err-msg": "Incorrect order state",
1482
+ # "order-state": 7,
1483
+ # "order-id": "",
1484
+ # "err-code": "order-orderstate-error",
1485
+ # "client-order-id": "first"
1486
+ # },
1487
+ # ...
1488
+ # ]
1489
+ # }
1490
+ #
1491
+ # {
1492
+ # "errors": [
1493
+ # {
1494
+ # "order_id": "769206471845261312",
1495
+ # "err_code": 1061,
1496
+ # "err_msg": "This order doesnt exist."
1497
+ # }
1498
+ # ],
1499
+ # "successes": "1258075374411399168,1258075393254871040"
1500
+ # }
1501
+ #
1502
+ successes = self.safe_string(orders, 'successes')
1503
+ success = None
1504
+ if successes is not None:
1505
+ success = successes.split(',')
1506
+ else:
1507
+ success = self.safe_list(orders, 'success', [])
1508
+ failed = self.safe_list_2(orders, 'errors', 'failed', [])
1509
+ result = []
1510
+ for i in range(0, len(success)):
1511
+ order = success[i]
1512
+ result.append(self.safe_order({
1513
+ 'info': order,
1514
+ 'id': order,
1515
+ 'status': 'canceled',
1516
+ }))
1517
+ for i in range(0, len(failed)):
1518
+ order = failed[i]
1519
+ result.append(self.safe_order({
1520
+ 'info': order,
1521
+ 'id': self.safe_string_2(order, 'order-id', 'order_id'),
1522
+ 'status': 'failed',
1523
+ 'clientOrderId': self.safe_string(order, 'client-order-id'),
1524
+ }))
1525
+ return result
1472
1526
 
1473
1527
  def cancel_all_orders(self, symbol: Str = None, params={}):
1474
1528
  """
@@ -1500,7 +1554,12 @@ class huobijp(Exchange, ImplicitAPI):
1500
1554
  # }
1501
1555
  # }
1502
1556
  #
1503
- return response
1557
+ data = self.safe_dict(response, 'data', {})
1558
+ return [
1559
+ self.safe_order({
1560
+ 'info': data,
1561
+ }),
1562
+ ]
1504
1563
 
1505
1564
  def currency_to_precision(self, code, fee, networkCode=None):
1506
1565
  return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], self.precisionMode)
ccxt/hyperliquid.py CHANGED
@@ -592,7 +592,7 @@ class hyperliquid(Exchange, ImplicitAPI):
592
592
  'limits': {
593
593
  'leverage': {
594
594
  'min': None,
595
- 'max': None,
595
+ 'max': self.safe_integer(market, 'maxLeverage'),
596
596
  },
597
597
  'amount': {
598
598
  'min': None,
ccxt/lbank.py CHANGED
@@ -1416,6 +1416,27 @@ class lbank(Exchange, ImplicitAPI):
1416
1416
  # "status":-1
1417
1417
  # }
1418
1418
  #
1419
+ # cancelOrder
1420
+ #
1421
+ # {
1422
+ # "executedQty":0.0,
1423
+ # "price":0.05,
1424
+ # "origQty":100.0,
1425
+ # "tradeType":"buy",
1426
+ # "status":0
1427
+ # }
1428
+ #
1429
+ # cancelAllOrders
1430
+ #
1431
+ # {
1432
+ # "executedQty":0.00000000000000000000,
1433
+ # "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
1434
+ # "price":0.05000000000000000000,
1435
+ # "origQty":100.00000000000000000000,
1436
+ # "tradeType":"buy",
1437
+ # "status":0
1438
+ # }
1439
+ #
1419
1440
  id = self.safe_string_2(order, 'orderId', 'order_id')
1420
1441
  clientOrderId = self.safe_string_2(order, 'clientOrderId', 'custom_id')
1421
1442
  timestamp = self.safe_integer_2(order, 'time', 'create_time')
@@ -1425,7 +1446,7 @@ class lbank(Exchange, ImplicitAPI):
1425
1446
  timeInForce = None
1426
1447
  postOnly = False
1427
1448
  type = 'limit'
1428
- rawType = self.safe_string(order, 'type') # buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1449
+ rawType = self.safe_string_2(order, 'type', 'tradeType') # buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1429
1450
  parts = rawType.split('_')
1430
1451
  side = self.safe_string(parts, 0)
1431
1452
  typePart = self.safe_string(parts, 1) # market, maker, ioc, fok or None(limit)
@@ -1759,12 +1780,12 @@ class lbank(Exchange, ImplicitAPI):
1759
1780
  # "origQty":100.0,
1760
1781
  # "tradeType":"buy",
1761
1782
  # "status":0
1762
- # },
1783
+ # },
1763
1784
  # "error_code":0,
1764
1785
  # "ts":1648501286196
1765
1786
  # }
1766
- result = self.safe_value(response, 'data', {})
1767
- return result
1787
+ data = self.safe_dict(response, 'data', {})
1788
+ return self.parse_order(data)
1768
1789
 
1769
1790
  def cancel_all_orders(self, symbol: Str = None, params={}):
1770
1791
  """
@@ -1799,8 +1820,8 @@ class lbank(Exchange, ImplicitAPI):
1799
1820
  # "ts":1648506641469
1800
1821
  # }
1801
1822
  #
1802
- result = self.safe_value(response, 'data', [])
1803
- return result
1823
+ data = self.safe_list(response, 'data', [])
1824
+ return self.parse_orders(data)
1804
1825
 
1805
1826
  def get_network_code_for_currency(self, currencyCode, params):
1806
1827
  defaultNetworks = self.safe_value(self.options, 'defaultNetworks')
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.55'
7
+ __version__ = '4.3.57'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ccxt
3
- Version: 4.3.55
3
+ Version: 4.3.57
4
4
  Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
5
5
  Home-page: https://ccxt.com
6
6
  Author: Igor Kroitor
@@ -71,8 +71,6 @@ Current feature list:
71
71
 
72
72
  ## Sponsored Promotion
73
73
 
74
- [![Trade derivatives in June with BitMEX](https://github.com/ccxt/ccxt/assets/1294454/94c3d456-fdf5-4d62-8178-a42e3999e29e)](https://www.bitmex.com/app/register/NZTR1q)
75
-
76
74
  ## See Also
77
75
 
78
76
  - <sub>[![TabTrader](https://user-images.githubusercontent.com/1294454/66755907-9c3e8880-eea1-11e9-846e-0bff349ceb87.png)](https://tab-trader.com/?utm_source=ccxt)</sub> **[TabTrader](https://tab-trader.com/?utm_source=ccxt)** – trading on all exchanges in one app. Available on **[Android](https://play.google.com/store/apps/details?id=com.tabtrader.android&referrer=utm_source%3Dccxt)** and **[iOS](https://itunes.apple.com/app/apple-store/id1095716562?mt=8)**!
@@ -270,13 +268,13 @@ console.log(version, Object.keys(exchanges));
270
268
 
271
269
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
272
270
 
273
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.55/dist/ccxt.browser.min.js
274
- * unpkg: https://unpkg.com/ccxt@4.3.55/dist/ccxt.browser.min.js
271
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.57/dist/ccxt.browser.min.js
272
+ * unpkg: https://unpkg.com/ccxt@4.3.57/dist/ccxt.browser.min.js
275
273
 
276
274
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
277
275
 
278
276
  ```HTML
279
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.55/dist/ccxt.browser.min.js"></script>
277
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.57/dist/ccxt.browser.min.js"></script>
280
278
  ```
281
279
 
282
280
  Creates a global `ccxt` object: