ccxt 4.4.36__py2.py3-none-any.whl → 4.4.37__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.
@@ -89,6 +89,8 @@ class coinbase(Exchange, ImplicitAPI):
89
89
  'fetchDepositAddress': 'emulated',
90
90
  'fetchDepositAddresses': False,
91
91
  'fetchDepositAddressesByNetwork': True,
92
+ 'fetchDepositMethodId': True,
93
+ 'fetchDepositMethodIds': True,
92
94
  'fetchDeposits': True,
93
95
  'fetchDepositsWithdrawals': True,
94
96
  'fetchFundingHistory': False,
@@ -4103,6 +4105,90 @@ class coinbase(Exchange, ImplicitAPI):
4103
4105
  data = self.safe_dict(response, 'data', {})
4104
4106
  return self.parse_transaction(data)
4105
4107
 
4108
+ async def fetch_deposit_method_ids(self, params={}):
4109
+ """
4110
+ fetch the deposit id for a fiat currency associated with self account
4111
+
4112
+ https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpaymentmethods
4113
+
4114
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4115
+ :returns dict: an array of `deposit id structures <https://docs.ccxt.com/#/?id=deposit-id-structure>`
4116
+ """
4117
+ await self.load_markets()
4118
+ response = await self.v3PrivateGetBrokeragePaymentMethods(params)
4119
+ #
4120
+ # {
4121
+ # "payment_methods": [
4122
+ # {
4123
+ # "id": "21b39a5d-f7b46876fb2e",
4124
+ # "type": "COINBASE_FIAT_ACCOUNT",
4125
+ # "name": "CAD Wallet",
4126
+ # "currency": "CAD",
4127
+ # "verified": True,
4128
+ # "allow_buy": False,
4129
+ # "allow_sell": True,
4130
+ # "allow_deposit": False,
4131
+ # "allow_withdraw": False,
4132
+ # "created_at": "2023-06-29T19:58:46Z",
4133
+ # "updated_at": "2023-10-30T20:25:01Z"
4134
+ # }
4135
+ # ]
4136
+ # }
4137
+ #
4138
+ result = self.safe_list(response, 'payment_methods', [])
4139
+ return self.parse_deposit_method_ids(result)
4140
+
4141
+ async def fetch_deposit_method_id(self, id: str, params={}):
4142
+ """
4143
+ fetch the deposit id for a fiat currency associated with self account
4144
+
4145
+ https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpaymentmethod
4146
+
4147
+ :param str id: the deposit payment method id
4148
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4149
+ :returns dict: a `deposit id structure <https://docs.ccxt.com/#/?id=deposit-id-structure>`
4150
+ """
4151
+ await self.load_markets()
4152
+ request: dict = {
4153
+ 'payment_method_id': id,
4154
+ }
4155
+ response = await self.v3PrivateGetBrokeragePaymentMethodsPaymentMethodId(self.extend(request, params))
4156
+ #
4157
+ # {
4158
+ # "payment_method": {
4159
+ # "id": "21b39a5d-f7b46876fb2e",
4160
+ # "type": "COINBASE_FIAT_ACCOUNT",
4161
+ # "name": "CAD Wallet",
4162
+ # "currency": "CAD",
4163
+ # "verified": True,
4164
+ # "allow_buy": False,
4165
+ # "allow_sell": True,
4166
+ # "allow_deposit": False,
4167
+ # "allow_withdraw": False,
4168
+ # "created_at": "2023-06-29T19:58:46Z",
4169
+ # "updated_at": "2023-10-30T20:25:01Z"
4170
+ # }
4171
+ # }
4172
+ #
4173
+ result = self.safe_dict(response, 'payment_method', {})
4174
+ return self.parse_deposit_method_id(result)
4175
+
4176
+ def parse_deposit_method_ids(self, ids, params={}):
4177
+ result = []
4178
+ for i in range(0, len(ids)):
4179
+ id = self.extend(self.parse_deposit_method_id(ids[i]), params)
4180
+ result.append(id)
4181
+ return result
4182
+
4183
+ def parse_deposit_method_id(self, depositId):
4184
+ return {
4185
+ 'info': depositId,
4186
+ 'id': self.safe_string(depositId, 'id'),
4187
+ 'currency': self.safe_string(depositId, 'currency'),
4188
+ 'verified': self.safe_bool(depositId, 'verified'),
4189
+ 'tag': self.safe_string(depositId, 'name'),
4190
+ }
4191
+
4106
4192
  async def fetch_convert_quote(self, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
4107
4193
  """
4108
4194
  fetch a quote for converting from one currency to another
@@ -41,7 +41,7 @@ class gate(Exchange, ImplicitAPI):
41
41
  'certified': True,
42
42
  'pro': True,
43
43
  'urls': {
44
- 'logo': 'https://user-images.githubusercontent.com/1294454/31784029-0313c702-b509-11e7-9ccc-bc0da6a0e435.jpg',
44
+ 'logo': 'https://github.com/user-attachments/assets/64f988c5-07b6-4652-b5c1-679a6bf67c85',
45
45
  'doc': 'https://www.gate.io/docs/developers/apiv4/en/',
46
46
  'www': 'https://gate.io/',
47
47
  'api': {
@@ -226,6 +226,96 @@ class hyperliquid(Exchange, ImplicitAPI):
226
226
  'defaultSlippage': 0.05,
227
227
  'zeroAddress': '0x0000000000000000000000000000000000000000',
228
228
  },
229
+ 'features': {
230
+ 'default': {
231
+ 'sandbox': True,
232
+ 'createOrder': {
233
+ 'marginMode': False,
234
+ 'triggerPrice': False,
235
+ 'triggerPriceType': None,
236
+ 'triggerDirection': False,
237
+ 'stopLossPrice': False,
238
+ 'takeProfitPrice': False,
239
+ 'attachedStopLossTakeProfit': None,
240
+ 'timeInForce': {
241
+ 'GTC': True,
242
+ 'IOC': True,
243
+ 'FOK': False,
244
+ 'PO': True,
245
+ 'GTD': False,
246
+ },
247
+ 'hedged': False,
248
+ 'trailing': False,
249
+ },
250
+ 'createOrders': {
251
+ 'max': 1000,
252
+ },
253
+ 'fetchMyTrades': {
254
+ 'marginMode': False,
255
+ 'limit': 2000,
256
+ 'daysBack': None,
257
+ 'untilDays': None,
258
+ },
259
+ 'fetchOrder': {
260
+ 'marginMode': False,
261
+ 'trigger': False,
262
+ 'trailing': False,
263
+ },
264
+ 'fetchOpenOrders': {
265
+ 'marginMode': False,
266
+ 'limit': 2000,
267
+ 'trigger': False,
268
+ 'trailing': False,
269
+ },
270
+ 'fetchOrders': {
271
+ 'marginMode': False,
272
+ 'limit': 2000,
273
+ 'daysBack': None,
274
+ 'untilDays': None,
275
+ 'trigger': False,
276
+ 'trailing': False,
277
+ },
278
+ 'fetchClosedOrders': {
279
+ 'marginMode': False,
280
+ 'limit': 2000,
281
+ 'daysBackClosed': None,
282
+ 'daysBackCanceled': None,
283
+ 'untilDays': None,
284
+ 'trigger': False,
285
+ 'trailing': False,
286
+ },
287
+ 'fetchOHLCV': {
288
+ 'limit': 5000,
289
+ },
290
+ },
291
+ 'spot': {
292
+ 'extends': 'default',
293
+ },
294
+ 'forPerps': {
295
+ 'extends': 'default',
296
+ 'createOrder': {
297
+ 'stopLossPrice': True,
298
+ 'takeProfitPrice': True,
299
+ 'attachedStopLossTakeProfit': None, # todo, in two orders
300
+ },
301
+ },
302
+ 'swap': {
303
+ 'linear': {
304
+ 'extends': 'forPerps',
305
+ },
306
+ 'inverse': {
307
+ 'extends': 'forPerps',
308
+ },
309
+ },
310
+ 'future': {
311
+ 'linear': {
312
+ 'extends': 'forPerps',
313
+ },
314
+ 'inverse': {
315
+ 'extends': 'forPerps',
316
+ },
317
+ },
318
+ },
229
319
  })
230
320
 
231
321
  def set_sandbox_mode(self, enabled):
@@ -503,7 +593,7 @@ class hyperliquid(Exchange, ImplicitAPI):
503
593
  pricePrecision = self.calculate_price_precision(price, amountPrecision, 8)
504
594
  pricePrecisionStr = self.number_to_string(pricePrecision)
505
595
  # quotePrecision = self.parse_number(self.parse_precision(self.safe_string(innerQuoteTokenInfo, 'szDecimals')))
506
- baseId = self.number_to_string(i + 10000)
596
+ baseId = self.number_to_string(index + 10000)
507
597
  markets.append(self.safe_market_structure({
508
598
  'id': marketName,
509
599
  'symbol': symbol,
@@ -1192,7 +1282,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1192
1282
  signature = self.sign_message(msg, self.privateKey)
1193
1283
  return signature
1194
1284
 
1195
- def build_transfer_sig(self, message):
1285
+ def build_usd_send_sig(self, message):
1196
1286
  messageTypes: dict = {
1197
1287
  'HyperliquidTransaction:UsdSend': [
1198
1288
  {'name': 'hyperliquidChain', 'type': 'string'},
@@ -1203,6 +1293,17 @@ class hyperliquid(Exchange, ImplicitAPI):
1203
1293
  }
1204
1294
  return self.sign_user_signed_action(messageTypes, message)
1205
1295
 
1296
+ def build_usd_class_send_sig(self, message):
1297
+ messageTypes: dict = {
1298
+ 'HyperliquidTransaction:UsdClassTransfer': [
1299
+ {'name': 'hyperliquidChain', 'type': 'string'},
1300
+ {'name': 'amount', 'type': 'string'},
1301
+ {'name': 'toPerp', 'type': 'bool'},
1302
+ {'name': 'nonce', 'type': 'uint64'},
1303
+ ],
1304
+ }
1305
+ return self.sign_user_signed_action(messageTypes, message)
1306
+
1206
1307
  def build_withdraw_sig(self, message):
1207
1308
  messageTypes: dict = {
1208
1309
  'HyperliquidTransaction:Withdraw': [
@@ -2590,25 +2691,34 @@ class hyperliquid(Exchange, ImplicitAPI):
2590
2691
  # handle swap <> spot account transfer
2591
2692
  if not self.in_array(toAccount, ['spot', 'swap', 'perp']):
2592
2693
  raise NotSupported(self.id + 'transfer() only support spot <> swap transfer')
2694
+ strAmount = self.number_to_string(amount)
2593
2695
  vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
2594
2696
  params = self.omit(params, 'vaultAddress')
2697
+ if vaultAddress is not None:
2698
+ strAmount = strAmount + ' subaccount:' + vaultAddress
2595
2699
  toPerp = (toAccount == 'perp') or (toAccount == 'swap')
2596
- action: dict = {
2597
- 'type': 'spotUser',
2598
- 'classTransfer': {
2599
- 'usdc': amount,
2700
+ transferPayload: dict = {
2701
+ 'hyperliquidChain': 'Testnet' if isSandboxMode else 'Mainnet',
2702
+ 'amount': strAmount,
2703
+ 'toPerp': toPerp,
2704
+ 'nonce': nonce,
2705
+ }
2706
+ transferSig = self.build_usd_class_send_sig(transferPayload)
2707
+ transferRequest: dict = {
2708
+ 'action': {
2709
+ 'hyperliquidChain': transferPayload['hyperliquidChain'],
2710
+ 'signatureChainId': '0x66eee',
2711
+ 'type': 'usdClassTransfer',
2712
+ 'amount': strAmount,
2600
2713
  'toPerp': toPerp,
2714
+ 'nonce': nonce,
2601
2715
  },
2602
- }
2603
- signature = self.sign_l1_action(action, nonce, vaultAddress)
2604
- innerRequest: dict = {
2605
- 'action': action,
2606
2716
  'nonce': nonce,
2607
- 'signature': signature,
2717
+ 'signature': transferSig,
2608
2718
  }
2609
2719
  if vaultAddress is not None:
2610
- innerRequest['vaultAddress'] = vaultAddress
2611
- transferResponse = await self.privatePostExchange(innerRequest)
2720
+ transferRequest['vaultAddress'] = vaultAddress
2721
+ transferResponse = await self.privatePostExchange(transferRequest)
2612
2722
  return transferResponse
2613
2723
  # handle sub-account/different account transfer
2614
2724
  self.check_address(toAccount)
@@ -2622,7 +2732,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2622
2732
  'amount': self.number_to_string(amount),
2623
2733
  'time': nonce,
2624
2734
  }
2625
- sig = self.build_transfer_sig(payload)
2735
+ sig = self.build_usd_send_sig(payload)
2626
2736
  request: dict = {
2627
2737
  'action': {
2628
2738
  'hyperliquidChain': payload['hyperliquidChain'],
@@ -276,6 +276,7 @@ class paradex(Exchange, ImplicitAPI):
276
276
  'commonCurrencies': {
277
277
  },
278
278
  'options': {
279
+ 'paradexAccount': None, # add {"privateKey": A, "publicKey": B, "address": C}
279
280
  'broker': 'CCXT',
280
281
  },
281
282
  })
@@ -964,10 +965,10 @@ class paradex(Exchange, ImplicitAPI):
964
965
  }
965
966
 
966
967
  async def retrieve_account(self):
967
- self.check_required_credentials()
968
968
  cachedAccount: dict = self.safe_dict(self.options, 'paradexAccount')
969
969
  if cachedAccount is not None:
970
970
  return cachedAccount
971
+ self.check_required_credentials()
971
972
  systemConfig = await self.get_system_config()
972
973
  domain = await self.prepare_paradex_domain(True)
973
974
  messageTypes = {
@@ -1956,7 +1957,6 @@ class paradex(Exchange, ImplicitAPI):
1956
1957
  if query:
1957
1958
  url += '?' + self.urlencode(query)
1958
1959
  elif api == 'private':
1959
- self.check_required_credentials()
1960
1960
  headers = {
1961
1961
  'Accept': 'application/json',
1962
1962
  'PARADEX-PARTNER': self.safe_string(self.options, 'broker', 'CCXT'),
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.36'
7
+ __version__ = '4.4.37'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2804,9 +2804,13 @@ class Exchange(object):
2804
2804
  if value is not None:
2805
2805
  featuresObj['createOrder']['stopLoss'] = value
2806
2806
  featuresObj['createOrder']['takeProfit'] = value
2807
- # False 'hedged' for spot
2807
+ # for spot, default 'hedged' to False
2808
2808
  if marketType == 'spot':
2809
2809
  featuresObj['createOrder']['hedged'] = False
2810
+ # default 'GTC' to True
2811
+ gtcValue = self.safe_bool(featuresObj['createOrder']['timeInForce'], 'gtc')
2812
+ if gtcValue is None:
2813
+ featuresObj['createOrder']['timeInForce']['gtc'] = True
2810
2814
  return featuresObj
2811
2815
 
2812
2816
  def orderbook_checksum_message(self, symbol: Str):