ccxt 4.3.89 → 4.3.91

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 (69) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +2 -2
  5. package/dist/cjs/src/ascendex.js +95 -97
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/bingx.js +31 -17
  8. package/dist/cjs/src/bitfinex2.js +21 -22
  9. package/dist/cjs/src/bitget.js +2 -2
  10. package/dist/cjs/src/bitmart.js +6 -9
  11. package/dist/cjs/src/coinbaseinternational.js +2 -1
  12. package/dist/cjs/src/coinex.js +1 -17
  13. package/dist/cjs/src/hitbtc.js +2 -0
  14. package/dist/cjs/src/htx.js +49 -49
  15. package/dist/cjs/src/huobijp.js +0 -9
  16. package/dist/cjs/src/kucoin.js +59 -21
  17. package/dist/cjs/src/kucoinfutures.js +26 -2
  18. package/dist/cjs/src/latoken.js +1 -0
  19. package/dist/cjs/src/okx.js +1 -8
  20. package/dist/cjs/src/pro/binance.js +323 -0
  21. package/dist/cjs/src/pro/bingx.js +263 -91
  22. package/dist/cjs/src/pro/bithumb.js +5 -1
  23. package/dist/cjs/src/pro/bybit.js +1 -1
  24. package/dist/cjs/src/pro/coinex.js +994 -679
  25. package/dist/cjs/src/pro/lbank.js +2 -3
  26. package/dist/cjs/src/pro/okx.js +159 -3
  27. package/dist/cjs/src/whitebit.js +5 -3
  28. package/dist/cjs/src/woo.js +1 -1
  29. package/js/ccxt.d.ts +1 -1
  30. package/js/ccxt.js +1 -1
  31. package/js/src/abstract/kucoin.d.ts +1 -0
  32. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  33. package/js/src/alpaca.js +2 -2
  34. package/js/src/ascendex.js +95 -97
  35. package/js/src/binance.js +1 -1
  36. package/js/src/bingx.js +31 -17
  37. package/js/src/bitfinex2.d.ts +0 -1
  38. package/js/src/bitfinex2.js +21 -22
  39. package/js/src/bitget.js +2 -2
  40. package/js/src/bitmart.d.ts +0 -1
  41. package/js/src/bitmart.js +6 -9
  42. package/js/src/coinbaseinternational.js +2 -1
  43. package/js/src/coinex.d.ts +0 -2
  44. package/js/src/coinex.js +1 -17
  45. package/js/src/hitbtc.js +2 -0
  46. package/js/src/htx.js +49 -49
  47. package/js/src/huobijp.d.ts +0 -1
  48. package/js/src/huobijp.js +0 -9
  49. package/js/src/kucoin.d.ts +3 -1
  50. package/js/src/kucoin.js +59 -21
  51. package/js/src/kucoinfutures.d.ts +1 -0
  52. package/js/src/kucoinfutures.js +26 -2
  53. package/js/src/latoken.js +1 -0
  54. package/js/src/okx.d.ts +0 -1
  55. package/js/src/okx.js +1 -8
  56. package/js/src/pro/binance.d.ts +9 -1
  57. package/js/src/pro/binance.js +327 -1
  58. package/js/src/pro/bingx.d.ts +2 -2
  59. package/js/src/pro/bingx.js +263 -91
  60. package/js/src/pro/bithumb.js +5 -1
  61. package/js/src/pro/bybit.js +1 -1
  62. package/js/src/pro/coinex.d.ts +12 -6
  63. package/js/src/pro/coinex.js +996 -681
  64. package/js/src/pro/lbank.js +2 -3
  65. package/js/src/pro/okx.d.ts +7 -0
  66. package/js/src/pro/okx.js +162 -4
  67. package/js/src/whitebit.js +5 -3
  68. package/js/src/woo.js +1 -1
  69. package/package.json +1 -1
@@ -498,7 +498,7 @@ class lbank extends lbank$1 {
498
498
  /**
499
499
  * @method
500
500
  * @name lbank#watchOrders
501
- * @see https://github.com/LBank-exchange/lbank-official-api-docs/blob/master/API-For-Spot-EN/WebSocket%20API(Asset%20%26%20Order).md#websocketsubscribeunsubscribe
501
+ * @see https://www.lbank.com/en-US/docs/index.html#update-subscribed-orders
502
502
  * @description get the list of trades associated with the user
503
503
  * @param {string} [symbol] unified symbol of the market to fetch trades for
504
504
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -662,7 +662,7 @@ class lbank extends lbank$1 {
662
662
  async fetchOrderBookWs(symbol, limit = undefined, params = {}) {
663
663
  /**
664
664
  * @method
665
- * @name lbank#watchOrderBook
665
+ * @name lbank#fetchOrderBookWs
666
666
  * @see https://www.lbank.com/en-US/docs/index.html#request-amp-subscription-instruction
667
667
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
668
668
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -692,7 +692,6 @@ class lbank extends lbank$1 {
692
692
  * @method
693
693
  * @name lbank#watchOrderBook
694
694
  * @see https://www.lbank.com/en-US/docs/index.html#market-depth
695
- * @see https://www.lbank.com/en-US/docs/index.html#market-increment-depth
696
695
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
697
696
  * @param {string} symbol unified symbol of the market to fetch the order book for
698
697
  * @param {int|undefined} limit the maximum amount of order book entries to return
@@ -217,6 +217,48 @@ class okx extends okx$1 {
217
217
  }
218
218
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
219
219
  }
220
+ async unWatchTradesForSymbols(symbols, params = {}) {
221
+ /**
222
+ * @method
223
+ * @name okx#unWatchTradesForSymbols
224
+ * @description unWatches from the stream channel
225
+ * @param {string} symbol unified symbol of the market to fetch trades for
226
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
227
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
228
+ */
229
+ await this.loadMarkets();
230
+ symbols = this.marketSymbols(symbols, undefined, false);
231
+ const channel = 'trades';
232
+ const topics = [];
233
+ const messageHashes = [];
234
+ for (let i = 0; i < symbols.length; i++) {
235
+ const symbol = symbols[i];
236
+ messageHashes.push('unsubscribe:trades:' + symbol);
237
+ const marketId = this.marketId(symbol);
238
+ const topic = {
239
+ 'channel': channel,
240
+ 'instId': marketId,
241
+ };
242
+ topics.push(topic);
243
+ }
244
+ const request = {
245
+ 'op': 'unsubscribe',
246
+ 'args': topics,
247
+ };
248
+ const url = this.getUrl(channel, 'public');
249
+ return await this.watchMultiple(url, messageHashes, request, messageHashes);
250
+ }
251
+ async unWatchTrades(symbol, params = {}) {
252
+ /**
253
+ * @method
254
+ * @name okx#unWatchTradesForSymbols
255
+ * @description unWatches from the stream channel
256
+ * @param {string} symbol unified symbol of the market to fetch trades for
257
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
258
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
259
+ */
260
+ return await this.unWatchTradesForSymbols([symbol], params);
261
+ }
220
262
  handleTrades(client, message) {
221
263
  //
222
264
  // {
@@ -363,9 +405,8 @@ class okx extends okx$1 {
363
405
  * @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
364
406
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
365
407
  */
366
- if (this.isEmpty(symbols)) {
367
- throw new errors.ArgumentsRequired(this.id + ' watchTickers requires a list of symbols');
368
- }
408
+ await this.loadMarkets();
409
+ symbols = this.marketSymbols(symbols, undefined, false);
369
410
  let channel = undefined;
370
411
  [channel, params] = this.handleOptionAndParams(params, 'watchTickers', 'channel', 'tickers');
371
412
  const newTickers = await this.subscribeMultiple('public', channel, symbols, params);
@@ -892,6 +933,70 @@ class okx extends okx$1 {
892
933
  const orderbook = await this.watchMultiple(url, messageHashes, request, messageHashes);
893
934
  return orderbook.limit();
894
935
  }
936
+ async unWatchOrderBookForSymbols(symbols, params = {}) {
937
+ /**
938
+ * @method
939
+ * @name okx#unWatchOrderBookForSymbols
940
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel
941
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
942
+ * @param {string[]} symbols unified array of symbols
943
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
944
+ * @param {int} [params.limit] the maximum amount of order book entries to return
945
+ * @param {string} [params.depth] okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
946
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
947
+ */
948
+ await this.loadMarkets();
949
+ symbols = this.marketSymbols(symbols, undefined, false);
950
+ let depth = undefined;
951
+ [depth, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'depth', 'books');
952
+ const limit = this.safeInteger(params, 'limit');
953
+ if (limit !== undefined) {
954
+ if (limit === 1) {
955
+ depth = 'bbo-tbt';
956
+ }
957
+ else if (limit > 1 && limit <= 5) {
958
+ depth = 'books5';
959
+ }
960
+ else if (limit === 50) {
961
+ depth = 'books50-l2-tbt'; // Make sure you have VIP4 and above
962
+ }
963
+ else if (limit === 400) {
964
+ depth = 'books';
965
+ }
966
+ }
967
+ const topics = [];
968
+ const messageHashes = [];
969
+ for (let i = 0; i < symbols.length; i++) {
970
+ const symbol = symbols[i];
971
+ messageHashes.push('unsubscribe:orderbook:' + symbol);
972
+ const marketId = this.marketId(symbol);
973
+ const topic = {
974
+ 'channel': depth,
975
+ 'instId': marketId,
976
+ };
977
+ topics.push(topic);
978
+ }
979
+ const request = {
980
+ 'op': 'unsubscribe',
981
+ 'args': topics,
982
+ };
983
+ const url = this.getUrl(depth, 'public');
984
+ return await this.watchMultiple(url, messageHashes, request, messageHashes);
985
+ }
986
+ async unWatchOrderBook(symbol, params = {}) {
987
+ /**
988
+ * @method
989
+ * @name okx#unWatchOrderBook
990
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel
991
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
992
+ * @param {string} symbol unified array of symbols
993
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
994
+ * @param {int} [params.limit] the maximum amount of order book entries to return
995
+ * @param {string} [params.depth] okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
996
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
997
+ */
998
+ return await this.unWatchOrderBookForSymbols([symbol], params);
999
+ }
895
1000
  handleDelta(bookside, delta) {
896
1001
  //
897
1002
  // [
@@ -1987,6 +2092,7 @@ class okx extends okx$1 {
1987
2092
  // 'book': 'handleOrderBook',
1988
2093
  'login': this.handleAuthenticate,
1989
2094
  'subscribe': this.handleSubscriptionStatus,
2095
+ 'unsubscribe': this.handleUnsubscription,
1990
2096
  'order': this.handlePlaceOrders,
1991
2097
  'batch-orders': this.handlePlaceOrders,
1992
2098
  'amend-order': this.handlePlaceOrders,
@@ -2033,6 +2139,56 @@ class okx extends okx$1 {
2033
2139
  }
2034
2140
  }
2035
2141
  }
2142
+ handleUnSubscriptionTrades(client, symbol) {
2143
+ const subMessageHash = 'trades:' + symbol;
2144
+ const messageHash = 'unsubscribe:trades:' + symbol;
2145
+ if (subMessageHash in client.subscriptions) {
2146
+ delete client.subscriptions[subMessageHash];
2147
+ }
2148
+ if (messageHash in client.subscriptions) {
2149
+ delete client.subscriptions[messageHash];
2150
+ }
2151
+ delete this.trades[symbol];
2152
+ const error = new errors.UnsubscribeError(this.id + ' ' + subMessageHash);
2153
+ client.reject(error, subMessageHash);
2154
+ client.resolve(true, messageHash);
2155
+ }
2156
+ handleUnsubscriptionOrderBook(client, symbol, channel) {
2157
+ const subMessageHash = channel + ':' + symbol;
2158
+ const messageHash = 'unsubscribe:orderbook:' + symbol;
2159
+ if (subMessageHash in client.subscriptions) {
2160
+ delete client.subscriptions[subMessageHash];
2161
+ }
2162
+ if (messageHash in client.subscriptions) {
2163
+ delete client.subscriptions[messageHash];
2164
+ }
2165
+ delete this.orderbooks[symbol];
2166
+ const error = new errors.UnsubscribeError(this.id + ' ' + subMessageHash);
2167
+ client.reject(error, subMessageHash);
2168
+ client.resolve(true, messageHash);
2169
+ }
2170
+ handleUnsubscription(client, message) {
2171
+ //
2172
+ // {
2173
+ // "event": "unsubscribe",
2174
+ // "arg": {
2175
+ // "channel": "tickers",
2176
+ // "instId": "LTC-USD-200327"
2177
+ // },
2178
+ // "connId": "a4d3ae55"
2179
+ // }
2180
+ // arg might be an array or list
2181
+ const arg = this.safeDict(message, 'arg', {});
2182
+ const channel = this.safeString(arg, 'channel');
2183
+ const marketId = this.safeString(arg, 'instId');
2184
+ const symbol = this.safeSymbol(marketId);
2185
+ if (channel === 'trades') {
2186
+ this.handleUnSubscriptionTrades(client, symbol);
2187
+ }
2188
+ else if (channel.startsWith('bbo') || channel.startsWith('book')) {
2189
+ this.handleUnsubscriptionOrderBook(client, symbol, channel);
2190
+ }
2191
+ }
2036
2192
  }
2037
2193
 
2038
2194
  module.exports = okx;
@@ -2633,9 +2633,11 @@ class whitebit extends whitebit$1 {
2633
2633
  errorInfo = status;
2634
2634
  }
2635
2635
  else {
2636
- const errorObject = this.safeValue(response, 'errors');
2637
- if (errorObject !== undefined) {
2638
- const errorKey = Object.keys(errorObject)[0];
2636
+ const errorObject = this.safeDict(response, 'errors', {});
2637
+ const errorKeys = Object.keys(errorObject);
2638
+ const errorsLength = errorKeys.length;
2639
+ if (errorsLength > 0) {
2640
+ const errorKey = errorKeys[0];
2639
2641
  const errorMessageArray = this.safeValue(errorObject, errorKey, []);
2640
2642
  const errorMessageLength = errorMessageArray.length;
2641
2643
  errorInfo = (errorMessageLength > 0) ? errorMessageArray[0] : body;
@@ -482,7 +482,7 @@ class woo extends woo$1 {
482
482
  'swap': swap,
483
483
  'future': false,
484
484
  'option': false,
485
- 'active': undefined,
485
+ 'active': this.safeString(market, 'is_trading') === '1',
486
486
  'contract': contract,
487
487
  'linear': linear,
488
488
  'inverse': undefined,
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.3.88";
7
+ declare const version = "4.3.90";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.89';
41
+ const version = '4.3.91';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -87,6 +87,7 @@ interface Exchange {
87
87
  privateGetRedeemOrders(params?: {}): Promise<implicitReturnType>;
88
88
  privateGetPurchaseOrders(params?: {}): Promise<implicitReturnType>;
89
89
  privateGetBrokerApiRebaseDownload(params?: {}): Promise<implicitReturnType>;
90
+ privateGetMigrateUserAccountStatus(params?: {}): Promise<implicitReturnType>;
90
91
  privateGetAffiliateInviterStatistics(params?: {}): Promise<implicitReturnType>;
91
92
  privatePostSubUserCreated(params?: {}): Promise<implicitReturnType>;
92
93
  privatePostSubApiKey(params?: {}): Promise<implicitReturnType>;
@@ -87,6 +87,7 @@ interface kucoin {
87
87
  privateGetRedeemOrders(params?: {}): Promise<implicitReturnType>;
88
88
  privateGetPurchaseOrders(params?: {}): Promise<implicitReturnType>;
89
89
  privateGetBrokerApiRebaseDownload(params?: {}): Promise<implicitReturnType>;
90
+ privateGetMigrateUserAccountStatus(params?: {}): Promise<implicitReturnType>;
90
91
  privateGetAffiliateInviterStatistics(params?: {}): Promise<implicitReturnType>;
91
92
  privatePostSubUserCreated(params?: {}): Promise<implicitReturnType>;
92
93
  privatePostSubApiKey(params?: {}): Promise<implicitReturnType>;
package/js/src/alpaca.js CHANGED
@@ -560,8 +560,8 @@ export default class alpaca extends Exchange {
560
560
  // }
561
561
  // }
562
562
  //
563
- const orderbooks = this.safeValue(response, 'orderbooks', {});
564
- const rawOrderbook = this.safeValue(orderbooks, id, {});
563
+ const orderbooks = this.safeDict(response, 'orderbooks', {});
564
+ const rawOrderbook = this.safeDict(orderbooks, id, {});
565
565
  const timestamp = this.parse8601(this.safeString(rawOrderbook, 't'));
566
566
  return this.parseOrderBook(rawOrderbook, market['symbol'], timestamp, 'b', 'a', 'p', 's');
567
567
  }