ccxt 4.4.95__py2.py3-none-any.whl → 4.4.97__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.
Files changed (110) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/binance.py +3 -0
  3. ccxt/abstract/binancecoinm.py +3 -0
  4. ccxt/abstract/binanceus.py +3 -0
  5. ccxt/abstract/binanceusdm.py +3 -0
  6. ccxt/abstract/foxbit.py +26 -0
  7. ccxt/abstract/hyperliquid.py +1 -1
  8. ccxt/abstract/phemex.py +1 -0
  9. ccxt/apex.py +3 -3
  10. ccxt/ascendex.py +2 -2
  11. ccxt/async_support/__init__.py +3 -1
  12. ccxt/async_support/apex.py +3 -3
  13. ccxt/async_support/ascendex.py +2 -2
  14. ccxt/async_support/base/exchange.py +10 -5
  15. ccxt/async_support/base/ws/future.py +5 -3
  16. ccxt/async_support/binance.py +90 -34
  17. ccxt/async_support/binancecoinm.py +5 -1
  18. ccxt/async_support/binanceus.py +3 -1
  19. ccxt/async_support/binanceusdm.py +3 -1
  20. ccxt/async_support/bingx.py +1 -1
  21. ccxt/async_support/bitget.py +30 -143
  22. ccxt/async_support/bitmart.py +2 -2
  23. ccxt/async_support/bitrue.py +13 -8
  24. ccxt/async_support/bybit.py +14 -5
  25. ccxt/async_support/coinbaseexchange.py +4 -2
  26. ccxt/async_support/coinbaseinternational.py +2 -2
  27. ccxt/async_support/coinspot.py +36 -1
  28. ccxt/async_support/cryptocom.py +78 -3
  29. ccxt/async_support/cryptomus.py +41 -1
  30. ccxt/async_support/defx.py +1 -1
  31. ccxt/async_support/derive.py +1 -1
  32. ccxt/async_support/ellipx.py +40 -0
  33. ccxt/async_support/exmo.py +1 -1
  34. ccxt/async_support/foxbit.py +1935 -0
  35. ccxt/async_support/gate.py +1 -2
  36. ccxt/async_support/hashkey.py +39 -0
  37. ccxt/async_support/hyperliquid.py +42 -27
  38. ccxt/async_support/independentreserve.py +35 -0
  39. ccxt/async_support/indodax.py +34 -0
  40. ccxt/async_support/kucoin.py +3 -2
  41. ccxt/async_support/kucoinfutures.py +3 -2
  42. ccxt/async_support/latoken.py +42 -0
  43. ccxt/async_support/luno.py +36 -0
  44. ccxt/async_support/mercado.py +34 -0
  45. ccxt/async_support/mexc.py +31 -32
  46. ccxt/async_support/modetrade.py +3 -3
  47. ccxt/async_support/okcoin.py +1 -1
  48. ccxt/async_support/okx.py +10 -3
  49. ccxt/async_support/onetrading.py +1 -1
  50. ccxt/async_support/oxfun.py +2 -1
  51. ccxt/async_support/paradex.py +2 -2
  52. ccxt/async_support/phemex.py +36 -31
  53. ccxt/async_support/vertex.py +3 -2
  54. ccxt/async_support/woo.py +6 -2
  55. ccxt/async_support/woofipro.py +2 -2
  56. ccxt/base/decimal_to_precision.py +16 -10
  57. ccxt/base/errors.py +6 -0
  58. ccxt/base/exchange.py +60 -17
  59. ccxt/binance.py +90 -34
  60. ccxt/binancecoinm.py +5 -1
  61. ccxt/binanceus.py +3 -1
  62. ccxt/binanceusdm.py +3 -1
  63. ccxt/bingx.py +1 -1
  64. ccxt/bitget.py +30 -143
  65. ccxt/bitmart.py +2 -2
  66. ccxt/bitrue.py +13 -8
  67. ccxt/bybit.py +14 -5
  68. ccxt/coinbaseexchange.py +4 -2
  69. ccxt/coinbaseinternational.py +2 -2
  70. ccxt/coinspot.py +36 -1
  71. ccxt/cryptocom.py +78 -3
  72. ccxt/cryptomus.py +41 -1
  73. ccxt/defx.py +1 -1
  74. ccxt/derive.py +1 -1
  75. ccxt/ellipx.py +40 -0
  76. ccxt/exmo.py +1 -1
  77. ccxt/foxbit.py +1935 -0
  78. ccxt/gate.py +1 -2
  79. ccxt/hashkey.py +39 -0
  80. ccxt/hyperliquid.py +42 -27
  81. ccxt/independentreserve.py +35 -0
  82. ccxt/indodax.py +34 -0
  83. ccxt/kucoin.py +3 -2
  84. ccxt/kucoinfutures.py +3 -2
  85. ccxt/latoken.py +42 -0
  86. ccxt/luno.py +36 -0
  87. ccxt/mercado.py +34 -0
  88. ccxt/mexc.py +31 -32
  89. ccxt/modetrade.py +3 -3
  90. ccxt/okcoin.py +1 -1
  91. ccxt/okx.py +10 -3
  92. ccxt/onetrading.py +1 -1
  93. ccxt/oxfun.py +2 -1
  94. ccxt/paradex.py +2 -2
  95. ccxt/phemex.py +36 -31
  96. ccxt/pro/__init__.py +1 -1
  97. ccxt/pro/binancecoinm.py +3 -1
  98. ccxt/pro/binanceus.py +3 -1
  99. ccxt/pro/binanceusdm.py +3 -1
  100. ccxt/pro/bybit.py +33 -1
  101. ccxt/test/tests_async.py +15 -0
  102. ccxt/test/tests_sync.py +15 -0
  103. ccxt/vertex.py +3 -2
  104. ccxt/woo.py +6 -2
  105. ccxt/woofipro.py +2 -2
  106. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/METADATA +19 -19
  107. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/RECORD +110 -107
  108. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/LICENSE.txt +0 -0
  109. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/WHEEL +0 -0
  110. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/top_level.txt +0 -0
@@ -32,6 +32,9 @@ class mercado(Exchange, ImplicitAPI):
32
32
  'future': False,
33
33
  'option': False,
34
34
  'addMargin': False,
35
+ 'borrowCrossMargin': False,
36
+ 'borrowIsolatedMargin': False,
37
+ 'borrowMargin': False,
35
38
  'cancelOrder': True,
36
39
  'closeAllPositions': False,
37
40
  'closePosition': False,
@@ -41,29 +44,54 @@ class mercado(Exchange, ImplicitAPI):
41
44
  'createStopLimitOrder': False,
42
45
  'createStopMarketOrder': False,
43
46
  'createStopOrder': False,
47
+ 'fetchAllGreeks': False,
44
48
  'fetchBalance': True,
49
+ 'fetchBorrowInterest': False,
50
+ 'fetchBorrowRate': False,
51
+ 'fetchBorrowRateHistories': False,
45
52
  'fetchBorrowRateHistory': False,
53
+ 'fetchBorrowRates': False,
54
+ 'fetchBorrowRatesPerSymbol': False,
46
55
  'fetchCrossBorrowRate': False,
47
56
  'fetchCrossBorrowRates': False,
48
57
  'fetchDepositAddress': False,
49
58
  'fetchDepositAddresses': False,
50
59
  'fetchDepositAddressesByNetwork': False,
51
60
  'fetchFundingHistory': False,
61
+ 'fetchFundingInterval': False,
62
+ 'fetchFundingIntervals': False,
52
63
  'fetchFundingRate': False,
53
64
  'fetchFundingRateHistory': False,
54
65
  'fetchFundingRates': False,
66
+ 'fetchGreeks': False,
55
67
  'fetchIndexOHLCV': False,
56
68
  'fetchIsolatedBorrowRate': False,
57
69
  'fetchIsolatedBorrowRates': False,
70
+ 'fetchIsolatedPositions': False,
58
71
  'fetchLeverage': False,
72
+ 'fetchLeverages': False,
59
73
  'fetchLeverageTiers': False,
74
+ 'fetchLiquidations': False,
75
+ 'fetchLongShortRatio': False,
76
+ 'fetchLongShortRatioHistory': False,
77
+ 'fetchMarginAdjustmentHistory': False,
60
78
  'fetchMarginMode': False,
79
+ 'fetchMarginModes': False,
80
+ 'fetchMarketLeverageTiers': False,
61
81
  'fetchMarkets': True,
62
82
  'fetchMarkOHLCV': False,
83
+ 'fetchMarkPrice': False,
84
+ 'fetchMarkPrices': False,
85
+ 'fetchMyLiquidations': False,
86
+ 'fetchMySettlementHistory': False,
63
87
  'fetchMyTrades': 'emulated',
64
88
  'fetchOHLCV': True,
89
+ 'fetchOpenInterest': False,
65
90
  'fetchOpenInterestHistory': False,
91
+ 'fetchOpenInterests': False,
66
92
  'fetchOpenOrders': True,
93
+ 'fetchOption': False,
94
+ 'fetchOptionChain': False,
67
95
  'fetchOrder': True,
68
96
  'fetchOrderBook': True,
69
97
  'fetchOrders': True,
@@ -75,13 +103,19 @@ class mercado(Exchange, ImplicitAPI):
75
103
  'fetchPositionsHistory': False,
76
104
  'fetchPositionsRisk': False,
77
105
  'fetchPremiumIndexOHLCV': False,
106
+ 'fetchSettlementHistory': False,
78
107
  'fetchTicker': True,
79
108
  'fetchTickers': False,
80
109
  'fetchTrades': True,
81
110
  'fetchTradingFee': False,
82
111
  'fetchTradingFees': False,
112
+ 'fetchUnderlyingAssets': False,
113
+ 'fetchVolatilityHistory': False,
83
114
  'reduceMargin': False,
115
+ 'repayCrossMargin': False,
116
+ 'repayIsolatedMargin': False,
84
117
  'setLeverage': False,
118
+ 'setMargin': False,
85
119
  'setMarginMode': False,
86
120
  'setPositionMode': False,
87
121
  'withdraw': True,
@@ -449,6 +449,7 @@ class mexc(Exchange, ImplicitAPI):
449
449
  },
450
450
  },
451
451
  },
452
+ 'useCcxtTradeId': True,
452
453
  'timeframes': {
453
454
  'spot': {
454
455
  '1m': '1m',
@@ -1695,8 +1696,8 @@ class mexc(Exchange, ImplicitAPI):
1695
1696
  'cost': self.safe_string(trade, 'commission'),
1696
1697
  'currency': self.safe_currency_code(feeAsset),
1697
1698
  }
1698
- if id is None:
1699
- id = self.synthetic_trade_id(market, timestamp, side, amountString, priceString, type, takerOrMaker)
1699
+ if id is None and self.safe_bool(self.options, 'useCcxtTradeId', True):
1700
+ id = self.create_ccxt_trade_id(timestamp, side, amountString, priceString, takerOrMaker)
1700
1701
  return self.safe_trade({
1701
1702
  'id': id,
1702
1703
  'order': orderId,
@@ -1713,23 +1714,6 @@ class mexc(Exchange, ImplicitAPI):
1713
1714
  'info': trade,
1714
1715
  }, market)
1715
1716
 
1716
- def synthetic_trade_id(self, market=None, timestamp=None, side=None, amount=None, price=None, orderType=None, takerOrMaker=None):
1717
- # TODO: can be unified method? self approach is being used by multiple exchanges(mexc, woo-coinsbit, dydx, ...)
1718
- id = ''
1719
- if timestamp is not None:
1720
- id = self.number_to_string(timestamp) + '-' + self.safe_string(market, 'id', '_')
1721
- if side is not None:
1722
- id += '-' + side
1723
- if amount is not None:
1724
- id += '-' + self.number_to_string(amount)
1725
- if price is not None:
1726
- id += '-' + self.number_to_string(price)
1727
- if takerOrMaker is not None:
1728
- id += '-' + takerOrMaker
1729
- if orderType is not None:
1730
- id += '-' + orderType
1731
- return id
1732
-
1733
1717
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1734
1718
  """
1735
1719
 
@@ -4652,11 +4636,14 @@ class mexc(Exchange, ImplicitAPI):
4652
4636
  # "network": "TRX",
4653
4637
  # "status": "5",
4654
4638
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4655
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4639
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4656
4640
  # "insertTime": "1664805021000",
4657
4641
  # "unlockConfirm": "200",
4658
4642
  # "confirmTimes": "203",
4659
- # "memo": "xxyy1122"
4643
+ # "memo": "xxyy1122",
4644
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4645
+ # "updateTime": "1664805621000",
4646
+ # "netWork: "TRX"
4660
4647
  # }
4661
4648
  # ]
4662
4649
  #
@@ -4697,7 +4684,7 @@ class mexc(Exchange, ImplicitAPI):
4697
4684
  # [
4698
4685
  # {
4699
4686
  # "id": "adcd1c8322154de691b815eedcd10c42",
4700
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4687
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4701
4688
  # "coin": "USDC-MATIC",
4702
4689
  # "network": "MATIC",
4703
4690
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4708,7 +4695,11 @@ class mexc(Exchange, ImplicitAPI):
4708
4695
  # "confirmNo": null,
4709
4696
  # "applyTime": "1664882739000",
4710
4697
  # "remark": '',
4711
- # "memo": null
4698
+ # "memo": null,
4699
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4700
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4701
+ # "updateTime": "1664882799000",
4702
+ # "netWork: "MATIC"
4712
4703
  # }
4713
4704
  # ]
4714
4705
  #
@@ -4724,18 +4715,21 @@ class mexc(Exchange, ImplicitAPI):
4724
4715
  # "network": "TRX",
4725
4716
  # "status": "5",
4726
4717
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4727
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4718
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4728
4719
  # "insertTime": "1664805021000",
4729
4720
  # "unlockConfirm": "200",
4730
4721
  # "confirmTimes": "203",
4731
- # "memo": "xxyy1122"
4722
+ # "memo": "xxyy1122",
4723
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4724
+ # "updateTime": "1664805621000",
4725
+ # "netWork: "TRX"
4732
4726
  # }
4733
4727
  #
4734
4728
  # fetchWithdrawals
4735
4729
  #
4736
4730
  # {
4737
4731
  # "id": "adcd1c8322154de691b815eedcd10c42",
4738
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4732
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4739
4733
  # "coin": "USDC-MATIC",
4740
4734
  # "network": "MATIC",
4741
4735
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4745,8 +4739,12 @@ class mexc(Exchange, ImplicitAPI):
4745
4739
  # "transactionFee": "1",
4746
4740
  # "confirmNo": null,
4747
4741
  # "applyTime": "1664882739000",
4748
- # "remark": '',
4749
- # "memo": null
4742
+ # "remark": "",
4743
+ # "memo": null,
4744
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4745
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4746
+ # "updateTime": "1664882799000",
4747
+ # "netWork: "MATIC"
4750
4748
  # }
4751
4749
  #
4752
4750
  # withdraw
@@ -4758,6 +4756,7 @@ class mexc(Exchange, ImplicitAPI):
4758
4756
  id = self.safe_string(transaction, 'id')
4759
4757
  type = 'deposit' if (id is None) else 'withdrawal'
4760
4758
  timestamp = self.safe_integer_2(transaction, 'insertTime', 'applyTime')
4759
+ updated = self.safe_integer(transaction, 'updateTime')
4761
4760
  currencyId = None
4762
4761
  currencyWithNetwork = self.safe_string(transaction, 'coin')
4763
4762
  if currencyWithNetwork is not None:
@@ -4770,7 +4769,7 @@ class mexc(Exchange, ImplicitAPI):
4770
4769
  status = self.parse_transaction_status_by_type(self.safe_string(transaction, 'status'), type)
4771
4770
  amountString = self.safe_string(transaction, 'amount')
4772
4771
  address = self.safe_string(transaction, 'address')
4773
- txid = self.safe_string(transaction, 'txId')
4772
+ txid = self.safe_string_2(transaction, 'transHash', 'txId')
4774
4773
  fee = None
4775
4774
  feeCostString = self.safe_string(transaction, 'transactionFee')
4776
4775
  if feeCostString is not None:
@@ -4798,8 +4797,8 @@ class mexc(Exchange, ImplicitAPI):
4798
4797
  'amount': self.parse_number(amountString),
4799
4798
  'currency': code,
4800
4799
  'status': status,
4801
- 'updated': None,
4802
- 'comment': None,
4800
+ 'updated': updated,
4801
+ 'comment': self.safe_string(transaction, 'remark'),
4803
4802
  'internal': None,
4804
4803
  'fee': fee,
4805
4804
  }
@@ -5705,7 +5704,7 @@ class mexc(Exchange, ImplicitAPI):
5705
5704
  #
5706
5705
  # {success: True, code: '0'}
5707
5706
  #
5708
- return self.parse_leverage(response, market)
5707
+ return self.parse_leverage(response, market) # tmp revert type
5709
5708
 
5710
5709
  def nonce(self):
5711
5710
  return self.milliseconds() - self.safe_integer(self.options, 'timeDifference', 0)
@@ -29,7 +29,7 @@ class modetrade(Exchange, ImplicitAPI):
29
29
  'countries': ['KY'], # Cayman Islands
30
30
  'rateLimit': 100,
31
31
  'version': 'v1',
32
- 'certified': True,
32
+ 'certified': False,
33
33
  'pro': True,
34
34
  'dex': True,
35
35
  'hostname': 'trade.mode.network',
@@ -1750,9 +1750,9 @@ class modetrade(Exchange, ImplicitAPI):
1750
1750
  # }
1751
1751
  #
1752
1752
  return [
1753
- {
1753
+ self.safe_order({
1754
1754
  'info': response,
1755
- },
1755
+ }),
1756
1756
  ]
1757
1757
 
1758
1758
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
@@ -1650,7 +1650,7 @@ class okcoin(Exchange, ImplicitAPI):
1650
1650
  advanced = self.safe_value(params, 'advanced')
1651
1651
  if trigger or advanced:
1652
1652
  orderInner = await self.cancel_orders([id], symbol, params)
1653
- return self.safe_value(orderInner, 0)
1653
+ return self.safe_dict(orderInner, 0)
1654
1654
  market = self.market(symbol)
1655
1655
  request: dict = {
1656
1656
  'instId': market['id'],
ccxt/async_support/okx.py CHANGED
@@ -1173,7 +1173,9 @@ class okx(Exchange, ImplicitAPI):
1173
1173
  },
1174
1174
  'createOrder': 'privatePostTradeBatchOrders', # or 'privatePostTradeOrder' or 'privatePostTradeOrderAlgo'
1175
1175
  'createMarketBuyOrderRequiresPrice': False,
1176
- 'fetchMarkets': ['spot', 'future', 'swap', 'option'], # spot, future, swap, option
1176
+ 'fetchMarkets': {
1177
+ 'types': ['spot', 'future', 'swap', 'option'], # spot, future, swap, option
1178
+ },
1177
1179
  'timeDifference': 0, # the difference between system clock and exchange server clock
1178
1180
  'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
1179
1181
  'defaultType': 'spot', # 'funding', 'spot', 'margin', 'future', 'swap', 'option'
@@ -1559,7 +1561,12 @@ class okx(Exchange, ImplicitAPI):
1559
1561
  """
1560
1562
  if self.options['adjustForTimeDifference']:
1561
1563
  await self.load_time_difference()
1562
- types = self.safe_list(self.options, 'fetchMarkets', [])
1564
+ types = ['spot', 'future', 'swap', 'option']
1565
+ fetchMarketsOption = self.safe_dict(self.options, 'fetchMarkets')
1566
+ if fetchMarketsOption is not None:
1567
+ types = self.safe_list(fetchMarketsOption, 'types', types)
1568
+ else:
1569
+ types = self.safe_list(self.options, 'fetchMarkets', types) # backward-support
1563
1570
  promises = []
1564
1571
  result = []
1565
1572
  for i in range(0, len(types)):
@@ -3325,7 +3332,7 @@ class okx(Exchange, ImplicitAPI):
3325
3332
  trailing = self.safe_bool(params, 'trailing', False)
3326
3333
  if trigger or trailing:
3327
3334
  orderInner = await self.cancel_orders([id], symbol, params)
3328
- return self.safe_value(orderInner, 0)
3335
+ return self.safe_dict(orderInner, 0)
3329
3336
  await self.load_markets()
3330
3337
  market = self.market(symbol)
3331
3338
  request: dict = {
@@ -1321,7 +1321,7 @@ class onetrading(Exchange, ImplicitAPI):
1321
1321
  # "a10e9bd1-8f72-4cfe-9f1b-7f1c8a9bd8ee"
1322
1322
  # ]
1323
1323
  #
1324
- return response
1324
+ return [self.safe_order({'info': response})]
1325
1325
 
1326
1326
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
1327
1327
  """
@@ -2585,7 +2585,8 @@ class oxfun(Exchange, ImplicitAPI):
2585
2585
  # "data": {"notice": "No working orders found"}
2586
2586
  # }
2587
2587
  #
2588
- return await self.privateDeleteV3OrdersCancelAll(self.extend(request, params))
2588
+ response = await self.privateDeleteV3OrdersCancelAll(self.extend(request, params))
2589
+ return [self.safe_order({'info': response})]
2589
2590
 
2590
2591
  async def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
2591
2592
  """
@@ -1249,7 +1249,7 @@ class paradex(Exchange, ImplicitAPI):
1249
1249
  cancelReason = self.safe_string(order, 'cancel_reason')
1250
1250
  status = self.safe_string(order, 'status')
1251
1251
  if cancelReason is not None:
1252
- if cancelReason == 'NOT_ENOUGH_MARGIN':
1252
+ if cancelReason == 'NOT_ENOUGH_MARGIN' or cancelReason == 'ORDER_EXCEEDS_POSITION_LIMIT':
1253
1253
  status = 'rejected'
1254
1254
  else:
1255
1255
  status = 'canceled'
@@ -1527,7 +1527,7 @@ class paradex(Exchange, ImplicitAPI):
1527
1527
  #
1528
1528
  # if success, no response...
1529
1529
  #
1530
- return response
1530
+ return [self.safe_order({'info': response})]
1531
1531
 
1532
1532
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
1533
1533
  """
@@ -282,6 +282,7 @@ class phemex(Exchange, ImplicitAPI):
282
282
  # swap
283
283
  'orders/replace': 1, # ?symbol=<symbol>&orderID=<orderID>&origClOrdID=<origClOrdID>&clOrdID=<clOrdID>&price=<price>&priceEp=<priceEp>&orderQty=<orderQty>&stopPx=<stopPx>&stopPxEp=<stopPxEp>&takeProfit=<takeProfit>&takeProfitEp=<takeProfitEp>&stopLoss=<stopLoss>&stopLossEp=<stopLossEp>&pegOffsetValueEp=<pegOffsetValueEp>&pegPriceType=<pegPriceType>
284
284
  'g-orders/replace': 1, # ?symbol=<symbol>&orderID=<orderID>&origClOrdID=<origClOrdID>&clOrdID=<clOrdID>&price=<price>&priceEp=<priceEp>&orderQty=<orderQty>&stopPx=<stopPx>&stopPxEp=<stopPxEp>&takeProfit=<takeProfit>&takeProfitEp=<takeProfitEp>&stopLoss=<stopLoss>&stopLossEp=<stopLossEp>&pegOffsetValueEp=<pegOffsetValueEp>&pegPriceType=<pegPriceType>
285
+ 'g-orders/create': 1,
285
286
  'positions/leverage': 5, # ?symbol=<symbol>&leverage=<leverage>&leverageEr=<leverageEr>
286
287
  'g-positions/leverage': 5, # ?symbol=<symbol>&leverage=<leverage>&leverageEr=<leverageEr>
287
288
  'g-positions/switch-pos-mode-sync': 5, # ?symbol=<symbol>&targetPosMode=<targetPosMode>
@@ -1219,7 +1220,8 @@ class phemex(Exchange, ImplicitAPI):
1219
1220
  # 'id': 123456789, # optional request id
1220
1221
  }
1221
1222
  response = None
1222
- if market['linear'] and market['settle'] == 'USDT':
1223
+ isStableSettled = (market['settle'] == 'USDT') or (market['settle'] == 'USDC')
1224
+ if market['linear'] and isStableSettled:
1223
1225
  response = await self.v2GetMdV2Orderbook(self.extend(request, params))
1224
1226
  else:
1225
1227
  if (limit is not None) and (limit <= 30):
@@ -1351,7 +1353,8 @@ class phemex(Exchange, ImplicitAPI):
1351
1353
  }
1352
1354
  until = self.safe_integer_2(params, 'until', 'to')
1353
1355
  params = self.omit(params, ['until'])
1354
- usesSpecialFromToEndpoint = ((market['linear'] or market['settle'] == 'USDT')) and ((since is not None) or (until is not None))
1356
+ isStableSettled = (market['settle'] == 'USDT') or (market['settle'] == 'USDC')
1357
+ usesSpecialFromToEndpoint = ((market['linear'] or isStableSettled)) and ((since is not None) or (until is not None))
1355
1358
  maxLimit = 1000
1356
1359
  if usesSpecialFromToEndpoint:
1357
1360
  maxLimit = 2000
@@ -1359,7 +1362,7 @@ class phemex(Exchange, ImplicitAPI):
1359
1362
  limit = maxLimit
1360
1363
  request['limit'] = min(limit, maxLimit)
1361
1364
  response = None
1362
- if market['linear'] or market['settle'] == 'USDT':
1365
+ if market['linear'] or isStableSettled:
1363
1366
  if (until is not None) or (since is not None):
1364
1367
  candleDuration = self.parse_timeframe(timeframe)
1365
1368
  if since is not None:
@@ -1615,7 +1618,8 @@ class phemex(Exchange, ImplicitAPI):
1615
1618
  # 'id': 123456789, # optional request id
1616
1619
  }
1617
1620
  response = None
1618
- if market['linear'] and market['settle'] == 'USDT':
1621
+ isStableSettled = (market['settle'] == 'USDT') or (market['settle'] == 'USDC')
1622
+ if market['linear'] and isStableSettled:
1619
1623
  response = await self.v2GetMdV2Trade(self.extend(request, params))
1620
1624
  else:
1621
1625
  response = await self.v1GetMdTrade(self.extend(request, params))
@@ -1854,7 +1858,7 @@ class phemex(Exchange, ImplicitAPI):
1854
1858
  timestamp = self.safe_integer(trade, 'createdAt')
1855
1859
  id = self.safe_string_2(trade, 'execId', 'execID')
1856
1860
  orderId = self.safe_string(trade, 'orderID')
1857
- if market['settle'] == 'USDT':
1861
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
1858
1862
  sideId = self.safe_string_lower(trade, 'side')
1859
1863
  if (sideId == 'buy') or (sideId == 'sell'):
1860
1864
  side = sideId
@@ -2590,6 +2594,7 @@ class phemex(Exchange, ImplicitAPI):
2590
2594
  stopLossDefined = (stopLoss is not None)
2591
2595
  takeProfit = self.safe_value(params, 'takeProfit')
2592
2596
  takeProfitDefined = (takeProfit is not None)
2597
+ isStableSettled = (market['settle'] == 'USDT') or (market['settle'] == 'USDC')
2593
2598
  if clientOrderId is None:
2594
2599
  brokerId = self.safe_string(self.options, 'brokerId', 'CCXT123456')
2595
2600
  if brokerId is not None:
@@ -2599,7 +2604,7 @@ class phemex(Exchange, ImplicitAPI):
2599
2604
  params = self.omit(params, ['clOrdID', 'clientOrderId'])
2600
2605
  triggerPrice = self.safe_string_n(params, ['stopPx', 'stopPrice', 'triggerPrice'])
2601
2606
  if triggerPrice is not None:
2602
- if market['settle'] == 'USDT':
2607
+ if isStableSettled:
2603
2608
  request['stopPxRp'] = self.price_to_precision(symbol, triggerPrice)
2604
2609
  else:
2605
2610
  request['stopPxEp'] = self.to_ep(triggerPrice, market)
@@ -2648,7 +2653,7 @@ class phemex(Exchange, ImplicitAPI):
2648
2653
  posSide = 'Merged'
2649
2654
  posSide = self.capitalize(posSide)
2650
2655
  request['posSide'] = posSide
2651
- if market['settle'] == 'USDT':
2656
+ if isStableSettled:
2652
2657
  request['orderQtyRq'] = amount
2653
2658
  else:
2654
2659
  request['orderQty'] = self.parse_to_int(amount)
@@ -2676,7 +2681,7 @@ class phemex(Exchange, ImplicitAPI):
2676
2681
  stopLossTriggerPrice = self.safe_value_2(stopLoss, 'triggerPrice', 'stopPrice')
2677
2682
  if stopLossTriggerPrice is None:
2678
2683
  raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"] for a stop loss order')
2679
- if market['settle'] == 'USDT':
2684
+ if isStableSettled:
2680
2685
  request['stopLossRp'] = self.price_to_precision(symbol, stopLossTriggerPrice)
2681
2686
  else:
2682
2687
  request['stopLossEp'] = self.to_ep(stopLossTriggerPrice, market)
@@ -2690,7 +2695,7 @@ class phemex(Exchange, ImplicitAPI):
2690
2695
  takeProfitTriggerPrice = self.safe_value_2(takeProfit, 'triggerPrice', 'stopPrice')
2691
2696
  if takeProfitTriggerPrice is None:
2692
2697
  raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"] for a take profit order')
2693
- if market['settle'] == 'USDT':
2698
+ if isStableSettled:
2694
2699
  request['takeProfitRp'] = self.price_to_precision(symbol, takeProfitTriggerPrice)
2695
2700
  else:
2696
2701
  request['takeProfitEp'] = self.to_ep(takeProfitTriggerPrice, market)
@@ -2701,27 +2706,27 @@ class phemex(Exchange, ImplicitAPI):
2701
2706
  if tpLimitPrice is not None:
2702
2707
  request['tpPxRp'] = self.price_to_precision(symbol, tpLimitPrice)
2703
2708
  if (type == 'Limit') or (type == 'StopLimit') or (type == 'LimitIfTouched'):
2704
- if market['settle'] == 'USDT':
2709
+ if isStableSettled:
2705
2710
  request['priceRp'] = self.price_to_precision(symbol, price)
2706
2711
  else:
2707
2712
  priceString = self.number_to_string(price)
2708
2713
  request['priceEp'] = self.to_ep(priceString, market)
2709
2714
  takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
2710
2715
  if takeProfitPrice is not None:
2711
- if market['settle'] == 'USDT':
2716
+ if isStableSettled:
2712
2717
  request['takeProfitRp'] = self.price_to_precision(symbol, takeProfitPrice)
2713
2718
  else:
2714
2719
  request['takeProfitEp'] = self.to_ep(takeProfitPrice, market)
2715
2720
  params = self.omit(params, 'takeProfitPrice')
2716
2721
  stopLossPrice = self.safe_string(params, 'stopLossPrice')
2717
2722
  if stopLossPrice is not None:
2718
- if market['settle'] == 'USDT':
2723
+ if isStableSettled:
2719
2724
  request['stopLossRp'] = self.price_to_precision(symbol, stopLossPrice)
2720
2725
  else:
2721
2726
  request['stopLossEp'] = self.to_ep(stopLossPrice, market)
2722
2727
  params = self.omit(params, 'stopLossPrice')
2723
2728
  response = None
2724
- if market['settle'] == 'USDT':
2729
+ if isStableSettled:
2725
2730
  response = await self.privatePostGOrders(self.extend(request, params))
2726
2731
  elif market['contract']:
2727
2732
  response = await self.privatePostOrders(self.extend(request, params))
@@ -2829,13 +2834,13 @@ class phemex(Exchange, ImplicitAPI):
2829
2834
  }
2830
2835
  clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clOrdID')
2831
2836
  params = self.omit(params, ['clientOrderId', 'clOrdID'])
2832
- isUSDTSettled = (market['settle'] == 'USDT')
2837
+ isStableSettled = (market['settle'] == 'USDT') or (market['settle'] == 'USDC')
2833
2838
  if clientOrderId is not None:
2834
2839
  request['clOrdID'] = clientOrderId
2835
2840
  else:
2836
2841
  request['orderID'] = id
2837
2842
  if price is not None:
2838
- if isUSDTSettled:
2843
+ if isStableSettled:
2839
2844
  request['priceRp'] = self.price_to_precision(market['symbol'], price)
2840
2845
  else:
2841
2846
  request['priceEp'] = self.to_ep(price, market)
@@ -2845,19 +2850,19 @@ class phemex(Exchange, ImplicitAPI):
2845
2850
  if finalQty is not None:
2846
2851
  request['baseQtyEV'] = finalQty
2847
2852
  elif amount is not None:
2848
- if isUSDTSettled:
2853
+ if isStableSettled:
2849
2854
  request['orderQtyRq'] = self.amount_to_precision(market['symbol'], amount)
2850
2855
  else:
2851
2856
  request['baseQtyEV'] = self.to_ev(amount, market)
2852
2857
  triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPx', 'stopPrice'])
2853
2858
  if triggerPrice is not None:
2854
- if isUSDTSettled:
2859
+ if isStableSettled:
2855
2860
  request['stopPxRp'] = self.price_to_precision(symbol, triggerPrice)
2856
2861
  else:
2857
2862
  request['stopPxEp'] = self.to_ep(triggerPrice, market)
2858
2863
  params = self.omit(params, ['triggerPrice', 'stopPx', 'stopPrice'])
2859
2864
  response = None
2860
- if isUSDTSettled:
2865
+ if isStableSettled:
2861
2866
  posSide = self.safe_string(params, 'posSide')
2862
2867
  if posSide is None:
2863
2868
  request['posSide'] = 'Merged'
@@ -2895,7 +2900,7 @@ class phemex(Exchange, ImplicitAPI):
2895
2900
  else:
2896
2901
  request['orderID'] = id
2897
2902
  response = None
2898
- if market['settle'] == 'USDT':
2903
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
2899
2904
  posSide = self.safe_string(params, 'posSide')
2900
2905
  if posSide is None:
2901
2906
  request['posSide'] = 'Merged'
@@ -2931,7 +2936,7 @@ class phemex(Exchange, ImplicitAPI):
2931
2936
  if trigger:
2932
2937
  request['untriggerred'] = trigger
2933
2938
  response = None
2934
- if market['settle'] == 'USDT':
2939
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
2935
2940
  response = await self.privateDeleteGOrdersAll(self.extend(request, params))
2936
2941
  #
2937
2942
  # {
@@ -2991,7 +2996,7 @@ class phemex(Exchange, ImplicitAPI):
2991
2996
  else:
2992
2997
  request['orderID'] = id
2993
2998
  response = None
2994
- if market['settle'] == 'USDT':
2999
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
2995
3000
  response = await self.privateGetApiDataGFuturesOrdersByOrderId(self.extend(request, params))
2996
3001
  elif market['spot']:
2997
3002
  response = await self.privateGetApiDataSpotsOrdersByOrderId(self.extend(request, params))
@@ -3036,7 +3041,7 @@ class phemex(Exchange, ImplicitAPI):
3036
3041
  if limit is not None:
3037
3042
  request['limit'] = limit
3038
3043
  response = None
3039
- if market['settle'] == 'USDT':
3044
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
3040
3045
  request['currency'] = market['settle']
3041
3046
  response = await self.privateGetExchangeOrderV2OrderList(self.extend(request, params))
3042
3047
  elif market['swap']:
@@ -3071,7 +3076,7 @@ class phemex(Exchange, ImplicitAPI):
3071
3076
  }
3072
3077
  response = None
3073
3078
  try:
3074
- if market['settle'] == 'USDT':
3079
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
3075
3080
  response = await self.privateGetGOrdersActiveList(self.extend(request, params))
3076
3081
  elif market['swap']:
3077
3082
  response = await self.privateGetOrdersActiveList(self.extend(request, params))
@@ -3876,8 +3881,8 @@ class phemex(Exchange, ImplicitAPI):
3876
3881
  raise BadRequest(self.id + ' fetchFundingHistory() limit argument cannot exceed 200')
3877
3882
  request['limit'] = limit
3878
3883
  response = None
3879
- isUsdt = market['settle'] == 'USDT'
3880
- if isUsdt:
3884
+ isStableSettled = market['settle'] == 'USDT' or market['settle'] == 'USDC'
3885
+ if isStableSettled:
3881
3886
  response = await self.privateGetApiDataGFuturesFundingFees(self.extend(request, params))
3882
3887
  else:
3883
3888
  response = await self.privateGetApiDataFuturesFundingFees(self.extend(request, params))
@@ -3926,8 +3931,8 @@ class phemex(Exchange, ImplicitAPI):
3926
3931
  if value is None or currencyCode is None:
3927
3932
  return value
3928
3933
  # it was confirmed by phemex support, that USDT contracts use direct amounts in funding fees, while USD & INVERSE needs 'valueScale'
3929
- isUsdt = market['settle'] == 'USDT'
3930
- if not isUsdt:
3934
+ isStableSettled = market['settle'] == 'USDT' or market['settle'] == 'USDC'
3935
+ if not isStableSettled:
3931
3936
  currency = self.safe_currency(currencyCode)
3932
3937
  scale = self.safe_string(currency['info'], 'valueScale')
3933
3938
  tickPrecision = self.parse_precision(scale)
@@ -4119,8 +4124,8 @@ class phemex(Exchange, ImplicitAPI):
4119
4124
  raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
4120
4125
  await self.load_markets()
4121
4126
  market = self.market(symbol)
4122
- if not market['swap'] or market['settle'] == 'USDT':
4123
- raise BadSymbol(self.id + ' setMarginMode() supports swap(non USDT based) contracts only')
4127
+ if not market['swap'] or market['settle'] == 'USDT' or market['settle'] == 'USDC':
4128
+ raise BadSymbol(self.id + ' setMarginMode() supports swap(non USDT/USDC based) contracts only')
4124
4129
  marginMode = marginMode.lower()
4125
4130
  if marginMode != 'isolated' and marginMode != 'cross':
4126
4131
  raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
@@ -4356,7 +4361,7 @@ class phemex(Exchange, ImplicitAPI):
4356
4361
  'symbol': market['id'],
4357
4362
  }
4358
4363
  response = None
4359
- if market['settle'] == 'USDT':
4364
+ if market['settle'] == 'USDT' or market['settle'] == 'USDC':
4360
4365
  if not isHedged and longLeverageRr is None and shortLeverageRr is None:
4361
4366
  request['leverageRr'] = leverage
4362
4367
  else:
@@ -4579,7 +4584,7 @@ class phemex(Exchange, ImplicitAPI):
4579
4584
  raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
4580
4585
  await self.load_markets()
4581
4586
  market = self.market(symbol)
4582
- isUsdtSettled = market['settle'] == 'USDT'
4587
+ isUsdtSettled = market['settle'] == 'USDT' or market['settle'] == 'USDC'
4583
4588
  if not market['swap']:
4584
4589
  raise BadRequest(self.id + ' fetchFundingRateHistory() supports swap contracts only')
4585
4590
  paginate = False
@@ -2351,7 +2351,7 @@ class vertex(Exchange, ImplicitAPI):
2351
2351
  # "request_type": "execute_cancel_product_orders"
2352
2352
  # }
2353
2353
  #
2354
- return response
2354
+ return [self.safe_order({'info': response})]
2355
2355
 
2356
2356
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
2357
2357
  """
@@ -2365,7 +2365,8 @@ class vertex(Exchange, ImplicitAPI):
2365
2365
  :param dict [params]: extra parameters specific to the exchange API endpoint
2366
2366
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2367
2367
  """
2368
- return await self.cancel_orders([id], symbol, params)
2368
+ order = await self.cancel_orders([id], symbol, params)
2369
+ return self.safe_order({'info': order})
2369
2370
 
2370
2371
  async def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
2371
2372
  """