ccxt 4.4.31__py2.py3-none-any.whl → 4.4.33__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 (70) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/coinbaseexchange.py +1 -0
  3. ccxt/abstract/kraken.py +1 -0
  4. ccxt/async_support/__init__.py +1 -1
  5. ccxt/async_support/base/exchange.py +1 -1
  6. ccxt/async_support/base/ws/aiohttp_client.py +25 -3
  7. ccxt/async_support/binance.py +153 -0
  8. ccxt/async_support/bitvavo.py +0 -3
  9. ccxt/async_support/bybit.py +134 -6
  10. ccxt/async_support/cex.py +4 -2
  11. ccxt/async_support/coinbase.py +2 -22
  12. ccxt/async_support/coinbaseexchange.py +2 -1
  13. ccxt/async_support/coinex.py +2 -1
  14. ccxt/async_support/deribit.py +2 -2
  15. ccxt/async_support/gate.py +15 -2
  16. ccxt/async_support/hitbtc.py +3 -3
  17. ccxt/async_support/htx.py +1 -1
  18. ccxt/async_support/hyperliquid.py +11 -2
  19. ccxt/async_support/indodax.py +1 -1
  20. ccxt/async_support/kraken.py +3 -2
  21. ccxt/async_support/kucoin.py +5 -3
  22. ccxt/async_support/kucoinfutures.py +94 -26
  23. ccxt/async_support/lbank.py +1 -0
  24. ccxt/async_support/okx.py +94 -3
  25. ccxt/async_support/phemex.py +34 -21
  26. ccxt/async_support/wavesexchange.py +3 -0
  27. ccxt/async_support/woofipro.py +2 -2
  28. ccxt/base/exchange.py +92 -2
  29. ccxt/binance.py +153 -0
  30. ccxt/bitvavo.py +0 -3
  31. ccxt/bybit.py +134 -6
  32. ccxt/cex.py +4 -2
  33. ccxt/coinbase.py +2 -22
  34. ccxt/coinbaseexchange.py +2 -1
  35. ccxt/coinex.py +2 -1
  36. ccxt/deribit.py +2 -2
  37. ccxt/gate.py +15 -2
  38. ccxt/hitbtc.py +3 -3
  39. ccxt/htx.py +1 -1
  40. ccxt/hyperliquid.py +11 -2
  41. ccxt/indodax.py +1 -1
  42. ccxt/kraken.py +3 -2
  43. ccxt/kucoin.py +5 -3
  44. ccxt/kucoinfutures.py +94 -26
  45. ccxt/lbank.py +1 -0
  46. ccxt/okx.py +94 -3
  47. ccxt/phemex.py +34 -21
  48. ccxt/pro/__init__.py +1 -1
  49. ccxt/pro/binance.py +8 -8
  50. ccxt/pro/bitget.py +4 -4
  51. ccxt/pro/bitmart.py +2 -2
  52. ccxt/pro/bitmex.py +2 -2
  53. ccxt/pro/bitvavo.py +46 -45
  54. ccxt/pro/blofin.py +2 -2
  55. ccxt/pro/bybit.py +2 -2
  56. ccxt/pro/cryptocom.py +4 -4
  57. ccxt/pro/gate.py +4 -4
  58. ccxt/pro/hashkey.py +3 -3
  59. ccxt/pro/mexc.py +1 -2
  60. ccxt/pro/okx.py +8 -0
  61. ccxt/test/tests_async.py +3 -1
  62. ccxt/test/tests_helpers.py +1 -1
  63. ccxt/test/tests_sync.py +3 -1
  64. ccxt/wavesexchange.py +3 -0
  65. ccxt/woofipro.py +2 -2
  66. {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/METADATA +10 -4
  67. {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/RECORD +70 -70
  68. {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/LICENSE.txt +0 -0
  69. {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/WHEEL +0 -0
  70. {ccxt-4.4.31.dist-info → ccxt-4.4.33.dist-info}/top_level.txt +0 -0
@@ -734,14 +734,23 @@ class hyperliquid(Exchange, ImplicitAPI):
734
734
  https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
735
735
  https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
736
736
 
737
- :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
737
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
738
738
  :param dict [params]: extra parameters specific to the exchange API endpoint
739
+ :param str [params.type]: 'spot' or 'swap', by default fetches both
739
740
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
740
741
  """
741
742
  await self.load_markets()
742
743
  symbols = self.market_symbols(symbols)
743
744
  # at self stage, to get tickers data, we use fetchMarkets endpoints
744
- response = await self.fetch_markets(params)
745
+ response = []
746
+ type = self.safe_string(params, 'type')
747
+ params = self.omit(params, 'type')
748
+ if type == 'spot':
749
+ response = await self.fetch_spot_markets(params)
750
+ elif type == 'swap':
751
+ response = await self.fetch_swap_markets(params)
752
+ else:
753
+ response = await self.fetch_markets(params)
745
754
  # same response "fetchMarkets"
746
755
  result: dict = {}
747
756
  for i in range(0, len(response)):
@@ -29,7 +29,7 @@ class indodax(Exchange, ImplicitAPI):
29
29
  'countries': ['ID'], # Indonesia
30
30
  # 10 requests per second for making trades => 1000ms / 10 = 100ms
31
31
  # 180 requests per minute(public endpoints) = 2 requests per second => cost = (1000ms / rateLimit) / 2 = 5
32
- 'rateLimit': 100,
32
+ 'rateLimit': 50,
33
33
  'has': {
34
34
  'CORS': None,
35
35
  'spot': True,
@@ -197,6 +197,7 @@ class kraken(Exchange, ImplicitAPI):
197
197
  'AddOrder': 0,
198
198
  'AddOrderBatch': 0,
199
199
  'AddExport': 3,
200
+ 'AmendOrder': 0,
200
201
  'Balance': 3,
201
202
  'CancelAll': 3,
202
203
  'CancelAllOrdersAfter': 3,
@@ -2045,8 +2046,8 @@ class kraken(Exchange, ImplicitAPI):
2045
2046
 
2046
2047
  https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
2047
2048
 
2048
- :param str[]|None ids: list of order id
2049
- @param symbol
2049
+ :param str[] [ids]: list of order id
2050
+ :param str [symbol]: unified ccxt market symbol
2050
2051
  :param dict [params]: extra parameters specific to the kraken api endpoint
2051
2052
  :returns dict[]: a list of `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2052
2053
  """
@@ -591,6 +591,8 @@ class kucoin(Exchange, ImplicitAPI):
591
591
  '400303': PermissionDenied, # {"msg":"To enjoy the full range of our products and services, we kindly request you complete the identity verification process.","code":"400303"}
592
592
  '500000': ExchangeNotAvailable, # {"code":"500000","msg":"Internal Server Error"}
593
593
  '260220': InvalidAddress, # {"code": "260220", "msg": "deposit.address.not.exists"}
594
+ '600100': InsufficientFunds, # {"msg":"Funds below the minimum requirement.","code":"600100"}
595
+ '600101': InvalidOrder, # {"msg":"The order funds should more then 0.1 USDT.","code":"600101"}
594
596
  '900014': BadRequest, # {"code":"900014","msg":"Invalid chainId"}
595
597
  },
596
598
  'broad': {
@@ -1245,7 +1247,7 @@ class kucoin(Exchange, ImplicitAPI):
1245
1247
 
1246
1248
  async def load_migration_status(self, force: bool = False):
1247
1249
  """
1248
- @param force
1250
+ :param boolean force: load account state for non hf
1249
1251
  loads the migration status for the account(hf or not)
1250
1252
 
1251
1253
  https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-user-type
@@ -4740,8 +4742,8 @@ class kucoin(Exchange, ImplicitAPI):
4740
4742
 
4741
4743
  https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/modify-leverage-multiplier
4742
4744
 
4743
- @param leverage
4744
- :param str symbol: unified market symbol
4745
+ :param int [leverage]: New leverage multiplier. Must be greater than 1 and up to two decimal places, and cannot be less than the user's current debt leverage or greater than the system's maximum leverage
4746
+ :param str [symbol]: unified market symbol
4745
4747
  :param dict [params]: extra parameters specific to the exchange API endpoint
4746
4748
  :returns dict: response from the exchange
4747
4749
  """
@@ -1212,8 +1212,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
1212
1212
  https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
1213
1213
 
1214
1214
  :param str[] [symbols]: list of unified market symbols
1215
- @param since
1216
- @param limit
1215
+ :param int [since]: the earliest time in ms to fetch position history for
1216
+ :param int [limit]: the maximum number of entries to retrieve
1217
1217
  :param dict [params]: extra parameters specific to the exchange API endpoint
1218
1218
  :param int [params.until]: closing end time
1219
1219
  :param int [params.pageId]: page id
@@ -1404,7 +1404,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1404
1404
  """
1405
1405
  Create an order on the exchange
1406
1406
 
1407
- https://docs.kucoin.com/futures/#place-an-order
1407
+ https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
1408
1408
  https://www.kucoin.com/docs/rest/futures-trading/orders/place-take-profit-and-stop-loss-order#http-request
1409
1409
 
1410
1410
  :param str symbol: Unified CCXT market symbol
@@ -1421,8 +1421,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
1421
1421
  :param bool [params.reduceOnly]: A mark to reduce the position size only. Set to False by default. Need to set the position size when reduceOnly is True.
1422
1422
  :param str [params.timeInForce]: GTC, GTT, IOC, or FOK, default is GTC, limit orders only
1423
1423
  :param str [params.postOnly]: Post only flag, invalid when timeInForce is IOC or FOK
1424
+ :param float [params.cost]: the cost of the order in units of USDT
1424
1425
  ----------------- Exchange Specific Parameters -----------------
1425
- :param float [params.leverage]: Leverage size of the order
1426
+ :param float [params.leverage]: Leverage size of the order(mandatory param in request, default is 1)
1426
1427
  :param str [params.clientOid]: client order id, defaults to uuid if not passed
1427
1428
  :param str [params.remark]: remark for the order, length cannot exceed 100 utf8 characters
1428
1429
  :param str [params.stop]: 'up' or 'down', the direction the stopPrice is triggered from, requires stopPrice. down: Triggers when the price reaches or goes below the stopPrice. up: Triggers when the price reaches or goes above the stopPrice.
@@ -1510,17 +1511,21 @@ class kucoinfutures(kucoin, ImplicitAPI):
1510
1511
  # required param, cannot be used twice
1511
1512
  clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId', self.uuid())
1512
1513
  params = self.omit(params, ['clientOid', 'clientOrderId'])
1513
- if amount < 1:
1514
- raise InvalidOrder(self.id + ' createOrder() minimum contract order amount is 1')
1515
- preciseAmount = int(self.amount_to_precision(symbol, amount))
1516
1514
  request: dict = {
1517
1515
  'clientOid': clientOrderId,
1518
1516
  'side': side,
1519
1517
  'symbol': market['id'],
1520
1518
  'type': type, # limit or market
1521
- 'size': preciseAmount,
1522
1519
  'leverage': 1,
1523
1520
  }
1521
+ cost = self.safe_string(params, 'cost')
1522
+ params = self.omit(params, 'cost')
1523
+ if cost is not None:
1524
+ request['valueQty'] = self.cost_to_precision(symbol, cost)
1525
+ else:
1526
+ if amount < 1:
1527
+ raise InvalidOrder(self.id + ' createOrder() minimum contract order amount is 1')
1528
+ request['size'] = int(self.amount_to_precision(symbol, amount))
1524
1529
  triggerPrice, stopLossPrice, takeProfitPrice = self.handle_trigger_prices(params)
1525
1530
  stopLoss = self.safe_dict(params, 'stopLoss')
1526
1531
  takeProfit = self.safe_dict(params, 'takeProfit')
@@ -2349,6 +2354,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
2349
2354
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2350
2355
  """
2351
2356
  transfer currency internally between wallets on the same account
2357
+
2358
+ https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-main-or-trade-account
2359
+ https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-futures-account
2360
+
2352
2361
  :param str code: unified currency code
2353
2362
  :param float amount: amount to transfer
2354
2363
  :param str fromAccount: account to transfer from
@@ -2356,47 +2365,99 @@ class kucoinfutures(kucoin, ImplicitAPI):
2356
2365
  :param dict [params]: extra parameters specific to the exchange API endpoint
2357
2366
  :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
2358
2367
  """
2359
- if (toAccount != 'main' and toAccount != 'funding') or (fromAccount != 'futures' and fromAccount != 'future' and fromAccount != 'contract'):
2360
- raise BadRequest(self.id + ' transfer() only supports transfers from contract(future) account to main(funding) account')
2361
2368
  await self.load_markets()
2362
2369
  currency = self.currency(code)
2363
2370
  amountToPrecision = self.currency_to_precision(code, amount)
2364
2371
  request: dict = {
2365
- 'currency': self.safe_string(currency, 'id'), # Currency,including XBT,USDT
2372
+ 'currency': self.safe_string(currency, 'id'),
2366
2373
  'amount': amountToPrecision,
2367
2374
  }
2368
- # transfer from usdm futures wallet to spot wallet
2369
- response = await self.futuresPrivatePostTransferOut(self.extend(request, params))
2370
- #
2371
- # {
2372
- # "code": "200000",
2373
- # "data": {
2374
- # "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
2375
- # }
2376
- # }
2377
- #
2378
- data = self.safe_value(response, 'data')
2375
+ toAccountString = self.parse_transfer_type(toAccount)
2376
+ response = None
2377
+ if toAccountString == 'TRADE' or toAccountString == 'MAIN':
2378
+ request['recAccountType'] = toAccountString
2379
+ response = await self.futuresPrivatePostTransferOut(self.extend(request, params))
2380
+ #
2381
+ # {
2382
+ # "code": "200000",
2383
+ # "data": {
2384
+ # "applyId": "6738754373ceee00011ec3f8",
2385
+ # "bizNo": "6738754373ceee00011ec3f7",
2386
+ # "payAccountType": "CONTRACT",
2387
+ # "payTag": "DEFAULT",
2388
+ # "remark": "",
2389
+ # "recAccountType": "MAIN",
2390
+ # "recTag": "DEFAULT",
2391
+ # "recRemark": "",
2392
+ # "recSystem": "KUCOIN",
2393
+ # "status": "PROCESSING",
2394
+ # "currency": "USDT",
2395
+ # "amount": "5",
2396
+ # "fee": "0",
2397
+ # "sn": 1519769124846692,
2398
+ # "reason": "",
2399
+ # "createdAt": 1731753283000,
2400
+ # "updatedAt": 1731753283000
2401
+ # }
2402
+ # }
2403
+ #
2404
+ elif toAccount == 'future' or toAccount == 'swap' or toAccount == 'contract':
2405
+ request['payAccountType'] = self.parse_transfer_type(fromAccount)
2406
+ response = await self.futuresPrivatePostTransferIn(self.extend(request, params))
2407
+ #
2408
+ # {
2409
+ # "code": "200000",
2410
+ # "data": {
2411
+ # "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
2412
+ # }
2413
+ # }
2414
+ #
2415
+ else:
2416
+ raise BadRequest(self.id + ' transfer() only supports transfers between future/swap, spot and funding accounts')
2417
+ data = self.safe_dict(response, 'data', {})
2379
2418
  return self.extend(self.parse_transfer(data, currency), {
2380
2419
  'amount': self.parse_number(amountToPrecision),
2381
- 'fromAccount': 'future',
2382
- 'toAccount': 'spot',
2420
+ 'fromAccount': fromAccount,
2421
+ 'toAccount': toAccount,
2383
2422
  })
2384
2423
 
2385
2424
  def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
2386
2425
  #
2387
- # transfer
2426
+ # transfer to spot or funding account
2388
2427
  #
2389
2428
  # {
2390
2429
  # "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
2391
2430
  # }
2392
2431
  #
2432
+ # transfer to future account
2433
+ #
2434
+ # {
2435
+ # "applyId": "6738754373ceee00011ec3f8",
2436
+ # "bizNo": "6738754373ceee00011ec3f7",
2437
+ # "payAccountType": "CONTRACT",
2438
+ # "payTag": "DEFAULT",
2439
+ # "remark": "",
2440
+ # "recAccountType": "MAIN",
2441
+ # "recTag": "DEFAULT",
2442
+ # "recRemark": "",
2443
+ # "recSystem": "KUCOIN",
2444
+ # "status": "PROCESSING",
2445
+ # "currency": "USDT",
2446
+ # "amount": "5",
2447
+ # "fee": "0",
2448
+ # "sn": 1519769124846692,
2449
+ # "reason": "",
2450
+ # "createdAt": 1731753283000,
2451
+ # "updatedAt": 1731753283000
2452
+ # }
2453
+ #
2393
2454
  timestamp = self.safe_integer(transfer, 'updatedAt')
2394
2455
  return {
2395
2456
  'id': self.safe_string(transfer, 'applyId'),
2396
2457
  'timestamp': timestamp,
2397
2458
  'datetime': self.iso8601(timestamp),
2398
2459
  'currency': self.safe_currency_code(None, currency),
2399
- 'amount': None,
2460
+ 'amount': self.safe_number(transfer, 'amount'),
2400
2461
  'fromAccount': None,
2401
2462
  'toAccount': None,
2402
2463
  'status': self.safe_string(transfer, 'status'),
@@ -2409,6 +2470,13 @@ class kucoinfutures(kucoin, ImplicitAPI):
2409
2470
  }
2410
2471
  return self.safe_string(statuses, status, status)
2411
2472
 
2473
+ def parse_transfer_type(self, transferType: Str) -> Str:
2474
+ transferTypes: dict = {
2475
+ 'spot': 'TRADE',
2476
+ 'funding': 'MAIN',
2477
+ }
2478
+ return self.safe_string_upper(transferTypes, transferType, transferType)
2479
+
2412
2480
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2413
2481
  """
2414
2482
 
@@ -222,6 +222,7 @@ class lbank(Exchange, ImplicitAPI):
222
222
  },
223
223
  },
224
224
  'commonCurrencies': {
225
+ 'HIT': 'Hiver',
225
226
  'VET_ERC20': 'VEN',
226
227
  'PNT': 'Penta',
227
228
  },
ccxt/async_support/okx.py CHANGED
@@ -1200,6 +1200,97 @@ class okx(Exchange, ImplicitAPI):
1200
1200
  },
1201
1201
  'brokerId': 'e847386590ce4dBC',
1202
1202
  },
1203
+ 'features': {
1204
+ # https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
1205
+ 'default': {
1206
+ 'sandbox': True,
1207
+ 'createOrder': {
1208
+ 'triggerPrice': True,
1209
+ 'triggerPriceType': {
1210
+ 'last': True,
1211
+ 'mark': True,
1212
+ 'index': True,
1213
+ },
1214
+ 'triggerDirection': False,
1215
+ 'stopLossPrice': True,
1216
+ 'takeProfitPrice': True,
1217
+ 'marginMode': True,
1218
+ 'attachedStopLossTakeProfit': {
1219
+ 'triggerPriceType': {
1220
+ 'last': True,
1221
+ 'mark': True,
1222
+ 'index': True,
1223
+ },
1224
+ 'limitPrice': True,
1225
+ },
1226
+ 'timeInForce': {
1227
+ 'GTC': True,
1228
+ 'IOC': True,
1229
+ 'FOK': True,
1230
+ 'PO': True,
1231
+ 'GTD': False,
1232
+ },
1233
+ 'hedged': True,
1234
+ # even though the below params not unified yet, it's useful metadata for users to know that exchange supports them
1235
+ 'selfTradePrevention': True,
1236
+ 'trailing': True,
1237
+ 'twap': True,
1238
+ 'iceberg': True,
1239
+ 'oco': True,
1240
+ },
1241
+ 'createOrders': {
1242
+ 'max': 20,
1243
+ },
1244
+ 'fetchMyTrades': {
1245
+ 'daysBack': 90,
1246
+ 'limit': 100,
1247
+ 'untilDays': 10000,
1248
+ },
1249
+ 'fetchOrder': {
1250
+ 'marginMode': False,
1251
+ 'trigger': True,
1252
+ 'trailing': True,
1253
+ },
1254
+ 'fetchOpenOrders': {
1255
+ 'limit': 100,
1256
+ 'marginMode': False,
1257
+ 'trigger': True,
1258
+ 'trailing': True,
1259
+ },
1260
+ 'fetchOrders': None, # not supported
1261
+ 'fetchClosedOrders': {
1262
+ 'limit': 100,
1263
+ 'daysBackClosed': 90, # 3 months
1264
+ 'daysBackCanceled': 1 / 12, # 2 hour
1265
+ 'untilDays': None,
1266
+ 'marginMode': False,
1267
+ 'trigger': True,
1268
+ 'trailing': True,
1269
+ },
1270
+ 'fetchOHLCV': {
1271
+ 'limit': 300,
1272
+ },
1273
+ },
1274
+ 'spot': {
1275
+ 'extends': 'default',
1276
+ },
1277
+ 'swap': {
1278
+ 'linear': {
1279
+ 'extends': 'default',
1280
+ },
1281
+ 'inverse': {
1282
+ 'extends': 'default',
1283
+ },
1284
+ },
1285
+ 'future': {
1286
+ 'linear': {
1287
+ 'extends': 'default',
1288
+ },
1289
+ 'inverse': {
1290
+ 'extends': 'default',
1291
+ },
1292
+ },
1293
+ },
1203
1294
  'commonCurrencies': {
1204
1295
  # the exchange refers to ERC20 version of Aeternity(AEToken)
1205
1296
  'AE': 'AET', # https://github.com/ccxt/ccxt/issues/4981
@@ -3078,7 +3169,7 @@ class okx(Exchange, ImplicitAPI):
3078
3169
  if not isAlgoOrder:
3079
3170
  if price is not None:
3080
3171
  request['newPx'] = self.price_to_precision(symbol, price)
3081
- params = self.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit'])
3172
+ params = self.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit', 'postOnly'])
3082
3173
  return self.extend(request, params)
3083
3174
 
3084
3175
  async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
@@ -7933,8 +8024,8 @@ class okx(Exchange, ImplicitAPI):
7933
8024
 
7934
8025
  :param str [symbol]: not used by okx fetchMarginAdjustmentHistory
7935
8026
  :param str [type]: "add" or "reduce"
7936
- @param since
7937
- @param limit
8027
+ :param int [since]: the earliest time in ms to fetch margin adjustment history for
8028
+ :param int [limit]: the maximum number of entries to retrieve
7938
8029
  :param dict params: extra parameters specific to the exchange api endpoint
7939
8030
  :param boolean [params.auto]: True if fetching auto margin increases
7940
8031
  :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
@@ -504,6 +504,13 @@ class phemex(Exchange, ImplicitAPI):
504
504
  'transfer': {
505
505
  'fillResponseFromRequest': True,
506
506
  },
507
+ 'triggerPriceTypesMap': {
508
+ 'last': 'ByLastPrice',
509
+ 'mark': 'ByMarkPrice',
510
+ 'index': 'ByIndexPrice',
511
+ 'ask': 'ByAskPrice',
512
+ 'bid': 'ByBidPrice',
513
+ },
507
514
  },
508
515
  })
509
516
 
@@ -518,7 +525,7 @@ class phemex(Exchange, ImplicitAPI):
518
525
  def parse_swap_market(self, market: dict):
519
526
  #
520
527
  # {
521
- # "symbol":"BTCUSD",
528
+ # "symbol":"BTCUSD", #
522
529
  # "code":"1",
523
530
  # "type":"Perpetual",
524
531
  # "displaySymbol":"BTC / USD",
@@ -526,7 +533,7 @@ class phemex(Exchange, ImplicitAPI):
526
533
  # "markSymbol":".MBTC",
527
534
  # "fundingRateSymbol":".BTCFR",
528
535
  # "fundingRate8hSymbol":".BTCFR8H",
529
- # "contractUnderlyingAssets":"USD",
536
+ # "contractUnderlyingAssets":"USD", # or eg. `1000 SHIB`
530
537
  # "settleCurrency":"BTC",
531
538
  # "quoteCurrency":"USD",
532
539
  # "contractSize":"1 USD",
@@ -570,6 +577,7 @@ class phemex(Exchange, ImplicitAPI):
570
577
  quoteId = self.safe_string(market, 'quoteCurrency')
571
578
  settleId = self.safe_string(market, 'settleCurrency')
572
579
  base = self.safe_currency_code(baseId)
580
+ base = base.replace(' ', '') # replace space for junction codes, eg. `1000 SHIB`
573
581
  quote = self.safe_currency_code(quoteId)
574
582
  settle = self.safe_currency_code(settleId)
575
583
  inverse = False
@@ -2070,6 +2078,7 @@ class phemex(Exchange, ImplicitAPI):
2070
2078
  'PartiallyFilled': 'open',
2071
2079
  'Filled': 'closed',
2072
2080
  'Canceled': 'canceled',
2081
+ 'Suspended': 'canceled',
2073
2082
  '1': 'open',
2074
2083
  '2': 'canceled',
2075
2084
  '3': 'closed',
@@ -2532,37 +2541,31 @@ class phemex(Exchange, ImplicitAPI):
2532
2541
  if stopLossDefined:
2533
2542
  stopLossTriggerPrice = self.safe_value_2(stopLoss, 'triggerPrice', 'stopPrice')
2534
2543
  if stopLossTriggerPrice is None:
2535
- raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"], or params["stopLoss"]["stopPrice"] for a stop loss order')
2544
+ raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"] for a stop loss order')
2536
2545
  if market['settle'] == 'USDT':
2537
2546
  request['stopLossRp'] = self.price_to_precision(symbol, stopLossTriggerPrice)
2538
2547
  else:
2539
2548
  request['stopLossEp'] = self.to_ep(stopLossTriggerPrice, market)
2540
2549
  stopLossTriggerPriceType = self.safe_string_2(stopLoss, 'triggerPriceType', 'slTrigger')
2541
2550
  if stopLossTriggerPriceType is not None:
2542
- if market['settle'] == 'USDT':
2543
- if (stopLossTriggerPriceType != 'ByMarkPrice') and (stopLossTriggerPriceType != 'ByLastPrice') and (stopLossTriggerPriceType != 'ByIndexPrice') and (stopLossTriggerPriceType != 'ByAskPrice') and (stopLossTriggerPriceType != 'ByBidPrice') and (stopLossTriggerPriceType != 'ByMarkPriceLimit') and (stopLossTriggerPriceType != 'ByLastPriceLimit'):
2544
- raise InvalidOrder(self.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", "ByIndexPrice", "ByAskPrice", "ByBidPrice", "ByMarkPriceLimit", "ByLastPriceLimit" or "ByLastPrice"')
2545
- else:
2546
- if (stopLossTriggerPriceType != 'ByMarkPrice') and (stopLossTriggerPriceType != 'ByLastPrice'):
2547
- raise InvalidOrder(self.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", or "ByLastPrice"')
2548
- request['slTrigger'] = stopLossTriggerPriceType
2551
+ request['slTrigger'] = self.safe_string(self.options['triggerPriceTypesMap'], stopLossTriggerPriceType, stopLossTriggerPriceType)
2552
+ slLimitPrice = self.safe_string(stopLoss, 'price')
2553
+ if slLimitPrice is not None:
2554
+ request['slPxRp'] = self.price_to_precision(symbol, slLimitPrice)
2549
2555
  if takeProfitDefined:
2550
2556
  takeProfitTriggerPrice = self.safe_value_2(takeProfit, 'triggerPrice', 'stopPrice')
2551
2557
  if takeProfitTriggerPrice is None:
2552
- raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"], or params["takeProfit"]["stopPrice"] for a take profit order')
2558
+ raise InvalidOrder(self.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"] for a take profit order')
2553
2559
  if market['settle'] == 'USDT':
2554
2560
  request['takeProfitRp'] = self.price_to_precision(symbol, takeProfitTriggerPrice)
2555
2561
  else:
2556
2562
  request['takeProfitEp'] = self.to_ep(takeProfitTriggerPrice, market)
2557
- takeProfitTriggerPriceType = self.safe_string_2(stopLoss, 'triggerPriceType', 'tpTrigger')
2563
+ takeProfitTriggerPriceType = self.safe_string_2(takeProfit, 'triggerPriceType', 'tpTrigger')
2558
2564
  if takeProfitTriggerPriceType is not None:
2559
- if market['settle'] == 'USDT':
2560
- if (takeProfitTriggerPriceType != 'ByMarkPrice') and (takeProfitTriggerPriceType != 'ByLastPrice') and (takeProfitTriggerPriceType != 'ByIndexPrice') and (takeProfitTriggerPriceType != 'ByAskPrice') and (takeProfitTriggerPriceType != 'ByBidPrice') and (takeProfitTriggerPriceType != 'ByMarkPriceLimit') and (takeProfitTriggerPriceType != 'ByLastPriceLimit'):
2561
- raise InvalidOrder(self.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", "ByIndexPrice", "ByAskPrice", "ByBidPrice", "ByMarkPriceLimit", "ByLastPriceLimit" or "ByLastPrice"')
2562
- else:
2563
- if (takeProfitTriggerPriceType != 'ByMarkPrice') and (takeProfitTriggerPriceType != 'ByLastPrice'):
2564
- raise InvalidOrder(self.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", or "ByLastPrice"')
2565
- request['tpTrigger'] = takeProfitTriggerPriceType
2565
+ request['tpTrigger'] = self.safe_string(self.options['triggerPriceTypesMap'], takeProfitTriggerPriceType, takeProfitTriggerPriceType)
2566
+ tpLimitPrice = self.safe_string(takeProfit, 'price')
2567
+ if tpLimitPrice is not None:
2568
+ request['tpPxRp'] = self.price_to_precision(symbol, tpLimitPrice)
2566
2569
  if (type == 'Limit') or (type == 'StopLimit') or (type == 'LimitIfTouched'):
2567
2570
  if market['settle'] == 'USDT':
2568
2571
  request['priceRp'] = self.price_to_precision(symbol, price)
@@ -2713,13 +2716,13 @@ class phemex(Exchange, ImplicitAPI):
2713
2716
  request['orderQtyRq'] = self.amount_to_precision(market['symbol'], amount)
2714
2717
  else:
2715
2718
  request['baseQtyEV'] = self.to_ev(amount, market)
2716
- stopPrice = self.safe_string_2(params, 'stopPx', 'stopPrice')
2719
+ stopPrice = self.safe_string_n(params, ['triggerPrice', 'stopPx', 'stopPrice'])
2717
2720
  if stopPrice is not None:
2718
2721
  if isUSDTSettled:
2719
2722
  request['stopPxRp'] = self.price_to_precision(symbol, stopPrice)
2720
2723
  else:
2721
2724
  request['stopPxEp'] = self.to_ep(stopPrice, market)
2722
- params = self.omit(params, ['stopPx', 'stopPrice'])
2725
+ params = self.omit(params, ['triggerPrice', 'stopPx', 'stopPrice'])
2723
2726
  response = None
2724
2727
  if isUSDTSettled:
2725
2728
  posSide = self.safe_string(params, 'posSide')
@@ -3958,6 +3961,9 @@ class phemex(Exchange, ImplicitAPI):
3958
3961
  async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
3959
3962
  """
3960
3963
  set margin mode to 'cross' or 'isolated'
3964
+
3965
+ https://phemex-docs.github.io/#set-leverage
3966
+
3961
3967
  :param str marginMode: 'cross' or 'isolated'
3962
3968
  :param str symbol: unified market symbol
3963
3969
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4221,6 +4227,10 @@ class phemex(Exchange, ImplicitAPI):
4221
4227
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4222
4228
  """
4223
4229
  transfer currency internally between wallets on the same account
4230
+
4231
+ https://phemex-docs.github.io/#transfer-between-spot-and-futures
4232
+ https://phemex-docs.github.io/#universal-transfer-main-account-only-transfer-between-sub-to-main-main-to-sub-or-sub-to-sub
4233
+
4224
4234
  :param str code: unified currency code
4225
4235
  :param float amount: amount to transfer
4226
4236
  :param str fromAccount: account to transfer from
@@ -4297,6 +4307,9 @@ class phemex(Exchange, ImplicitAPI):
4297
4307
  async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
4298
4308
  """
4299
4309
  fetch a history of internal transfers made on an account
4310
+
4311
+ https://phemex-docs.github.io/#query-transfer-history
4312
+
4300
4313
  :param str code: unified currency code of the currency transferred
4301
4314
  :param int [since]: the earliest time in ms to fetch transfers for
4302
4315
  :param int [limit]: the maximum number of transfers structures to retrieve
@@ -1890,6 +1890,9 @@ class wavesexchange(Exchange, ImplicitAPI):
1890
1890
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1891
1891
  """
1892
1892
  fetch all trades made by the user
1893
+
1894
+ https://api.wavesplatform.com/v0/docs/#/transactions/searchTxsExchange
1895
+
1893
1896
  :param str symbol: unified market symbol
1894
1897
  :param int [since]: the earliest time in ms to fetch trades for
1895
1898
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -2379,8 +2379,8 @@ class woofipro(Exchange, ImplicitAPI):
2379
2379
 
2380
2380
  https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/update-leverage-setting
2381
2381
 
2382
- @param leverage
2383
- :param str symbol: unified market symbol
2382
+ :param int [leverage]: the rate of leverage
2383
+ :param str [symbol]: unified market symbol
2384
2384
  :param dict [params]: extra parameters specific to the exchange API endpoint
2385
2385
  :returns dict: response from the exchange
2386
2386
  """