ccxt 4.2.50 → 4.2.52

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 (44) hide show
  1. package/CHANGELOG.md +76 -16
  2. package/README.md +5 -6
  3. package/dist/ccxt.browser.js +703 -1367
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -4
  6. package/dist/cjs/src/base/Exchange.js +65 -26
  7. package/dist/cjs/src/binance.js +52 -2
  8. package/dist/cjs/src/mexc.js +2 -1
  9. package/dist/cjs/src/okx.js +1 -1
  10. package/dist/cjs/src/pro/binance.js +156 -1
  11. package/dist/cjs/src/pro/bitcoincom.js +4 -5
  12. package/dist/cjs/src/pro/bitfinex2.js +3 -1
  13. package/dist/cjs/src/pro/gate.js +2 -1
  14. package/dist/cjs/src/woo.js +3 -1
  15. package/js/ccxt.d.ts +2 -5
  16. package/js/ccxt.js +2 -4
  17. package/js/src/abstract/binance.d.ts +5 -0
  18. package/js/src/abstract/binancecoinm.d.ts +5 -0
  19. package/js/src/abstract/binanceus.d.ts +5 -0
  20. package/js/src/abstract/binanceusdm.d.ts +5 -0
  21. package/js/src/base/Exchange.d.ts +65 -26
  22. package/js/src/base/Exchange.js +65 -26
  23. package/js/src/binance.d.ts +4 -0
  24. package/js/src/binance.js +52 -2
  25. package/js/src/deribit.js +1 -1
  26. package/js/src/mexc.js +2 -1
  27. package/js/src/ndax.js +1 -1
  28. package/js/src/okx.js +1 -1
  29. package/js/src/pro/binance.d.ts +3 -0
  30. package/js/src/pro/binance.js +156 -1
  31. package/js/src/pro/bingx.js +1 -1
  32. package/js/src/pro/bitcoincom.js +4 -5
  33. package/js/src/pro/bitfinex2.js +3 -1
  34. package/js/src/pro/gate.js +2 -1
  35. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  36. package/js/src/woo.js +4 -2
  37. package/package.json +2 -2
  38. package/skip-tests.json +5 -5
  39. package/dist/cjs/src/abstract/bitforex.js +0 -9
  40. package/dist/cjs/src/bitforex.js +0 -884
  41. package/js/src/abstract/bitforex.d.ts +0 -27
  42. package/js/src/abstract/bitforex.js +0 -11
  43. package/js/src/bitforex.d.ts +0 -39
  44. package/js/src/bitforex.js +0 -885
package/dist/cjs/ccxt.js CHANGED
@@ -30,7 +30,6 @@ var bitcoincom = require('./src/bitcoincom.js');
30
30
  var bitfinex = require('./src/bitfinex.js');
31
31
  var bitfinex2 = require('./src/bitfinex2.js');
32
32
  var bitflyer = require('./src/bitflyer.js');
33
- var bitforex = require('./src/bitforex.js');
34
33
  var bitget = require('./src/bitget.js');
35
34
  var bithumb = require('./src/bithumb.js');
36
35
  var bitmart = require('./src/bitmart.js');
@@ -177,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
177
176
 
178
177
  //-----------------------------------------------------------------------------
179
178
  // this is updated by vss.js when building
180
- const version = '4.2.50';
179
+ const version = '4.2.52';
181
180
  Exchange["default"].ccxtVersion = version;
182
181
  const exchanges = {
183
182
  'ace': ace,
@@ -198,7 +197,6 @@ const exchanges = {
198
197
  'bitfinex': bitfinex,
199
198
  'bitfinex2': bitfinex2,
200
199
  'bitflyer': bitflyer,
201
- 'bitforex': bitforex,
202
200
  'bitget': bitget,
203
201
  'bithumb': bithumb,
204
202
  'bitmart': bitmart,
@@ -404,7 +402,6 @@ exports.bitcoincom = bitcoincom;
404
402
  exports.bitfinex = bitfinex;
405
403
  exports.bitfinex2 = bitfinex2;
406
404
  exports.bitflyer = bitflyer;
407
- exports.bitforex = bitforex;
408
405
  exports.bitget = bitget;
409
406
  exports.bithumb = bithumb;
410
407
  exports.bitmart = bitmart;
@@ -355,51 +355,59 @@ class Exchange {
355
355
  'future': undefined,
356
356
  'option': undefined,
357
357
  'addMargin': undefined,
358
+ 'borrowCrossMargin': undefined,
359
+ 'borrowIsolatedMargin': undefined,
360
+ 'borrowMargin': undefined,
358
361
  'cancelAllOrders': undefined,
362
+ 'cancelAllOrdersWs': undefined,
359
363
  'cancelOrder': true,
360
364
  'cancelOrders': undefined,
365
+ 'cancelOrdersWs': undefined,
366
+ 'cancelOrderWs': undefined,
361
367
  'closeAllPositions': undefined,
362
368
  'closePosition': undefined,
363
369
  'createDepositAddress': undefined,
370
+ 'createLimitBuyOrder': undefined,
364
371
  'createLimitOrder': true,
365
- 'createMarketOrder': true,
366
- 'createOrder': true,
372
+ 'createLimitSellOrder': undefined,
373
+ 'createMarketBuyOrder': undefined,
367
374
  'createMarketBuyOrderWithCost': undefined,
375
+ 'createMarketOrder': true,
368
376
  'createMarketOrderWithCost': undefined,
377
+ 'createMarketSellOrder': undefined,
369
378
  'createMarketSellOrderWithCost': undefined,
379
+ 'createOrder': true,
370
380
  'createOrders': undefined,
371
381
  'createOrderWithTakeProfitAndStopLoss': undefined,
382
+ 'createOrderWs': undefined,
372
383
  'createPostOnlyOrder': undefined,
373
384
  'createReduceOnlyOrder': undefined,
374
- 'createStopLossOrder': undefined,
375
- 'createStopOrder': undefined,
376
385
  'createStopLimitOrder': undefined,
386
+ 'createStopLossOrder': undefined,
377
387
  'createStopMarketOrder': undefined,
388
+ 'createStopOrder': undefined,
378
389
  'createTakeProfitOrder': undefined,
379
390
  'createTrailingAmountOrder': undefined,
380
391
  'createTrailingPercentOrder': undefined,
381
392
  'createTriggerOrder': undefined,
382
- 'createOrderWs': undefined,
383
- 'editOrderWs': undefined,
384
- 'fetchOpenOrdersWs': undefined,
385
- 'fetchClosedOrdersWs': undefined,
386
- 'fetchOrderWs': undefined,
387
- 'fetchOrdersWs': undefined,
388
- 'cancelOrderWs': undefined,
389
- 'cancelOrdersWs': undefined,
390
- 'cancelAllOrdersWs': undefined,
391
- 'fetchTradesWs': undefined,
392
- 'fetchBalanceWs': undefined,
393
+ 'deposit': undefined,
393
394
  'editOrder': 'emulated',
395
+ 'editOrderWs': undefined,
394
396
  'fetchAccounts': undefined,
395
397
  'fetchBalance': true,
398
+ 'fetchBalanceWs': undefined,
396
399
  'fetchBidsAsks': undefined,
397
400
  'fetchBorrowInterest': undefined,
401
+ 'fetchBorrowRate': undefined,
402
+ 'fetchBorrowRateHistories': undefined,
398
403
  'fetchBorrowRateHistory': undefined,
399
- 'fetchCanceledOrders': undefined,
404
+ 'fetchBorrowRates': undefined,
405
+ 'fetchBorrowRatesPerSymbol': undefined,
400
406
  'fetchCanceledAndClosedOrders': undefined,
407
+ 'fetchCanceledOrders': undefined,
401
408
  'fetchClosedOrder': undefined,
402
409
  'fetchClosedOrders': undefined,
410
+ 'fetchClosedOrdersWs': undefined,
403
411
  'fetchCrossBorrowRate': undefined,
404
412
  'fetchCrossBorrowRates': undefined,
405
413
  'fetchCurrencies': 'emulated',
@@ -409,78 +417,109 @@ class Exchange {
409
417
  'fetchDepositAddresses': undefined,
410
418
  'fetchDepositAddressesByNetwork': undefined,
411
419
  'fetchDeposits': undefined,
412
- 'fetchDepositsWs': undefined,
413
420
  'fetchDepositsWithdrawals': undefined,
414
- 'fetchTransactionFee': undefined,
415
- 'fetchTransactionFees': undefined,
421
+ 'fetchDepositsWs': undefined,
422
+ 'fetchDepositWithdrawFee': undefined,
423
+ 'fetchDepositWithdrawFees': undefined,
416
424
  'fetchFundingHistory': undefined,
417
425
  'fetchFundingRate': undefined,
418
426
  'fetchFundingRateHistory': undefined,
419
427
  'fetchFundingRates': undefined,
428
+ 'fetchGreeks': undefined,
420
429
  'fetchIndexOHLCV': undefined,
421
430
  'fetchIsolatedBorrowRate': undefined,
422
431
  'fetchIsolatedBorrowRates': undefined,
432
+ 'fetchIsolatedPositions': undefined,
423
433
  'fetchL2OrderBook': true,
434
+ 'fetchL3OrderBook': undefined,
424
435
  'fetchLastPrices': undefined,
425
436
  'fetchLedger': undefined,
426
437
  'fetchLedgerEntry': undefined,
438
+ 'fetchLeverage': undefined,
427
439
  'fetchLeverageTiers': undefined,
440
+ 'fetchLiquidations': undefined,
441
+ 'fetchMarginMode': undefined,
428
442
  'fetchMarketLeverageTiers': undefined,
429
443
  'fetchMarkets': true,
430
444
  'fetchMarketsWs': undefined,
431
445
  'fetchMarkOHLCV': undefined,
446
+ 'fetchMyLiquidations': undefined,
447
+ 'fetchMySettlementHistory': undefined,
432
448
  'fetchMyTrades': undefined,
449
+ 'fetchMyTradesWs': undefined,
433
450
  'fetchOHLCV': undefined,
434
451
  'fetchOHLCVWs': undefined,
435
452
  'fetchOpenInterest': undefined,
436
453
  'fetchOpenInterestHistory': undefined,
437
454
  'fetchOpenOrder': undefined,
438
455
  'fetchOpenOrders': undefined,
456
+ 'fetchOpenOrdersWs': undefined,
439
457
  'fetchOrder': undefined,
440
458
  'fetchOrderBook': true,
441
459
  'fetchOrderBooks': undefined,
460
+ 'fetchOrderBookWs': undefined,
442
461
  'fetchOrders': undefined,
462
+ 'fetchOrdersByStatus': undefined,
463
+ 'fetchOrdersWs': undefined,
443
464
  'fetchOrderTrades': undefined,
465
+ 'fetchOrderWs': undefined,
444
466
  'fetchPermissions': undefined,
445
467
  'fetchPosition': undefined,
468
+ 'fetchPositionMode': undefined,
446
469
  'fetchPositions': undefined,
447
470
  'fetchPositionsForSymbol': undefined,
448
471
  'fetchPositionsRisk': undefined,
449
472
  'fetchPremiumIndexOHLCV': undefined,
473
+ 'fetchSettlementHistory': undefined,
450
474
  'fetchStatus': undefined,
451
475
  'fetchTicker': true,
452
476
  'fetchTickers': undefined,
477
+ 'fetchTickerWs': undefined,
453
478
  'fetchTime': undefined,
454
479
  'fetchTrades': true,
480
+ 'fetchTradesWs': undefined,
455
481
  'fetchTradingFee': undefined,
456
482
  'fetchTradingFees': undefined,
457
483
  'fetchTradingFeesWs': undefined,
458
484
  'fetchTradingLimits': undefined,
485
+ 'fetchTransactionFee': undefined,
486
+ 'fetchTransactionFees': undefined,
459
487
  'fetchTransactions': undefined,
488
+ 'fetchTransfer': undefined,
460
489
  'fetchTransfers': undefined,
490
+ 'fetchUnderlyingAssets': undefined,
491
+ 'fetchVolatilityHistory': undefined,
461
492
  'fetchWithdrawAddresses': undefined,
462
493
  'fetchWithdrawal': undefined,
463
494
  'fetchWithdrawals': undefined,
464
495
  'fetchWithdrawalsWs': undefined,
496
+ 'fetchWithdrawalWhitelist': undefined,
465
497
  'reduceMargin': undefined,
498
+ 'repayCrossMargin': undefined,
499
+ 'repayIsolatedMargin': undefined,
466
500
  'setLeverage': undefined,
467
501
  'setMargin': undefined,
468
502
  'setMarginMode': undefined,
469
503
  'setPositionMode': undefined,
470
504
  'signIn': undefined,
471
505
  'transfer': undefined,
472
- 'withdraw': undefined,
506
+ 'watchBalance': undefined,
507
+ 'watchMyTrades': undefined,
508
+ 'watchOHLCV': undefined,
509
+ 'watchOHLCVForSymbols': undefined,
473
510
  'watchOrderBook': undefined,
511
+ 'watchOrderBookForSymbols': undefined,
474
512
  'watchOrders': undefined,
475
- 'watchMyTrades': undefined,
476
- 'watchTickers': undefined,
513
+ 'watchOrdersForSymbols': undefined,
514
+ 'watchPosition': undefined,
515
+ 'watchPositions': undefined,
516
+ 'watchStatus': undefined,
477
517
  'watchTicker': undefined,
518
+ 'watchTickers': undefined,
478
519
  'watchTrades': undefined,
479
520
  'watchTradesForSymbols': undefined,
480
- 'watchOrderBookForSymbols': undefined,
481
- 'watchOHLCVForSymbols': undefined,
482
- 'watchBalance': undefined,
483
- 'watchOHLCV': undefined,
521
+ 'withdraw': undefined,
522
+ 'ws': undefined,
484
523
  },
485
524
  'urls': {
486
525
  'logo': undefined,
@@ -44,6 +44,10 @@ class binance extends binance$1 {
44
44
  'createMarketBuyOrderWithCost': true,
45
45
  'createMarketOrderWithCost': true,
46
46
  'createMarketSellOrderWithCost': true,
47
+ 'createLimitBuyOrder': true,
48
+ 'createLimitSellOrder': true,
49
+ 'createMarketBuyOrder': true,
50
+ 'createMarketSellOrder': true,
47
51
  'createOrder': true,
48
52
  'createOrders': true,
49
53
  'createOrderWithTakeProfitAndStopLoss': true,
@@ -108,6 +112,7 @@ class binance extends binance$1 {
108
112
  'fetchOrders': true,
109
113
  'fetchOrderTrades': true,
110
114
  'fetchPosition': true,
115
+ 'fetchPositionMode': true,
111
116
  'fetchPositions': true,
112
117
  'fetchPositionsRisk': true,
113
118
  'fetchPremiumIndexOHLCV': false,
@@ -123,6 +128,7 @@ class binance extends binance$1 {
123
128
  'fetchTransactionFee': 'emulated',
124
129
  'fetchTransactionFees': true,
125
130
  'fetchTransactions': false,
131
+ 'fetchTransfer': false,
126
132
  'fetchTransfers': true,
127
133
  'fetchUnderlyingAssets': false,
128
134
  'fetchVolatilityHistory': false,
@@ -472,6 +478,10 @@ class binance extends binance$1 {
472
478
  'simple-earn/flexible/history/rewardsRecord': 15,
473
479
  'simple-earn/locked/history/rewardsRecord': 15,
474
480
  'simple-earn/flexible/history/collateralRecord': 0.1,
481
+ // Convert
482
+ 'dci/product/list': 0.1,
483
+ 'dci/product/positions': 0.1,
484
+ 'dci/product/accounts': 0.1,
475
485
  },
476
486
  'post': {
477
487
  'asset/dust': 0.06667,
@@ -600,6 +610,9 @@ class binance extends binance$1 {
600
610
  'simple-earn/locked/redeem': 0.1,
601
611
  'simple-earn/flexible/setAutoSubscribe': 15,
602
612
  'simple-earn/locked/setAutoSubscribe': 15,
613
+ // convert
614
+ 'dci/product/subscribe': 0.1,
615
+ 'dci/product/auto_compound/edit': 0.1,
603
616
  },
604
617
  'put': {
605
618
  'userDataStream': 0.1,
@@ -4106,7 +4119,8 @@ class binance extends binance$1 {
4106
4119
  // "closeTime": 1677097200000
4107
4120
  // }
4108
4121
  //
4109
- const volumeIndex = (market['inverse']) ? 7 : 5;
4122
+ const inverse = this.safeBool(market, 'inverse');
4123
+ const volumeIndex = inverse ? 7 : 5;
4110
4124
  return [
4111
4125
  this.safeInteger2(ohlcv, 0, 'closeTime'),
4112
4126
  this.safeNumber2(ohlcv, 1, 'open'),
@@ -8092,7 +8106,6 @@ class binance extends binance$1 {
8092
8106
  /**
8093
8107
  * @method
8094
8108
  * @name binance#fetchTransfers
8095
- * @see https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data
8096
8109
  * @description fetch a history of internal transfers made on an account
8097
8110
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data
8098
8111
  * @param {string} code unified currency code of the currency transferred
@@ -11981,6 +11994,43 @@ class binance extends binance$1 {
11981
11994
  'info': greeks,
11982
11995
  };
11983
11996
  }
11997
+ async fetchPositionMode(symbol = undefined, params = {}) {
11998
+ /**
11999
+ * @method
12000
+ * @name binance#fetchPositionMode
12001
+ * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
12002
+ * @param {string} symbol unified symbol of the market to fetch the order book for
12003
+ * @param {object} params extra parameters specific to the exchange API endpoint
12004
+ * @param {string} params.subType "linear" or "inverse"
12005
+ * @returns {object} an object detailing whether the market is in hedged or one-way mode
12006
+ */
12007
+ let market = undefined;
12008
+ if (symbol !== undefined) {
12009
+ market = this.market(symbol);
12010
+ }
12011
+ let subType = undefined;
12012
+ [subType, params] = this.handleSubTypeAndParams('fetchPositionMode', market, params);
12013
+ let response = undefined;
12014
+ if (subType === 'linear') {
12015
+ response = await this.fapiPrivateGetPositionSideDual(params);
12016
+ }
12017
+ else if (subType === 'inverse') {
12018
+ response = await this.dapiPrivateGetPositionSideDual(params);
12019
+ }
12020
+ else {
12021
+ throw new errors.BadRequest(this.id + ' fetchPositionMode requires either a symbol argument or params["subType"]');
12022
+ }
12023
+ //
12024
+ // {
12025
+ // dualSidePosition: false
12026
+ // }
12027
+ //
12028
+ const dualSidePosition = this.safeBool(response, 'dualSidePosition');
12029
+ return {
12030
+ 'info': response,
12031
+ 'hedged': dualSidePosition,
12032
+ };
12033
+ }
11984
12034
  }
11985
12035
 
11986
12036
  module.exports = binance;
@@ -889,6 +889,7 @@ class mexc extends mexc$1 {
889
889
  '700006': errors.BadRequest,
890
890
  '700007': errors.AuthenticationError,
891
891
  '700008': errors.BadRequest,
892
+ '700013': errors.AuthenticationError,
892
893
  '730001': errors.BadRequest,
893
894
  '730002': errors.BadRequest,
894
895
  '730000': errors.ExchangeError,
@@ -5420,7 +5421,7 @@ class mexc extends mexc$1 {
5420
5421
  'source': this.safeString(this.options, 'broker', 'CCXT'),
5421
5422
  };
5422
5423
  }
5423
- if (method === 'POST') {
5424
+ if ((method === 'POST') || (method === 'PUT')) {
5424
5425
  headers['Content-Type'] = 'application/json';
5425
5426
  }
5426
5427
  }
@@ -5468,7 +5468,7 @@ class okx extends okx$1 {
5468
5468
  const liquidationPrice = this.safeNumber(position, 'liqPx');
5469
5469
  const percentageString = this.safeString(position, 'uplRatio');
5470
5470
  const percentage = this.parseNumber(Precise["default"].stringMul(percentageString, '100'));
5471
- const timestamp = this.safeInteger(position, 'uTime');
5471
+ const timestamp = this.safeInteger(position, 'cTime');
5472
5472
  const marginRatio = this.parseNumber(Precise["default"].stringDiv(maintenanceMarginString, collateralString, 4));
5473
5473
  return this.safePosition({
5474
5474
  'info': position,
@@ -38,9 +38,11 @@ class binance extends binance$1 {
38
38
  'fetchDepositsWs': false,
39
39
  'fetchMarketsWs': false,
40
40
  'fetchMyTradesWs': true,
41
+ 'fetchOHLCVWs': true,
41
42
  'fetchOpenOrdersWs': true,
42
43
  'fetchOrderWs': true,
43
44
  'fetchOrdersWs': true,
45
+ 'fetchTradesWs': true,
44
46
  'fetchTradingFeesWs': false,
45
47
  'fetchWithdrawalsWs': false,
46
48
  },
@@ -837,6 +839,94 @@ class binance extends binance$1 {
837
839
  stored.append(parsed);
838
840
  client.resolve(stored, messageHash);
839
841
  }
842
+ async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
843
+ /**
844
+ * @method
845
+ * @name binance#fetchOHLCVWs
846
+ * @see https://binance-docs.github.io/apidocs/websocket_api/en/#klines
847
+ * @description query historical candlestick data containing the open, high, low, and close price, and the volume of a market
848
+ * @param {string} symbol unified symbol of the market to query OHLCV data for
849
+ * @param {string} timeframe the length of time each candle represents
850
+ * @param {int} since timestamp in ms of the earliest candle to fetch
851
+ * @param {int} limit the maximum amount of candles to fetch
852
+ * @param {object} params extra parameters specific to the exchange API endpoint
853
+ * @param {int} params.until timestamp in ms of the earliest candle to fetch
854
+ *
855
+ * EXCHANGE SPECIFIC PARAMETERS
856
+ * @param {string} params.timeZone default=0 (UTC)
857
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
858
+ */
859
+ await this.loadMarkets();
860
+ this.checkIsSpot('fetchOHLCVWs', symbol, params);
861
+ const url = this.urls['api']['ws']['ws'];
862
+ const requestId = this.requestId(url);
863
+ const messageHash = requestId.toString();
864
+ let returnRateLimits = false;
865
+ [returnRateLimits, params] = this.handleOptionAndParams(params, 'fetchOHLCVWs', 'returnRateLimits', false);
866
+ const payload = {
867
+ 'symbol': this.marketId(symbol),
868
+ 'returnRateLimits': returnRateLimits,
869
+ 'interval': this.timeframes[timeframe],
870
+ };
871
+ const until = this.safeInteger(params, 'until');
872
+ params = this.omit(params, 'until');
873
+ if (since !== undefined) {
874
+ payload['startTime'] = since;
875
+ }
876
+ if (limit !== undefined) {
877
+ payload['limit'] = limit;
878
+ }
879
+ if (until !== undefined) {
880
+ payload['endTime'] = until;
881
+ }
882
+ const message = {
883
+ 'id': messageHash,
884
+ 'method': 'klines',
885
+ 'params': this.extend(payload, params),
886
+ };
887
+ const subscription = {
888
+ 'method': this.handleFetchOHLCV,
889
+ };
890
+ return await this.watch(url, messageHash, message, messageHash, subscription);
891
+ }
892
+ handleFetchOHLCV(client, message) {
893
+ //
894
+ // {
895
+ // "id": "1dbbeb56-8eea-466a-8f6e-86bdcfa2fc0b",
896
+ // "status": 200,
897
+ // "result": [
898
+ // [
899
+ // 1655971200000, // Kline open time
900
+ // "0.01086000", // Open price
901
+ // "0.01086600", // High price
902
+ // "0.01083600", // Low price
903
+ // "0.01083800", // Close price
904
+ // "2290.53800000", // Volume
905
+ // 1655974799999, // Kline close time
906
+ // "24.85074442", // Quote asset volume
907
+ // 2283, // Number of trades
908
+ // "1171.64000000", // Taker buy base asset volume
909
+ // "12.71225884", // Taker buy quote asset volume
910
+ // "0" // Unused field, ignore
911
+ // ]
912
+ // ],
913
+ // "rateLimits": [
914
+ // {
915
+ // "rateLimitType": "REQUEST_WEIGHT",
916
+ // "interval": "MINUTE",
917
+ // "intervalNum": 1,
918
+ // "limit": 6000,
919
+ // "count": 2
920
+ // }
921
+ // ]
922
+ // }
923
+ //
924
+ const result = this.safeList(message, 'result');
925
+ const parsed = this.parseOHLCVs(result);
926
+ // use a reverse lookup in a static map instead
927
+ const messageHash = this.safeString(message, 'id');
928
+ client.resolve(parsed, messageHash);
929
+ }
840
930
  async watchTicker(symbol, params = {}) {
841
931
  /**
842
932
  * @method
@@ -2538,12 +2628,58 @@ class binance extends binance$1 {
2538
2628
  const trades = await this.watch(url, messageHash, message, messageHash, subscription);
2539
2629
  return this.filterBySymbolSinceLimit(trades, symbol, since, limit);
2540
2630
  }
2631
+ async fetchTradesWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2632
+ /**
2633
+ * @method
2634
+ * @name binance#fetchTradesWs
2635
+ * @see https://binance-docs.github.io/apidocs/websocket_api/en/#recent-trades
2636
+ * @description fetch all trades made by the user
2637
+ * @param {string} symbol unified market symbol
2638
+ * @param {int} [since] the earliest time in ms to fetch trades for
2639
+ * @param {int} [limit] the maximum number of trades structures to retrieve, default=500, max=1000
2640
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2641
+ *
2642
+ * EXCHANGE SPECIFIC PARAMETERS
2643
+ * @param {int} [params.fromId] trade ID to begin at
2644
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2645
+ */
2646
+ await this.loadMarkets();
2647
+ if (symbol === undefined) {
2648
+ throw new errors.BadRequest(this.id + ' fetchTradesWs () requires a symbol argument');
2649
+ }
2650
+ this.checkIsSpot('fetchTradesWs', symbol, params);
2651
+ const url = this.urls['api']['ws']['ws'];
2652
+ const requestId = this.requestId(url);
2653
+ const messageHash = requestId.toString();
2654
+ let returnRateLimits = false;
2655
+ [returnRateLimits, params] = this.handleOptionAndParams(params, 'fetchTradesWs', 'returnRateLimits', false);
2656
+ const payload = {
2657
+ 'symbol': this.marketId(symbol),
2658
+ 'returnRateLimits': returnRateLimits,
2659
+ };
2660
+ if (limit !== undefined) {
2661
+ payload['limit'] = limit;
2662
+ }
2663
+ const message = {
2664
+ 'id': messageHash,
2665
+ 'method': 'trades.historical',
2666
+ 'params': this.extend(payload, params),
2667
+ };
2668
+ const subscription = {
2669
+ 'method': this.handleTradesWs,
2670
+ };
2671
+ const trades = await this.watch(url, messageHash, message, messageHash, subscription);
2672
+ return this.filterBySinceLimit(trades, since, limit);
2673
+ }
2541
2674
  handleTradesWs(client, message) {
2675
+ //
2676
+ // fetchMyTradesWs
2542
2677
  //
2543
2678
  // {
2544
2679
  // "id": "f4ce6a53-a29d-4f70-823b-4ab59391d6e8",
2545
2680
  // "status": 200,
2546
- // "result": [{
2681
+ // "result": [
2682
+ // {
2547
2683
  // "symbol": "BTCUSDT",
2548
2684
  // "id": 1650422481,
2549
2685
  // "orderId": 12569099453,
@@ -2562,6 +2698,25 @@ class binance extends binance$1 {
2562
2698
  // ],
2563
2699
  // }
2564
2700
  //
2701
+ // fetchTradesWs
2702
+ //
2703
+ // {
2704
+ // "id": "f4ce6a53-a29d-4f70-823b-4ab59391d6e8",
2705
+ // "status": 200,
2706
+ // "result": [
2707
+ // {
2708
+ // "id": 0,
2709
+ // "price": "0.00005000",
2710
+ // "qty": "40.00000000",
2711
+ // "quoteQty": "0.00200000",
2712
+ // "time": 1500004800376,
2713
+ // "isBuyerMaker": true,
2714
+ // "isBestMatch": true
2715
+ // }
2716
+ // ...
2717
+ // ],
2718
+ // }
2719
+ //
2565
2720
  const messageHash = this.safeString(message, 'id');
2566
2721
  const result = this.safeValue(message, 'result', []);
2567
2722
  const trades = this.parseTrades(result);
@@ -1,17 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var hitbtc = require('./hitbtc.js');
4
- var bequant = require('../bequant.js');
4
+ var hitbtc$1 = require('../hitbtc.js');
5
+ var bitcoincom$1 = require('../bitcoincom.js');
5
6
 
6
7
  // ---------------------------------------------------------------------------
7
8
  // ---------------------------------------------------------------------------
8
9
  class bitcoincom extends hitbtc {
9
10
  describe() {
10
11
  // eslint-disable-next-line new-cap
11
- const restInstance = new bequant();
12
- const restDescribe = restInstance.describe();
13
- const extended = this.deepExtend(super.describe(), restDescribe);
14
- return this.deepExtend(extended, {
12
+ const describeExtended = this.getDescribeForExtendedWsExchange(new bitcoincom$1(), new hitbtc$1(), super.describe());
13
+ return this.deepExtend(describeExtended, {
15
14
  'id': 'bitcoincom',
16
15
  'name': 'bitcoin.com',
17
16
  'countries': ['KN'],
@@ -320,7 +320,9 @@ class bitfinex2 extends bitfinex2$1 {
320
320
  const messageLength = message.length;
321
321
  if (messageLength === 2) {
322
322
  // initial snapshot
323
- const trades = this.safeValue(message, 1, []);
323
+ let trades = this.safeList(message, 1, []);
324
+ // needs to be reversed to make chronological order
325
+ trades = trades.reverse();
324
326
  for (let i = 0; i < trades.length; i++) {
325
327
  const parsed = this.parseWsTrade(trades[i], market);
326
328
  stored.append(parsed);
@@ -383,8 +383,9 @@ class gate extends gate$1 {
383
383
  const parts = channel.split('.');
384
384
  const rawMarketType = this.safeString(parts, 0);
385
385
  const marketType = (rawMarketType === 'futures') ? 'contract' : 'spot';
386
+ const result = this.safeValue(message, 'result');
386
387
  let results = [];
387
- if (marketType === 'contract') {
388
+ if (Array.isArray(result)) {
388
389
  results = this.safeList(message, 'result', []);
389
390
  }
390
391
  else {
@@ -295,7 +295,6 @@ class woo extends woo$1 {
295
295
  '-1007': errors.BadRequest,
296
296
  '-1008': errors.InvalidOrder,
297
297
  '-1009': errors.BadRequest,
298
- '-1011': errors.ExchangeError,
299
298
  '-1012': errors.BadRequest,
300
299
  '-1101': errors.InvalidOrder,
301
300
  '-1102': errors.InvalidOrder,
@@ -304,6 +303,8 @@ class woo extends woo$1 {
304
303
  '-1105': errors.InvalidOrder, // { "code": -1105, "message": "Price is X% too high or X% too low from the mid price." }
305
304
  },
306
305
  'broad': {
306
+ 'Can not place': errors.ExchangeError,
307
+ 'maintenance': errors.OnMaintenance,
307
308
  'symbol must not be blank': errors.BadRequest,
308
309
  'The token is not supported': errors.BadRequest,
309
310
  'Your order and symbol are not valid or already canceled': errors.BadRequest,
@@ -2380,6 +2381,7 @@ class woo extends woo$1 {
2380
2381
  }
2381
2382
  //
2382
2383
  // 400 Bad Request {"success":false,"code":-1012,"message":"Amount is required for buy market orders when margin disabled."}
2384
+ // {"code":"-1011","message":"The system is under maintenance.","success":false}
2383
2385
  //
2384
2386
  const success = this.safeValue(response, 'success');
2385
2387
  const errorCode = this.safeString(response, 'code');