ccxt 4.3.13 → 4.3.15

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 (61) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/base/Exchange.js +14 -6
  5. package/dist/cjs/src/base/errors.js +8 -1
  6. package/dist/cjs/src/base/functions/misc.js +2 -2
  7. package/dist/cjs/src/base/ws/Client.js +2 -1
  8. package/dist/cjs/src/binance.js +106 -5
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bybit.js +105 -105
  11. package/dist/cjs/src/coinbase.js +103 -0
  12. package/dist/cjs/src/coinex.js +435 -423
  13. package/dist/cjs/src/cryptocom.js +2 -1
  14. package/dist/cjs/src/hitbtc.js +1 -0
  15. package/dist/cjs/src/luno.js +2 -0
  16. package/dist/cjs/src/okx.js +1 -1
  17. package/dist/cjs/src/phemex.js +1 -1
  18. package/dist/cjs/src/pro/hitbtc.js +1 -1
  19. package/dist/cjs/src/pro/independentreserve.js +3 -3
  20. package/dist/cjs/src/pro/poloniex.js +3 -3
  21. package/dist/cjs/src/pro/woo.js +147 -9
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +3 -3
  24. package/js/src/abstract/luno.d.ts +2 -0
  25. package/js/src/alpaca.d.ts +1 -1
  26. package/js/src/base/Exchange.d.ts +5 -5
  27. package/js/src/base/Exchange.js +14 -6
  28. package/js/src/base/errorHierarchy.d.ts +1 -0
  29. package/js/src/base/errorHierarchy.js +1 -0
  30. package/js/src/base/errors.d.ts +5 -1
  31. package/js/src/base/errors.js +8 -2
  32. package/js/src/base/functions/generic.d.ts +1 -1
  33. package/js/src/base/functions/misc.d.ts +5 -4
  34. package/js/src/base/functions/misc.js +2 -2
  35. package/js/src/base/functions/number.d.ts +5 -5
  36. package/js/src/base/functions/rsa.d.ts +2 -1
  37. package/js/src/base/functions/totp.d.ts +1 -1
  38. package/js/src/base/ws/Client.d.ts +8 -7
  39. package/js/src/base/ws/Client.js +2 -1
  40. package/js/src/binance.d.ts +14 -1
  41. package/js/src/binance.js +107 -6
  42. package/js/src/bingx.d.ts +1 -1
  43. package/js/src/bingx.js +1 -0
  44. package/js/src/bybit.js +105 -105
  45. package/js/src/coinbase.d.ts +5 -1
  46. package/js/src/coinbase.js +103 -0
  47. package/js/src/coinex.js +435 -423
  48. package/js/src/cryptocom.js +2 -1
  49. package/js/src/hitbtc.js +1 -0
  50. package/js/src/luno.js +2 -0
  51. package/js/src/okx.js +1 -1
  52. package/js/src/phemex.js +1 -1
  53. package/js/src/pro/hitbtc.js +1 -1
  54. package/js/src/pro/independentreserve.js +3 -3
  55. package/js/src/pro/poloniex.js +3 -3
  56. package/js/src/pro/woo.d.ts +2 -0
  57. package/js/src/pro/woo.js +147 -9
  58. package/js/src/upbit.d.ts +1 -1
  59. package/js/src/woo.d.ts +1 -1
  60. package/js/src/zonda.d.ts +1 -1
  61. package/package.json +1 -1
@@ -499,7 +499,8 @@ export default class cryptocom extends Exchange {
499
499
  const strike = this.safeString(market, 'strike');
500
500
  const marginBuyEnabled = this.safeValue(market, 'margin_buy_enabled');
501
501
  const marginSellEnabled = this.safeValue(market, 'margin_sell_enabled');
502
- const expiry = this.omitZero(this.safeInteger(market, 'expiry_timestamp_ms'));
502
+ const expiryString = this.omitZero(this.safeString(market, 'expiry_timestamp_ms'));
503
+ const expiry = (expiryString !== undefined) ? parseInt(expiryString) : undefined;
503
504
  let symbol = base + '/' + quote;
504
505
  let type = undefined;
505
506
  let contract = undefined;
package/js/src/hitbtc.js CHANGED
@@ -618,6 +618,7 @@ export default class hitbtc extends Exchange {
618
618
  'accountsByType': {
619
619
  'spot': 'spot',
620
620
  'funding': 'wallet',
621
+ 'swap': 'derivatives',
621
622
  'future': 'derivatives',
622
623
  },
623
624
  'withdraw': {
package/js/src/luno.js CHANGED
@@ -150,6 +150,7 @@ export default class luno extends Exchange {
150
150
  'withdrawals': 1,
151
151
  'send': 1,
152
152
  'oauth2/grant': 1,
153
+ 'beneficiaries': 1,
153
154
  // POST /api/exchange/1/move
154
155
  },
155
156
  'put': {
@@ -157,6 +158,7 @@ export default class luno extends Exchange {
157
158
  },
158
159
  'delete': {
159
160
  'withdrawals/{id}': 1,
161
+ 'beneficiaries/{id}': 1,
160
162
  },
161
163
  },
162
164
  },
package/js/src/okx.js CHANGED
@@ -5578,7 +5578,7 @@ export default class okx extends Exchange {
5578
5578
  // }
5579
5579
  //
5580
5580
  const marketId = this.safeString(position, 'instId');
5581
- market = this.safeMarket(marketId, market);
5581
+ market = this.safeMarket(marketId, market, undefined, 'contract');
5582
5582
  const symbol = market['symbol'];
5583
5583
  const pos = this.safeString(position, 'pos'); // 'pos' field: One way mode: 0 if position is not open, 1 if open | Two way (hedge) mode: -1 if short, 1 if long, 0 if position is not open
5584
5584
  const contractsAbs = Precise.stringAbs(pos);
package/js/src/phemex.js CHANGED
@@ -2383,7 +2383,7 @@ export default class phemex extends Exchange {
2383
2383
  lastTradeTimestamp = undefined;
2384
2384
  }
2385
2385
  const timeInForce = this.parseTimeInForce(this.safeString(order, 'timeInForce'));
2386
- const stopPrice = this.omitZero(this.safeNumber2(order, 'stopPx', 'stopPxRp'));
2386
+ const stopPrice = this.omitZero(this.safeString2(order, 'stopPx', 'stopPxRp'));
2387
2387
  const postOnly = (timeInForce === 'PO');
2388
2388
  let reduceOnly = this.safeValue(order, 'reduceOnly');
2389
2389
  const execInst = this.safeString(order, 'execInst');
@@ -1198,7 +1198,7 @@ export default class hitbtc extends hitbtcRest {
1198
1198
  // "id": 1700233093414
1199
1199
  // }
1200
1200
  //
1201
- const messageHash = this.safeInteger(message, 'id');
1201
+ const messageHash = this.safeString(message, 'id');
1202
1202
  const result = this.safeValue(message, 'result', {});
1203
1203
  if (Array.isArray(result)) {
1204
1204
  const parsedOrders = [];
@@ -135,9 +135,9 @@ export default class independentreserve extends independentreserveRest {
135
135
  if (limit === undefined) {
136
136
  limit = 100;
137
137
  }
138
- limit = this.numberToString(limit);
139
- const url = this.urls['api']['ws'] + '/orderbook/' + limit + '?subscribe=' + market['base'] + '-' + market['quote'];
140
- const messageHash = 'orderbook:' + symbol + ':' + limit;
138
+ const limitString = this.numberToString(limit);
139
+ const url = this.urls['api']['ws'] + '/orderbook/' + limitString + '?subscribe=' + market['base'] + '-' + market['quote'];
140
+ const messageHash = 'orderbook:' + symbol + ':' + limitString;
141
141
  const subscription = {
142
142
  'receivedSnapshot': false,
143
143
  };
@@ -317,7 +317,7 @@ export default class poloniex extends poloniexRest {
317
317
  // }]
318
318
  // }
319
319
  //
320
- const messageHash = this.safeInteger(message, 'id');
320
+ const messageHash = this.safeString(message, 'id');
321
321
  const data = this.safeValue(message, 'data', []);
322
322
  const orders = [];
323
323
  for (let i = 0; i < data.length; i++) {
@@ -655,8 +655,8 @@ export default class poloniex extends poloniexRest {
655
655
  'type': this.safeStringLower(trade, 'type'),
656
656
  'side': this.safeStringLower2(trade, 'takerSide', 'side'),
657
657
  'takerOrMaker': takerMaker,
658
- 'price': this.omitZero(this.safeNumber2(trade, 'tradePrice', 'price')),
659
- 'amount': this.omitZero(this.safeNumber2(trade, 'filledQuantity', 'quantity')),
658
+ 'price': this.omitZero(this.safeString2(trade, 'tradePrice', 'price')),
659
+ 'amount': this.omitZero(this.safeString2(trade, 'filledQuantity', 'quantity')),
660
660
  'cost': this.safeString2(trade, 'amount', 'filledAmount'),
661
661
  'fee': {
662
662
  'rate': undefined,
@@ -21,9 +21,11 @@ export default class woo extends wooRest {
21
21
  authenticate(params?: {}): Promise<any>;
22
22
  watchPrivate(messageHash: any, message: any, params?: {}): Promise<any>;
23
23
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
24
+ watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
24
25
  parseWsOrder(order: any, market?: any): Order;
25
26
  handleOrderUpdate(client: Client, message: any): void;
26
27
  handleOrder(client: Client, message: any): void;
28
+ handleMyTrade(client: Client, message: any): void;
27
29
  watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
28
30
  setPositionsCache(client: Client, type: any, symbols?: Strings): void;
29
31
  loadPositionsSnapshot(client: any, messageHash: any): Promise<void>;
package/js/src/pro/woo.js CHANGED
@@ -17,7 +17,7 @@ export default class woo extends wooRest {
17
17
  'has': {
18
18
  'ws': true,
19
19
  'watchBalance': true,
20
- 'watchMyTrades': false,
20
+ 'watchMyTrades': true,
21
21
  'watchOHLCV': true,
22
22
  'watchOrderBook': true,
23
23
  'watchOrders': true,
@@ -87,6 +87,7 @@ export default class woo extends wooRest {
87
87
  /**
88
88
  * @method
89
89
  * @name woo#watchOrderBook
90
+ * @see https://docs.woo.org/#orderbook
90
91
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
91
92
  * @param {string} symbol unified symbol of the market to fetch the order book for
92
93
  * @param {int} [limit] the maximum amount of order book entries to return.
@@ -231,6 +232,7 @@ export default class woo extends wooRest {
231
232
  /**
232
233
  * @method
233
234
  * @name woo#watchTickers
235
+ * @see https://docs.woo.org/#24h-tickers
234
236
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
235
237
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
236
238
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -292,6 +294,18 @@ export default class woo extends wooRest {
292
294
  client.resolve(result, topic);
293
295
  }
294
296
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
297
+ /**
298
+ * @method
299
+ * @name woo#watchOHLCV
300
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
301
+ * @see https://docs.woo.org/#k-line
302
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
303
+ * @param {string} timeframe the length of time each candle represents
304
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
305
+ * @param {int} [limit] the maximum amount of candles to fetch
306
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
307
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
308
+ */
295
309
  await this.loadMarkets();
296
310
  if ((timeframe !== '1m') && (timeframe !== '5m') && (timeframe !== '15m') && (timeframe !== '30m') && (timeframe !== '1h') && (timeframe !== '1d') && (timeframe !== '1w') && (timeframe !== '1M')) {
297
311
  throw new ExchangeError(this.id + ' watchOHLCV timeframe argument must be 1m, 5m, 15m, 30m, 1h, 1d, 1w, 1M');
@@ -360,6 +374,7 @@ export default class woo extends wooRest {
360
374
  * @method
361
375
  * @name woo#watchTrades
362
376
  * @description watches information on multiple trades made in a market
377
+ * @see https://docs.woo.org/#trade
363
378
  * @param {string} symbol unified market symbol of the market trades were made in
364
379
  * @param {int} [since] the earliest time in ms to fetch trades for
365
380
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -421,17 +436,60 @@ export default class woo extends wooRest {
421
436
  // "side":"BUY",
422
437
  // "source":0
423
438
  // }
439
+ // private trade
440
+ // {
441
+ // "msgType": 0, // execution report
442
+ // "symbol": "SPOT_BTC_USDT",
443
+ // "clientOrderId": 0,
444
+ // "orderId": 54774393,
445
+ // "type": "MARKET",
446
+ // "side": "BUY",
447
+ // "quantity": 0.0,
448
+ // "price": 0.0,
449
+ // "tradeId": 56201985,
450
+ // "executedPrice": 23534.06,
451
+ // "executedQuantity": 0.00040791,
452
+ // "fee": 2.1E-7,
453
+ // "feeAsset": "BTC",
454
+ // "totalExecutedQuantity": 0.00040791,
455
+ // "avgPrice": 23534.06,
456
+ // "status": "FILLED",
457
+ // "reason": "",
458
+ // "orderTag": "default",
459
+ // "totalFee": 2.1E-7,
460
+ // "feeCurrency": "BTC",
461
+ // "totalRebate": 0,
462
+ // "rebateCurrency": "USDT",
463
+ // "visible": 0.0,
464
+ // "timestamp": 1675406261689,
465
+ // "reduceOnly": false,
466
+ // "maker": false
467
+ // }
424
468
  //
425
469
  const marketId = this.safeString(trade, 'symbol');
426
470
  market = this.safeMarket(marketId, market);
427
471
  const symbol = market['symbol'];
428
- const price = this.safeString(trade, 'price');
429
- const amount = this.safeString(trade, 'size');
472
+ const price = this.safeString(trade, 'executedPrice', 'price');
473
+ const amount = this.safeString2(trade, 'executedQuantity', 'size');
430
474
  const cost = Precise.stringMul(price, amount);
431
475
  const side = this.safeStringLower(trade, 'side');
432
476
  const timestamp = this.safeInteger(trade, 'timestamp');
477
+ const maker = this.safeBool(trade, 'marker');
478
+ let takerOrMaker = undefined;
479
+ if (maker !== undefined) {
480
+ takerOrMaker = maker ? 'maker' : 'taker';
481
+ }
482
+ const type = this.safeStringLower(trade, 'type');
483
+ let fee = undefined;
484
+ const feeCost = this.safeNumber(trade, 'fee');
485
+ if (feeCost !== undefined) {
486
+ fee = {
487
+ 'cost': feeCost,
488
+ 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeCurrency')),
489
+ };
490
+ }
433
491
  return this.safeTrade({
434
- 'id': undefined,
492
+ 'id': this.safeString(trade, 'tradeId'),
435
493
  'timestamp': timestamp,
436
494
  'datetime': this.iso8601(timestamp),
437
495
  'symbol': symbol,
@@ -439,10 +497,10 @@ export default class woo extends wooRest {
439
497
  'price': price,
440
498
  'amount': amount,
441
499
  'cost': cost,
442
- 'order': undefined,
443
- 'takerOrMaker': undefined,
444
- 'type': undefined,
445
- 'fee': undefined,
500
+ 'order': this.safeString(trade, 'orderId'),
501
+ 'takerOrMaker': takerOrMaker,
502
+ 'type': type,
503
+ 'fee': fee,
446
504
  'info': trade,
447
505
  }, market);
448
506
  }
@@ -496,6 +554,8 @@ export default class woo extends wooRest {
496
554
  /**
497
555
  * @method
498
556
  * @name woo#watchOrders
557
+ * @see https://docs.woo.org/#executionreport
558
+ * @see https://docs.woo.org/#algoexecutionreportv2
499
559
  * @description watches information on multiple orders made by the user
500
560
  * @param {string} symbol unified market symbol of the market orders were made in
501
561
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -522,6 +582,37 @@ export default class woo extends wooRest {
522
582
  }
523
583
  return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
524
584
  }
585
+ async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
586
+ /**
587
+ * @method
588
+ * @name woo#watchOrders
589
+ * @see https://docs.woo.org/#executionreport
590
+ * @description watches information on multiple trades made by the user
591
+ * @param {string} symbol unified market symbol of the market orders were made in
592
+ * @param {int} [since] the earliest time in ms to fetch orders for
593
+ * @param {int} [limit] the maximum number of order structures to retrieve
594
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
595
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
596
+ */
597
+ await this.loadMarkets();
598
+ const topic = 'executionreport';
599
+ let messageHash = 'myTrades';
600
+ if (symbol !== undefined) {
601
+ const market = this.market(symbol);
602
+ symbol = market['symbol'];
603
+ messageHash += ':' + symbol;
604
+ }
605
+ const request = {
606
+ 'event': 'subscribe',
607
+ 'topic': topic,
608
+ };
609
+ const message = this.extend(request, params);
610
+ const trades = await this.watchPrivate(messageHash, message);
611
+ if (this.newUpdates) {
612
+ limit = trades.getLimit(symbol, limit);
613
+ }
614
+ return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
615
+ }
525
616
  parseWsOrder(order, market = undefined) {
526
617
  //
527
618
  // {
@@ -630,7 +721,11 @@ export default class woo extends wooRest {
630
721
  // }
631
722
  // }
632
723
  //
633
- const order = this.safeValue(message, 'data');
724
+ const order = this.safeDict(message, 'data');
725
+ const tradeId = this.safeString(order, 'tradeId');
726
+ if ((tradeId !== undefined) && (tradeId !== '0')) {
727
+ this.handleMyTrade(client, order);
728
+ }
634
729
  this.handleOrder(client, order);
635
730
  }
636
731
  handleOrder(client, message) {
@@ -665,6 +760,49 @@ export default class woo extends wooRest {
665
760
  client.resolve(this.orders, messageHashSymbol);
666
761
  }
667
762
  }
763
+ handleMyTrade(client, message) {
764
+ //
765
+ // {
766
+ // "msgType": 0, // execution report
767
+ // "symbol": "SPOT_BTC_USDT",
768
+ // "clientOrderId": 0,
769
+ // "orderId": 54774393,
770
+ // "type": "MARKET",
771
+ // "side": "BUY",
772
+ // "quantity": 0.0,
773
+ // "price": 0.0,
774
+ // "tradeId": 56201985,
775
+ // "executedPrice": 23534.06,
776
+ // "executedQuantity": 0.00040791,
777
+ // "fee": 2.1E-7,
778
+ // "feeAsset": "BTC",
779
+ // "totalExecutedQuantity": 0.00040791,
780
+ // "avgPrice": 23534.06,
781
+ // "status": "FILLED",
782
+ // "reason": "",
783
+ // "orderTag": "default",
784
+ // "totalFee": 2.1E-7,
785
+ // "feeCurrency": "BTC",
786
+ // "totalRebate": 0,
787
+ // "rebateCurrency": "USDT",
788
+ // "visible": 0.0,
789
+ // "timestamp": 1675406261689,
790
+ // "reduceOnly": false,
791
+ // "maker": false
792
+ // }
793
+ //
794
+ let myTrades = this.myTrades;
795
+ if (myTrades === undefined) {
796
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
797
+ myTrades = new ArrayCacheBySymbolById(limit);
798
+ }
799
+ const trade = this.parseWsTrade(message);
800
+ myTrades.append(trade);
801
+ let messageHash = 'myTrades:' + trade['symbol'];
802
+ client.resolve(myTrades, messageHash);
803
+ messageHash = 'myTrades';
804
+ client.resolve(myTrades, messageHash);
805
+ }
668
806
  async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
669
807
  /**
670
808
  * @method
package/js/src/upbit.d.ts CHANGED
@@ -92,7 +92,7 @@ export default class upbit extends Exchange {
92
92
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
93
93
  nonce(): number;
94
94
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
95
- url: any;
95
+ url: string;
96
96
  method: string;
97
97
  body: any;
98
98
  headers: any;
package/js/src/woo.d.ts CHANGED
@@ -111,7 +111,7 @@ export default class woo extends Exchange {
111
111
  };
112
112
  nonce(): number;
113
113
  sign(path: any, section?: string, method?: string, params?: {}, headers?: any, body?: any): {
114
- url: any;
114
+ url: string;
115
115
  method: string;
116
116
  body: any;
117
117
  headers: any;
package/js/src/zonda.d.ts CHANGED
@@ -74,7 +74,7 @@ export default class zonda extends Exchange {
74
74
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
75
75
  parseTransaction(transaction: any, currency?: Currency): Transaction;
76
76
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
77
- url: any;
77
+ url: string;
78
78
  method: string;
79
79
  body: any;
80
80
  headers: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.13",
3
+ "version": "4.3.15",
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",