ccxt 4.4.23 → 4.4.25

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 (42) hide show
  1. package/README.md +110 -110
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +4 -3
  5. package/dist/cjs/src/binance.js +1 -1
  6. package/dist/cjs/src/bitmex.js +8 -7
  7. package/dist/cjs/src/bybit.js +41 -4
  8. package/dist/cjs/src/coincatch.js +1 -1
  9. package/dist/cjs/src/coinex.js +46 -25
  10. package/dist/cjs/src/gate.js +195 -59
  11. package/dist/cjs/src/hitbtc.js +6 -12
  12. package/dist/cjs/src/htx.js +16 -16
  13. package/dist/cjs/src/hyperliquid.js +1 -1
  14. package/dist/cjs/src/kucoin.js +18 -8
  15. package/dist/cjs/src/pro/kucoin.js +2 -1
  16. package/dist/cjs/src/pro/onetrading.js +2 -1
  17. package/dist/cjs/src/woofipro.js +1 -1
  18. package/dist/cjs/src/xt.js +5 -1
  19. package/dist/cjs/src/yobit.js +1 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/kucoin.d.ts +1 -0
  23. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  24. package/js/src/base/Exchange.js +4 -3
  25. package/js/src/binance.js +1 -1
  26. package/js/src/bitmex.js +8 -7
  27. package/js/src/bybit.js +41 -4
  28. package/js/src/coincatch.js +1 -1
  29. package/js/src/coinex.js +46 -25
  30. package/js/src/gate.d.ts +13 -1
  31. package/js/src/gate.js +195 -59
  32. package/js/src/hitbtc.d.ts +0 -1
  33. package/js/src/hitbtc.js +6 -12
  34. package/js/src/htx.js +16 -16
  35. package/js/src/hyperliquid.js +1 -1
  36. package/js/src/kucoin.js +18 -8
  37. package/js/src/pro/kucoin.js +2 -1
  38. package/js/src/pro/onetrading.js +2 -1
  39. package/js/src/woofipro.js +1 -1
  40. package/js/src/xt.js +5 -1
  41. package/js/src/yobit.js +1 -1
  42. package/package.json +1 -1
package/js/src/htx.js CHANGED
@@ -5256,17 +5256,17 @@ export default class htx extends Exchange {
5256
5256
  let orderType = type.replace('buy-', '');
5257
5257
  orderType = orderType.replace('sell-', '');
5258
5258
  const options = this.safeValue(this.options, market['type'], {});
5259
- const stopPrice = this.safeString2(params, 'stopPrice', 'stop-price');
5260
- if (stopPrice === undefined) {
5259
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'stop-price']);
5260
+ if (triggerPrice === undefined) {
5261
5261
  const stopOrderTypes = this.safeValue(options, 'stopOrderTypes', {});
5262
5262
  if (orderType in stopOrderTypes) {
5263
- throw new ArgumentsRequired(this.id + ' createOrder() requires a stopPrice or a stop-price parameter for a stop order');
5263
+ throw new ArgumentsRequired(this.id + ' createOrder() requires a triggerPrice for a stop order');
5264
5264
  }
5265
5265
  }
5266
5266
  else {
5267
5267
  const defaultOperator = (side === 'sell') ? 'lte' : 'gte';
5268
5268
  const stopOperator = this.safeString(params, 'operator', defaultOperator);
5269
- request['stop-price'] = this.priceToPrecision(symbol, stopPrice);
5269
+ request['stop-price'] = this.priceToPrecision(symbol, triggerPrice);
5270
5270
  request['operator'] = stopOperator;
5271
5271
  if ((orderType === 'limit') || (orderType === 'limit-fok')) {
5272
5272
  orderType = 'stop-' + orderType;
@@ -5343,7 +5343,7 @@ export default class htx extends Exchange {
5343
5343
  if (orderType in limitOrderTypes) {
5344
5344
  request['price'] = this.priceToPrecision(symbol, price);
5345
5345
  }
5346
- params = this.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
5346
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
5347
5347
  return this.extend(request, params);
5348
5348
  }
5349
5349
  createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
@@ -5381,16 +5381,16 @@ export default class htx extends Exchange {
5381
5381
  else if (timeInForce === 'IOC') {
5382
5382
  type = 'ioc';
5383
5383
  }
5384
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
5384
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
5385
5385
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
5386
5386
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
5387
5387
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
5388
5388
  const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
5389
5389
  const isTrailingPercentOrder = trailingPercent !== undefined;
5390
- const isStop = triggerPrice !== undefined;
5390
+ const isTrigger = triggerPrice !== undefined;
5391
5391
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
5392
5392
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
5393
- if (isStop) {
5393
+ if (isTrigger) {
5394
5394
  const triggerType = this.safeString2(params, 'triggerType', 'trigger_type', 'le');
5395
5395
  request['trigger_type'] = triggerType;
5396
5396
  request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
@@ -5443,7 +5443,7 @@ export default class htx extends Exchange {
5443
5443
  const broker = this.safeValue(this.options, 'broker', {});
5444
5444
  const brokerId = this.safeString(broker, 'id');
5445
5445
  request['channel_code'] = brokerId;
5446
- params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
5446
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
5447
5447
  return this.extend(request, params);
5448
5448
  }
5449
5449
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -5466,7 +5466,7 @@ export default class htx extends Exchange {
5466
5466
  * @param {float} amount how much you want to trade in units of the base currency
5467
5467
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
5468
5468
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5469
- * @param {float} [params.stopPrice] the price a trigger order is triggered at
5469
+ * @param {float} [params.triggerPrice] the price a trigger order is triggered at
5470
5470
  * @param {string} [params.triggerType] *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
5471
5471
  * @param {float} [params.stopLossPrice] *contract only* the price a stop-loss order is triggered at
5472
5472
  * @param {float} [params.takeProfitPrice] *contract only* the price a take-profit order is triggered at
@@ -5482,12 +5482,12 @@ export default class htx extends Exchange {
5482
5482
  */
5483
5483
  await this.loadMarkets();
5484
5484
  const market = this.market(symbol);
5485
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
5485
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
5486
5486
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
5487
5487
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
5488
5488
  const trailingPercent = this.safeNumber(params, 'trailingPercent');
5489
5489
  const isTrailingPercentOrder = trailingPercent !== undefined;
5490
- const isStop = triggerPrice !== undefined;
5490
+ const isTrigger = triggerPrice !== undefined;
5491
5491
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
5492
5492
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
5493
5493
  let response = undefined;
@@ -5505,7 +5505,7 @@ export default class htx extends Exchange {
5505
5505
  [marginMode, contractRequest] = this.handleMarginModeAndParams('createOrder', contractRequest);
5506
5506
  marginMode = (marginMode === undefined) ? 'cross' : marginMode;
5507
5507
  if (marginMode === 'isolated') {
5508
- if (isStop) {
5508
+ if (isTrigger) {
5509
5509
  response = await this.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(contractRequest);
5510
5510
  }
5511
5511
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -5519,7 +5519,7 @@ export default class htx extends Exchange {
5519
5519
  }
5520
5520
  }
5521
5521
  else if (marginMode === 'cross') {
5522
- if (isStop) {
5522
+ if (isTrigger) {
5523
5523
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(contractRequest);
5524
5524
  }
5525
5525
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -5539,7 +5539,7 @@ export default class htx extends Exchange {
5539
5539
  throw new ArgumentsRequired(this.id + ' createOrder () requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse markets');
5540
5540
  }
5541
5541
  if (market['swap']) {
5542
- if (isStop) {
5542
+ if (isTrigger) {
5543
5543
  response = await this.contractPrivatePostSwapApiV1SwapTriggerOrder(contractRequest);
5544
5544
  }
5545
5545
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -5553,7 +5553,7 @@ export default class htx extends Exchange {
5553
5553
  }
5554
5554
  }
5555
5555
  else if (market['future']) {
5556
- if (isStop) {
5556
+ if (isTrigger) {
5557
5557
  response = await this.contractPrivatePostApiV1ContractTriggerOrder(contractRequest);
5558
5558
  }
5559
5559
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -2257,7 +2257,7 @@ export default class hyperliquid extends Exchange {
2257
2257
  'notional': this.safeNumber(entry, 'positionValue'),
2258
2258
  'leverage': this.safeNumber(leverage, 'value'),
2259
2259
  'collateral': this.safeNumber(entry, 'marginUsed'),
2260
- 'initialMargin': initialMargin,
2260
+ 'initialMargin': this.parseNumber(initialMargin),
2261
2261
  'maintenanceMargin': undefined,
2262
2262
  'initialMarginPercentage': undefined,
2263
2263
  'maintenanceMarginPercentage': undefined,
package/js/src/kucoin.js CHANGED
@@ -206,6 +206,7 @@ export default class kucoin extends Exchange {
206
206
  'market/orderbook/level{level}': 3,
207
207
  'market/orderbook/level2': 3,
208
208
  'market/orderbook/level3': 3,
209
+ 'hf/accounts/opened': 2,
209
210
  'hf/orders/active': 2,
210
211
  'hf/orders/active/symbols': 2,
211
212
  'hf/margin/order/active/symbols': 2,
@@ -635,7 +636,7 @@ export default class kucoin extends Exchange {
635
636
  'FUD': 'FTX Users\' Debt',
636
637
  },
637
638
  'options': {
638
- 'hf': false,
639
+ 'hf': undefined,
639
640
  'version': 'v1',
640
641
  'symbolSeparator': '-',
641
642
  'fetchMyTradesMethod': 'private_get_fills',
@@ -1073,7 +1074,8 @@ export default class kucoin extends Exchange {
1073
1074
  // "enableTrading": true
1074
1075
  // },
1075
1076
  //
1076
- const requestMarginables = this.checkRequiredCredentials(false);
1077
+ const credentialsSet = this.checkRequiredCredentials(false);
1078
+ const requestMarginables = credentialsSet && this.safeBool(params, 'marginables', true);
1077
1079
  if (requestMarginables) {
1078
1080
  promises.push(this.privateGetMarginSymbols(params)); // cross margin symbols
1079
1081
  //
@@ -1138,6 +1140,10 @@ export default class kucoin extends Exchange {
1138
1140
  // }
1139
1141
  //
1140
1142
  }
1143
+ if (credentialsSet) {
1144
+ // load migration status for account
1145
+ promises.push(this.loadMigrationStatus());
1146
+ }
1141
1147
  const responses = await Promise.all(promises);
1142
1148
  const symbolsData = this.safeList(responses[0], 'data');
1143
1149
  const crossData = requestMarginables ? this.safeDict(responses[1], 'data', {}) : {};
@@ -1225,15 +1231,19 @@ export default class kucoin extends Exchange {
1225
1231
  return result;
1226
1232
  }
1227
1233
  async loadMigrationStatus(force = false) {
1228
- if (!('hfMigrated' in this.options) || (this.options['hfMigrated'] === undefined) || force) {
1229
- const result = await this.privateGetMigrateUserAccountStatus();
1230
- const data = this.safeDict(result, 'data', {});
1231
- const status = this.safeInteger(data, 'status');
1232
- this.options['hfMigrated'] = (status === 2);
1234
+ /**
1235
+ * @method
1236
+ * @name kucoin#loadMigrationStatus
1237
+ * @description loads the migration status for the account (hf or not)
1238
+ * @see https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-user-type
1239
+ */
1240
+ if (!('hf' in this.options) || (this.options['hf'] === undefined) || force) {
1241
+ const result = await this.privateGetHfAccountsOpened();
1242
+ this.options['hf'] = this.safeBool(result, 'data');
1233
1243
  }
1234
1244
  }
1235
1245
  handleHfAndParams(params = {}) {
1236
- const migrated = this.safeBool2(this.options, 'hfMigrated', 'hf', false);
1246
+ const migrated = this.safeBool(this.options, 'hf', false);
1237
1247
  let loadedHf = undefined;
1238
1248
  if (migrated !== undefined) {
1239
1249
  if (migrated) {
@@ -1180,7 +1180,8 @@ export default class kucoin extends kucoinRest {
1180
1180
  }
1181
1181
  const data = this.safeDict(message, 'data');
1182
1182
  const parsed = this.parseWsTrade(data);
1183
- this.myTrades.append(parsed);
1183
+ const myTrades = this.myTrades;
1184
+ myTrades.append(parsed);
1184
1185
  const messageHash = 'myTrades';
1185
1186
  client.resolve(this.myTrades, messageHash);
1186
1187
  const symbolSpecificMessageHash = messageHash + ':' + parsed['symbol'];
@@ -1001,7 +1001,8 @@ export default class onetrading extends onetradingRest {
1001
1001
  if (updateType === 'TRADE_SETTLED') {
1002
1002
  const parsed = this.parseTrade(update);
1003
1003
  symbol = this.safeString(parsed, 'symbol', '');
1004
- this.myTrades.append(parsed);
1004
+ const myTrades = this.myTrades;
1005
+ myTrades.append(parsed);
1005
1006
  client.resolve(this.myTrades, 'myTrades:' + symbol);
1006
1007
  client.resolve(this.myTrades, 'myTrades');
1007
1008
  }
@@ -129,7 +129,7 @@ export default class woofipro extends Exchange {
129
129
  '1y': '1y',
130
130
  },
131
131
  'urls': {
132
- 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/b1e7b348-a0fc-4605-8b7f-91176958fd69',
132
+ 'logo': 'https://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1',
133
133
  'api': {
134
134
  'public': 'https://api-evm.orderly.org',
135
135
  'private': 'https://api-evm.orderly.org',
package/js/src/xt.js CHANGED
@@ -1747,6 +1747,10 @@ export default class xt extends Exchange {
1747
1747
  market = this.safeMarket(marketId, market, '_', marketType);
1748
1748
  const symbol = market['symbol'];
1749
1749
  const timestamp = this.safeInteger(ticker, 't');
1750
+ let percentage = this.safeString2(ticker, 'cr', 'r');
1751
+ if (percentage !== undefined) {
1752
+ percentage = Precise.stringMul(percentage, '100');
1753
+ }
1750
1754
  return this.safeTicker({
1751
1755
  'symbol': symbol,
1752
1756
  'timestamp': timestamp,
@@ -1763,7 +1767,7 @@ export default class xt extends Exchange {
1763
1767
  'last': this.safeString(ticker, 'c'),
1764
1768
  'previousClose': undefined,
1765
1769
  'change': this.safeNumber(ticker, 'cv'),
1766
- 'percentage': this.safeNumber2(ticker, 'cr', 'r'),
1770
+ 'percentage': this.parseNumber(percentage),
1767
1771
  'average': undefined,
1768
1772
  'baseVolume': undefined,
1769
1773
  'quoteVolume': this.safeNumber2(ticker, 'a', 'v'),
package/js/src/yobit.js CHANGED
@@ -1176,7 +1176,7 @@ export default class yobit extends Exchange {
1176
1176
  const ids = Object.keys(trades);
1177
1177
  const result = [];
1178
1178
  for (let i = 0; i < ids.length; i++) {
1179
- const id = ids[i];
1179
+ const id = this.safeString(ids, i);
1180
1180
  const trade = this.parseTrade(this.extend(trades[id], {
1181
1181
  'trade_id': id,
1182
1182
  }), market);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.23",
3
+ "version": "4.4.25",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",