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.

@@ -2922,14 +2922,17 @@ class bybit(Exchange, ImplicitAPI):
2922
2922
  enableUnifiedMargin, enableUnifiedAccount = await self.is_unified_enabled()
2923
2923
  isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
2924
2924
  type = None
2925
- type, params = self.handle_market_type_and_params('fetchBalance', None, params)
2925
+ type, params = self.get_bybit_type('fetchBalance', None, params)
2926
2926
  isSpot = (type == 'spot')
2927
- isSwap = (type == 'swap')
2927
+ isLinear = (type == 'linear')
2928
+ isInverse = (type == 'inverse')
2928
2929
  if isUnifiedAccount:
2929
- if isSpot or isSwap:
2930
+ if isInverse:
2931
+ type = 'contract'
2932
+ else:
2930
2933
  type = 'unified'
2931
2934
  else:
2932
- if isSwap:
2935
+ if isLinear or isInverse:
2933
2936
  type = 'contract'
2934
2937
  accountTypes = self.safe_dict(self.options, 'accountsByType', {})
2935
2938
  unifiedType = self.safe_string_upper(accountTypes, type, type)
@@ -3232,7 +3235,7 @@ class bybit(Exchange, ImplicitAPI):
3232
3235
  else:
3233
3236
  feeCurrencyCode = market['base'] if market['inverse'] else market['settle']
3234
3237
  fee = {
3235
- 'cost': feeCostString,
3238
+ 'cost': self.parse_number(feeCostString),
3236
3239
  'currency': feeCurrencyCode,
3237
3240
  }
3238
3241
  clientOrderId = self.safe_string(order, 'orderLinkId')
@@ -25,8 +25,7 @@ class coinone(Exchange, ImplicitAPI):
25
25
  'id': 'coinone',
26
26
  'name': 'CoinOne',
27
27
  'countries': ['KR'], # Korea
28
- # 'enableRateLimit': False,
29
- 'rateLimit': 667,
28
+ 'rateLimit': 50,
30
29
  'version': 'v2',
31
30
  'pro': False,
32
31
  'has': {
@@ -198,10 +197,10 @@ class coinone(Exchange, ImplicitAPI):
198
197
  },
199
198
  'precisionMode': TICK_SIZE,
200
199
  'exceptions': {
201
- '405': OnMaintenance, # {"errorCode":"405","status":"maintenance","result":"error"}
202
- '104': OrderNotFound, # {"errorCode":"104","errorMsg":"Order id is not exist","result":"error"}
203
- '108': BadSymbol, # {"errorCode":"108","errorMsg":"Unknown CryptoCurrency","result":"error"}
204
- '107': BadRequest, # {"errorCode":"107","errorMsg":"Parameter error","result":"error"}
200
+ '104': OrderNotFound,
201
+ '107': BadRequest,
202
+ '108': BadSymbol,
203
+ '405': OnMaintenance,
205
204
  },
206
205
  'commonCurrencies': {
207
206
  'SOC': 'Soda Coin',
@@ -1111,17 +1110,14 @@ class coinone(Exchange, ImplicitAPI):
1111
1110
 
1112
1111
  def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
1113
1112
  if response is None:
1114
- return None
1115
- if 'result' in response:
1116
- result = response['result']
1117
- if result != 'success':
1118
- #
1119
- # { "errorCode": "405", "status": "maintenance", "result": "error"}
1120
- #
1121
- errorCode = self.safe_string(response, 'errorCode')
1122
- feedback = self.id + ' ' + body
1123
- self.throw_exactly_matched_exception(self.exceptions, errorCode, feedback)
1124
- raise ExchangeError(feedback)
1125
- else:
1126
- raise ExchangeError(self.id + ' ' + body)
1113
+ return None # fallback to default error handler
1114
+ #
1115
+ # {"result":"error","error_code":"107","error_msg":"Parameter value is wrong"}
1116
+ # {"result":"error","error_code":"108","error_msg":"Unknown CryptoCurrency"}
1117
+ #
1118
+ errorCode = self.safe_string(response, 'error_code')
1119
+ if errorCode != '0':
1120
+ feedback = self.id + ' ' + body
1121
+ self.throw_exactly_matched_exception(self.exceptions, errorCode, feedback)
1122
+ raise ExchangeError(feedback) # unknown message
1127
1123
  return None
@@ -1946,7 +1946,11 @@ class delta(Exchange, ImplicitAPI):
1946
1946
  # "success":true
1947
1947
  # }
1948
1948
  #
1949
- return response
1949
+ return [
1950
+ self.safe_order({
1951
+ 'info': response,
1952
+ }),
1953
+ ]
1950
1954
 
1951
1955
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1952
1956
  """
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- 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
10
+ 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
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -100,6 +100,8 @@ class gate(Exchange, ImplicitAPI):
100
100
  'borrowIsolatedMargin': True,
101
101
  'cancelAllOrders': True,
102
102
  'cancelOrder': True,
103
+ 'cancelOrders': True,
104
+ 'cancelOrdersForSymbols': True,
103
105
  'createMarketBuyOrderWithCost': True,
104
106
  'createMarketOrder': True,
105
107
  'createMarketOrderWithCost': False,
@@ -641,6 +643,7 @@ class gate(Exchange, ImplicitAPI):
641
643
  'createOrder': {
642
644
  'expiration': 86400, # for conditional orders
643
645
  },
646
+ 'createMarketBuyOrderRequiresPrice': True,
644
647
  'networks': {
645
648
  'AVAXC': 'AVAX_C',
646
649
  'BEP20': 'BSC',
@@ -4184,6 +4187,8 @@ class gate(Exchange, ImplicitAPI):
4184
4187
  # "message": "Not enough balance"
4185
4188
  # }
4186
4189
  #
4190
+ # {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
4191
+ #
4187
4192
  succeeded = self.safe_bool(order, 'succeeded', True)
4188
4193
  if not succeeded:
4189
4194
  # cancelOrders response
@@ -4191,6 +4196,7 @@ class gate(Exchange, ImplicitAPI):
4191
4196
  'clientOrderId': self.safe_string(order, 'text'),
4192
4197
  'info': order,
4193
4198
  'status': 'rejected',
4199
+ 'id': self.safe_string(order, 'id'),
4194
4200
  })
4195
4201
  put = self.safe_value_2(order, 'put', 'initial', {})
4196
4202
  trigger = self.safe_value(order, 'trigger', {})
@@ -4726,6 +4732,81 @@ class gate(Exchange, ImplicitAPI):
4726
4732
  #
4727
4733
  return self.parse_order(response, market)
4728
4734
 
4735
+ async def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
4736
+ """
4737
+ cancel multiple orders
4738
+ :see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
4739
+ :see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list-2
4740
+ :param str[] ids: order ids
4741
+ :param str symbol: unified symbol of the market the order was made in
4742
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4743
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4744
+ """
4745
+ await self.load_markets()
4746
+ market = None
4747
+ if symbol is not None:
4748
+ market = self.market(symbol)
4749
+ type = None
4750
+ defaultSettle = 'usdt' if (market is None) else market['settle']
4751
+ settle = self.safe_string_lower(params, 'settle', defaultSettle)
4752
+ type, params = self.handle_market_type_and_params('cancelOrders', market, params)
4753
+ isSpot = (type == 'spot')
4754
+ if isSpot and (symbol is None):
4755
+ raise ArgumentsRequired(self.id + ' cancelOrders requires a symbol argument for spot markets')
4756
+ if isSpot:
4757
+ ordersRequests = []
4758
+ for i in range(0, len(ids)):
4759
+ id = ids[i]
4760
+ orderItem: dict = {
4761
+ 'id': id,
4762
+ 'symbol': symbol,
4763
+ }
4764
+ ordersRequests.append(orderItem)
4765
+ return await self.cancel_orders_for_symbols(ordersRequests, params)
4766
+ request = {
4767
+ 'settle': settle,
4768
+ }
4769
+ finalList = [request] # hacky but needs to be done here
4770
+ for i in range(0, len(ids)):
4771
+ finalList.append(ids[i])
4772
+ response = await self.privateFuturesPostSettleBatchCancelOrders(finalList)
4773
+ return self.parse_orders(response)
4774
+
4775
+ async def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
4776
+ """
4777
+ cancel multiple orders for multiple symbols
4778
+ :see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
4779
+ :param str[] ids: order ids
4780
+ :param str symbol: unified symbol of the market the order was made in
4781
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4782
+ :param str[] [params.clientOrderIds]: client order ids
4783
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4784
+ """
4785
+ await self.load_markets()
4786
+ ordersRequests = []
4787
+ for i in range(0, len(orders)):
4788
+ order = orders[i]
4789
+ symbol = self.safe_string(order, 'symbol')
4790
+ market = self.market(symbol)
4791
+ if not market['spot']:
4792
+ raise NotSupported(self.id + ' cancelOrdersForSymbols() supports only spot markets')
4793
+ id = self.safe_string(order, 'id')
4794
+ orderItem: dict = {
4795
+ 'id': id,
4796
+ 'currency_pair': market['id'],
4797
+ }
4798
+ ordersRequests.append(orderItem)
4799
+ response = await self.privateSpotPostCancelBatchOrders(ordersRequests)
4800
+ #
4801
+ # [
4802
+ # {
4803
+ # "currency_pair": "BTC_USDT",
4804
+ # "id": "123456"
4805
+ # }
4806
+ # ]
4807
+ #
4808
+ return self.parse_orders(response)
4809
+
4729
4810
  async def cancel_all_orders(self, symbol: Str = None, params={}):
4730
4811
  """
4731
4812
  cancel all open orders
@@ -5652,7 +5733,20 @@ class gate(Exchange, ImplicitAPI):
5652
5733
  authentication = api[0] # public, private
5653
5734
  type = api[1] # spot, margin, future, delivery
5654
5735
  query = self.omit(params, self.extract_params(path))
5655
- if isinstance(params, list):
5736
+ containsSettle = path.find('settle') > -1
5737
+ if containsSettle and path.endswith('batch_cancel_orders'): # weird check to prevent $settle in php and converting {settle} to array(settle)
5738
+ # special case where we need to extract the settle from the path
5739
+ # but the body is an array of strings
5740
+ settle = self.safe_dict(params, 0)
5741
+ path = self.implode_params(path, settle)
5742
+ # remove the first element from params
5743
+ newParams = []
5744
+ anyParams = params
5745
+ for i in range(1, len(anyParams)):
5746
+ newParams.append(params[i])
5747
+ params = newParams
5748
+ query = newParams
5749
+ elif isinstance(params, list):
5656
5750
  # endpoints like createOrders use an array instead of an object
5657
5751
  # so we infer the settle from one of the elements
5658
5752
  # they have to be all the same so relying on the first one is fine
@@ -7011,6 +7105,7 @@ class gate(Exchange, ImplicitAPI):
7011
7105
  # {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: Trigger.rule"}
7012
7106
  # {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: trigger.expiration invalid range"}
7013
7107
  # {"label": "INVALID_ARGUMENT", "detail": "invalid size"}
7108
+ # {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
7014
7109
  #
7015
7110
  label = self.safe_string(response, 'label')
7016
7111
  if label is not None:
ccxt/async_support/htx.py CHANGED
@@ -5522,7 +5522,62 @@ class htx(Exchange, ImplicitAPI):
5522
5522
  # "ts": 1604367997451
5523
5523
  # }
5524
5524
  #
5525
- return response
5525
+ data = self.safe_dict(response, 'data')
5526
+ return self.parse_cancel_orders(data)
5527
+
5528
+ def parse_cancel_orders(self, orders):
5529
+ #
5530
+ # {
5531
+ # "success": [
5532
+ # "5983466"
5533
+ # ],
5534
+ # "failed": [
5535
+ # {
5536
+ # "err-msg": "Incorrect order state",
5537
+ # "order-state": 7,
5538
+ # "order-id": "",
5539
+ # "err-code": "order-orderstate-error",
5540
+ # "client-order-id": "first"
5541
+ # },
5542
+ # ...
5543
+ # ]
5544
+ # }
5545
+ #
5546
+ # {
5547
+ # "errors": [
5548
+ # {
5549
+ # "order_id": "769206471845261312",
5550
+ # "err_code": 1061,
5551
+ # "err_msg": "This order doesnt exist."
5552
+ # }
5553
+ # ],
5554
+ # "successes": "1258075374411399168,1258075393254871040"
5555
+ # }
5556
+ #
5557
+ successes = self.safe_string(orders, 'successes')
5558
+ success = None
5559
+ if successes is not None:
5560
+ success = successes.split(',')
5561
+ else:
5562
+ success = self.safe_list(orders, 'success', [])
5563
+ failed = self.safe_list_2(orders, 'errors', 'failed', [])
5564
+ result = []
5565
+ for i in range(0, len(success)):
5566
+ order = success[i]
5567
+ result.append(self.safe_order({
5568
+ 'info': order,
5569
+ 'id': order,
5570
+ 'status': 'canceled',
5571
+ }))
5572
+ for i in range(0, len(failed)):
5573
+ order = failed[i]
5574
+ result.append(self.safe_order({
5575
+ 'info': order,
5576
+ 'id': self.safe_string_2(order, 'order-id', 'order_id'),
5577
+ 'status': 'failed',
5578
+ 'clientOrderId': self.safe_string(order, 'client-order-id'),
5579
+ }))
5580
+ return result
5526
5581
 
5527
5582
  async def cancel_all_orders(self, symbol: Str = None, params={}):
5528
5583
  """
@@ -5559,6 +5614,22 @@ class htx(Exchange, ImplicitAPI):
5559
5614
  if symbol is not None:
5560
5615
  request['symbol'] = market['id']
5561
5616
  response = await self.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(self.extend(request, params))
5617
+ #
5618
+ # {
5619
+ # "code": 200,
5620
+ # "data": {
5621
+ # "success-count": 2,
5622
+ # "failed-count": 0,
5623
+ # "next-id": 5454600
5624
+ # }
5625
+ # }
5626
+ #
5627
+ data = self.safe_dict(response, 'data')
5628
+ return [
5629
+ self.safe_order({
5630
+ 'info': data,
5631
+ }),
5632
+ ]
5562
5633
  else:
5563
5634
  if symbol is None:
5564
5635
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
@@ -5612,30 +5683,18 @@ class htx(Exchange, ImplicitAPI):
5612
5683
  response = await self.contractPrivatePostApiV1ContractCancelall(self.extend(request, params))
5613
5684
  else:
5614
5685
  raise NotSupported(self.id + ' cancelAllOrders() does not support ' + marketType + ' markets')
5615
- #
5616
- # spot
5617
- #
5618
- # {
5619
- # "code": 200,
5620
- # "data": {
5621
- # "success-count": 2,
5622
- # "failed-count": 0,
5623
- # "next-id": 5454600
5624
- # }
5625
- # }
5626
- #
5627
- # future and swap
5628
- #
5629
- # {
5630
- # "status": "ok",
5631
- # "data": {
5632
- # "errors": [],
5633
- # "successes": "1104754904426696704"
5634
- # },
5635
- # "ts": "1683435723755"
5636
- # }
5637
- #
5638
- return response
5686
+ #
5687
+ # {
5688
+ # "status": "ok",
5689
+ # "data": {
5690
+ # "errors": [],
5691
+ # "successes": "1104754904426696704"
5692
+ # },
5693
+ # "ts": "1683435723755"
5694
+ # }
5695
+ #
5696
+ data = self.safe_dict(response, 'data')
5697
+ return self.parse_cancel_orders(data)
5639
5698
 
5640
5699
  async def cancel_all_orders_after(self, timeout: Int, params={}):
5641
5700
  """
@@ -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
  async 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)
@@ -593,7 +593,7 @@ class hyperliquid(Exchange, ImplicitAPI):
593
593
  'limits': {
594
594
  'leverage': {
595
595
  'min': None,
596
- 'max': None,
596
+ 'max': self.safe_integer(market, 'maxLeverage'),
597
597
  },
598
598
  'amount': {
599
599
  'min': None,
@@ -1417,6 +1417,27 @@ class lbank(Exchange, ImplicitAPI):
1417
1417
  # "status":-1
1418
1418
  # }
1419
1419
  #
1420
+ # cancelOrder
1421
+ #
1422
+ # {
1423
+ # "executedQty":0.0,
1424
+ # "price":0.05,
1425
+ # "origQty":100.0,
1426
+ # "tradeType":"buy",
1427
+ # "status":0
1428
+ # }
1429
+ #
1430
+ # cancelAllOrders
1431
+ #
1432
+ # {
1433
+ # "executedQty":0.00000000000000000000,
1434
+ # "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
1435
+ # "price":0.05000000000000000000,
1436
+ # "origQty":100.00000000000000000000,
1437
+ # "tradeType":"buy",
1438
+ # "status":0
1439
+ # }
1440
+ #
1420
1441
  id = self.safe_string_2(order, 'orderId', 'order_id')
1421
1442
  clientOrderId = self.safe_string_2(order, 'clientOrderId', 'custom_id')
1422
1443
  timestamp = self.safe_integer_2(order, 'time', 'create_time')
@@ -1426,7 +1447,7 @@ class lbank(Exchange, ImplicitAPI):
1426
1447
  timeInForce = None
1427
1448
  postOnly = False
1428
1449
  type = 'limit'
1429
- rawType = self.safe_string(order, 'type') # buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
1450
+ 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
1430
1451
  parts = rawType.split('_')
1431
1452
  side = self.safe_string(parts, 0)
1432
1453
  typePart = self.safe_string(parts, 1) # market, maker, ioc, fok or None(limit)
@@ -1760,12 +1781,12 @@ class lbank(Exchange, ImplicitAPI):
1760
1781
  # "origQty":100.0,
1761
1782
  # "tradeType":"buy",
1762
1783
  # "status":0
1763
- # },
1784
+ # },
1764
1785
  # "error_code":0,
1765
1786
  # "ts":1648501286196
1766
1787
  # }
1767
- result = self.safe_value(response, 'data', {})
1768
- return result
1788
+ data = self.safe_dict(response, 'data', {})
1789
+ return self.parse_order(data)
1769
1790
 
1770
1791
  async def cancel_all_orders(self, symbol: Str = None, params={}):
1771
1792
  """
@@ -1800,8 +1821,8 @@ class lbank(Exchange, ImplicitAPI):
1800
1821
  # "ts":1648506641469
1801
1822
  # }
1802
1823
  #
1803
- result = self.safe_value(response, 'data', [])
1804
- return result
1824
+ data = self.safe_list(response, 'data', [])
1825
+ return self.parse_orders(data)
1805
1826
 
1806
1827
  def get_network_code_for_currency(self, currencyCode, params):
1807
1828
  defaultNetworks = self.safe_value(self.options, 'defaultNetworks')
ccxt/base/exchange.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
 
@@ -1449,7 +1449,7 @@ class Exchange(object):
1449
1449
  @staticmethod
1450
1450
  def eddsa(request, secret, curve='ed25519'):
1451
1451
  if isinstance(secret, str):
1452
- Exchange.encode(secret)
1452
+ secret = Exchange.encode(secret)
1453
1453
  private_key = ed25519.Ed25519PrivateKey.from_private_bytes(secret) if len(secret) == 32 else load_pem_private_key(secret, None)
1454
1454
  return Exchange.binary_to_base64(private_key.sign(request))
1455
1455
 
@@ -3734,7 +3734,23 @@ class Exchange(object):
3734
3734
  self.last_request_headers = request['headers']
3735
3735
  self.last_request_body = request['body']
3736
3736
  self.last_request_url = request['url']
3737
- return self.fetch(request['url'], request['method'], request['headers'], request['body'])
3737
+ retries = None
3738
+ retries, params = self.handle_option_and_params(params, path, 'maxRetriesOnFailure', 0)
3739
+ retryDelay = None
3740
+ retryDelay, params = self.handle_option_and_params(params, path, 'maxRetriesOnFailureDelay', 0)
3741
+ for i in range(0, retries + 1):
3742
+ try:
3743
+ return self.fetch(request['url'], request['method'], request['headers'], request['body'])
3744
+ except Exception as e:
3745
+ if isinstance(e, NetworkError):
3746
+ if i < retries:
3747
+ if self.verbose:
3748
+ self.log('Request failed with the error: ' + str(e) + ', retrying ' + (i + str(1)) + ' of ' + str(retries) + '...')
3749
+ if (retryDelay is not None) and (retryDelay != 0):
3750
+ self.sleep(retryDelay)
3751
+ continue
3752
+ raise e
3753
+ return None # self line is never reached, but exists for c# value return requirement
3738
3754
 
3739
3755
  def request(self, path, api: Any = 'public', method='GET', params={}, headers: Any = None, body: Any = None, config={}):
3740
3756
  return self.fetch2(path, api, method, params, headers, body, config)
ccxt/binance.py CHANGED
@@ -1566,7 +1566,7 @@ class binance(Exchange, ImplicitAPI):
1566
1566
  '-3042': BadRequest, # {"code":-3042,"msg":"PriceIndex not available for self margin pair."}
1567
1567
  '-3043': PermissionDenied, # {"code":-3043,"msg":"Transferring in not allowed."}
1568
1568
  '-3044': OperationFailed, # {"code":-3044,"msg":"System busy."}
1569
- '-3045': OperationFailed, # {"code":-3045,"msg":"The system doesn't have enough asset now."}
1569
+ '-3045': OperationRejected, # {"code":-3045,"msg":"The system doesn't have enough asset now."}
1570
1570
  '-3999': PermissionDenied, # {"code":-3999,"msg":"This function is only available for invited users."}
1571
1571
  #
1572
1572
  # 4xxx(different from contract markets)
@@ -1585,7 +1585,7 @@ class binance(Exchange, ImplicitAPI):
1585
1585
  '-4011': BadRequest, # {"code":-4011 ,"msg":"White list mail is invalid."}
1586
1586
  '-4012': PermissionDenied, # {"code":-4012 ,"msg":"White list is not opened."}
1587
1587
  '-4013': AuthenticationError, # {"code":-4013 ,"msg":"2FA is not opened."}
1588
- '-4014': OperationFailed, # {"code":-4014 ,"msg":"Withdraw is not allowed within 2 min login."}
1588
+ '-4014': OperationRejected, # {"code":-4014 ,"msg":"Withdraw is not allowed within 2 min login."}
1589
1589
  '-4015': PermissionDenied, # {"code":-4015 ,"msg":"Withdraw is limited."}
1590
1590
  '-4016': PermissionDenied, # {"code":-4016 ,"msg":"Within 24 hours after password modification, withdrawal is prohibited."}
1591
1591
  '-4017': PermissionDenied, # {"code":-4017 ,"msg":"Within 24 hours after the release of 2FA, withdrawal is prohibited."}
@@ -1594,7 +1594,7 @@ class binance(Exchange, ImplicitAPI):
1594
1594
  '-4020': ExchangeError, # override commons
1595
1595
  '-4021': BadRequest, # {"code":-4021,"msg":"Asset withdrawal must be an %s multiple of %s."}
1596
1596
  '-4022': BadRequest, # {"code":-4022,"msg":"Not less than the minimum pick-up quantity %s."}
1597
- '-4023': OperationFailed, # {"code":-4023,"msg":"Within 24 hours, the withdrawal exceeds the maximum amount."}
1597
+ '-4023': OperationRejected, # {"code":-4023,"msg":"Within 24 hours, the withdrawal exceeds the maximum amount."}
1598
1598
  '-4024': InsufficientFunds, # {"code":-4024,"msg":"You don't have self asset."}
1599
1599
  '-4025': InsufficientFunds, # {"code":-4025,"msg":"The number of hold asset is less than zero."}
1600
1600
  '-4026': InsufficientFunds, # {"code":-4026,"msg":"You have insufficient balance."}
@@ -1603,7 +1603,7 @@ class binance(Exchange, ImplicitAPI):
1603
1603
  '-4029': BadRequest, # {"code":-4029,"msg":"The withdrawal record does not exist."}
1604
1604
  '-4030': BadResponse, # {"code":-4030,"msg":"Confirmation of successful asset withdrawal. [TODO] possible bug in docs"}
1605
1605
  '-4031': OperationFailed, # {"code":-4031,"msg":"Cancellation failed."}
1606
- '-4032': OperationFailed, # {"code":-4032,"msg":"Withdraw verification exception."}
1606
+ '-4032': OperationRejected, # {"code":-4032,"msg":"Withdraw verification exception."}
1607
1607
  '-4033': BadRequest, # {"code":-4033,"msg":"Illegal address."}
1608
1608
  '-4034': OperationRejected, # {"code":-4034,"msg":"The address is suspected of fake."}
1609
1609
  '-4035': PermissionDenied, # {"code":-4035,"msg":"This address is not on the whitelist. Please join and try again."}
@@ -1726,7 +1726,7 @@ class binance(Exchange, ImplicitAPI):
1726
1726
  '-5003': InsufficientFunds, # You don't have self asset.
1727
1727
  '-5004': OperationRejected, # The residual balances of %s have exceeded 0.001BTC, Please re-choose.
1728
1728
  '-5005': OperationRejected, # The residual balances of %s is too low, Please re-choose.
1729
- '-5006': OperationFailed, # Only transfer once in 24 hours.
1729
+ '-5006': OperationRejected, # Only transfer once in 24 hours.
1730
1730
  '-5007': BadRequest, # Quantity must be greater than zero.
1731
1731
  '-5008': OperationRejected, # Insufficient amount of returnable assets.
1732
1732
  '-5009': BadSymbol, # Product does not exist.
@@ -1744,8 +1744,8 @@ class binance(Exchange, ImplicitAPI):
1744
1744
  '-6004': BadRequest, # Product not in purchase status
1745
1745
  '-6005': BadRequest, # Smaller than min purchase limit
1746
1746
  '-6006': BadRequest, # Redeem amount error
1747
- '-6007': OperationFailed, # Not in redeem time
1748
- '-6008': OperationFailed, # Product not in redeem status
1747
+ '-6007': OperationRejected, # Not in redeem time
1748
+ '-6008': OperationRejected, # Product not in redeem status
1749
1749
  '-6009': RateLimitExceeded, # Request frequency too high
1750
1750
  '-6011': OperationRejected, # Exceeding the maximum num allowed to purchase per user
1751
1751
  '-6012': InsufficientFunds, # Balance not enough