ccxt 4.5.1 → 4.5.3

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 (73) hide show
  1. package/README.md +110 -112
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -9
  4. package/dist/cjs/src/ascendex.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +11 -0
  6. package/dist/cjs/src/binance.js +25 -25
  7. package/dist/cjs/src/bitget.js +2 -2
  8. package/dist/cjs/src/coincatch.js +2 -2
  9. package/dist/cjs/src/gate.js +27 -12
  10. package/dist/cjs/src/gemini.js +3 -3
  11. package/dist/cjs/src/htx.js +4 -4
  12. package/dist/cjs/src/indodax.js +11 -12
  13. package/dist/cjs/src/kucoinfutures.js +8 -8
  14. package/dist/cjs/src/mexc.js +30 -1
  15. package/dist/cjs/src/okx.js +19 -5
  16. package/dist/cjs/src/poloniex.js +1 -1
  17. package/dist/cjs/src/pro/binance.js +3 -3
  18. package/dist/cjs/src/pro/bitfinex.js +140 -0
  19. package/dist/cjs/src/pro/bitget.js +222 -42
  20. package/dist/cjs/src/pro/bitmart.js +1 -1
  21. package/dist/cjs/src/pro/bybit.js +3 -3
  22. package/dist/cjs/src/pro/gemini.js +7 -2
  23. package/dist/cjs/src/pro/hyperliquid.js +5 -0
  24. package/dist/cjs/src/pro/kraken.js +4 -6
  25. package/dist/cjs/src/pro/kucoin.js +64 -0
  26. package/dist/cjs/src/pro/mexc.js +7 -3
  27. package/dist/cjs/src/zonda.js +12 -0
  28. package/js/ccxt.d.ts +2 -11
  29. package/js/ccxt.js +2 -8
  30. package/js/src/ascendex.js +1 -1
  31. package/js/src/base/Exchange.d.ts +2 -0
  32. package/js/src/base/Exchange.js +11 -0
  33. package/js/src/binance.d.ts +1 -1
  34. package/js/src/binance.js +25 -25
  35. package/js/src/bitget.js +2 -2
  36. package/js/src/coincatch.js +2 -2
  37. package/js/src/gate.js +27 -12
  38. package/js/src/gemini.js +3 -3
  39. package/js/src/htx.js +4 -4
  40. package/js/src/indodax.js +11 -12
  41. package/js/src/kucoinfutures.js +8 -8
  42. package/js/src/mexc.d.ts +3 -0
  43. package/js/src/mexc.js +30 -1
  44. package/js/src/okx.d.ts +4 -2
  45. package/js/src/okx.js +19 -5
  46. package/js/src/poloniex.js +1 -1
  47. package/js/src/pro/binance.js +3 -3
  48. package/js/src/pro/bitfinex.d.ts +30 -0
  49. package/js/src/pro/bitfinex.js +140 -0
  50. package/js/src/pro/bitget.d.ts +10 -0
  51. package/js/src/pro/bitget.js +228 -42
  52. package/js/src/pro/bitmart.js +1 -1
  53. package/js/src/pro/bybit.d.ts +2 -2
  54. package/js/src/pro/bybit.js +3 -3
  55. package/js/src/pro/gemini.d.ts +1 -1
  56. package/js/src/pro/gemini.js +7 -2
  57. package/js/src/pro/hyperliquid.js +5 -0
  58. package/js/src/pro/kraken.js +4 -6
  59. package/js/src/pro/kucoin.d.ts +22 -0
  60. package/js/src/pro/kucoin.js +64 -0
  61. package/js/src/pro/mexc.js +7 -3
  62. package/js/src/zonda.js +12 -0
  63. package/package.json +2 -1
  64. package/js/src/abstract/ellipx.d.ts +0 -28
  65. package/js/src/abstract/ellipx.js +0 -11
  66. package/js/src/abstract/vertex.d.ts +0 -22
  67. package/js/src/abstract/vertex.js +0 -11
  68. package/js/src/ellipx.d.ts +0 -237
  69. package/js/src/ellipx.js +0 -2071
  70. package/js/src/pro/vertex.d.ts +0 -104
  71. package/js/src/pro/vertex.js +0 -999
  72. package/js/src/vertex.d.ts +0 -346
  73. package/js/src/vertex.js +0 -3146
package/js/src/gate.js CHANGED
@@ -57,14 +57,24 @@ export default class gate extends Exchange {
57
57
  },
58
58
  'test': {
59
59
  'public': {
60
- 'futures': 'https://fx-api-testnet.gateio.ws/api/v4',
61
- 'delivery': 'https://fx-api-testnet.gateio.ws/api/v4',
62
- 'options': 'https://fx-api-testnet.gateio.ws/api/v4',
60
+ 'futures': 'https://api-testnet.gateapi.io/api/v4',
61
+ 'delivery': 'https://api-testnet.gateapi.io/api/v4',
62
+ 'options': 'https://api-testnet.gateapi.io/api/v4',
63
+ 'spot': 'https://api-testnet.gateapi.io/api/v4',
64
+ 'wallet': 'https://api-testnet.gateapi.io/api/v4',
65
+ 'margin': 'https://api-testnet.gateapi.io/api/v4',
66
+ 'sub_accounts': 'https://api-testnet.gateapi.io/api/v4',
67
+ 'account': 'https://api-testnet.gateapi.io/api/v4',
63
68
  },
64
69
  'private': {
65
- 'futures': 'https://fx-api-testnet.gateio.ws/api/v4',
66
- 'delivery': 'https://fx-api-testnet.gateio.ws/api/v4',
67
- 'options': 'https://fx-api-testnet.gateio.ws/api/v4',
70
+ 'futures': 'https://api-testnet.gateapi.io/api/v4',
71
+ 'delivery': 'https://api-testnet.gateapi.io/api/v4',
72
+ 'options': 'https://api-testnet.gateapi.io/api/v4',
73
+ 'spot': 'https://api-testnet.gateapi.io/api/v4',
74
+ 'wallet': 'https://api-testnet.gateapi.io/api/v4',
75
+ 'margin': 'https://api-testnet.gateapi.io/api/v4',
76
+ 'sub_accounts': 'https://api-testnet.gateapi.io/api/v4',
77
+ 'account': 'https://api-testnet.gateapi.io/api/v4',
68
78
  },
69
79
  },
70
80
  'referral': {
@@ -1231,16 +1241,15 @@ export default class gate extends Exchange {
1231
1241
  await this.loadUnifiedStatus();
1232
1242
  }
1233
1243
  const rawPromises = [];
1234
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1235
1244
  const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets');
1236
1245
  const types = this.safeList(fetchMarketsOptions, 'types', ['spot', 'swap', 'future', 'option']);
1237
1246
  for (let i = 0; i < types.length; i++) {
1238
1247
  const marketType = types[i];
1239
1248
  if (marketType === 'spot') {
1240
- if (!sandboxMode) {
1241
- // gate doesn't have a sandbox for spot markets
1242
- rawPromises.push(this.fetchSpotMarkets(params));
1243
- }
1249
+ // if (!sandboxMode) {
1250
+ // gate doesn't have a sandbox for spot markets
1251
+ rawPromises.push(this.fetchSpotMarkets(params));
1252
+ // }
1244
1253
  }
1245
1254
  else if (marketType === 'swap') {
1246
1255
  rawPromises.push(this.fetchSwapMarkets(params));
@@ -1371,7 +1380,10 @@ export default class gate extends Exchange {
1371
1380
  }
1372
1381
  async fetchSwapMarkets(params = {}) {
1373
1382
  const result = [];
1374
- const swapSettlementCurrencies = this.getSettlementCurrencies('swap', 'fetchMarkets');
1383
+ let swapSettlementCurrencies = this.getSettlementCurrencies('swap', 'fetchMarkets');
1384
+ if (this.options['sandboxMode']) {
1385
+ swapSettlementCurrencies = ['usdt']; // gate sandbox only has usdt-margined swaps
1386
+ }
1375
1387
  for (let c = 0; c < swapSettlementCurrencies.length; c++) {
1376
1388
  const settleId = swapSettlementCurrencies[c];
1377
1389
  const request = {
@@ -1386,6 +1398,9 @@ export default class gate extends Exchange {
1386
1398
  return result;
1387
1399
  }
1388
1400
  async fetchFutureMarkets(params = {}) {
1401
+ if (this.options['sandboxMode']) {
1402
+ return []; // right now sandbox does not have inverse swaps
1403
+ }
1389
1404
  const result = [];
1390
1405
  const futureSettlementCurrencies = this.getSettlementCurrencies('future', 'fetchMarkets');
1391
1406
  for (let c = 0; c < futureSettlementCurrencies.length; c++) {
package/js/src/gemini.js CHANGED
@@ -694,8 +694,8 @@ export default class gemini extends Exchange {
694
694
  //
695
695
  // [
696
696
  // 'BTCUSD', // symbol
697
- // 2, // priceTickDecimalPlaces
698
- // 8, // quantityTickDecimalPlaces
697
+ // 2, // tick precision (priceTickDecimalPlaces)
698
+ // 8, // amount precision (quantityTickDecimalPlaces)
699
699
  // '0.00001', // quantityMinimum
700
700
  // 10, // quantityRoundDecimalPlaces
701
701
  // true // minimumsAreInclusive
@@ -714,7 +714,7 @@ export default class gemini extends Exchange {
714
714
  // "wrap_enabled": false
715
715
  // "product_type": "swap", // only in perps
716
716
  // "contract_type": "linear", // only in perps
717
- // "contract_price_currency": "GUSD" // only in perps
717
+ // "contract_price_currency": "GUSD"
718
718
  // }
719
719
  //
720
720
  let marketId = undefined;
package/js/src/htx.js CHANGED
@@ -664,7 +664,7 @@ export default class htx extends Exchange {
664
664
  'api/v1/contract_batchorder': 1,
665
665
  'api/v1/contract_cancel': 1,
666
666
  'api/v1/contract_cancelall': 1,
667
- 'api/v1/contract_switch_lever_rate': 1,
667
+ 'api/v1/contract_switch_lever_rate': 30,
668
668
  'api/v1/lightning_close_position': 1,
669
669
  'api/v1/contract_order_info': 1,
670
670
  'api/v1/contract_order_detail': 1,
@@ -723,7 +723,7 @@ export default class htx extends Exchange {
723
723
  'swap-api/v1/swap_cancel': 1,
724
724
  'swap-api/v1/swap_cancelall': 1,
725
725
  'swap-api/v1/swap_lightning_close_position': 1,
726
- 'swap-api/v1/swap_switch_lever_rate': 1,
726
+ 'swap-api/v1/swap_switch_lever_rate': 30,
727
727
  'swap-api/v1/swap_order_info': 1,
728
728
  'swap-api/v1/swap_order_detail': 1,
729
729
  'swap-api/v1/swap_openorders': 1,
@@ -797,8 +797,8 @@ export default class htx extends Exchange {
797
797
  'linear-swap-api/v1/swap_cross_cancel': 1,
798
798
  'linear-swap-api/v1/swap_cancelall': 1,
799
799
  'linear-swap-api/v1/swap_cross_cancelall': 1,
800
- 'linear-swap-api/v1/swap_switch_lever_rate': 1,
801
- 'linear-swap-api/v1/swap_cross_switch_lever_rate': 1,
800
+ 'linear-swap-api/v1/swap_switch_lever_rate': 30,
801
+ 'linear-swap-api/v1/swap_cross_switch_lever_rate': 30,
802
802
  'linear-swap-api/v1/swap_lightning_close_position': 1,
803
803
  'linear-swap-api/v1/swap_cross_lightning_close_position': 1,
804
804
  'linear-swap-api/v1/swap_order_info': 1,
package/js/src/indodax.js CHANGED
@@ -198,6 +198,16 @@ export default class indodax extends Exchange {
198
198
  'Minimum order': InvalidOrder,
199
199
  },
200
200
  },
201
+ 'timeframes': {
202
+ '1m': '1',
203
+ '15m': '15',
204
+ '30m': '30',
205
+ '1h': '60',
206
+ '4h': '240',
207
+ '1d': '1D',
208
+ '3d': '3D',
209
+ '1w': '1W',
210
+ },
201
211
  // exchange-specific options
202
212
  'options': {
203
213
  'recvWindow': 5 * 1000,
@@ -221,16 +231,6 @@ export default class indodax extends Exchange {
221
231
  // 'ETH': 'eth'
222
232
  // 'BASE': 'base'
223
233
  },
224
- 'timeframes': {
225
- '1m': '1',
226
- '15m': '15',
227
- '30m': '30',
228
- '1h': '60',
229
- '4h': '240',
230
- '1d': '1D',
231
- '3d': '3D',
232
- '1w': '1W',
233
- },
234
234
  },
235
235
  'features': {
236
236
  'spot': {
@@ -688,8 +688,7 @@ export default class indodax extends Exchange {
688
688
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
689
689
  await this.loadMarkets();
690
690
  const market = this.market(symbol);
691
- const timeframes = this.options['timeframes'];
692
- const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
691
+ const selectedTimeframe = this.safeString(this.timeframes, timeframe, timeframe);
693
692
  const now = this.seconds();
694
693
  const until = this.safeInteger(params, 'until', now);
695
694
  params = this.omit(params, ['until']);
@@ -469,7 +469,7 @@ export default class kucoinfutures extends kucoin {
469
469
  // }
470
470
  // }
471
471
  //
472
- const data = this.safeValue(response, 'data', {});
472
+ const data = this.safeDict(response, 'data', {});
473
473
  const status = this.safeString(data, 'status');
474
474
  return {
475
475
  'status': (status === 'open') ? 'ok' : 'maintenance',
@@ -552,7 +552,7 @@ export default class kucoinfutures extends kucoin {
552
552
  // }
553
553
  //
554
554
  const result = [];
555
- const data = this.safeValue(response, 'data', []);
555
+ const data = this.safeList(response, 'data', []);
556
556
  for (let i = 0; i < data.length; i++) {
557
557
  const market = data[i];
558
558
  const id = this.safeString(market, 'symbol');
@@ -769,7 +769,7 @@ export default class kucoinfutures extends kucoin {
769
769
  // }
770
770
  // }
771
771
  //
772
- const data = this.safeValue(response, 'data', {});
772
+ const data = this.safeDict(response, 'data', {});
773
773
  const address = this.safeString(data, 'address');
774
774
  if (currencyId !== 'NIM') {
775
775
  // contains spaces
@@ -833,7 +833,7 @@ export default class kucoinfutures extends kucoin {
833
833
  // }
834
834
  // }
835
835
  //
836
- const data = this.safeValue(response, 'data', {});
836
+ const data = this.safeDict(response, 'data', {});
837
837
  const timestamp = this.parseToInt(this.safeInteger(data, 'ts') / 1000000);
838
838
  const orderbook = this.parseOrderBook(data, market['symbol'], timestamp, 'bids', 'asks', 0, 1);
839
839
  orderbook['nonce'] = this.safeInteger(data, 'sequence');
@@ -1163,7 +1163,7 @@ export default class kucoinfutures extends kucoin {
1163
1163
  // }
1164
1164
  //
1165
1165
  const data = this.safeValue(response, 'data');
1166
- const dataList = this.safeValue(data, 'dataList', []);
1166
+ const dataList = this.safeList(data, 'dataList', []);
1167
1167
  const fees = [];
1168
1168
  for (let i = 0; i < dataList.length; i++) {
1169
1169
  const listItem = dataList[i];
@@ -2124,7 +2124,7 @@ export default class kucoinfutures extends kucoin {
2124
2124
  // }
2125
2125
  // }
2126
2126
  //
2127
- const responseData = this.safeValue(response, 'data', {});
2127
+ const responseData = this.safeDict(response, 'data', {});
2128
2128
  const orders = this.safeList(responseData, 'items', []);
2129
2129
  return this.parseOrders(orders, market, since, limit);
2130
2130
  }
@@ -3052,7 +3052,7 @@ export default class kucoinfutures extends kucoin {
3052
3052
  // ]
3053
3053
  // }
3054
3054
  //
3055
- const data = this.safeValue(response, 'data');
3055
+ const data = this.safeList(response, 'data', []);
3056
3056
  return this.parseMarketLeverageTiers(data, market);
3057
3057
  }
3058
3058
  parseMarketLeverageTiers(info, market = undefined) {
@@ -3141,7 +3141,7 @@ export default class kucoinfutures extends kucoin {
3141
3141
  // ]
3142
3142
  // }
3143
3143
  //
3144
- const data = this.safeValue(response, 'data');
3144
+ const data = this.safeList(response, 'data', []);
3145
3145
  return this.parseFundingRateHistories(data, market, since, limit);
3146
3146
  }
3147
3147
  parseFundingRateHistory(info, market = undefined) {
package/js/src/mexc.d.ts CHANGED
@@ -653,11 +653,14 @@ export default class mexc extends Exchange {
653
653
  * @name mexc#withdraw
654
654
  * @description make a withdrawal
655
655
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-new
656
+ * @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints#internal-transfer
656
657
  * @param {string} code unified currency code
657
658
  * @param {float} amount the amount to withdraw
658
659
  * @param {string} address the address to withdraw to
659
660
  * @param {string} tag
660
661
  * @param {object} [params] extra parameters specific to the exchange API endpoint
662
+ * @param {object} [params.internal] false by default, set to true for an "internal transfer"
663
+ * @param {object} [params.toAccountType] skipped by default, set to 'EMAIL|UID|MOBILE' when making an "internal transfer"
661
664
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
662
665
  */
663
666
  withdraw(code: string, amount: number, address: string, tag?: Str, params?: {}): Promise<Transaction>;
package/js/src/mexc.js CHANGED
@@ -4998,7 +4998,13 @@ export default class mexc extends Exchange {
4998
4998
  // "id":"25fb2831fb6d4fc7aa4094612a26c81d"
4999
4999
  // }
5000
5000
  //
5001
- const id = this.safeString(transaction, 'id');
5001
+ // internal withdraw (aka internal-transfer)
5002
+ //
5003
+ // {
5004
+ // "tranId":"ad36f0e9c9a24ae794b36fa4f152e471"
5005
+ // }
5006
+ //
5007
+ const id = this.safeString2(transaction, 'id', 'tranId');
5002
5008
  const type = (id === undefined) ? 'deposit' : 'withdrawal';
5003
5009
  const timestamp = this.safeInteger2(transaction, 'insertTime', 'applyTime');
5004
5010
  const updated = this.safeInteger(transaction, 'updateTime');
@@ -5511,17 +5517,40 @@ export default class mexc extends Exchange {
5511
5517
  * @name mexc#withdraw
5512
5518
  * @description make a withdrawal
5513
5519
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-new
5520
+ * @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints#internal-transfer
5514
5521
  * @param {string} code unified currency code
5515
5522
  * @param {float} amount the amount to withdraw
5516
5523
  * @param {string} address the address to withdraw to
5517
5524
  * @param {string} tag
5518
5525
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5526
+ * @param {object} [params.internal] false by default, set to true for an "internal transfer"
5527
+ * @param {object} [params.toAccountType] skipped by default, set to 'EMAIL|UID|MOBILE' when making an "internal transfer"
5519
5528
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
5520
5529
  */
5521
5530
  async withdraw(code, amount, address, tag = undefined, params = {}) {
5522
5531
  await this.loadMarkets();
5523
5532
  const currency = this.currency(code);
5524
5533
  [tag, params] = this.handleWithdrawTagAndParams(tag, params);
5534
+ const internal = this.safeBool(params, 'internal', false);
5535
+ if (internal) {
5536
+ params = this.omit(params, 'internal');
5537
+ const requestForInternal = {
5538
+ 'asset': currency['id'],
5539
+ 'amount': amount,
5540
+ 'toAccount': address,
5541
+ };
5542
+ const toAccountType = this.safeString(params, 'toAccountType');
5543
+ if (toAccountType === undefined) {
5544
+ throw new ArgumentsRequired(this.id + ' withdraw() requires a toAccountType parameter for internal transfer to be of: EMAIL | UID | MOBILE');
5545
+ }
5546
+ const responseForInternal = await this.spotPrivatePostCapitalTransferInternal(this.extend(requestForInternal, params));
5547
+ //
5548
+ // {
5549
+ // "id":"7213fea8e94b4a5593d507237e5a555b"
5550
+ // }
5551
+ //
5552
+ return this.parseTransaction(responseForInternal, currency);
5553
+ }
5525
5554
  const networks = this.safeDict(this.options, 'networks', {});
5526
5555
  let network = this.safeString2(params, 'network', 'netWork'); // this line allows the user to specify either ERC20 or ETH
5527
5556
  network = this.safeString(networks, network, network); // handle ETH > ERC-20 alias
package/js/src/okx.d.ts CHANGED
@@ -138,6 +138,7 @@ export default class okx extends Exchange {
138
138
  * @see https://www.okx.com/docs-v5/en/#rest-api-market-data-get-mark-price-candlesticks-history
139
139
  * @see https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-candlesticks
140
140
  * @see https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-candlesticks-history
141
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks-history
141
142
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
142
143
  * @param {string} timeframe the length of time each candle represents
143
144
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -145,6 +146,7 @@ export default class okx extends Exchange {
145
146
  * @param {object} [params] extra parameters specific to the exchange API endpoint
146
147
  * @param {string} [params.price] "mark" or "index" for mark price and index price candles
147
148
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
149
+ * @param {string} [params.type] "Candles" or "HistoryCandles", default is "Candles" for recent candles, "HistoryCandles" for older candles
148
150
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
149
151
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
150
152
  */
@@ -190,8 +192,8 @@ export default class okx extends Exchange {
190
192
  /**
191
193
  * @method
192
194
  * @name okx#createMarketBuyOrderWithCost
193
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
194
195
  * @description create a market buy order by providing the symbol and cost
196
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
195
197
  * @param {string} symbol unified symbol of the market to create an order in
196
198
  * @param {float} cost how much you want to trade in units of the quote currency
197
199
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -201,8 +203,8 @@ export default class okx extends Exchange {
201
203
  /**
202
204
  * @method
203
205
  * @name okx#createMarketSellOrderWithCost
204
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
205
206
  * @description create a market buy order by providing the symbol and cost
207
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
206
208
  * @param {string} symbol unified symbol of the market to create an order in
207
209
  * @param {float} cost how much you want to trade in units of the quote currency
208
210
  * @param {object} [params] extra parameters specific to the exchange API endpoint
package/js/src/okx.js CHANGED
@@ -1220,7 +1220,7 @@ export default class okx extends Exchange {
1220
1220
  'FUTURES': 'FUTURES',
1221
1221
  'OPTION': 'OPTION',
1222
1222
  },
1223
- 'brokerId': 'e847386590ce4dBC',
1223
+ 'brokerId': '6b9ad766b55dBCDE',
1224
1224
  },
1225
1225
  'features': {
1226
1226
  'default': {
@@ -2420,6 +2420,7 @@ export default class okx extends Exchange {
2420
2420
  * @see https://www.okx.com/docs-v5/en/#rest-api-market-data-get-mark-price-candlesticks-history
2421
2421
  * @see https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-candlesticks
2422
2422
  * @see https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-candlesticks-history
2423
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks-history
2423
2424
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
2424
2425
  * @param {string} timeframe the length of time each candle represents
2425
2426
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -2427,6 +2428,7 @@ export default class okx extends Exchange {
2427
2428
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2428
2429
  * @param {string} [params.price] "mark" or "index" for mark price and index price candles
2429
2430
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
2431
+ * @param {string} [params.type] "Candles" or "HistoryCandles", default is "Candles" for recent candles, "HistoryCandles" for older candles
2430
2432
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2431
2433
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2432
2434
  */
@@ -2442,6 +2444,7 @@ export default class okx extends Exchange {
2442
2444
  params = this.omit(params, 'price');
2443
2445
  const options = this.safeDict(this.options, 'fetchOHLCV', {});
2444
2446
  const timezone = this.safeString(options, 'timezone', 'UTC');
2447
+ const limitIsUndefined = (limit === undefined);
2445
2448
  if (limit === undefined) {
2446
2449
  limit = 100; // default 100, max 100
2447
2450
  }
@@ -2466,7 +2469,8 @@ export default class okx extends Exchange {
2466
2469
  const historyBorder = now - ((1440 - 1) * durationInMilliseconds);
2467
2470
  if (since < historyBorder) {
2468
2471
  defaultType = 'HistoryCandles';
2469
- limit = Math.min(limit, 100); // max 100 for historical endpoint
2472
+ const maxLimit = (price !== undefined) ? 100 : 300;
2473
+ limit = Math.min(limit, maxLimit); // max 300 for historical endpoint
2470
2474
  }
2471
2475
  const startTime = Math.max(since - 1, 0);
2472
2476
  request['before'] = startTime;
@@ -2501,6 +2505,10 @@ export default class okx extends Exchange {
2501
2505
  }
2502
2506
  else {
2503
2507
  if (isHistoryCandles) {
2508
+ if (limitIsUndefined && (limit === 100)) {
2509
+ limit = 300;
2510
+ request['limit'] = 300; // reassign to 300, but this whole logic needs to be simplified...
2511
+ }
2504
2512
  response = await this.publicGetMarketHistoryCandles(this.extend(request, params));
2505
2513
  }
2506
2514
  else {
@@ -2848,8 +2856,8 @@ export default class okx extends Exchange {
2848
2856
  /**
2849
2857
  * @method
2850
2858
  * @name okx#createMarketBuyOrderWithCost
2851
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2852
2859
  * @description create a market buy order by providing the symbol and cost
2860
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2853
2861
  * @param {string} symbol unified symbol of the market to create an order in
2854
2862
  * @param {float} cost how much you want to trade in units of the quote currency
2855
2863
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2870,8 +2878,8 @@ export default class okx extends Exchange {
2870
2878
  /**
2871
2879
  * @method
2872
2880
  * @name okx#createMarketSellOrderWithCost
2873
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2874
2881
  * @description create a market buy order by providing the symbol and cost
2882
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2875
2883
  * @param {string} symbol unified symbol of the market to create an order in
2876
2884
  * @param {float} cost how much you want to trade in units of the quote currency
2877
2885
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2934,6 +2942,8 @@ export default class okx extends Exchange {
2934
2942
  const takeProfitDefined = (takeProfit !== undefined);
2935
2943
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
2936
2944
  const isTrailingPercentOrder = trailingPercent !== undefined;
2945
+ const trailingPrice = this.safeString2(params, 'trailingPrice', 'callbackSpread');
2946
+ const isTrailingPriceOrder = trailingPrice !== undefined;
2937
2947
  const trigger = (triggerPrice !== undefined) || (type === 'trigger');
2938
2948
  const isReduceOnly = this.safeValue(params, 'reduceOnly', false);
2939
2949
  const defaultMarginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
@@ -3050,6 +3060,10 @@ export default class okx extends Exchange {
3050
3060
  request['callbackRatio'] = convertedTrailingPercent;
3051
3061
  request['ordType'] = 'move_order_stop';
3052
3062
  }
3063
+ else if (isTrailingPriceOrder) {
3064
+ request['callbackSpread'] = trailingPrice;
3065
+ request['ordType'] = 'move_order_stop';
3066
+ }
3053
3067
  else if (stopLossDefined || takeProfitDefined) {
3054
3068
  if (stopLossDefined) {
3055
3069
  const stopLossTriggerPrice = this.safeValueN(stopLoss, ['triggerPrice', 'stopPrice', 'slTriggerPx']);
@@ -6316,7 +6330,7 @@ export default class okx extends Exchange {
6316
6330
  this.checkRequiredCredentials();
6317
6331
  // inject id in implicit api call
6318
6332
  if (method === 'POST' && (path === 'trade/batch-orders' || path === 'trade/order-algo' || path === 'trade/order')) {
6319
- const brokerId = this.safeString(this.options, 'brokerId', 'e847386590ce4dBC');
6333
+ const brokerId = this.safeString(this.options, 'brokerId', '6b9ad766b55dBCDE');
6320
6334
  if (Array.isArray(params)) {
6321
6335
  for (let i = 0; i < params.length; i++) {
6322
6336
  const entry = params[i];
@@ -2648,7 +2648,7 @@ export default class poloniex extends Exchange {
2648
2648
  // "scale" : "-1",
2649
2649
  // "asks" : [ "23139.82", "0.317981", "23140", "0.191091", "23170.06", "0.01", "23200", "0.107758", "23230.55", "0.01", "23247.2", "0.154", "23254", "0.005121", "23263", "0.038", "23285.4", "0.308", "23300", "0.108896" ],
2650
2650
  // "bids" : [ "23139.74", "0.432092", "23139.73", "0.198592", "23123.21", "0.000886", "23123.2", "0.308", "23121.4", "0.154", "23105", "0.000789", "23100", "0.078175", "23069.1", "0.026276", "23068.83", "0.001329", "23051", "0.000048" ],
2651
- // "ts" : 1659695219513
2651
+ // "ts" : 1659695219512
2652
2652
  // }
2653
2653
  //
2654
2654
  const timestamp = this.safeInteger(response, 'time');
@@ -3244,8 +3244,8 @@ export default class binance extends binanceRest {
3244
3244
  await this.loadMarkets();
3245
3245
  const market = this.market(symbol);
3246
3246
  const type = this.getMarketType('cancelAllOrdersWs', market, params);
3247
- if (type !== 'spot' && type !== 'future') {
3248
- throw new BadRequest(this.id + ' cancelAllOrdersWs only supports spot or swap markets');
3247
+ if (type !== 'spot') {
3248
+ throw new BadRequest(this.id + ' cancelAllOrdersWs only supports spot markets');
3249
3249
  }
3250
3250
  const url = this.urls['api']['ws']['ws-api'][type];
3251
3251
  const requestId = this.requestId(url);
@@ -3258,7 +3258,7 @@ export default class binance extends binanceRest {
3258
3258
  };
3259
3259
  const message = {
3260
3260
  'id': messageHash,
3261
- 'method': 'order.cancel',
3261
+ 'method': 'openOrders.cancelAll',
3262
3262
  'params': this.signParams(this.extend(payload, params)),
3263
3263
  };
3264
3264
  const subscription = {
@@ -4,6 +4,7 @@ import Client from '../base/ws/Client.js';
4
4
  export default class bitfinex extends bitfinexRest {
5
5
  describe(): any;
6
6
  subscribe(channel: any, symbol: any, params?: {}): Promise<any>;
7
+ unSubscribe(channel: any, topic: any, symbol: any, params?: {}): Promise<any>;
7
8
  subscribePrivate(messageHash: any): Promise<any>;
8
9
  /**
9
10
  * @method
@@ -17,6 +18,16 @@ export default class bitfinex extends bitfinexRest {
17
18
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
18
19
  */
19
20
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
21
+ /**
22
+ * @method
23
+ * @name bitfinex#unWatchOHLCV
24
+ * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
25
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
26
+ * @param {string} timeframe the length of time each candle represents
27
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
28
+ * @returns {bool} true if successfully unsubscribed, false otherwise
29
+ */
30
+ unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
20
31
  handleOHLCV(client: Client, message: any, subscription: any): void;
21
32
  /**
22
33
  * @method
@@ -29,6 +40,15 @@ export default class bitfinex extends bitfinexRest {
29
40
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
30
41
  */
31
42
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
43
+ /**
44
+ * @method
45
+ * @name bitfinex#unWatchTrades
46
+ * @description unWatches the list of most recent trades for a particular symbol
47
+ * @param {string} symbol unified symbol of the market to fetch trades for
48
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
49
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
50
+ */
51
+ unWatchTrades(symbol: string, params?: {}): Promise<any>;
32
52
  /**
33
53
  * @method
34
54
  * @name bitfinex#watchMyTrades
@@ -49,6 +69,15 @@ export default class bitfinex extends bitfinexRest {
49
69
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
50
70
  */
51
71
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
72
+ /**
73
+ * @method
74
+ * @name bitfinex#unWatchTicker
75
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
76
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
77
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
78
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
79
+ */
80
+ unWatchTicker(symbol: string, params?: {}): Promise<any>;
52
81
  handleMyTrade(client: Client, message: any, subscription?: {}): void;
53
82
  handleTrades(client: Client, message: any, subscription: any): void;
54
83
  parseWsTrade(trade: any, market?: any): Trade;
@@ -78,6 +107,7 @@ export default class bitfinex extends bitfinexRest {
78
107
  handleBalance(client: Client, message: any, subscription: any): void;
79
108
  parseWsBalance(balance: any): import("../base/types.js").BalanceAccount;
80
109
  handleSystemStatus(client: Client, message: any): any;
110
+ handleUnsubscriptionStatus(client: Client, message: any): boolean;
81
111
  handleSubscriptionStatus(client: Client, message: any): any;
82
112
  authenticate(params?: {}): Promise<any>;
83
113
  handleAuthenticationMessage(client: Client, message: any): void;