ccxt 4.3.24 → 4.3.28

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ascendex.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +24 -25
  5. package/dist/cjs/src/base/functions/number.js +10 -5
  6. package/dist/cjs/src/bingx.js +43 -7
  7. package/dist/cjs/src/bitget.js +1 -0
  8. package/dist/cjs/src/bitmart.js +65 -2
  9. package/dist/cjs/src/bybit.js +3 -3
  10. package/dist/cjs/src/coinbase.js +1 -1
  11. package/dist/cjs/src/coinex.js +44 -75
  12. package/dist/cjs/src/kraken.js +60 -7
  13. package/dist/cjs/src/krakenfutures.js +1 -1
  14. package/dist/cjs/src/phemex.js +18 -2
  15. package/dist/cjs/src/pro/binance.js +1 -1
  16. package/dist/cjs/src/pro/coinbase.js +5 -1
  17. package/dist/cjs/src/pro/cryptocom.js +9 -7
  18. package/dist/cjs/src/pro/kraken.js +6 -4
  19. package/dist/cjs/src/pro/okx.js +1 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/bitget.d.ts +1 -0
  23. package/js/src/abstract/bitmart.d.ts +1 -0
  24. package/js/src/ascendex.js +1 -1
  25. package/js/src/base/Exchange.d.ts +4 -2
  26. package/js/src/base/Exchange.js +24 -25
  27. package/js/src/base/functions/number.js +10 -5
  28. package/js/src/bingx.js +43 -7
  29. package/js/src/bitget.js +1 -0
  30. package/js/src/bitmart.d.ts +1 -0
  31. package/js/src/bitmart.js +65 -2
  32. package/js/src/bybit.js +3 -3
  33. package/js/src/coinbase.js +1 -1
  34. package/js/src/coinex.js +44 -75
  35. package/js/src/kraken.d.ts +3 -1
  36. package/js/src/kraken.js +60 -7
  37. package/js/src/krakenfutures.js +1 -1
  38. package/js/src/phemex.js +18 -2
  39. package/js/src/pro/binance.d.ts +1 -1
  40. package/js/src/pro/binance.js +1 -1
  41. package/js/src/pro/coinbase.js +5 -1
  42. package/js/src/pro/cryptocom.js +9 -7
  43. package/js/src/pro/kraken.d.ts +1 -1
  44. package/js/src/pro/kraken.js +6 -4
  45. package/js/src/pro/okx.d.ts +1 -1
  46. package/js/src/pro/okx.js +1 -1
  47. package/package.json +1 -1
package/js/src/bitmart.js CHANGED
@@ -38,7 +38,7 @@ export default class bitmart extends Exchange {
38
38
  'borrowIsolatedMargin': true,
39
39
  'cancelAllOrders': true,
40
40
  'cancelOrder': true,
41
- 'cancelOrders': false,
41
+ 'cancelOrders': true,
42
42
  'createMarketBuyOrderWithCost': true,
43
43
  'createMarketOrderWithCost': false,
44
44
  'createMarketSellOrderWithCost': false,
@@ -182,7 +182,7 @@ export default class bitmart extends Exchange {
182
182
  'spot/v2/orders': 5,
183
183
  'spot/v1/trades': 5,
184
184
  // newer order endpoint
185
- 'spot/v2/trades': 5,
185
+ 'spot/v2/trades': 4,
186
186
  'spot/v3/orders': 5,
187
187
  'spot/v2/order_detail': 1,
188
188
  // margin
@@ -226,6 +226,7 @@ export default class bitmart extends Exchange {
226
226
  'spot/v4/query/history-orders': 5,
227
227
  'spot/v4/query/trades': 5,
228
228
  'spot/v4/query/order-trades': 5,
229
+ 'spot/v4/cancel_orders': 3,
229
230
  // newer endpoint
230
231
  'spot/v3/cancel_order': 1,
231
232
  'spot/v2/batch_orders': 1,
@@ -2675,6 +2676,68 @@ export default class bitmart extends Exchange {
2675
2676
  const order = this.parseOrder(id, market);
2676
2677
  return this.extend(order, { 'id': id });
2677
2678
  }
2679
+ async cancelOrders(ids, symbol = undefined, params = {}) {
2680
+ /**
2681
+ * @method
2682
+ * @name bitmart#cancelOrders
2683
+ * @description cancel multiple orders
2684
+ * @see https://developer-pro.bitmart.com/en/spot/#cancel-batch-order-v4-signed
2685
+ * @param {string[]} ids order ids
2686
+ * @param {string} symbol unified symbol of the market the order was made in
2687
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2688
+ * @param {string[]} [params.clientOrderIds] client order ids
2689
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2690
+ */
2691
+ if (symbol === undefined) {
2692
+ throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
2693
+ }
2694
+ await this.loadMarkets();
2695
+ const market = this.market(symbol);
2696
+ if (!market['spot']) {
2697
+ throw new NotSupported(this.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted');
2698
+ }
2699
+ const clientOrderIds = this.safeList(params, 'clientOrderIds');
2700
+ params = this.omit(params, ['clientOrderIds']);
2701
+ const request = {
2702
+ 'symbol': market['id'],
2703
+ };
2704
+ if (clientOrderIds !== undefined) {
2705
+ request['clientOrderIds'] = clientOrderIds;
2706
+ }
2707
+ else {
2708
+ request['orderIds'] = ids;
2709
+ }
2710
+ const response = await this.privatePostSpotV4CancelOrders(this.extend(request, params));
2711
+ //
2712
+ // {
2713
+ // "message": "OK",
2714
+ // "code": 1000,
2715
+ // "trace": "c4edbce860164203954f7c3c81d60fc6.309.17022669632770001",
2716
+ // "data": {
2717
+ // "successIds": [
2718
+ // "213055379155243012"
2719
+ // ],
2720
+ // "failIds": [],
2721
+ // "totalCount": 1,
2722
+ // "successCount": 1,
2723
+ // "failedCount": 0
2724
+ // }
2725
+ // }
2726
+ //
2727
+ const data = this.safeDict(response, 'data', {});
2728
+ const allOrders = [];
2729
+ const successIds = this.safeList(data, 'successIds', []);
2730
+ for (let i = 0; i < successIds.length; i++) {
2731
+ const id = successIds[i];
2732
+ allOrders.push(this.safeOrder({ 'id': id, 'status': 'canceled' }, market));
2733
+ }
2734
+ const failIds = this.safeList(data, 'failIds', []);
2735
+ for (let i = 0; i < failIds.length; i++) {
2736
+ const id = failIds[i];
2737
+ allOrders.push(this.safeOrder({ 'id': id, 'status': 'failed' }, market));
2738
+ }
2739
+ return allOrders;
2740
+ }
2678
2741
  async cancelAllOrders(symbol = undefined, params = {}) {
2679
2742
  /**
2680
2743
  * @method
package/js/src/bybit.js CHANGED
@@ -2489,14 +2489,14 @@ export default class bybit extends Exchange {
2489
2489
  throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2490
2490
  }
2491
2491
  await this.loadMarkets();
2492
- if (limit === undefined) {
2493
- limit = 200;
2494
- }
2495
2492
  let paginate = false;
2496
2493
  [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2497
2494
  if (paginate) {
2498
2495
  return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 200);
2499
2496
  }
2497
+ if (limit === undefined) {
2498
+ limit = 200;
2499
+ }
2500
2500
  const request = {
2501
2501
  // 'category': '', // Product type. linear,inverse
2502
2502
  // 'symbol': '', // Symbol name
@@ -2981,7 +2981,7 @@ export default class coinbase extends Exchange {
2981
2981
  const marketId = this.safeString(order, 'product_id');
2982
2982
  const symbol = this.safeSymbol(marketId, market, '-');
2983
2983
  if (symbol !== undefined) {
2984
- market = this.market(symbol);
2984
+ market = this.safeMarket(symbol, market);
2985
2985
  }
2986
2986
  const orderConfiguration = this.safeDict(order, 'order_configuration', {});
2987
2987
  const limitGTC = this.safeDict(orderConfiguration, 'limit_limit_gtc');
package/js/src/coinex.js CHANGED
@@ -447,11 +447,16 @@ export default class coinex extends Exchange {
447
447
  'fetchDepositAddress': {
448
448
  'fillResponseFromRequest': true,
449
449
  },
450
- 'accountsById': {
450
+ 'accountsByType': {
451
451
  'spot': 'SPOT',
452
452
  'margin': 'MARGIN',
453
453
  'swap': 'FUTURES',
454
454
  },
455
+ 'accountsById': {
456
+ 'SPOT': 'spot',
457
+ 'MARGIN': 'margin',
458
+ 'FUTURES': 'swap',
459
+ },
455
460
  'networks': {
456
461
  'BEP20': 'BSC',
457
462
  'TRX': 'TRC20',
@@ -4904,9 +4909,9 @@ export default class coinex extends Exchange {
4904
4909
  await this.loadMarkets();
4905
4910
  const currency = this.currency(code);
4906
4911
  const amountToPrecision = this.currencyToPrecision(code, amount);
4907
- const accountsById = this.safeDict(this.options, 'accountsById', {});
4908
- const fromId = this.safeString(accountsById, fromAccount, fromAccount);
4909
- const toId = this.safeString(accountsById, toAccount, toAccount);
4912
+ const accountsByType = this.safeDict(this.options, 'accountsById', {});
4913
+ const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
4914
+ const toId = this.safeString(accountsByType, toAccount, toAccount);
4910
4915
  const request = {
4911
4916
  'ccy': currency['id'],
4912
4917
  'amount': amountToPrecision,
@@ -4943,6 +4948,8 @@ export default class coinex extends Exchange {
4943
4948
  '0': 'ok',
4944
4949
  'SUCCESS': 'ok',
4945
4950
  'OK': 'ok',
4951
+ 'finished': 'ok',
4952
+ 'FINISHED': 'ok',
4946
4953
  };
4947
4954
  return this.safeString(statuses, status, status);
4948
4955
  }
@@ -4968,31 +4975,29 @@ export default class coinex extends Exchange {
4968
4975
  * @method
4969
4976
  * @name coinex#fetchTransfers
4970
4977
  * @description fetch a history of internal transfers made on an account
4971
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account025_margin_transfer_history
4972
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_transfer_history
4978
+ * @see https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
4973
4979
  * @param {string} code unified currency code of the currency transferred
4974
4980
  * @param {int} [since] the earliest time in ms to fetch transfers for
4975
- * @param {int} [limit] the maximum number of transfers structures to retrieve
4981
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
4976
4982
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4983
+ * @param {string} [params.marginMode] 'cross' or 'isolated' for fetching transfers to and from your margin account
4977
4984
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4978
4985
  */
4979
4986
  await this.loadMarkets();
4980
- let currency = undefined;
4981
- const request = {
4982
- 'page': 1,
4983
- // 'limit': limit,
4984
- // 'asset': 'USDT',
4985
- // 'start_time': since,
4986
- // 'end_time': 1515806440,
4987
- // 'transfer_type': 'transfer_in', // transfer_in: from Spot to Swap Account, transfer_out: from Swap to Spot Account
4987
+ if (code === undefined) {
4988
+ throw new ArgumentsRequired(this.id + ' fetchTransfers() requires a code argument');
4989
+ }
4990
+ const currency = this.currency(code);
4991
+ let request = {
4992
+ 'ccy': currency['id'],
4988
4993
  };
4989
- const page = this.safeInteger(params, 'page');
4990
- if (page !== undefined) {
4991
- request['page'] = page;
4994
+ let marginMode = undefined;
4995
+ [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
4996
+ if (marginMode !== undefined) {
4997
+ request['transfer_type'] = 'MARGIN';
4992
4998
  }
4993
- if (code !== undefined) {
4994
- currency = this.currency(code);
4995
- request['asset'] = currency['id'];
4999
+ else {
5000
+ request['transfer_type'] = 'FUTURES';
4996
5001
  }
4997
5002
  if (since !== undefined) {
4998
5003
  request['start_time'] = since;
@@ -5000,66 +5005,30 @@ export default class coinex extends Exchange {
5000
5005
  if (limit !== undefined) {
5001
5006
  request['limit'] = limit;
5002
5007
  }
5003
- else {
5004
- request['limit'] = 100;
5005
- }
5006
- params = this.omit(params, 'page');
5007
- let marginMode = undefined;
5008
- [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
5009
- let response = undefined;
5010
- if (marginMode !== undefined) {
5011
- response = await this.v1PrivateGetMarginTransferHistory(this.extend(request, params));
5012
- }
5013
- else {
5014
- response = await this.v1PrivateGetContractTransferHistory(this.extend(request, params));
5015
- }
5016
- //
5017
- // Swap
5008
+ [request, params] = this.handleUntilOption('end_time', request, params);
5009
+ const response = await this.v2PrivateGetAssetsTransferHistory(this.extend(request, params));
5018
5010
  //
5019
5011
  // {
5020
- // "code": 0,
5021
- // "data": {
5022
- // "records": [
5023
- // {
5024
- // "amount": "10",
5025
- // "asset": "USDT",
5026
- // "transfer_type": "transfer_out",
5027
- // "created_at": 1651633422
5028
- // },
5029
- // ],
5030
- // "total": 5
5012
+ // "data": [
5013
+ // {
5014
+ // "created_at": 1715848480646,
5015
+ // "from_account_type": "SPOT",
5016
+ // "to_account_type": "FUTURES",
5017
+ // "ccy": "USDT",
5018
+ // "amount": "10",
5019
+ // "status": "finished"
5020
+ // },
5021
+ // ],
5022
+ // "pagination": {
5023
+ // "total": 8,
5024
+ // "has_next": false
5031
5025
  // },
5032
- // "message": "Success"
5033
- // }
5034
- //
5035
- // Margin
5036
- //
5037
- // {
5038
5026
  // "code": 0,
5039
- // "data": {
5040
- // "records": [
5041
- // {
5042
- // "id": 7580062,
5043
- // "updated_at": 1653684379,
5044
- // "user_id": 3620173,
5045
- // "from_account_id": 0,
5046
- // "to_account_id": 1,
5047
- // "asset": "BTC",
5048
- // "amount": "0.00160829",
5049
- // "balance": "0.00160829",
5050
- // "transfer_type": "IN",
5051
- // "status": "SUCCESS",
5052
- // "created_at": 1653684379
5053
- // }
5054
- // ],
5055
- // "total": 1
5056
- // },
5057
- // "message": "Success"
5027
+ // "message": "OK"
5058
5028
  // }
5059
5029
  //
5060
- const data = this.safeValue(response, 'data', {});
5061
- const transfers = this.safeList(data, 'records', []);
5062
- return this.parseTransfers(transfers, currency, since, limit);
5030
+ const data = this.safeList(response, 'data', []);
5031
+ return this.parseTransfers(data, currency, since, limit);
5063
5032
  }
5064
5033
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
5065
5034
  /**
@@ -56,13 +56,15 @@ export default class kraken extends Exchange {
56
56
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
57
57
  parseBalance(response: any): Balances;
58
58
  fetchBalance(params?: {}): Promise<Balances>;
59
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: number, params?: {}): Promise<Order>;
60
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
59
61
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
60
62
  findMarketByAltnameOrId(id: any): any;
61
63
  getDelistedMarketById(id: any): any;
62
64
  parseOrderStatus(status: any): string;
63
65
  parseOrderType(status: any): string;
64
66
  parseOrder(order: any, market?: Market): Order;
65
- orderRequest(method: any, symbol: any, type: any, request: any, price?: any, params?: {}): any[];
67
+ orderRequest(method: string, symbol: string, type: string, request: Dict, amount: Num, price?: Num, params?: {}): Dict[];
66
68
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
67
69
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
68
70
  fetchOrderTrades(id: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
package/js/src/kraken.js CHANGED
@@ -43,6 +43,9 @@ export default class kraken extends Exchange {
43
43
  'cancelOrder': true,
44
44
  'cancelOrders': true,
45
45
  'createDepositAddress': true,
46
+ 'createMarketBuyOrderWithCost': true,
47
+ 'createMarketOrderWithCost': false,
48
+ 'createMarketSellOrderWithCost': false,
46
49
  'createOrder': true,
47
50
  'createStopLimitOrder': true,
48
51
  'createStopMarketOrder': true,
@@ -1353,6 +1356,37 @@ export default class kraken extends Exchange {
1353
1356
  //
1354
1357
  return this.parseBalance(response);
1355
1358
  }
1359
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1360
+ /**
1361
+ * @method
1362
+ * @name kraken#createMarketOrderWithCost
1363
+ * @description create a market order by providing the symbol, side and cost
1364
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1365
+ * @param {string} symbol unified symbol of the market to create an order in (only USD markets are supported)
1366
+ * @param {string} side 'buy' or 'sell'
1367
+ * @param {float} cost how much you want to trade in units of the quote currency
1368
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1369
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1370
+ */
1371
+ await this.loadMarkets();
1372
+ // only buy orders are supported by the endpoint
1373
+ params['cost'] = cost;
1374
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
1375
+ }
1376
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1377
+ /**
1378
+ * @method
1379
+ * @name kraken#createMarketBuyOrderWithCost
1380
+ * @description create a market buy order by providing the symbol, side and cost
1381
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1382
+ * @param {string} symbol unified symbol of the market to create an order in
1383
+ * @param {float} cost how much you want to trade in units of the quote currency
1384
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1385
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1386
+ */
1387
+ await this.loadMarkets();
1388
+ return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
1389
+ }
1356
1390
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1357
1391
  /**
1358
1392
  * @method
@@ -1383,7 +1417,7 @@ export default class kraken extends Exchange {
1383
1417
  'ordertype': type,
1384
1418
  'volume': this.amountToPrecision(symbol, amount),
1385
1419
  };
1386
- const orderRequest = this.orderRequest('createOrder', symbol, type, request, price, params);
1420
+ const orderRequest = this.orderRequest('createOrder', symbol, type, request, amount, price, params);
1387
1421
  const response = await this.privatePostAddOrder(this.extend(orderRequest[0], orderRequest[1]));
1388
1422
  //
1389
1423
  // {
@@ -1689,7 +1723,7 @@ export default class kraken extends Exchange {
1689
1723
  'trades': trades,
1690
1724
  }, market);
1691
1725
  }
1692
- orderRequest(method, symbol, type, request, price = undefined, params = {}) {
1726
+ orderRequest(method, symbol, type, request, amount, price = undefined, params = {}) {
1693
1727
  const clientOrderId = this.safeString2(params, 'userref', 'clientOrderId');
1694
1728
  params = this.omit(params, ['userref', 'clientOrderId']);
1695
1729
  if (clientOrderId !== undefined) {
@@ -1704,10 +1738,25 @@ export default class kraken extends Exchange {
1704
1738
  const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
1705
1739
  const isTrailingAmountOrder = trailingAmount !== undefined;
1706
1740
  const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
1707
- if (isLimitOrder && !isTrailingAmountOrder) {
1741
+ const isMarketOrder = type === 'market';
1742
+ const cost = this.safeString(params, 'cost');
1743
+ const flags = this.safeString(params, 'oflags');
1744
+ params = this.omit(params, ['cost', 'oflags']);
1745
+ const isViqcOrder = (flags !== undefined) && (flags.indexOf('viqc') > -1); // volume in quote currency
1746
+ if (isMarketOrder && (cost !== undefined || isViqcOrder)) {
1747
+ if (cost === undefined && (amount !== undefined)) {
1748
+ request['volume'] = this.costToPrecision(symbol, this.numberToString(amount));
1749
+ }
1750
+ else {
1751
+ request['volume'] = this.costToPrecision(symbol, cost);
1752
+ }
1753
+ const extendedOflags = (flags !== undefined) ? flags + ',viqc' : 'viqc';
1754
+ request['oflags'] = extendedOflags;
1755
+ }
1756
+ else if (isLimitOrder && !isTrailingAmountOrder) {
1708
1757
  request['price'] = this.priceToPrecision(symbol, price);
1709
1758
  }
1710
- const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1759
+ const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
1711
1760
  if (isStopLossOrTakeProfitTrigger) {
1712
1761
  if (isStopLossTriggerOrder) {
1713
1762
  request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
@@ -1755,7 +1804,7 @@ export default class kraken extends Exchange {
1755
1804
  request['reduce_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
1756
1805
  }
1757
1806
  }
1758
- let close = this.safeValue(params, 'close');
1807
+ let close = this.safeDict(params, 'close');
1759
1808
  if (close !== undefined) {
1760
1809
  close = this.extend({}, close);
1761
1810
  const closePrice = this.safeValue(close, 'price');
@@ -1776,7 +1825,8 @@ export default class kraken extends Exchange {
1776
1825
  let postOnly = undefined;
1777
1826
  [postOnly, params] = this.handlePostOnly(isMarket, false, params);
1778
1827
  if (postOnly) {
1779
- request['oflags'] = 'post';
1828
+ const extendedPostFlags = (flags !== undefined) ? flags + ',post' : 'post';
1829
+ request['oflags'] = extendedPostFlags;
1780
1830
  }
1781
1831
  params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset']);
1782
1832
  return [request, params];
@@ -1814,7 +1864,7 @@ export default class kraken extends Exchange {
1814
1864
  if (amount !== undefined) {
1815
1865
  request['volume'] = this.amountToPrecision(symbol, amount);
1816
1866
  }
1817
- const orderRequest = this.orderRequest('editOrder', symbol, type, request, price, params);
1867
+ const orderRequest = this.orderRequest('editOrder', symbol, type, request, amount, price, params);
1818
1868
  const response = await this.privatePostEditOrder(this.extend(orderRequest[0], orderRequest[1]));
1819
1869
  //
1820
1870
  // {
@@ -3007,6 +3057,9 @@ export default class kraken extends Exchange {
3007
3057
  if (body.indexOf('Invalid arguments:volume') >= 0) {
3008
3058
  throw new InvalidOrder(this.id + ' ' + body);
3009
3059
  }
3060
+ if (body.indexOf('Invalid arguments:viqc') >= 0) {
3061
+ throw new InvalidOrder(this.id + ' ' + body);
3062
+ }
3010
3063
  if (body.indexOf('Rate limit exceeded') >= 0) {
3011
3064
  throw new RateLimitExceeded(this.id + ' ' + body);
3012
3065
  }
@@ -2240,7 +2240,7 @@ export default class krakenfutures extends Exchange {
2240
2240
  /**
2241
2241
  * @method
2242
2242
  * @name krakenfutures#fetchPositions
2243
- * @see https://docs.futures.kraken.com/#websocket-api-private-feeds-open-positions
2243
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-open-positions
2244
2244
  * @description Fetches current contract trading positions
2245
2245
  * @param {string[]} symbols List of unified symbols
2246
2246
  * @param {object} [params] Not used by krakenfutures
package/js/src/phemex.js CHANGED
@@ -2252,7 +2252,7 @@ export default class phemex extends Exchange {
2252
2252
  if (feeCost !== undefined) {
2253
2253
  fee = {
2254
2254
  'cost': feeCost,
2255
- 'currency': undefined,
2255
+ 'currency': this.safeCurrencyCode(this.safeString(order, 'feeCurrency')),
2256
2256
  };
2257
2257
  }
2258
2258
  const timeInForce = this.parseTimeInForce(this.safeString(order, 'timeInForce'));
@@ -2399,6 +2399,7 @@ export default class phemex extends Exchange {
2399
2399
  }
2400
2400
  const marketId = this.safeString(order, 'symbol');
2401
2401
  const symbol = this.safeSymbol(marketId, market);
2402
+ market = this.safeMarket(marketId, market);
2402
2403
  const status = this.parseOrderStatus(this.safeString(order, 'ordStatus'));
2403
2404
  const side = this.parseOrderSide(this.safeStringLower(order, 'side'));
2404
2405
  const type = this.parseOrderType(this.safeString(order, 'orderType'));
@@ -2428,6 +2429,21 @@ export default class phemex extends Exchange {
2428
2429
  }
2429
2430
  const takeProfit = this.safeString(order, 'takeProfitRp');
2430
2431
  const stopLoss = this.safeString(order, 'stopLossRp');
2432
+ const feeValue = this.omitZero(this.safeString(order, 'execFeeRv'));
2433
+ const ptFeeRv = this.omitZero(this.safeString(order, 'ptFeeRv'));
2434
+ let fee = undefined;
2435
+ if (feeValue !== undefined) {
2436
+ fee = {
2437
+ 'cost': feeValue,
2438
+ 'currency': market['quote'],
2439
+ };
2440
+ }
2441
+ else if (ptFeeRv !== undefined) {
2442
+ fee = {
2443
+ 'cost': ptFeeRv,
2444
+ 'currency': 'PT',
2445
+ };
2446
+ }
2431
2447
  return this.safeOrder({
2432
2448
  'info': order,
2433
2449
  'id': id,
@@ -2452,7 +2468,7 @@ export default class phemex extends Exchange {
2452
2468
  'cost': cost,
2453
2469
  'average': undefined,
2454
2470
  'status': status,
2455
- 'fee': undefined,
2471
+ 'fee': fee,
2456
2472
  'trades': undefined,
2457
2473
  });
2458
2474
  }
@@ -52,7 +52,7 @@ export default class binance extends binanceRest {
52
52
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
53
53
  handleOrderWs(client: Client, message: any): void;
54
54
  handleOrdersWs(client: Client, message: any): void;
55
- editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
55
+ editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
56
56
  handleEditOrderWs(client: Client, message: any): void;
57
57
  cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
58
58
  cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<any>;
@@ -2134,7 +2134,7 @@ export default class binance extends binanceRest {
2134
2134
  const orders = this.parseOrders(result);
2135
2135
  client.resolve(orders, messageHash);
2136
2136
  }
2137
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
2137
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
2138
2138
  /**
2139
2139
  * @method
2140
2140
  * @name binance#editOrderWs
@@ -249,13 +249,17 @@ export default class coinbase extends coinbaseRest {
249
249
  //
250
250
  const channel = this.safeString(message, 'channel');
251
251
  const events = this.safeValue(message, 'events', []);
252
+ const datetime = this.safeString(message, 'timestamp');
253
+ const timestamp = this.parse8601(datetime);
252
254
  const newTickers = [];
253
255
  for (let i = 0; i < events.length; i++) {
254
256
  const tickersObj = events[i];
255
- const tickers = this.safeValue(tickersObj, 'tickers', []);
257
+ const tickers = this.safeList(tickersObj, 'tickers', []);
256
258
  for (let j = 0; j < tickers.length; j++) {
257
259
  const ticker = tickers[j];
258
260
  const result = this.parseWsTicker(ticker);
261
+ result['timestamp'] = timestamp;
262
+ result['datetime'] = datetime;
259
263
  const symbol = result['symbol'];
260
264
  this.tickers[symbol] = result;
261
265
  const wsMarketId = this.safeString(ticker, 'product_id');
@@ -105,14 +105,16 @@ export default class cryptocom extends cryptocomRest {
105
105
  params['params'] = {};
106
106
  }
107
107
  let bookSubscriptionType = undefined;
108
- [bookSubscriptionType, params] = this.handleOptionAndParams2(params, 'watchOrderBook', 'watchOrderBookForSymbols', 'bookSubscriptionType', 'SNAPSHOT_AND_UPDATE');
109
- if (bookSubscriptionType !== undefined) {
110
- params['params']['bookSubscriptionType'] = bookSubscriptionType;
111
- }
108
+ let bookSubscriptionType2 = undefined;
109
+ [bookSubscriptionType, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'bookSubscriptionType', 'SNAPSHOT_AND_UPDATE');
110
+ [bookSubscriptionType2, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'bookSubscriptionType', bookSubscriptionType);
111
+ params['params']['bookSubscriptionType'] = bookSubscriptionType2;
112
112
  let bookUpdateFrequency = undefined;
113
- [bookUpdateFrequency, params] = this.handleOptionAndParams2(params, 'watchOrderBook', 'watchOrderBookForSymbols', 'bookUpdateFrequency');
114
- if (bookUpdateFrequency !== undefined) {
115
- params['params']['bookSubscriptionType'] = bookSubscriptionType;
113
+ let bookUpdateFrequency2 = undefined;
114
+ [bookUpdateFrequency, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'bookUpdateFrequency');
115
+ [bookUpdateFrequency2, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'bookUpdateFrequency', bookUpdateFrequency);
116
+ if (bookUpdateFrequency2 !== undefined) {
117
+ params['params']['bookSubscriptionType'] = bookUpdateFrequency2;
116
118
  }
117
119
  for (let i = 0; i < symbols.length; i++) {
118
120
  const symbol = symbols[i];
@@ -5,7 +5,7 @@ export default class kraken extends krakenRest {
5
5
  describe(): any;
6
6
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
7
7
  handleCreateEditOrder(client: any, message: any): void;
8
- editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
8
+ editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
9
9
  cancelOrdersWs(ids: string[], symbol?: Str, params?: {}): Promise<any>;
10
10
  cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
11
11
  handleCancelOrder(client: any, message: any): void;
@@ -137,7 +137,7 @@ export default class kraken extends krakenRest {
137
137
  'pair': market['wsId'],
138
138
  'volume': this.amountToPrecision(symbol, amount),
139
139
  };
140
- [request, params] = this.orderRequest('createOrderWs', symbol, type, request, price, params);
140
+ [request, params] = this.orderRequest('createOrderWs', symbol, type, request, amount, price, params);
141
141
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
142
142
  }
143
143
  handleCreateEditOrder(client, message) {
@@ -164,7 +164,7 @@ export default class kraken extends krakenRest {
164
164
  const messageHash = this.safeValue(message, 'reqid');
165
165
  client.resolve(order, messageHash);
166
166
  }
167
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
167
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
168
168
  /**
169
169
  * @method
170
170
  * @name kraken#editOrderWs
@@ -191,9 +191,11 @@ export default class kraken extends krakenRest {
191
191
  'reqid': requestId,
192
192
  'orderid': id,
193
193
  'pair': market['wsId'],
194
- 'volume': this.amountToPrecision(symbol, amount),
195
194
  };
196
- [request, params] = this.orderRequest('editOrderWs', symbol, type, request, price, params);
195
+ if (amount !== undefined) {
196
+ request['volume'] = this.amountToPrecision(symbol, amount);
197
+ }
198
+ [request, params] = this.orderRequest('editOrderWs', symbol, type, request, amount, price, params);
197
199
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
198
200
  }
199
201
  async cancelOrdersWs(ids, symbol = undefined, params = {}) {
@@ -36,7 +36,7 @@ export default class okx extends okxRest {
36
36
  handleMyTrades(client: Client, message: any): void;
37
37
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
38
38
  handlePlaceOrders(client: Client, message: any): void;
39
- editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
39
+ editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
40
40
  cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
41
41
  cancelOrdersWs(ids: string[], symbol?: Str, params?: {}): Promise<any>;
42
42
  cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<any>;
package/js/src/pro/okx.js CHANGED
@@ -1436,7 +1436,7 @@ export default class okx extends okxRest {
1436
1436
  const first = this.safeDict(orders, 0, {});
1437
1437
  client.resolve(first, messageHash);
1438
1438
  }
1439
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
1439
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1440
1440
  /**
1441
1441
  * @method
1442
1442
  * @name okx#editOrderWs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.24",
3
+ "version": "4.3.28",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",