ccxt 4.4.38__py2.py3-none-any.whl → 4.4.39__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.
ccxt/digifinex.py CHANGED
@@ -230,6 +230,7 @@ class digifinex(Exchange, ImplicitAPI):
230
230
  'trade/order_info',
231
231
  ],
232
232
  'post': [
233
+ 'account/transfer',
233
234
  'account/leverage',
234
235
  'account/position_mode',
235
236
  'account/position_margin',
@@ -2748,12 +2749,23 @@ class digifinex(Exchange, ImplicitAPI):
2748
2749
 
2749
2750
  def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
2750
2751
  #
2751
- # transfer
2752
+ # transfer between spot, margin and OTC
2752
2753
  #
2753
2754
  # {
2754
2755
  # "code": 0
2755
2756
  # }
2756
2757
  #
2758
+ # transfer between spot and swap
2759
+ #
2760
+ # {
2761
+ # "code": 0,
2762
+ # "data": {
2763
+ # "type": 2,
2764
+ # "currency": "USDT",
2765
+ # "transfer_amount": "5"
2766
+ # }
2767
+ # }
2768
+ #
2757
2769
  # fetchTransfers
2758
2770
  #
2759
2771
  # {
@@ -2766,7 +2778,8 @@ class digifinex(Exchange, ImplicitAPI):
2766
2778
  #
2767
2779
  fromAccount = None
2768
2780
  toAccount = None
2769
- type = self.safe_integer(transfer, 'type')
2781
+ data = self.safe_dict(transfer, 'data', transfer)
2782
+ type = self.safe_integer(data, 'type')
2770
2783
  if type == 1:
2771
2784
  fromAccount = 'spot'
2772
2785
  toAccount = 'swap'
@@ -2779,8 +2792,8 @@ class digifinex(Exchange, ImplicitAPI):
2779
2792
  'id': self.safe_string(transfer, 'transfer_id'),
2780
2793
  'timestamp': timestamp,
2781
2794
  'datetime': self.iso8601(timestamp),
2782
- 'currency': self.safe_currency_code(self.safe_string(transfer, 'currency'), currency),
2783
- 'amount': self.safe_number(transfer, 'amount'),
2795
+ 'currency': self.safe_currency_code(self.safe_string(data, 'currency'), currency),
2796
+ 'amount': self.safe_number_2(data, 'amount', 'transfer_amount'),
2784
2797
  'fromAccount': fromAccount,
2785
2798
  'toAccount': toAccount,
2786
2799
  'status': self.parse_transfer_status(self.safe_string(transfer, 'code')),
@@ -2789,30 +2802,56 @@ class digifinex(Exchange, ImplicitAPI):
2789
2802
  def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2790
2803
  """
2791
2804
  transfer currency internally between wallets on the same account
2805
+
2806
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
2807
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer
2808
+
2792
2809
  :param str code: unified currency code
2793
2810
  :param float amount: amount to transfer
2794
- :param str fromAccount: account to transfer from
2795
- :param str toAccount: account to transfer to
2811
+ :param str fromAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer from
2812
+ :param str toAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer to
2796
2813
  :param dict [params]: extra parameters specific to the exchange API endpoint
2797
2814
  :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
2798
2815
  """
2799
2816
  self.load_markets()
2800
2817
  currency = self.currency(code)
2818
+ currencyId = currency['id']
2801
2819
  accountsByType = self.safe_value(self.options, 'accountsByType', {})
2802
2820
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
2803
2821
  toId = self.safe_string(accountsByType, toAccount, toAccount)
2804
- request: dict = {
2805
- 'currency_mark': currency['id'],
2806
- 'num': self.currency_to_precision(code, amount),
2807
- 'from': fromId, # 1 = SPOT, 2 = MARGIN, 3 = OTC
2808
- 'to': toId, # 1 = SPOT, 2 = MARGIN, 3 = OTC
2809
- }
2810
- response = self.privateSpotPostTransfer(self.extend(request, params))
2811
- #
2812
- # {
2813
- # "code": 0
2814
- # }
2815
- #
2822
+ request = {}
2823
+ fromSwap = (fromAccount == 'swap')
2824
+ toSwap = (toAccount == 'swap')
2825
+ response = None
2826
+ amountString = self.currency_to_precision(code, amount)
2827
+ if fromSwap or toSwap:
2828
+ if (fromId != '1') and (toId != '1'):
2829
+ raise ExchangeError(self.id + ' transfer() supports transferring between spot and swap, spot and margin, spot and OTC only')
2830
+ request['type'] = 1 if toSwap else 2 # 1 = spot to swap, 2 = swap to spot
2831
+ request['currency'] = currencyId
2832
+ request['transfer_amount'] = amountString
2833
+ #
2834
+ # {
2835
+ # "code": 0,
2836
+ # "data": {
2837
+ # "type": 2,
2838
+ # "currency": "USDT",
2839
+ # "transfer_amount": "5"
2840
+ # }
2841
+ # }
2842
+ #
2843
+ response = self.privateSwapPostAccountTransfer(self.extend(request, params))
2844
+ else:
2845
+ request['currency_mark'] = currencyId
2846
+ request['num'] = amountString
2847
+ request['from'] = fromId # 1 = SPOT, 2 = MARGIN, 3 = OTC
2848
+ request['to'] = toId # 1 = SPOT, 2 = MARGIN, 3 = OTC
2849
+ #
2850
+ # {
2851
+ # "code": 0
2852
+ # }
2853
+ #
2854
+ response = self.privateSpotPostTransfer(self.extend(request, params))
2816
2855
  return self.parse_transfer(response, currency)
2817
2856
 
2818
2857
  def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
ccxt/htx.py CHANGED
@@ -1250,6 +1250,128 @@ class htx(Exchange, ImplicitAPI):
1250
1250
  'BIFI': 'BITCOINFILE', # conflict with Beefy.Finance https://github.com/ccxt/ccxt/issues/8706
1251
1251
  'FUD': 'FTX Users Debt',
1252
1252
  },
1253
+ 'features': {
1254
+ 'spot': {
1255
+ 'sandbox': True,
1256
+ 'createOrder': {
1257
+ 'marginMode': True,
1258
+ 'triggerPrice': True,
1259
+ 'triggerDirection': True,
1260
+ 'triggerPriceType': None,
1261
+ 'stopLossPrice': False, # todo: add support by triggerprice
1262
+ 'takeProfitPrice': False,
1263
+ 'attachedStopLossTakeProfit': None,
1264
+ 'timeInForce': {
1265
+ 'IOC': True,
1266
+ 'FOK': True,
1267
+ 'PO': True,
1268
+ 'GTD': False,
1269
+ },
1270
+ 'hedged': False,
1271
+ 'trailing': False,
1272
+ # exchange-specific features
1273
+ 'iceberg': False,
1274
+ 'selfTradePrevention': True,
1275
+ },
1276
+ 'createOrders': {
1277
+ 'max': 10,
1278
+ },
1279
+ 'fetchMyTrades': {
1280
+ 'marginMode': False,
1281
+ 'limit': 500,
1282
+ 'daysBack': 120,
1283
+ 'untilDays': 2,
1284
+ },
1285
+ 'fetchOrder': {
1286
+ 'marginMode': False,
1287
+ 'trigger': False,
1288
+ 'trailing': False,
1289
+ },
1290
+ 'fetchOpenOrders': {
1291
+ 'marginMode': False,
1292
+ 'trigger': True,
1293
+ 'trailing': False,
1294
+ 'limit': 500,
1295
+ },
1296
+ 'fetchOrders': {
1297
+ 'marginMode': False,
1298
+ 'trigger': True,
1299
+ 'trailing': False,
1300
+ 'limit': 500,
1301
+ 'untilDays': 2,
1302
+ 'daysBack': 180,
1303
+ },
1304
+ 'fetchClosedOrders': {
1305
+ 'marginMode': False,
1306
+ 'trigger': True,
1307
+ 'trailing': False,
1308
+ 'untilDays': 2,
1309
+ 'limit': 500,
1310
+ 'daysBackClosed': 180,
1311
+ 'daysBackCanceled': 1 / 12,
1312
+ },
1313
+ 'fetchOHLCV': {
1314
+ 'limit': 1000, # 2000 for non-historical
1315
+ },
1316
+ },
1317
+ 'forDerivatives': {
1318
+ 'extends': 'spot',
1319
+ 'createOrder': {
1320
+ 'stopLossPrice': True,
1321
+ 'takeProfitPrice': True,
1322
+ 'trailing': True,
1323
+ 'hedged': True,
1324
+ # 'leverage': True, # todo
1325
+ },
1326
+ 'createOrders': {
1327
+ 'max': 25,
1328
+ },
1329
+ 'fetchOrder': {
1330
+ 'marginMode': True,
1331
+ },
1332
+ 'fetchOpenOrders': {
1333
+ 'marginMode': True,
1334
+ 'trigger': False,
1335
+ 'trailing': False,
1336
+ 'limit': 50,
1337
+ },
1338
+ 'fetchOrders': {
1339
+ 'marginMode': True,
1340
+ 'trigger': False,
1341
+ 'trailing': False,
1342
+ 'limit': 50,
1343
+ 'daysBack': 90,
1344
+ },
1345
+ 'fetchClosedOrders': {
1346
+ 'marginMode': True,
1347
+ 'trigger': False,
1348
+ 'trailing': False,
1349
+ 'untilDays': 2,
1350
+ 'limit': 50,
1351
+ 'daysBackClosed': 90,
1352
+ 'daysBackCanceled': 1 / 12,
1353
+ },
1354
+ 'fetchOHLCV': {
1355
+ 'limit': 2000,
1356
+ },
1357
+ },
1358
+ 'swap': {
1359
+ 'linear': {
1360
+ 'extends': 'forDerivatives',
1361
+ },
1362
+ 'inverse': {
1363
+ 'extends': 'forDerivatives',
1364
+ },
1365
+ },
1366
+ 'future': {
1367
+ 'linear': {
1368
+ 'extends': 'forDerivatives',
1369
+ },
1370
+ 'inverse': {
1371
+ 'extends': 'forDerivatives',
1372
+ },
1373
+ },
1374
+ },
1253
1375
  })
1254
1376
 
1255
1377
  def fetch_status(self, params={}):
@@ -3864,11 +3986,11 @@ class htx(Exchange, ImplicitAPI):
3864
3986
  'status': '0', # support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled
3865
3987
  }
3866
3988
  response = None
3867
- stop = self.safe_bool_2(params, 'stop', 'trigger')
3989
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
3868
3990
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
3869
3991
  trailing = self.safe_bool(params, 'trailing', False)
3870
3992
  params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
3871
- if stop or stopLossTakeProfit or trailing:
3993
+ if trigger or stopLossTakeProfit or trailing:
3872
3994
  if limit is not None:
3873
3995
  request['page_size'] = limit
3874
3996
  request['contract_code'] = market['id']
@@ -3885,7 +4007,7 @@ class htx(Exchange, ImplicitAPI):
3885
4007
  marginMode, params = self.handle_margin_mode_and_params('fetchContractOrders', params)
3886
4008
  marginMode = 'cross' if (marginMode is None) else marginMode
3887
4009
  if marginMode == 'isolated':
3888
- if stop:
4010
+ if trigger:
3889
4011
  response = self.contractPrivatePostLinearSwapApiV1SwapTriggerHisorders(self.extend(request, params))
3890
4012
  elif stopLossTakeProfit:
3891
4013
  response = self.contractPrivatePostLinearSwapApiV1SwapTpslHisorders(self.extend(request, params))
@@ -3894,7 +4016,7 @@ class htx(Exchange, ImplicitAPI):
3894
4016
  else:
3895
4017
  response = self.contractPrivatePostLinearSwapApiV3SwapHisorders(self.extend(request, params))
3896
4018
  elif marginMode == 'cross':
3897
- if stop:
4019
+ if trigger:
3898
4020
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerHisorders(self.extend(request, params))
3899
4021
  elif stopLossTakeProfit:
3900
4022
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders(self.extend(request, params))
@@ -3904,7 +4026,7 @@ class htx(Exchange, ImplicitAPI):
3904
4026
  response = self.contractPrivatePostLinearSwapApiV3SwapCrossHisorders(self.extend(request, params))
3905
4027
  elif market['inverse']:
3906
4028
  if market['swap']:
3907
- if stop:
4029
+ if trigger:
3908
4030
  response = self.contractPrivatePostSwapApiV1SwapTriggerHisorders(self.extend(request, params))
3909
4031
  elif stopLossTakeProfit:
3910
4032
  response = self.contractPrivatePostSwapApiV1SwapTpslHisorders(self.extend(request, params))
@@ -3914,7 +4036,7 @@ class htx(Exchange, ImplicitAPI):
3914
4036
  response = self.contractPrivatePostSwapApiV3SwapHisorders(self.extend(request, params))
3915
4037
  elif market['future']:
3916
4038
  request['symbol'] = market['settleId']
3917
- if stop:
4039
+ if trigger:
3918
4040
  response = self.contractPrivatePostApiV1ContractTriggerHisorders(self.extend(request, params))
3919
4041
  elif stopLossTakeProfit:
3920
4042
  response = self.contractPrivatePostApiV1ContractTpslHisorders(self.extend(request, params))
@@ -4090,7 +4212,7 @@ class htx(Exchange, ImplicitAPI):
4090
4212
  :param int [since]: the earliest time in ms to fetch orders for
4091
4213
  :param int [limit]: the maximum number of order structures to retrieve
4092
4214
  :param dict [params]: extra parameters specific to the exchange API endpoint
4093
- :param bool [params.stop]: *contract only* if the orders are stop trigger orders or not
4215
+ :param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
4094
4216
  :param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
4095
4217
  :param int [params.until]: the latest time in ms to fetch entries for
4096
4218
  :param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
@@ -4156,7 +4278,7 @@ class htx(Exchange, ImplicitAPI):
4156
4278
  :param int [since]: the earliest time in ms to fetch open orders for
4157
4279
  :param int [limit]: the maximum number of open order structures to retrieve
4158
4280
  :param dict [params]: extra parameters specific to the exchange API endpoint
4159
- :param bool [params.stop]: *contract only* if the orders are stop trigger orders or not
4281
+ :param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
4160
4282
  :param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
4161
4283
  :param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
4162
4284
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -4194,7 +4316,7 @@ class htx(Exchange, ImplicitAPI):
4194
4316
  if limit is not None:
4195
4317
  request['page_size'] = limit
4196
4318
  request['contract_code'] = market['id']
4197
- stop = self.safe_bool_2(params, 'stop', 'trigger')
4319
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
4198
4320
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
4199
4321
  trailing = self.safe_bool(params, 'trailing', False)
4200
4322
  params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
@@ -4203,7 +4325,7 @@ class htx(Exchange, ImplicitAPI):
4203
4325
  marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
4204
4326
  marginMode = 'cross' if (marginMode is None) else marginMode
4205
4327
  if marginMode == 'isolated':
4206
- if stop:
4328
+ if trigger:
4207
4329
  response = self.contractPrivatePostLinearSwapApiV1SwapTriggerOpenorders(self.extend(request, params))
4208
4330
  elif stopLossTakeProfit:
4209
4331
  response = self.contractPrivatePostLinearSwapApiV1SwapTpslOpenorders(self.extend(request, params))
@@ -4212,7 +4334,7 @@ class htx(Exchange, ImplicitAPI):
4212
4334
  else:
4213
4335
  response = self.contractPrivatePostLinearSwapApiV1SwapOpenorders(self.extend(request, params))
4214
4336
  elif marginMode == 'cross':
4215
- if stop:
4337
+ if trigger:
4216
4338
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOpenorders(self.extend(request, params))
4217
4339
  elif stopLossTakeProfit:
4218
4340
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders(self.extend(request, params))
@@ -4222,7 +4344,7 @@ class htx(Exchange, ImplicitAPI):
4222
4344
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossOpenorders(self.extend(request, params))
4223
4345
  elif market['inverse']:
4224
4346
  if market['swap']:
4225
- if stop:
4347
+ if trigger:
4226
4348
  response = self.contractPrivatePostSwapApiV1SwapTriggerOpenorders(self.extend(request, params))
4227
4349
  elif stopLossTakeProfit:
4228
4350
  response = self.contractPrivatePostSwapApiV1SwapTpslOpenorders(self.extend(request, params))
@@ -4232,7 +4354,7 @@ class htx(Exchange, ImplicitAPI):
4232
4354
  response = self.contractPrivatePostSwapApiV1SwapOpenorders(self.extend(request, params))
4233
4355
  elif market['future']:
4234
4356
  request['symbol'] = market['settleId']
4235
- if stop:
4357
+ if trigger:
4236
4358
  response = self.contractPrivatePostApiV1ContractTriggerOpenorders(self.extend(request, params))
4237
4359
  elif stopLossTakeProfit:
4238
4360
  response = self.contractPrivatePostApiV1ContractTpslOpenorders(self.extend(request, params))
@@ -4958,7 +5080,7 @@ class htx(Exchange, ImplicitAPI):
4958
5080
  if triggerPrice is None:
4959
5081
  stopOrderTypes = self.safe_value(options, 'stopOrderTypes', {})
4960
5082
  if orderType in stopOrderTypes:
4961
- raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice for a stop order')
5083
+ raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice for a trigger order')
4962
5084
  else:
4963
5085
  defaultOperator = 'lte' if (side == 'sell') else 'gte'
4964
5086
  stopOperator = self.safe_string(params, 'operator', defaultOperator)
@@ -5394,7 +5516,7 @@ class htx(Exchange, ImplicitAPI):
5394
5516
  :param str id: order id
5395
5517
  :param str symbol: unified symbol of the market the order was made in
5396
5518
  :param dict [params]: extra parameters specific to the exchange API endpoint
5397
- :param boolean [params.stop]: *contract only* if the order is a stop trigger order or not
5519
+ :param boolean [params.trigger]: *contract only* if the order is a trigger trigger order or not
5398
5520
  :param boolean [params.stopLossTakeProfit]: *contract only* if the order is a stop-loss or take-profit order
5399
5521
  :param boolean [params.trailing]: *contract only* set to True if you want to cancel a trailing order
5400
5522
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -5440,7 +5562,7 @@ class htx(Exchange, ImplicitAPI):
5440
5562
  request['symbol'] = market['settleId']
5441
5563
  else:
5442
5564
  request['contract_code'] = market['id']
5443
- stop = self.safe_bool_2(params, 'stop', 'trigger')
5565
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5444
5566
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
5445
5567
  trailing = self.safe_bool(params, 'trailing', False)
5446
5568
  params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
@@ -5449,7 +5571,7 @@ class htx(Exchange, ImplicitAPI):
5449
5571
  marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
5450
5572
  marginMode = 'cross' if (marginMode is None) else marginMode
5451
5573
  if marginMode == 'isolated':
5452
- if stop:
5574
+ if trigger:
5453
5575
  response = self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
5454
5576
  elif stopLossTakeProfit:
5455
5577
  response = self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
@@ -5458,7 +5580,7 @@ class htx(Exchange, ImplicitAPI):
5458
5580
  else:
5459
5581
  response = self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
5460
5582
  elif marginMode == 'cross':
5461
- if stop:
5583
+ if trigger:
5462
5584
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
5463
5585
  elif stopLossTakeProfit:
5464
5586
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
@@ -5468,7 +5590,7 @@ class htx(Exchange, ImplicitAPI):
5468
5590
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
5469
5591
  elif market['inverse']:
5470
5592
  if market['swap']:
5471
- if stop:
5593
+ if trigger:
5472
5594
  response = self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
5473
5595
  elif stopLossTakeProfit:
5474
5596
  response = self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
@@ -5477,7 +5599,7 @@ class htx(Exchange, ImplicitAPI):
5477
5599
  else:
5478
5600
  response = self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
5479
5601
  elif market['future']:
5480
- if stop:
5602
+ if trigger:
5481
5603
  response = self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
5482
5604
  elif stopLossTakeProfit:
5483
5605
  response = self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
@@ -5517,7 +5639,7 @@ class htx(Exchange, ImplicitAPI):
5517
5639
  :param str[] ids: order ids
5518
5640
  :param str symbol: unified market symbol, default is None
5519
5641
  :param dict [params]: extra parameters specific to the exchange API endpoint
5520
- :param bool [params.stop]: *contract only* if the orders are stop trigger orders or not
5642
+ :param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
5521
5643
  :param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
5522
5644
  :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
5523
5645
  """
@@ -5567,7 +5689,7 @@ class htx(Exchange, ImplicitAPI):
5567
5689
  request['symbol'] = market['settleId']
5568
5690
  else:
5569
5691
  request['contract_code'] = market['id']
5570
- stop = self.safe_bool_2(params, 'stop', 'trigger')
5692
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5571
5693
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
5572
5694
  params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trigger'])
5573
5695
  if market['linear']:
@@ -5575,14 +5697,14 @@ class htx(Exchange, ImplicitAPI):
5575
5697
  marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
5576
5698
  marginMode = 'cross' if (marginMode is None) else marginMode
5577
5699
  if marginMode == 'isolated':
5578
- if stop:
5700
+ if trigger:
5579
5701
  response = self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
5580
5702
  elif stopLossTakeProfit:
5581
5703
  response = self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
5582
5704
  else:
5583
5705
  response = self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
5584
5706
  elif marginMode == 'cross':
5585
- if stop:
5707
+ if trigger:
5586
5708
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
5587
5709
  elif stopLossTakeProfit:
5588
5710
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
@@ -5590,14 +5712,14 @@ class htx(Exchange, ImplicitAPI):
5590
5712
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
5591
5713
  elif market['inverse']:
5592
5714
  if market['swap']:
5593
- if stop:
5715
+ if trigger:
5594
5716
  response = self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
5595
5717
  elif stopLossTakeProfit:
5596
5718
  response = self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
5597
5719
  else:
5598
5720
  response = self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
5599
5721
  elif market['future']:
5600
- if stop:
5722
+ if trigger:
5601
5723
  response = self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
5602
5724
  elif stopLossTakeProfit:
5603
5725
  response = self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
@@ -5718,7 +5840,7 @@ class htx(Exchange, ImplicitAPI):
5718
5840
  cancel all open orders
5719
5841
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
5720
5842
  :param dict [params]: extra parameters specific to the exchange API endpoint
5721
- :param boolean [params.stop]: *contract only* if the orders are stop trigger orders or not
5843
+ :param boolean [params.trigger]: *contract only* if the orders are trigger trigger orders or not
5722
5844
  :param boolean [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
5723
5845
  :param boolean [params.trailing]: *contract only* set to True if you want to cancel all trailing orders
5724
5846
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -5770,7 +5892,7 @@ class htx(Exchange, ImplicitAPI):
5770
5892
  if market['future']:
5771
5893
  request['symbol'] = market['settleId']
5772
5894
  request['contract_code'] = market['id']
5773
- stop = self.safe_bool_2(params, 'stop', 'trigger')
5895
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5774
5896
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
5775
5897
  trailing = self.safe_bool(params, 'trailing', False)
5776
5898
  params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
@@ -5779,7 +5901,7 @@ class htx(Exchange, ImplicitAPI):
5779
5901
  marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
5780
5902
  marginMode = 'cross' if (marginMode is None) else marginMode
5781
5903
  if marginMode == 'isolated':
5782
- if stop:
5904
+ if trigger:
5783
5905
  response = self.contractPrivatePostLinearSwapApiV1SwapTriggerCancelall(self.extend(request, params))
5784
5906
  elif stopLossTakeProfit:
5785
5907
  response = self.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(self.extend(request, params))
@@ -5788,7 +5910,7 @@ class htx(Exchange, ImplicitAPI):
5788
5910
  else:
5789
5911
  response = self.contractPrivatePostLinearSwapApiV1SwapCancelall(self.extend(request, params))
5790
5912
  elif marginMode == 'cross':
5791
- if stop:
5913
+ if trigger:
5792
5914
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancelall(self.extend(request, params))
5793
5915
  elif stopLossTakeProfit:
5794
5916
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(self.extend(request, params))
@@ -5798,7 +5920,7 @@ class htx(Exchange, ImplicitAPI):
5798
5920
  response = self.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(self.extend(request, params))
5799
5921
  elif market['inverse']:
5800
5922
  if market['swap']:
5801
- if stop:
5923
+ if trigger:
5802
5924
  response = self.contractPrivatePostSwapApiV1SwapTriggerCancelall(self.extend(request, params))
5803
5925
  elif stopLossTakeProfit:
5804
5926
  response = self.contractPrivatePostSwapApiV1SwapTpslCancelall(self.extend(request, params))
@@ -5807,7 +5929,7 @@ class htx(Exchange, ImplicitAPI):
5807
5929
  else:
5808
5930
  response = self.contractPrivatePostSwapApiV1SwapCancelall(self.extend(request, params))
5809
5931
  elif market['future']:
5810
- if stop:
5932
+ if trigger:
5811
5933
  response = self.contractPrivatePostApiV1ContractTriggerCancelall(self.extend(request, params))
5812
5934
  elif stopLossTakeProfit:
5813
5935
  response = self.contractPrivatePostApiV1ContractTpslCancelall(self.extend(request, params))
ccxt/kucoin.py CHANGED
@@ -576,6 +576,7 @@ class kucoin(Exchange, ImplicitAPI):
576
576
  '400008': NotSupported,
577
577
  '400100': InsufficientFunds, # {"msg":"account.available.amount","code":"400100"} or {"msg":"Withdrawal amount is below the minimum requirement.","code":"400100"}
578
578
  '400200': InvalidOrder, # {"code":"400200","msg":"Forbidden to place an order"}
579
+ '400330': InvalidOrder, # {"msg":"Order price can't deviate from NAV by 50%","code":"400330"}
579
580
  '400350': InvalidOrder, # {"code":"400350","msg":"Upper limit for holding: 10,000USDT, you can still buy 10,000USDT worth of coin."}
580
581
  '400370': InvalidOrder, # {"code":"400370","msg":"Max. price: 0.02500000000000000000"}
581
582
  '400400': BadRequest, # Parameter error
ccxt/mexc.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.mexc import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, DepositAddress, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currencies, Currency, DepositAddress, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -132,8 +132,8 @@ class mexc(Exchange, ImplicitAPI):
132
132
  'fetchTickers': True,
133
133
  'fetchTime': True,
134
134
  'fetchTrades': True,
135
- 'fetchTradingFee': None,
136
- 'fetchTradingFees': True,
135
+ 'fetchTradingFee': True,
136
+ 'fetchTradingFees': False,
137
137
  'fetchTradingLimits': None,
138
138
  'fetchTransactionFee': 'emulated',
139
139
  'fetchTransactionFees': True,
@@ -206,6 +206,7 @@ class mexc(Exchange, ImplicitAPI):
206
206
  'allOrders': 10,
207
207
  'account': 10,
208
208
  'myTrades': 10,
209
+ 'tradeFee': 10,
209
210
  'sub-account/list': 1,
210
211
  'sub-account/apiKey': 1,
211
212
  'capital/config/getall': 10,
@@ -3425,34 +3426,44 @@ class mexc(Exchange, ImplicitAPI):
3425
3426
  })
3426
3427
  return result
3427
3428
 
3428
- def fetch_trading_fees(self, params={}) -> TradingFees:
3429
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
3429
3430
  """
3430
- fetch the trading fees for multiple markets
3431
+ fetch the trading fees for a market
3431
3432
 
3432
- https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3433
- https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3433
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-mx-deduct-status
3434
3434
 
3435
+ :param str symbol: unified market symbol
3435
3436
  :param dict [params]: extra parameters specific to the exchange API endpoint
3436
- :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
3437
+ :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
3437
3438
  """
3438
3439
  self.load_markets()
3439
- response = self.fetch_account_helper('spot', params)
3440
- makerFee = self.safe_string(response, 'makerCommission')
3441
- takerFee = self.safe_string(response, 'takerCommission')
3442
- makerFee = Precise.string_div(makerFee, '1000')
3443
- takerFee = Precise.string_div(takerFee, '1000')
3444
- result: dict = {}
3445
- for i in range(0, len(self.symbols)):
3446
- symbol = self.symbols[i]
3447
- result[symbol] = {
3448
- 'symbol': symbol,
3449
- 'maker': self.parse_number(makerFee),
3450
- 'taker': self.parse_number(takerFee),
3451
- 'percentage': True,
3452
- 'tierBased': False,
3453
- 'info': response,
3454
- }
3455
- return result
3440
+ market = self.market(symbol)
3441
+ if not market['spot']:
3442
+ raise BadRequest(self.id + ' fetchTradingFee() supports spot markets only')
3443
+ request: dict = {
3444
+ 'symbol': market['id'],
3445
+ }
3446
+ response = self.spotPrivateGetTradeFee(self.extend(request, params))
3447
+ #
3448
+ # {
3449
+ # "data":{
3450
+ # "makerCommission":0.003000000000000000,
3451
+ # "takerCommission":0.003000000000000000
3452
+ # },
3453
+ # "code":0,
3454
+ # "msg":"success",
3455
+ # "timestamp":1669109672717
3456
+ # }
3457
+ #
3458
+ data = self.safe_dict(response, 'data', {})
3459
+ return {
3460
+ 'info': data,
3461
+ 'symbol': symbol,
3462
+ 'maker': self.safe_number(data, 'makerCommission'),
3463
+ 'taker': self.safe_number(data, 'takerCommission'),
3464
+ 'percentage': None,
3465
+ 'tierBased': None,
3466
+ }
3456
3467
 
3457
3468
  def custom_parse_balance(self, response, marketType) -> Balances:
3458
3469
  #
ccxt/okx.py CHANGED
@@ -2242,6 +2242,7 @@ class okx(Exchange, ImplicitAPI):
2242
2242
  :param int [since]: timestamp in ms of the earliest trade to fetch
2243
2243
  :param int [limit]: the maximum amount of trades to fetch
2244
2244
  :param dict [params]: extra parameters specific to the exchange API endpoint
2245
+ :param str [params.method]: 'publicGetMarketTrades' or 'publicGetMarketHistoryTrades' default is 'publicGetMarketTrades'
2245
2246
  :param boolean [params.paginate]: *only applies to publicGetMarketHistoryTrades* default False, when True will automatically paginate by calling self endpoint multiple times
2246
2247
  :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
2247
2248
  """