ccxt 4.3.40 → 4.3.42

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 (96) 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/binance.js +3 -0
  5. package/dist/cjs/src/bitfinex2.js +1 -1
  6. package/dist/cjs/src/bithumb.js +9 -1
  7. package/dist/cjs/src/bitmart.js +196 -100
  8. package/dist/cjs/src/bitstamp.js +38 -2
  9. package/dist/cjs/src/blockchaincom.js +11 -7
  10. package/dist/cjs/src/coinex.js +1 -1
  11. package/dist/cjs/src/coinlist.js +20 -1
  12. package/dist/cjs/src/coinmate.js +19 -3
  13. package/dist/cjs/src/coinone.js +1 -1
  14. package/dist/cjs/src/coinspot.js +13 -2
  15. package/dist/cjs/src/independentreserve.js +33 -1
  16. package/dist/cjs/src/indodax.js +43 -2
  17. package/dist/cjs/src/kraken.js +30 -3
  18. package/dist/cjs/src/krakenfutures.js +56 -1
  19. package/dist/cjs/src/kucoin.js +59 -2
  20. package/dist/cjs/src/okx.js +7 -0
  21. package/dist/cjs/src/pro/alpaca.js +5 -5
  22. package/dist/cjs/src/pro/ascendex.js +3 -3
  23. package/dist/cjs/src/pro/bingx.js +293 -47
  24. package/dist/cjs/src/pro/bitget.js +14 -6
  25. package/dist/cjs/src/pro/bitrue.js +3 -4
  26. package/dist/cjs/src/pro/currencycom.js +6 -5
  27. package/dist/cjs/src/pro/exmo.js +5 -6
  28. package/dist/cjs/src/pro/gemini.js +4 -3
  29. package/dist/cjs/src/pro/independentreserve.js +7 -7
  30. package/dist/cjs/src/pro/lbank.js +4 -4
  31. package/dist/cjs/src/pro/mexc.js +1 -1
  32. package/dist/cjs/src/pro/phemex.js +5 -5
  33. package/dist/cjs/src/pro/probit.js +4 -4
  34. package/dist/cjs/src/pro/upbit.js +322 -2
  35. package/dist/cjs/src/pro/wazirx.js +12 -12
  36. package/dist/cjs/src/pro/woo.js +2 -2
  37. package/dist/cjs/src/upbit.js +17 -9
  38. package/dist/cjs/src/woo.js +6 -2
  39. package/js/ccxt.d.ts +1 -1
  40. package/js/ccxt.js +1 -1
  41. package/js/src/abstract/binance.d.ts +2 -0
  42. package/js/src/abstract/binancecoinm.d.ts +2 -0
  43. package/js/src/abstract/binanceus.d.ts +2 -0
  44. package/js/src/abstract/binanceusdm.d.ts +2 -0
  45. package/js/src/abstract/okx.d.ts +7 -0
  46. package/js/src/binance.js +3 -0
  47. package/js/src/bitfinex2.js +1 -1
  48. package/js/src/bithumb.d.ts +2 -2
  49. package/js/src/bithumb.js +9 -1
  50. package/js/src/bitmart.js +196 -100
  51. package/js/src/bitstamp.d.ts +2 -2
  52. package/js/src/bitstamp.js +38 -2
  53. package/js/src/blockchaincom.d.ts +2 -8
  54. package/js/src/blockchaincom.js +11 -7
  55. package/js/src/coinex.js +1 -1
  56. package/js/src/coinlist.d.ts +1 -1
  57. package/js/src/coinlist.js +20 -1
  58. package/js/src/coinmate.d.ts +1 -3
  59. package/js/src/coinmate.js +19 -3
  60. package/js/src/coinone.d.ts +1 -1
  61. package/js/src/coinone.js +1 -1
  62. package/js/src/coinspot.d.ts +1 -1
  63. package/js/src/coinspot.js +13 -2
  64. package/js/src/independentreserve.d.ts +1 -1
  65. package/js/src/independentreserve.js +33 -1
  66. package/js/src/indodax.d.ts +1 -1
  67. package/js/src/indodax.js +43 -2
  68. package/js/src/kraken.d.ts +3 -3
  69. package/js/src/kraken.js +30 -3
  70. package/js/src/krakenfutures.d.ts +1 -1
  71. package/js/src/krakenfutures.js +56 -1
  72. package/js/src/kucoin.d.ts +1 -1
  73. package/js/src/kucoin.js +59 -2
  74. package/js/src/okx.js +7 -0
  75. package/js/src/pro/alpaca.js +5 -5
  76. package/js/src/pro/ascendex.js +3 -3
  77. package/js/src/pro/bingx.d.ts +6 -1
  78. package/js/src/pro/bingx.js +294 -48
  79. package/js/src/pro/bitget.js +14 -6
  80. package/js/src/pro/bitrue.js +3 -4
  81. package/js/src/pro/currencycom.js +6 -5
  82. package/js/src/pro/exmo.js +5 -6
  83. package/js/src/pro/gemini.js +4 -3
  84. package/js/src/pro/independentreserve.js +7 -7
  85. package/js/src/pro/lbank.js +4 -4
  86. package/js/src/pro/mexc.js +1 -1
  87. package/js/src/pro/phemex.js +5 -5
  88. package/js/src/pro/probit.js +4 -4
  89. package/js/src/pro/upbit.d.ts +13 -1
  90. package/js/src/pro/upbit.js +323 -3
  91. package/js/src/pro/wazirx.js +12 -12
  92. package/js/src/pro/woo.js +2 -2
  93. package/js/src/upbit.js +17 -9
  94. package/js/src/woo.d.ts +1 -1
  95. package/js/src/woo.js +6 -2
  96. package/package.json +1 -1
@@ -778,11 +778,11 @@ class lbank extends lbank$1 {
778
778
  const orderBook = this.safeValue(message, 'depth', message);
779
779
  const datetime = this.safeString(message, 'TS');
780
780
  const timestamp = this.parse8601(datetime);
781
- let orderbook = this.safeValue(this.orderbooks, symbol);
782
- if (orderbook === undefined) {
783
- orderbook = this.orderBook({});
784
- this.orderbooks[symbol] = orderbook;
781
+ // let orderbook = this.safeValue (this.orderbooks, symbol);
782
+ if (!(symbol in this.orderbooks)) {
783
+ this.orderbooks[symbol] = this.orderBook({});
785
784
  }
785
+ const orderbook = this.orderbooks[symbol];
786
786
  const snapshot = this.parseOrderBook(orderBook, symbol, timestamp, 'bids', 'asks');
787
787
  orderbook.reset(snapshot);
788
788
  let messageHash = 'orderbook:' + symbol;
@@ -34,7 +34,7 @@ class mexc extends mexc$1 {
34
34
  'api': {
35
35
  'ws': {
36
36
  'spot': 'wss://wbs.mexc.com/ws',
37
- 'swap': 'wss://contract.mexc.com/ws',
37
+ 'swap': 'wss://contract.mexc.com/edge',
38
38
  },
39
39
  },
40
40
  },
@@ -706,11 +706,11 @@ class phemex extends phemex$1 {
706
706
  client.resolve(orderbook, messageHash);
707
707
  }
708
708
  else {
709
- const orderbook = this.safeValue(this.orderbooks, symbol);
710
- if (orderbook !== undefined) {
711
- const changes = this.safeValue2(message, 'book', 'orderbook_p', {});
712
- const asks = this.safeValue(changes, 'asks', []);
713
- const bids = this.safeValue(changes, 'bids', []);
709
+ if (symbol in this.orderbooks) {
710
+ const orderbook = this.orderbooks[symbol];
711
+ const changes = this.safeDict2(message, 'book', 'orderbook_p', {});
712
+ const asks = this.safeList(changes, 'asks', []);
713
+ const bids = this.safeList(changes, 'bids', []);
714
714
  this.customHandleDeltas(orderbook['asks'], asks, market);
715
715
  this.customHandleDeltas(orderbook['bids'], bids, market);
716
716
  orderbook['nonce'] = nonce;
@@ -450,11 +450,11 @@ class probit extends probit$1 {
450
450
  const symbol = this.safeSymbol(marketId);
451
451
  const dataBySide = this.groupBy(orderBook, 'side');
452
452
  const messageHash = 'orderbook:' + symbol;
453
- let orderbook = this.safeValue(this.orderbooks, symbol);
454
- if (orderbook === undefined) {
455
- orderbook = this.orderBook({});
456
- this.orderbooks[symbol] = orderbook;
453
+ // let orderbook = this.safeValue (this.orderbooks, symbol);
454
+ if (!(symbol in this.orderbooks)) {
455
+ this.orderbooks[symbol] = this.orderBook({});
457
456
  }
457
+ const orderbook = this.orderbooks[symbol];
458
458
  const reset = this.safeBool(message, 'reset', false);
459
459
  if (reset) {
460
460
  const snapshot = this.parseOrderBook(dataBySide, symbol, undefined, 'buy', 'sell', 'price', 'quantity');
@@ -2,6 +2,8 @@
2
2
 
3
3
  var upbit$1 = require('../upbit.js');
4
4
  var Cache = require('../base/ws/Cache.js');
5
+ var sha256 = require('../static_dependencies/noble-hashes/sha256.js');
6
+ var rsa = require('../base/functions/rsa.js');
5
7
 
6
8
  // ---------------------------------------------------------------------------
7
9
  // ---------------------------------------------------------------------------
@@ -13,10 +15,13 @@ class upbit extends upbit$1 {
13
15
  'watchOrderBook': true,
14
16
  'watchTicker': true,
15
17
  'watchTrades': true,
18
+ 'watchOrders': true,
19
+ 'watchMyTrades': true,
20
+ 'watchBalance': true,
16
21
  },
17
22
  'urls': {
18
23
  'api': {
19
- 'ws': 'wss://api.upbit.com/websocket/v1',
24
+ 'ws': 'wss://{hostname}/websocket/v1',
20
25
  },
21
26
  },
22
27
  'options': {
@@ -29,7 +34,9 @@ class upbit extends upbit$1 {
29
34
  const market = this.market(symbol);
30
35
  symbol = market['symbol'];
31
36
  const marketId = market['id'];
32
- const url = this.urls['api']['ws'];
37
+ const url = this.implodeParams(this.urls['api']['ws'], {
38
+ 'hostname': this.hostname,
39
+ });
33
40
  this.options[channel] = this.safeValue(this.options, channel, {});
34
41
  this.options[channel][symbol] = true;
35
42
  const symbols = Object.keys(this.options[channel]);
@@ -53,6 +60,7 @@ class upbit extends upbit$1 {
53
60
  * @method
54
61
  * @name upbit#watchTicker
55
62
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
63
+ * @see https://global-docs.upbit.com/reference/websocket-ticker
56
64
  * @param {string} symbol unified symbol of the market to fetch the ticker for
57
65
  * @param {object} [params] extra parameters specific to the exchange API endpoint
58
66
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -64,6 +72,7 @@ class upbit extends upbit$1 {
64
72
  * @method
65
73
  * @name upbit#watchTrades
66
74
  * @description get the list of most recent trades for a particular symbol
75
+ * @see https://global-docs.upbit.com/reference/websocket-trade
67
76
  * @param {string} symbol unified symbol of the market to fetch trades for
68
77
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
69
78
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -83,6 +92,7 @@ class upbit extends upbit$1 {
83
92
  * @method
84
93
  * @name upbit#watchOrderBook
85
94
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
95
+ * @see https://global-docs.upbit.com/reference/websocket-orderbook
86
96
  * @param {string} symbol unified symbol of the market to fetch the order book for
87
97
  * @param {int} [limit] the maximum amount of order book entries to return
88
98
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -217,11 +227,321 @@ class upbit extends upbit$1 {
217
227
  const messageHash = 'trade:' + marketId;
218
228
  client.resolve(stored, messageHash);
219
229
  }
230
+ async authenticate(params = {}) {
231
+ this.checkRequiredCredentials();
232
+ const wsOptions = this.safeDict(this.options, 'ws', {});
233
+ const authenticated = this.safeString(wsOptions, 'token');
234
+ if (authenticated === undefined) {
235
+ const auth = {
236
+ 'access_key': this.apiKey,
237
+ 'nonce': this.uuid(),
238
+ };
239
+ const token = rsa.jwt(auth, this.encode(this.secret), sha256.sha256, false);
240
+ wsOptions['token'] = token;
241
+ wsOptions['options'] = {
242
+ 'headers': {
243
+ 'authorization': 'Bearer ' + token,
244
+ },
245
+ };
246
+ this.options['ws'] = wsOptions;
247
+ }
248
+ const url = this.urls['api']['ws'] + '/private';
249
+ const client = this.client(url);
250
+ return client;
251
+ }
252
+ async watchPrivate(symbol, channel, messageHash, params = {}) {
253
+ await this.authenticate();
254
+ const request = {
255
+ 'type': channel,
256
+ };
257
+ if (symbol !== undefined) {
258
+ await this.loadMarkets();
259
+ const market = this.market(symbol);
260
+ symbol = market['symbol'];
261
+ const symbols = [symbol];
262
+ const marketIds = this.marketIds(symbols);
263
+ request['codes'] = marketIds;
264
+ messageHash = messageHash + ':' + symbol;
265
+ }
266
+ let url = this.implodeParams(this.urls['api']['ws'], {
267
+ 'hostname': this.hostname,
268
+ });
269
+ url += '/private';
270
+ const message = [
271
+ {
272
+ 'ticket': this.uuid(),
273
+ },
274
+ request,
275
+ ];
276
+ return await this.watch(url, messageHash, message, messageHash);
277
+ }
278
+ async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
279
+ /**
280
+ * @method
281
+ * @name upbit#watchOrders
282
+ * @description watches information on multiple orders made by the user
283
+ * @see https://global-docs.upbit.com/reference/websocket-myorder
284
+ * @param {string} symbol unified market symbol of the market orders were made in
285
+ * @param {int} [since] the earliest time in ms to fetch orders for
286
+ * @param {int} [limit] the maximum number of order structures to retrieve
287
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
288
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
289
+ */
290
+ await this.loadMarkets();
291
+ const channel = 'myOrder';
292
+ const messageHash = 'myOrder';
293
+ const orders = await this.watchPrivate(symbol, channel, messageHash);
294
+ if (this.newUpdates) {
295
+ limit = orders.getLimit(symbol, limit);
296
+ }
297
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
298
+ }
299
+ async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
300
+ /**
301
+ * @method
302
+ * @name upbit#watchMyTrades
303
+ * @description watches information on multiple trades made by the user
304
+ * @see https://global-docs.upbit.com/reference/websocket-myorder
305
+ * @param {string} symbol unified market symbol of the market orders were made in
306
+ * @param {int} [since] the earliest time in ms to fetch orders for
307
+ * @param {int} [limit] the maximum number of order structures to retrieve
308
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
309
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
310
+ */
311
+ await this.loadMarkets();
312
+ const channel = 'myOrder';
313
+ const messageHash = 'myTrades';
314
+ const trades = await this.watchPrivate(symbol, channel, messageHash);
315
+ if (this.newUpdates) {
316
+ limit = trades.getLimit(symbol, limit);
317
+ }
318
+ return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
319
+ }
320
+ parseWsOrderStatus(status) {
321
+ const statuses = {
322
+ 'wait': 'open',
323
+ 'done': 'closed',
324
+ 'cancel': 'canceled',
325
+ 'watch': 'open',
326
+ 'trade': 'open',
327
+ };
328
+ return this.safeString(statuses, status, status);
329
+ }
330
+ parseWsOrder(order, market = undefined) {
331
+ //
332
+ // {
333
+ // "type": "myOrder",
334
+ // "code": "SGD-XRP",
335
+ // "uuid": "ac2dc2a3-fce9-40a2-a4f6-5987c25c438f",
336
+ // "ask_bid": "BID",
337
+ // "order_type": "limit",
338
+ // "state": "trade",
339
+ // "price": 0.001453,
340
+ // "avg_price": 0.00145372,
341
+ // "volume": 30925891.29839369,
342
+ // "remaining_volume": 29968038.09235948,
343
+ // "executed_volume": 30925891.29839369,
344
+ // "trades_count": 1,
345
+ // "reserved_fee": 44.23943970238218,
346
+ // "remaining_fee": 21.77177967409916,
347
+ // "paid_fee": 22.467660028283017,
348
+ // "locked": 43565.33112787242,
349
+ // "executed_funds": 44935.32005656603,
350
+ // "order_timestamp": 1710751590000,
351
+ // "timestamp": 1710751597500,
352
+ // "stream_type": "REALTIME"
353
+ // }
354
+ //
355
+ const id = this.safeString(order, 'uuid');
356
+ let side = this.safeStringLower(order, 'ask_bid');
357
+ if (side === 'bid') {
358
+ side = 'buy';
359
+ }
360
+ else {
361
+ side = 'sell';
362
+ }
363
+ const timestamp = this.parse8601(this.safeString(order, 'order_timestamp'));
364
+ const status = this.parseWsOrderStatus(this.safeString(order, 'state'));
365
+ const marketId = this.safeString(order, 'code');
366
+ market = this.safeMarket(marketId, market);
367
+ let fee = undefined;
368
+ const feeCost = this.safeString(order, 'paid_fee');
369
+ if (feeCost !== undefined) {
370
+ fee = {
371
+ 'currency': market['quote'],
372
+ 'cost': feeCost,
373
+ };
374
+ }
375
+ return this.safeOrder({
376
+ 'info': order,
377
+ 'id': id,
378
+ 'clientOrderId': undefined,
379
+ 'timestamp': timestamp,
380
+ 'datetime': this.iso8601(timestamp),
381
+ 'lastTradeTimestamp': this.safeString(order, 'trade_timestamp'),
382
+ 'symbol': market['symbol'],
383
+ 'type': this.safeString(order, 'order_type'),
384
+ 'timeInForce': this.safeString(order, 'time_in_force'),
385
+ 'postOnly': undefined,
386
+ 'side': side,
387
+ 'price': this.safeString(order, 'price'),
388
+ 'stopPrice': undefined,
389
+ 'triggerPrice': undefined,
390
+ 'cost': this.safeString(order, 'executed_funds'),
391
+ 'average': this.safeString(order, 'avg_price'),
392
+ 'amount': this.safeString(order, 'volume'),
393
+ 'filled': this.safeString(order, 'executed_volume'),
394
+ 'remaining': this.safeString(order, 'remaining_volume'),
395
+ 'status': status,
396
+ 'fee': fee,
397
+ 'trades': undefined,
398
+ });
399
+ }
400
+ parseWsTrade(trade, market = undefined) {
401
+ // see: parseWsOrder
402
+ let side = this.safeStringLower(trade, 'ask_bid');
403
+ if (side === 'bid') {
404
+ side = 'buy';
405
+ }
406
+ else {
407
+ side = 'sell';
408
+ }
409
+ const timestamp = this.parse8601(this.safeString(trade, 'trade_timestamp'));
410
+ const marketId = this.safeString(trade, 'code');
411
+ market = this.safeMarket(marketId, market);
412
+ let fee = undefined;
413
+ const feeCost = this.safeString(trade, 'paid_fee');
414
+ if (feeCost !== undefined) {
415
+ fee = {
416
+ 'currency': market['quote'],
417
+ 'cost': feeCost,
418
+ };
419
+ }
420
+ return this.safeTrade({
421
+ 'id': this.safeString(trade, 'trade_uuid'),
422
+ 'timestamp': timestamp,
423
+ 'datetime': this.iso8601(timestamp),
424
+ 'symbol': market['symbol'],
425
+ 'side': side,
426
+ 'price': this.safeString(trade, 'price'),
427
+ 'amount': this.safeString(trade, 'volume'),
428
+ 'cost': this.safeString(trade, 'executed_funds'),
429
+ 'order': this.safeString(trade, 'uuid'),
430
+ 'takerOrMaker': undefined,
431
+ 'type': this.safeString(trade, 'order_type'),
432
+ 'fee': fee,
433
+ 'info': trade,
434
+ }, market);
435
+ }
436
+ handleMyOrder(client, message) {
437
+ // see: parseWsOrder
438
+ const tradeId = this.safeString(message, 'trade_uuid');
439
+ if (tradeId !== undefined) {
440
+ this.handleMyTrade(client, message);
441
+ }
442
+ this.handleOrder(client, message);
443
+ }
444
+ handleMyTrade(client, message) {
445
+ // see: parseWsOrder
446
+ let myTrades = this.myTrades;
447
+ if (myTrades === undefined) {
448
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
449
+ myTrades = new Cache.ArrayCacheBySymbolById(limit);
450
+ }
451
+ const trade = this.parseWsTrade(message);
452
+ myTrades.append(trade);
453
+ let messageHash = 'myTrades';
454
+ client.resolve(myTrades, messageHash);
455
+ messageHash = 'myTrades:' + trade['symbol'];
456
+ client.resolve(myTrades, messageHash);
457
+ }
458
+ handleOrder(client, message) {
459
+ const parsed = this.parseWsOrder(message);
460
+ const symbol = this.safeString(parsed, 'symbol');
461
+ const orderId = this.safeString(parsed, 'id');
462
+ if (this.orders === undefined) {
463
+ const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
464
+ this.orders = new Cache.ArrayCacheBySymbolById(limit);
465
+ }
466
+ const cachedOrders = this.orders;
467
+ const orders = this.safeValue(cachedOrders.hashmap, symbol, {});
468
+ const order = this.safeValue(orders, orderId);
469
+ if (order !== undefined) {
470
+ const fee = this.safeValue(order, 'fee');
471
+ if (fee !== undefined) {
472
+ parsed['fee'] = fee;
473
+ }
474
+ const fees = this.safeValue(order, 'fees');
475
+ if (fees !== undefined) {
476
+ parsed['fees'] = fees;
477
+ }
478
+ parsed['trades'] = this.safeValue(order, 'trades');
479
+ parsed['timestamp'] = this.safeInteger(order, 'timestamp');
480
+ parsed['datetime'] = this.safeString(order, 'datetime');
481
+ }
482
+ cachedOrders.append(parsed);
483
+ let messageHash = 'myOrder';
484
+ client.resolve(this.orders, messageHash);
485
+ messageHash = messageHash + ':' + symbol;
486
+ client.resolve(this.orders, messageHash);
487
+ }
488
+ async watchBalance(params = {}) {
489
+ /**
490
+ * @method
491
+ * @name upbit#watchBalance
492
+ * @see https://global-docs.upbit.com/reference/websocket-myasset
493
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
494
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
495
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
496
+ */
497
+ await this.loadMarkets();
498
+ const channel = 'myAsset';
499
+ const messageHash = 'myAsset';
500
+ return await this.watchPrivate(undefined, channel, messageHash);
501
+ }
502
+ handleBalance(client, message) {
503
+ //
504
+ // {
505
+ // "type": "myAsset",
506
+ // "asset_uuid": "e635f223-1609-4969-8fb6-4376937baad6",
507
+ // "assets": [
508
+ // {
509
+ // "currency": "SGD",
510
+ // "balance": 1386929.37231066771348207123,
511
+ // "locked": 10329.670127489597585685
512
+ // }
513
+ // ],
514
+ // "asset_timestamp": 1710146517259,
515
+ // "timestamp": 1710146517267,
516
+ // "stream_type": "REALTIME"
517
+ // }
518
+ //
519
+ const data = this.safeList(message, 'assets', []);
520
+ const timestamp = this.safeInteger(message, 'timestamp');
521
+ this.balance['timestamp'] = timestamp;
522
+ this.balance['datetime'] = this.iso8601(timestamp);
523
+ for (let i = 0; i < data.length; i++) {
524
+ const balance = data[i];
525
+ const currencyId = this.safeString(balance, 'currency');
526
+ const code = this.safeCurrencyCode(currencyId);
527
+ const available = this.safeString(balance, 'balance');
528
+ const frozen = this.safeString(balance, 'locked');
529
+ const account = this.account();
530
+ account['free'] = available;
531
+ account['used'] = frozen;
532
+ this.balance[code] = account;
533
+ this.balance = this.safeBalance(this.balance);
534
+ }
535
+ const messageHash = this.safeString(message, 'type');
536
+ client.resolve(this.balance, messageHash);
537
+ }
220
538
  handleMessage(client, message) {
221
539
  const methods = {
222
540
  'ticker': this.handleTicker,
223
541
  'orderbook': this.handleOrderBook,
224
542
  'trade': this.handleTrades,
543
+ 'myOrder': this.handleMyOrder,
544
+ 'myAsset': this.handleBalance,
225
545
  };
226
546
  const methodName = this.safeString(message, 'type');
227
547
  const method = this.safeValue(methods, methodName);
@@ -520,21 +520,21 @@ class wazirx extends wazirx$1 {
520
520
  const market = this.safeMarket(marketId);
521
521
  const symbol = market['symbol'];
522
522
  const messageHash = 'orderbook:' + symbol;
523
- const currentOrderBook = this.safeValue(this.orderbooks, symbol);
524
- if (currentOrderBook === undefined) {
523
+ // const currentOrderBook = this.safeValue (this.orderbooks, symbol);
524
+ if (!(symbol in this.orderbooks)) {
525
525
  const snapshot = this.parseOrderBook(data, symbol, timestamp, 'b', 'a');
526
- const orderBook = this.orderBook(snapshot);
527
- this.orderbooks[symbol] = orderBook;
526
+ this.orderbooks[symbol] = this.orderBook(snapshot);
528
527
  }
529
528
  else {
530
- const asks = this.safeValue(data, 'a', []);
531
- const bids = this.safeValue(data, 'b', []);
532
- this.handleDeltas(currentOrderBook['asks'], asks);
533
- this.handleDeltas(currentOrderBook['bids'], bids);
534
- currentOrderBook['nonce'] = timestamp;
535
- currentOrderBook['timestamp'] = timestamp;
536
- currentOrderBook['datetime'] = this.iso8601(timestamp);
537
- this.orderbooks[symbol] = currentOrderBook;
529
+ const orderbook = this.orderbooks[symbol];
530
+ const asks = this.safeList(data, 'a', []);
531
+ const bids = this.safeList(data, 'b', []);
532
+ this.handleDeltas(orderbook['asks'], asks);
533
+ this.handleDeltas(orderbook['bids'], bids);
534
+ orderbook['nonce'] = timestamp;
535
+ orderbook['timestamp'] = timestamp;
536
+ orderbook['datetime'] = this.iso8601(timestamp);
537
+ this.orderbooks[symbol] = orderbook;
538
538
  }
539
539
  client.resolve(this.orderbooks[symbol], messageHash);
540
540
  }
@@ -595,7 +595,7 @@ class woo extends woo$1 {
595
595
  async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
596
596
  /**
597
597
  * @method
598
- * @name woo#watchOrders
598
+ * @name woo#watchMyTrades
599
599
  * @see https://docs.woo.org/#executionreport
600
600
  * @see https://docs.woo.org/#algoexecutionreportv2
601
601
  * @description watches information on multiple trades made by the user
@@ -604,7 +604,7 @@ class woo extends woo$1 {
604
604
  * @param {int} [limit] the maximum number of order structures to retrieve
605
605
  * @param {object} [params] extra parameters specific to the exchange API endpoint
606
606
  * @param {bool} [params.trigger] true if trigger order
607
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
607
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
608
608
  */
609
609
  await this.loadMarkets();
610
610
  const trigger = this.safeBool2(params, 'stop', 'trigger', false);
@@ -1884,25 +1884,33 @@ class upbit extends upbit$1 {
1884
1884
  }
1885
1885
  if (api === 'private') {
1886
1886
  this.checkRequiredCredentials();
1887
+ headers = {};
1887
1888
  const nonce = this.uuid();
1888
1889
  const request = {
1889
1890
  'access_key': this.apiKey,
1890
1891
  'nonce': nonce,
1891
1892
  };
1892
- if (Object.keys(query).length) {
1893
- const auth = this.urlencode(query);
1893
+ const hasQuery = Object.keys(query).length;
1894
+ let auth = undefined;
1895
+ if ((method !== 'GET') && (method !== 'DELETE')) {
1896
+ body = this.json(params);
1897
+ headers['Content-Type'] = 'application/json';
1898
+ if (hasQuery) {
1899
+ auth = this.urlencode(query);
1900
+ }
1901
+ }
1902
+ else {
1903
+ if (hasQuery) {
1904
+ auth = this.urlencode(this.keysort(query));
1905
+ }
1906
+ }
1907
+ if (auth !== undefined) {
1894
1908
  const hash = this.hash(this.encode(auth), sha512.sha512);
1895
1909
  request['query_hash'] = hash;
1896
1910
  request['query_hash_alg'] = 'SHA512';
1897
1911
  }
1898
1912
  const token = rsa.jwt(request, this.encode(this.secret), sha256.sha256);
1899
- headers = {
1900
- 'Authorization': 'Bearer ' + token,
1901
- };
1902
- if ((method !== 'GET') && (method !== 'DELETE')) {
1903
- body = this.json(params);
1904
- headers['Content-Type'] = 'application/json';
1905
- }
1913
+ headers['Authorization'] = 'Bearer ' + token;
1906
1914
  }
1907
1915
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1908
1916
  }
@@ -1297,7 +1297,9 @@ class woo extends woo$1 {
1297
1297
  // "status":"CANCEL_ALL_SENT"
1298
1298
  // }
1299
1299
  //
1300
- return response;
1300
+ return [
1301
+ this.safeOrder(response),
1302
+ ];
1301
1303
  }
1302
1304
  async cancelAllOrdersAfter(timeout, params = {}) {
1303
1305
  /**
@@ -1324,7 +1326,9 @@ class woo extends woo$1 {
1324
1326
  // "timestamp": 1711534302943
1325
1327
  // }
1326
1328
  //
1327
- return response;
1329
+ return [
1330
+ this.safeOrder(response),
1331
+ ];
1328
1332
  }
1329
1333
  async fetchOrder(id, symbol = undefined, params = {}) {
1330
1334
  /**
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.39";
7
+ declare const version = "4.3.41";
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, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.40';
41
+ const version = '4.3.42';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -1,6 +1,8 @@
1
1
  import { implicitReturnType } from '../base/types.js';
2
2
  import { Exchange as _Exchange } from '../base/Exchange.js';
3
3
  interface Exchange {
4
+ sapiGetCopyTradingFuturesUserStatus(params?: {}): Promise<implicitReturnType>;
5
+ sapiGetCopyTradingFuturesLeadSymbol(params?: {}): Promise<implicitReturnType>;
4
6
  sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
5
7
  sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
6
8
  sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
@@ -1,6 +1,8 @@
1
1
  import { implicitReturnType } from '../base/types.js';
2
2
  import _binance from '../binance.js';
3
3
  interface binance {
4
+ sapiGetCopyTradingFuturesUserStatus(params?: {}): Promise<implicitReturnType>;
5
+ sapiGetCopyTradingFuturesLeadSymbol(params?: {}): Promise<implicitReturnType>;
4
6
  sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
5
7
  sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
6
8
  sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
@@ -1,6 +1,8 @@
1
1
  import { implicitReturnType } from '../base/types.js';
2
2
  import _binance from '../binance.js';
3
3
  interface binance {
4
+ sapiGetCopyTradingFuturesUserStatus(params?: {}): Promise<implicitReturnType>;
5
+ sapiGetCopyTradingFuturesLeadSymbol(params?: {}): Promise<implicitReturnType>;
4
6
  sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
5
7
  sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
6
8
  sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
@@ -1,6 +1,8 @@
1
1
  import { implicitReturnType } from '../base/types.js';
2
2
  import _binance from '../binance.js';
3
3
  interface binance {
4
+ sapiGetCopyTradingFuturesUserStatus(params?: {}): Promise<implicitReturnType>;
5
+ sapiGetCopyTradingFuturesLeadSymbol(params?: {}): Promise<implicitReturnType>;
4
6
  sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
5
7
  sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
6
8
  sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
@@ -147,6 +147,9 @@ interface Exchange {
147
147
  privateGetAccountGreeks(params?: {}): Promise<implicitReturnType>;
148
148
  privateGetAccountPositionTiers(params?: {}): Promise<implicitReturnType>;
149
149
  privateGetAccountMmpConfig(params?: {}): Promise<implicitReturnType>;
150
+ privateGetAccountFixedLoanBorrowingLimit(params?: {}): Promise<implicitReturnType>;
151
+ privateGetAccountFixedLoanBorrowingQuote(params?: {}): Promise<implicitReturnType>;
152
+ privateGetAccountFixedLoanBorrowingOrdersList(params?: {}): Promise<implicitReturnType>;
150
153
  privateGetUsersSubaccountList(params?: {}): Promise<implicitReturnType>;
151
154
  privateGetAccountSubaccountBalances(params?: {}): Promise<implicitReturnType>;
152
155
  privateGetAssetSubaccountBalances(params?: {}): Promise<implicitReturnType>;
@@ -258,6 +261,10 @@ interface Exchange {
258
261
  privatePostAccountSetAccountLevel(params?: {}): Promise<implicitReturnType>;
259
262
  privatePostAccountMmpReset(params?: {}): Promise<implicitReturnType>;
260
263
  privatePostAccountMmpConfig(params?: {}): Promise<implicitReturnType>;
264
+ privatePostAccountFixedLoanBorrowingOrder(params?: {}): Promise<implicitReturnType>;
265
+ privatePostAccountFixedLoanAmendBorrowingOrder(params?: {}): Promise<implicitReturnType>;
266
+ privatePostAccountFixedLoanManualReborrow(params?: {}): Promise<implicitReturnType>;
267
+ privatePostAccountFixedLoanRepayBorrowingOrder(params?: {}): Promise<implicitReturnType>;
261
268
  privatePostUsersSubaccountModifyApikey(params?: {}): Promise<implicitReturnType>;
262
269
  privatePostAssetSubaccountTransfer(params?: {}): Promise<implicitReturnType>;
263
270
  privatePostUsersSubaccountSetTransferOut(params?: {}): Promise<implicitReturnType>;