ccxt 4.2.20 → 4.2.22

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 (82) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1405 -274
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +37 -4
  6. package/dist/cjs/src/base/ws/WsClient.js +3 -1
  7. package/dist/cjs/src/bigone.js +1 -0
  8. package/dist/cjs/src/binance.js +14 -3
  9. package/dist/cjs/src/bitget.js +12 -2
  10. package/dist/cjs/src/bitrue.js +1 -0
  11. package/dist/cjs/src/bitvavo.js +271 -172
  12. package/dist/cjs/src/blockchaincom.js +3 -1
  13. package/dist/cjs/src/bybit.js +57 -9
  14. package/dist/cjs/src/coinbasepro.js +1 -0
  15. package/dist/cjs/src/coinex.js +37 -12
  16. package/dist/cjs/src/deribit.js +164 -0
  17. package/dist/cjs/src/gate.js +32 -1
  18. package/dist/cjs/src/novadax.js +26 -22
  19. package/dist/cjs/src/okcoin.js +3 -0
  20. package/dist/cjs/src/phemex.js +7 -3
  21. package/dist/cjs/src/poloniex.js +1 -0
  22. package/dist/cjs/src/pro/bequant.js +6 -1
  23. package/dist/cjs/src/pro/binance.js +7 -4
  24. package/dist/cjs/src/pro/binancecoinm.js +6 -1
  25. package/dist/cjs/src/pro/binanceus.js +6 -1
  26. package/dist/cjs/src/pro/bitcoincom.js +6 -1
  27. package/dist/cjs/src/pro/bitget.js +1 -1
  28. package/dist/cjs/src/pro/bitopro.js +7 -3
  29. package/dist/cjs/src/pro/bitrue.js +6 -1
  30. package/dist/cjs/src/pro/bitvavo.js +668 -22
  31. package/dist/cjs/src/pro/lbank.js +1 -1
  32. package/dist/cjs/src/pro/okx.js +13 -3
  33. package/dist/cjs/src/woo.js +1 -1
  34. package/js/ccxt.d.ts +1 -1
  35. package/js/ccxt.js +1 -1
  36. package/js/src/abstract/binance.d.ts +3 -0
  37. package/js/src/abstract/binancecoinm.d.ts +3 -0
  38. package/js/src/abstract/binanceus.d.ts +4 -0
  39. package/js/src/abstract/binanceusdm.d.ts +3 -0
  40. package/js/src/abstract/gate.d.ts +1 -0
  41. package/js/src/abstract/gateio.d.ts +1 -0
  42. package/js/src/abstract/novadax.d.ts +5 -1
  43. package/js/src/abstract/phemex.d.ts +1 -0
  44. package/js/src/base/Exchange.d.ts +12 -1
  45. package/js/src/base/Exchange.js +37 -4
  46. package/js/src/base/ws/WsClient.js +3 -2
  47. package/js/src/bigone.js +1 -0
  48. package/js/src/binance.js +14 -3
  49. package/js/src/bitget.js +12 -2
  50. package/js/src/bitrue.js +1 -0
  51. package/js/src/bitvavo.d.ts +14 -2
  52. package/js/src/bitvavo.js +271 -172
  53. package/js/src/blockchaincom.js +3 -1
  54. package/js/src/bybit.d.ts +2 -1
  55. package/js/src/bybit.js +57 -9
  56. package/js/src/coinbasepro.js +1 -0
  57. package/js/src/coinex.d.ts +1 -0
  58. package/js/src/coinex.js +37 -12
  59. package/js/src/deribit.d.ts +6 -1
  60. package/js/src/deribit.js +164 -0
  61. package/js/src/gate.d.ts +1 -0
  62. package/js/src/gate.js +32 -1
  63. package/js/src/novadax.js +26 -22
  64. package/js/src/okcoin.js +3 -0
  65. package/js/src/phemex.js +7 -3
  66. package/js/src/poloniex.js +1 -0
  67. package/js/src/pro/bequant.js +6 -1
  68. package/js/src/pro/binance.js +7 -4
  69. package/js/src/pro/binancecoinm.js +6 -1
  70. package/js/src/pro/binanceus.js +6 -1
  71. package/js/src/pro/bitcoincom.js +6 -1
  72. package/js/src/pro/bitget.js +1 -1
  73. package/js/src/pro/bitopro.js +7 -3
  74. package/js/src/pro/bitrue.js +6 -1
  75. package/js/src/pro/bitvavo.d.ts +35 -2
  76. package/js/src/pro/bitvavo.js +669 -23
  77. package/js/src/pro/lbank.js +1 -1
  78. package/js/src/pro/okx.js +13 -3
  79. package/js/src/woo.js +1 -1
  80. package/jsdoc2md.js +38 -16
  81. package/package.json +4 -1
  82. package/skip-tests.json +4 -0
@@ -12,21 +12,38 @@ class bitvavo extends bitvavo$1 {
12
12
  return this.deepExtend(super.describe(), {
13
13
  'has': {
14
14
  'ws': true,
15
- 'createOrderWs': false,
16
- 'editOrderWs': false,
17
- 'fetchOpenOrdersWs': false,
18
- 'fetchOrderWs': false,
19
- 'cancelOrderWs': false,
20
15
  'cancelOrdersWs': false,
21
- 'cancelAllOrdersWs': false,
22
16
  'fetchTradesWs': false,
23
- 'fetchBalanceWs': false,
24
17
  'watchOrderBook': true,
25
18
  'watchTrades': true,
26
19
  'watchTicker': true,
27
20
  'watchOHLCV': true,
28
21
  'watchOrders': true,
29
22
  'watchMyTrades': true,
23
+ 'cancelAllOrdersWs': true,
24
+ 'cancelOrderWs': true,
25
+ 'createOrderWs': true,
26
+ 'createStopLimitOrderWs': true,
27
+ 'createStopMarketOrderWs': true,
28
+ 'createStopOrderWs': true,
29
+ 'editOrderWs': true,
30
+ 'fetchBalanceWs': true,
31
+ 'fetchCurrenciesWS': true,
32
+ 'fetchDepositAddressWs': true,
33
+ 'fetchDepositsWs': true,
34
+ 'fetchDepositWithdrawFeesWs': true,
35
+ 'fetchMyTradesWs': true,
36
+ 'fetchOHLCVWs': true,
37
+ 'fetchOpenOrdersWs': true,
38
+ 'fetchOrderWs': true,
39
+ 'fetchOrderBookWs': true,
40
+ 'fetchOrdersWs': true,
41
+ 'fetchTickerWs': true,
42
+ 'fetchTickersWs': true,
43
+ 'fetchTimeWs': true,
44
+ 'fetchTradingFeesWs': true,
45
+ 'fetchWithdrawalsWs': true,
46
+ 'withdrawWs': true,
30
47
  },
31
48
  'urls': {
32
49
  'api': {
@@ -34,6 +51,7 @@ class bitvavo extends bitvavo$1 {
34
51
  },
35
52
  },
36
53
  'options': {
54
+ 'supressMultipleWsRequestsError': false,
37
55
  'tradesLimit': 1000,
38
56
  'ordersLimit': 1000,
39
57
  'OHLCVLimit': 1000,
@@ -189,6 +207,22 @@ class bitvavo extends bitvavo$1 {
189
207
  }
190
208
  return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
191
209
  }
210
+ handleFetchOHLCV(client, message) {
211
+ //
212
+ // {
213
+ // action: 'getCandles',
214
+ // response: [
215
+ // [1690325820000, '26453', '26453', '26436', '26447', '0.01626246'],
216
+ // [1690325760000, '26454', '26454', '26453', '26453', '0.00037707']
217
+ // ]
218
+ // }
219
+ //
220
+ const action = this.safeString(message, 'action');
221
+ const response = this.safeValue(message, 'response');
222
+ const ohlcv = this.parseOHLCVs(response, undefined, undefined, undefined);
223
+ const messageHash = this.buildMessageHash(action);
224
+ client.resolve(ohlcv, messageHash);
225
+ }
192
226
  handleOHLCV(client, message) {
193
227
  //
194
228
  // {
@@ -494,6 +528,584 @@ class bitvavo extends bitvavo$1 {
494
528
  }
495
529
  return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
496
530
  }
531
+ async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
532
+ /**
533
+ * @method
534
+ * @name bitvavo#createOrderWs
535
+ * @description create a trade order
536
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1order/post
537
+ * @param {string} symbol unified symbol of the market to create an order in
538
+ * @param {string} type 'market' or 'limit'
539
+ * @param {string} side 'buy' or 'sell'
540
+ * @param {float} amount how much of currency you want to trade in units of base currency
541
+ * @param {float} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
542
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
543
+ * @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
544
+ * @param {float} [params.stopPrice] The price at which a trigger order is triggered at
545
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
546
+ * @param {bool} [params.postOnly] If true, the order will only be posted to the order book and not executed immediately
547
+ * @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
548
+ * @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
549
+ * @param {string} [params.triggerType] "price"
550
+ * @param {string} [params.triggerReference] "lastTrade", "bestBid", "bestAsk", "midPrice" Only for stop orders: Use this to determine which parameter will trigger the order
551
+ * @param {string} [params.selfTradePrevention] "decrementAndCancel", "cancelOldest", "cancelNewest", "cancelBoth"
552
+ * @param {bool} [params.disableMarketProtection] don't cancel if the next fill price is 10% worse than the best fill price
553
+ * @param {bool} [params.responseRequired] Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
554
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
555
+ */
556
+ await this.loadMarkets();
557
+ await this.authenticate();
558
+ const request = this.createOrderRequest(symbol, type, side, amount, price, params);
559
+ return await this.watchRequest('privateCreateOrder', request);
560
+ }
561
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
562
+ /**
563
+ * @method
564
+ * @name bitvavo#editOrderWs
565
+ * @description edit a trade order
566
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1order/put
567
+ * @param {string} id cancel order id
568
+ * @param {string} symbol unified symbol of the market to create an order in
569
+ * @param {string} type 'market' or 'limit'
570
+ * @param {string} side 'buy' or 'sell'
571
+ * @param {float} [amount] how much of currency you want to trade in units of base currency
572
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
573
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
574
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
575
+ */
576
+ await this.loadMarkets();
577
+ await this.authenticate();
578
+ const request = this.editOrderRequest(id, symbol, type, side, amount, price, params);
579
+ return await this.watchRequest('privateUpdateOrder', request);
580
+ }
581
+ async cancelOrderWs(id, symbol = undefined, params = {}) {
582
+ /**
583
+ * @method
584
+ * @name bitvavo#cancelOrderWs
585
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1order/delete
586
+ * @description cancels an open order
587
+ * @param {string} id order id
588
+ * @param {string} symbol unified symbol of the market the order was made in
589
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
590
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
591
+ */
592
+ await this.loadMarkets();
593
+ await this.authenticate();
594
+ const request = this.cancelOrderRequest(id, symbol, params);
595
+ return await this.watchRequest('privateCancelOrder', request);
596
+ }
597
+ async cancelAllOrdersWs(symbol = undefined, params = {}) {
598
+ /**
599
+ * @method
600
+ * @name bitvavo#cancelAllOrdersWs
601
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1orders/delete
602
+ * @description cancel all open orders
603
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
604
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
605
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
606
+ */
607
+ await this.loadMarkets();
608
+ await this.authenticate();
609
+ const request = {};
610
+ let market = undefined;
611
+ if (symbol !== undefined) {
612
+ market = this.market(symbol);
613
+ request['market'] = market['id'];
614
+ }
615
+ return await this.watchRequest('privateCancelOrders', this.extend(request, params));
616
+ }
617
+ handleMultipleOrders(client, message) {
618
+ //
619
+ // {
620
+ // action: 'privateCancelOrders',
621
+ // response: [{
622
+ // orderId: 'd71df826-1130-478a-8741-d219128675b0'
623
+ // }]
624
+ // }
625
+ //
626
+ const action = this.safeString(message, 'action');
627
+ const response = this.safeValue(message, 'response');
628
+ const firstRawOrder = this.safeValue(response, 0, {});
629
+ const marketId = this.safeString(firstRawOrder, 'market');
630
+ const orders = this.parseOrders(response);
631
+ let messageHash = this.buildMessageHash(action, { 'market': marketId });
632
+ client.resolve(orders, messageHash);
633
+ messageHash = this.buildMessageHash(action, message);
634
+ client.resolve(orders, messageHash);
635
+ }
636
+ async fetchOrderWs(id, symbol = undefined, params = {}) {
637
+ /**
638
+ * @method
639
+ * @name bitvavo#fetchOrderWs
640
+ * @see https://docs.bitvavo.com/#tag/General/paths/~1assets/get
641
+ * @description fetches information on an order made by the user
642
+ * @param {string} symbol unified symbol of the market the order was made in
643
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
644
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
645
+ */
646
+ if (symbol === undefined) {
647
+ throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
648
+ }
649
+ await this.loadMarkets();
650
+ await this.authenticate();
651
+ const market = this.market(symbol);
652
+ const request = {
653
+ 'orderId': id,
654
+ 'market': market['id'],
655
+ };
656
+ return await this.watchRequest('privateGetOrder', this.extend(request, params));
657
+ }
658
+ async fetchOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
659
+ /**
660
+ * @method
661
+ * @name bitvavo#fetchOrdersWs
662
+ * @see https://docs.bitvavo.com/#tag/Orders/paths/~1orders/get
663
+ * @description fetches information on multiple orders made by the user
664
+ * @param {string} symbol unified market symbol of the market orders were made in
665
+ * @param {int} [since] the earliest time in ms to fetch orders for
666
+ * @param {int} [limit] the maximum number of orde structures to retrieve
667
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
668
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
669
+ */
670
+ if (symbol === undefined) {
671
+ throw new errors.ArgumentsRequired(this.id + ' fetchOrdersWs() requires a symbol argument');
672
+ }
673
+ await this.loadMarkets();
674
+ await this.authenticate();
675
+ const request = this.fetchOrdersRequest(symbol, since, limit, params);
676
+ const orders = await this.watchRequest('privateGetOrders', request);
677
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
678
+ }
679
+ async watchRequest(action, request) {
680
+ request['action'] = action;
681
+ const messageHash = this.buildMessageHash(action, request);
682
+ this.checkMessageHashDoesNotExist(messageHash);
683
+ const url = this.urls['api']['ws'];
684
+ return await this.watch(url, messageHash, request, messageHash);
685
+ }
686
+ async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
687
+ /**
688
+ * @method
689
+ * @name bitvavo#fetchOpenOrdersWs
690
+ * @description fetch all unfilled currently open orders
691
+ * @param {string} symbol unified market symbol
692
+ * @param {int} [since] the earliest time in ms to fetch open orders for
693
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
694
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
695
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
696
+ */
697
+ await this.loadMarkets();
698
+ await this.authenticate();
699
+ const request = {
700
+ // 'market': market['id'], // rate limit 25 without a market, 1 with market specified
701
+ };
702
+ let market = undefined;
703
+ if (symbol !== undefined) {
704
+ market = this.market(symbol);
705
+ request['market'] = market['id'];
706
+ }
707
+ const orders = await this.watchRequest('privateGetOrdersOpen', this.extend(request, params));
708
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
709
+ }
710
+ async fetchMyTradesWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
711
+ /**
712
+ * @method
713
+ * @name bitvavo#fetchMyTradesWs
714
+ * @see https://docs.bitvavo.com/#tag/Trades
715
+ * @description fetch all trades made by the user
716
+ * @param {string} symbol unified market symbol
717
+ * @param {int} [since] the earliest time in ms to fetch trades for
718
+ * @param {int} [limit] the maximum number of trades structures to retrieve
719
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
720
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
721
+ */
722
+ if (symbol === undefined) {
723
+ throw new errors.ArgumentsRequired(this.id + ' fetchMyTradesWs() requires a symbol argument');
724
+ }
725
+ await this.loadMarkets();
726
+ await this.authenticate();
727
+ const request = this.fetchMyTradesRequest(symbol, since, limit, params);
728
+ const myTrades = await this.watchRequest('privateGetTrades', request);
729
+ return this.filterBySymbolSinceLimit(myTrades, symbol, since, limit);
730
+ }
731
+ handleMyTrades(client, message) {
732
+ //
733
+ // {
734
+ // action: 'privateGetTrades',
735
+ // response: [
736
+ // {
737
+ // "id": "108c3633-0276-4480-a902-17a01829deae",
738
+ // "orderId": "1d671998-3d44-4df4-965f-0d48bd129a1b",
739
+ // "timestamp": 1542967486256,
740
+ // "market": "BTC-EUR",
741
+ // "side": "buy",
742
+ // "amount": "0.005",
743
+ // "price": "5000.1",
744
+ // "taker": true,
745
+ // "fee": "0.03",
746
+ // "feeCurrency": "EUR",
747
+ // "settled": true
748
+ // }
749
+ // ]
750
+ // }
751
+ //
752
+ //
753
+ const action = this.safeString(message, 'action');
754
+ const response = this.safeValue(message, 'response');
755
+ const firstRawTrade = this.safeValue(response, 0, {});
756
+ const marketId = this.safeString(firstRawTrade, 'market');
757
+ const trades = this.parseTrades(response, undefined, undefined, undefined);
758
+ const messageHash = this.buildMessageHash(action, { 'market': marketId });
759
+ client.resolve(trades, messageHash);
760
+ }
761
+ async withdrawWs(code, amount, address, tag = undefined, params = {}) {
762
+ /**
763
+ * @method
764
+ * @name bitvavo#withdrawWs
765
+ * @description make a withdrawal
766
+ * @param {string} code unified currency code
767
+ * @param {float} amount the amount to withdraw
768
+ * @param {string} address the address to withdraw to
769
+ * @param {string} tag
770
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
771
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
772
+ */
773
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
774
+ this.checkAddress(address);
775
+ await this.loadMarkets();
776
+ await this.authenticate();
777
+ const request = this.withdrawRequest(code, amount, address, tag, params);
778
+ return await this.watchRequest('privateWithdrawAssets', request);
779
+ }
780
+ handleWithdraw(client, message) {
781
+ //
782
+ // {
783
+ // action: 'privateWithdrawAssets',
784
+ // response: {
785
+ // "success": true,
786
+ // "symbol": "BTC",
787
+ // "amount": "1.5"
788
+ // }
789
+ // }
790
+ //
791
+ const action = this.safeString(message, 'action');
792
+ const messageHash = this.buildMessageHash(action, message);
793
+ const response = this.safeValue(message, 'response');
794
+ const withdraw = this.parseTransaction(response);
795
+ client.resolve(withdraw, messageHash);
796
+ }
797
+ async fetchWithdrawalsWs(code = undefined, since = undefined, limit = undefined, params = {}) {
798
+ /**
799
+ * @method
800
+ * @name bitvavo#fetchWithdrawalsWs
801
+ * @see https://docs.bitvavo.com/#tag/Account/paths/~1withdrawalHistory/get
802
+ * @description fetch all withdrawals made from an account
803
+ * @param {string} code unified currency code
804
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
805
+ * @param {int} [limit] the maximum number of withdrawals structures to retrieve
806
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
807
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
808
+ */
809
+ await this.loadMarkets();
810
+ await this.authenticate();
811
+ const request = this.fetchWithdrawalsRequest(code, since, limit, params);
812
+ const withdraws = await this.watchRequest('privateGetWithdrawalHistory', request);
813
+ return this.filterByCurrencySinceLimit(withdraws, code, since, limit);
814
+ }
815
+ handleWithdraws(client, message) {
816
+ //
817
+ // {
818
+ // action: 'privateGetWithdrawalHistory',
819
+ // response: [{
820
+ // timestamp: 1689792085000,
821
+ // symbol: 'BTC',
822
+ // amount: '0.0009',
823
+ // fee: '0',
824
+ // status: 'completed',
825
+ // txId: '7dbadc658d7d59c129de1332c55ee8e08d0ab74432faae03b417b9809c819d1f'
826
+ // },
827
+ // ...
828
+ // ]
829
+ // }
830
+ //
831
+ const action = this.safeString(message, 'action');
832
+ const messageHash = this.buildMessageHash(action, message);
833
+ const response = this.safeValue(message, 'response');
834
+ const withdrawals = this.parseTransactions(response, undefined, undefined, undefined, { 'type': 'withdrawal' });
835
+ client.resolve(withdrawals, messageHash);
836
+ }
837
+ async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
838
+ /**
839
+ * @method
840
+ * @name bitvavo#fetchOHLCVWs
841
+ * @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1candles/get
842
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
843
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
844
+ * @param {string} timeframe the length of time each candle represents
845
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
846
+ * @param {int} [limit] the maximum amount of candles to fetch
847
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
848
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
849
+ */
850
+ await this.loadMarkets();
851
+ const request = this.fetchOHLCVRequest(symbol, timeframe, since, limit, params);
852
+ const action = 'getCandles';
853
+ const ohlcv = await this.watchRequest(action, request);
854
+ return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
855
+ }
856
+ async fetchDepositsWs(code = undefined, since = undefined, limit = undefined, params = {}) {
857
+ /**
858
+ * @method
859
+ * @name bitvavo#fetchDepositsWs
860
+ * @see https://docs.bitvavo.com/#tag/Account/paths/~1depositHistory/get
861
+ * @description fetch all deposits made to an account
862
+ * @param {string} code unified currency code
863
+ * @param {int} [since] the earliest time in ms to fetch deposits for
864
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
865
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
866
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
867
+ */
868
+ await this.loadMarkets();
869
+ await this.authenticate();
870
+ const request = this.fetchDepositsRequest(code, since, limit, params);
871
+ const deposits = await this.watchRequest('privateGetDepositHistory', request);
872
+ return this.filterByCurrencySinceLimit(deposits, code, since, limit);
873
+ }
874
+ handleDeposits(client, message) {
875
+ //
876
+ // {
877
+ // action: 'privateGetDepositHistory',
878
+ // response: [{
879
+ // timestamp: 1689792085000,
880
+ // symbol: 'BTC',
881
+ // amount: '0.0009',
882
+ // fee: '0',
883
+ // status: 'completed',
884
+ // txId: '7dbadc658d7d59c129de1332c55ee8e08d0ab74432faae03b417b9809c819d1f'
885
+ // },
886
+ // ...
887
+ // ]
888
+ // }
889
+ //
890
+ const action = this.safeString(message, 'action');
891
+ const messageHash = this.buildMessageHash(action, message);
892
+ const response = this.safeValue(message, 'response');
893
+ const deposits = this.parseTransactions(response, undefined, undefined, undefined, { 'type': 'deposit' });
894
+ client.resolve(deposits, messageHash);
895
+ }
896
+ async fetchTradingFeesWs(params = {}) {
897
+ /**
898
+ * @method
899
+ * @name bitvavo#fetchTradingFeesWs
900
+ * @see https://docs.bitvavo.com/#tag/Account/paths/~1account/get
901
+ * @description fetch the trading fees for multiple markets
902
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
903
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
904
+ */
905
+ await this.loadMarkets();
906
+ await this.authenticate();
907
+ return await this.watchRequest('privateGetAccount', params);
908
+ }
909
+ async fetchMarketsWs(params = {}) {
910
+ /**
911
+ * @method
912
+ * @name bitvavo#fetchMarketsWs
913
+ * @see https://docs.bitvavo.com/#tag/General/paths/~1markets/get
914
+ * @description retrieves data on all markets for bitvavo
915
+ * @param {object} [params] extra parameters specific to the exchange api endpoint
916
+ * @returns {object[]} an array of objects representing market data
917
+ */
918
+ return await this.watchRequest('getMarkets', params);
919
+ }
920
+ async fetchCurrenciesWs(params = {}) {
921
+ /**
922
+ * @method
923
+ * @name bitvavo#fetchCurrenciesWs
924
+ * @see https://docs.bitvavo.com/#tag/General/paths/~1assets/get
925
+ * @description fetches all available currencies on an exchange
926
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
927
+ * @returns {object} an associative dictionary of currencies
928
+ */
929
+ await this.loadMarkets();
930
+ return await this.watchRequest('getAssets', params);
931
+ }
932
+ handleFetchCurrencies(client, message) {
933
+ //
934
+ // {
935
+ // action: 'getAssets',
936
+ // response: [{
937
+ // symbol: '1INCH',
938
+ // name: '1inch',
939
+ // decimals: 8,
940
+ // depositFee: '0',
941
+ // depositConfirmations: 64,
942
+ // depositStatus: 'OK',
943
+ // withdrawalFee: '13',
944
+ // withdrawalMinAmount: '13',
945
+ // withdrawalStatus: 'OK',
946
+ // networks: [Array],
947
+ // message: ''
948
+ // },
949
+ // ...
950
+ // ]
951
+ // }
952
+ //
953
+ const action = this.safeString(message, 'action');
954
+ const messageHash = this.buildMessageHash(action, message);
955
+ const response = this.safeValue(message, 'response');
956
+ const currencies = this.parseCurrencies(response);
957
+ client.resolve(currencies, messageHash);
958
+ }
959
+ handleTradingFees(client, message) {
960
+ //
961
+ // {
962
+ // action: 'privateGetAccount',
963
+ // response: {
964
+ // fees: {
965
+ // taker: '0.0025',
966
+ // maker: '0.0015',
967
+ // volume: '1693.74'
968
+ // }
969
+ // }
970
+ // }
971
+ //
972
+ const action = this.safeString(message, 'action');
973
+ const messageHash = this.buildMessageHash(action, message);
974
+ const response = this.safeValue(message, 'response');
975
+ const fees = this.parseTradingFees(response);
976
+ client.resolve(fees, messageHash);
977
+ }
978
+ async fetchBalanceWs(params = {}) {
979
+ /**
980
+ * @method
981
+ * @name bitvavo#fetchBalanceWs
982
+ * @see https://docs.bitvavo.com/#tag/Account/paths/~1balance/get
983
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
984
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
985
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/en/latest/manual.html?#balance-structure}
986
+ */
987
+ await this.loadMarkets();
988
+ await this.authenticate();
989
+ return await this.watchRequest('privateGetBalance', params);
990
+ }
991
+ handleFetchBalance(client, message) {
992
+ //
993
+ // {
994
+ // action: 'privateGetBalance',
995
+ // response: [{
996
+ // symbol: 'ADA',
997
+ // available: '0',
998
+ // inOrder: '0'
999
+ // },
1000
+ // ...
1001
+ // ]
1002
+ // }
1003
+ //
1004
+ const action = this.safeString(message, 'action', 'privateGetBalance');
1005
+ const messageHash = this.buildMessageHash(action, message);
1006
+ const response = this.safeValue(message, 'response', []);
1007
+ const balance = this.parseBalance(response);
1008
+ client.resolve(balance, messageHash);
1009
+ }
1010
+ handleSingleOrder(client, message) {
1011
+ //
1012
+ // {
1013
+ // action: 'privateCreateOrder',
1014
+ // response: {
1015
+ // orderId: 'd71df826-1130-478a-8741-d219128675b0',
1016
+ // market: 'BTC-EUR',
1017
+ // created: 1689792749748,
1018
+ // updated: 1689792749748,
1019
+ // status: 'new',
1020
+ // side: 'sell',
1021
+ // orderType: 'limit',
1022
+ // amount: '0.0002',
1023
+ // amountRemaining: '0.0002',
1024
+ // price: '37000',
1025
+ // onHold: '0.0002',
1026
+ // onHoldCurrency: 'BTC',
1027
+ // filledAmount: '0',
1028
+ // filledAmountQuote: '0',
1029
+ // feePaid: '0',
1030
+ // feeCurrency: 'EUR',
1031
+ // fills: [],
1032
+ // selfTradePrevention: 'decrementAndCancel',
1033
+ // visible: true,
1034
+ // timeInForce: 'GTC',
1035
+ // postOnly: false
1036
+ // }
1037
+ // }
1038
+ //
1039
+ const action = this.safeString(message, 'action');
1040
+ const response = this.safeValue(message, 'response', {});
1041
+ const order = this.parseOrder(response);
1042
+ const messageHash = this.buildMessageHash(action, response);
1043
+ client.resolve(order, messageHash);
1044
+ }
1045
+ handleMarkets(client, message) {
1046
+ //
1047
+ // {
1048
+ // action: 'getMarkets',
1049
+ // response: [{
1050
+ // market: '1INCH-EUR',
1051
+ // status: 'trading',
1052
+ // base: '1INCH',
1053
+ // quote: 'EUR',
1054
+ // pricePrecision: 5,
1055
+ // minOrderInBaseAsset: '2',
1056
+ // minOrderInQuoteAsset: '5',
1057
+ // maxOrderInBaseAsset: '1000000000',
1058
+ // maxOrderInQuoteAsset: '1000000000',
1059
+ // orderTypes: [Array]
1060
+ // },
1061
+ // ...
1062
+ // ]
1063
+ // }
1064
+ //
1065
+ const action = this.safeString(message, 'action');
1066
+ const response = this.safeValue(message, 'response', {});
1067
+ const markets = this.parseMarkets(response);
1068
+ const messageHash = this.buildMessageHash(action, response);
1069
+ client.resolve(markets, messageHash);
1070
+ }
1071
+ buildMessageHash(action, params = {}) {
1072
+ const methods = {
1073
+ 'privateCreateOrder': this.actionAndMarketMessageHash,
1074
+ 'privateUpdateOrder': this.actionAndOrderIdMessageHash,
1075
+ 'privateCancelOrder': this.actionAndOrderIdMessageHash,
1076
+ 'privateGetOrder': this.actionAndOrderIdMessageHash,
1077
+ 'privateGetTrades': this.actionAndMarketMessageHash,
1078
+ };
1079
+ const method = this.safeValue(methods, action);
1080
+ let messageHash = action;
1081
+ if (method !== undefined) {
1082
+ messageHash = method.call(this, action, params);
1083
+ }
1084
+ return messageHash;
1085
+ }
1086
+ checkMessageHashDoesNotExist(messageHash) {
1087
+ const supressMultipleWsRequestsError = this.safeValue(this.options, 'supressMultipleWsRequestsError', false);
1088
+ if (!supressMultipleWsRequestsError) {
1089
+ const client = this.safeValue(this.clients, this.urls['api']['ws']);
1090
+ if (client !== undefined) {
1091
+ const future = this.safeValue(client.futures, messageHash);
1092
+ if (future !== undefined) {
1093
+ throw new errors.ExchangeError(this.id + ' a similar request with messageHash ' + messageHash + ' is already pending, you must wait for a response, or turn off this error by setting supressMultipleWsRequestsError in the options to true');
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+ actionAndMarketMessageHash(action, params = {}) {
1099
+ const symbol = this.safeString(params, 'market', '');
1100
+ return action + symbol;
1101
+ }
1102
+ actionAndOrderIdMessageHash(action, params = {}) {
1103
+ const orderId = this.safeString(params, 'orderId');
1104
+ if (orderId === undefined) {
1105
+ throw new errors.ExchangeError(this.id + ' privateUpdateOrderMessageHash requires a orderId parameter');
1106
+ }
1107
+ return action + orderId;
1108
+ }
497
1109
  handleOrder(client, message) {
498
1110
  //
499
1111
  // {
@@ -627,6 +1239,31 @@ class bitvavo extends bitvavo$1 {
627
1239
  }
628
1240
  }
629
1241
  }
1242
+ handleErrorMessage(client, message) {
1243
+ //
1244
+ // {
1245
+ // action: 'privateCreateOrder',
1246
+ // market: 'BTC-EUR',
1247
+ // errorCode: 217,
1248
+ // error: 'Minimum order size in quote currency is 5 EUR or 0.001 BTC.'
1249
+ // }
1250
+ //
1251
+ const error = this.safeString(message, 'error');
1252
+ const code = this.safeInteger(error, 'errorCode');
1253
+ const action = this.safeString(message, 'action');
1254
+ const messageHash = this.buildMessageHash(action, message);
1255
+ let rejected = false;
1256
+ try {
1257
+ this.handleErrors(code, error, client.url, undefined, undefined, error, message, undefined, undefined);
1258
+ }
1259
+ catch (e) {
1260
+ rejected = true;
1261
+ client.reject(e, messageHash);
1262
+ }
1263
+ if (!rejected) {
1264
+ client.reject(message, messageHash);
1265
+ }
1266
+ }
630
1267
  handleMessage(client, message) {
631
1268
  //
632
1269
  // {
@@ -636,7 +1273,6 @@ class bitvavo extends bitvavo$1 {
636
1273
  // }
637
1274
  // }
638
1275
  //
639
- //
640
1276
  // {
641
1277
  // "event": "book",
642
1278
  // "market": "BTC-EUR",
@@ -672,6 +1308,10 @@ class bitvavo extends bitvavo$1 {
672
1308
  // "authenticated": true
673
1309
  // }
674
1310
  //
1311
+ const error = this.safeString(message, 'error');
1312
+ if (error !== undefined) {
1313
+ this.handleErrorMessage(client, message);
1314
+ }
675
1315
  const methods = {
676
1316
  'subscribed': this.handleSubscriptionStatus,
677
1317
  'book': this.handleOrderBook,
@@ -682,21 +1322,27 @@ class bitvavo extends bitvavo$1 {
682
1322
  'authenticate': this.handleAuthenticationMessage,
683
1323
  'order': this.handleOrder,
684
1324
  'fill': this.handleMyTrade,
1325
+ 'privateCreateOrder': this.handleSingleOrder,
1326
+ 'privateUpdateOrder': this.handleSingleOrder,
1327
+ 'privateGetBalance': this.handleFetchBalance,
1328
+ 'privateCancelOrders': this.handleMultipleOrders,
1329
+ 'privateGetOrders': this.handleMultipleOrders,
1330
+ 'privateGetOrder': this.handleSingleOrder,
1331
+ 'privateCancelOrder': this.handleSingleOrder,
1332
+ 'privateGetOrdersOpen': this.handleMultipleOrders,
1333
+ 'privateGetAccount': this.handleTradingFees,
1334
+ 'privateGetDepositHistory': this.handleDeposits,
1335
+ 'privateGetWithdrawalHistory': this.handleWithdraws,
1336
+ 'privateWithdrawAssets': this.handleWithdraw,
1337
+ 'privateGetTrades': this.handleMyTrades,
1338
+ 'getAssets': this.handleFetchCurrencies,
1339
+ 'getCandles': this.handleFetchOHLCV,
1340
+ 'getMarkets': this.handleMarkets,
685
1341
  };
686
- const event = this.safeString(message, 'event');
687
- let method = this.safeValue(methods, event);
688
- if (method === undefined) {
689
- const action = this.safeString(message, 'action');
690
- method = this.safeValue(methods, action);
691
- if (method === undefined) {
692
- return message;
693
- }
694
- else {
695
- return method.call(this, client, message);
696
- }
697
- }
698
- else {
699
- return method.call(this, client, message);
1342
+ const event = this.safeString2(message, 'event', 'action');
1343
+ const method = this.safeValue(methods, event);
1344
+ if (method !== undefined) {
1345
+ method.call(this, client, message);
700
1346
  }
701
1347
  }
702
1348
  }