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
@@ -6,10 +6,15 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import hitbtc from './hitbtc.js';
9
+ import bequantRest from '../bequant.js';
9
10
  // ---------------------------------------------------------------------------
10
11
  export default class bequant extends hitbtc {
11
12
  describe() {
12
- return this.deepExtend(super.describe(), {
13
+ // eslint-disable-next-line new-cap
14
+ const restInstance = new bequantRest();
15
+ const restDescribe = restInstance.describe();
16
+ const extended = this.deepExtend(super.describe(), restDescribe);
17
+ return this.deepExtend(extended, {
13
18
  'id': 'bequant',
14
19
  'name': 'Bequant',
15
20
  'countries': ['MT'],
@@ -47,7 +47,7 @@ export default class binance extends binanceRest {
47
47
  'ws': {
48
48
  'spot': 'wss://testnet.binance.vision/ws',
49
49
  'margin': 'wss://testnet.binance.vision/ws',
50
- 'future': 'wss://stream.binancefuture.com/ws',
50
+ 'future': 'wss://fstream.binancefuture.com/ws',
51
51
  'delivery': 'wss://dstream.binancefuture.com/ws',
52
52
  'ws': 'wss://testnet.binance.vision/ws-api/v3',
53
53
  },
@@ -1980,12 +1980,13 @@ export default class binance extends binanceRest {
1980
1980
  /**
1981
1981
  * @method
1982
1982
  * @name binance#watchOrders
1983
- * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
1984
1983
  * @description watches information on multiple orders made by the user
1985
- * @param {string} symbol unified market symbol of the market orders were made in
1984
+ * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
1985
+ * @param {string} symbol unified market symbol of the market the orders were made in
1986
1986
  * @param {int} [since] the earliest time in ms to fetch orders for
1987
1987
  * @param {int} [limit] the maximum number of order structures to retrieve
1988
1988
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1989
+ * @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
1989
1990
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1990
1991
  */
1991
1992
  await this.loadMarkets();
@@ -2008,8 +2009,10 @@ export default class binance extends binanceRest {
2008
2009
  }
2009
2010
  params = this.extend(params, { 'type': type, 'symbol': symbol }); // needed inside authenticate for isolated margin
2010
2011
  await this.authenticate(params);
2012
+ let marginMode = undefined;
2013
+ [marginMode, params] = this.handleMarginModeAndParams('watchOrders', params);
2011
2014
  let urlType = type;
2012
- if (type === 'margin') {
2015
+ if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
2013
2016
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
2014
2017
  }
2015
2018
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
@@ -6,10 +6,15 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import binance from './binance.js';
9
+ import binancecoinmRest from '../binancecoinm.js';
9
10
  // ---------------------------------------------------------------------------
10
11
  export default class binancecoinm extends binance {
11
12
  describe() {
12
- return this.deepExtend(super.describe(), {
13
+ // eslint-disable-next-line new-cap
14
+ const restInstance = new binancecoinmRest();
15
+ const restDescribe = restInstance.describe();
16
+ const extended = this.deepExtend(super.describe(), restDescribe);
17
+ return this.deepExtend(extended, {
13
18
  'id': 'binancecoinm',
14
19
  'name': 'Binance COIN-M',
15
20
  'urls': {
@@ -6,10 +6,15 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import binance from './binance.js';
9
+ import binanceusRest from '../binanceus.js';
9
10
  // ---------------------------------------------------------------------------
10
11
  export default class binanceus extends binance {
11
12
  describe() {
12
- return this.deepExtend(super.describe(), {
13
+ // eslint-disable-next-line new-cap
14
+ const restInstance = new binanceusRest();
15
+ const restDescribe = restInstance.describe();
16
+ const extended = this.deepExtend(super.describe(), restDescribe);
17
+ return this.deepExtend(extended, {
13
18
  'id': 'binanceus',
14
19
  'name': 'Binance US',
15
20
  'countries': ['US'],
@@ -6,10 +6,15 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import hitbtc from './hitbtc.js';
9
+ import bequantRest from '../bequant.js';
9
10
  // ---------------------------------------------------------------------------
10
11
  export default class bitcoincom extends hitbtc {
11
12
  describe() {
12
- return this.deepExtend(super.describe(), {
13
+ // eslint-disable-next-line new-cap
14
+ const restInstance = new bequantRest();
15
+ const restDescribe = restInstance.describe();
16
+ const extended = this.deepExtend(super.describe(), restDescribe);
17
+ return this.deepExtend(extended, {
13
18
  'id': 'bitcoincom',
14
19
  'name': 'bitcoin.com',
15
20
  'countries': ['KN'],
@@ -1248,7 +1248,7 @@ export default class bitget extends bitgetRest {
1248
1248
  'price': this.safeString(order, 'price'),
1249
1249
  'stopPrice': triggerPrice,
1250
1250
  'triggerPrice': triggerPrice,
1251
- 'amount': this.safeString2(order, 'size', 'baseSize'),
1251
+ 'amount': this.safeString(order, 'baseVolume'),
1252
1252
  'cost': this.safeStringN(order, ['notional', 'notionalUsd', 'quoteSize']),
1253
1253
  'average': this.omitZero(this.safeString2(order, 'priceAvg', 'fillPrice')),
1254
1254
  'filled': this.safeString2(order, 'accBaseVolume', 'baseVolume'),
@@ -26,8 +26,8 @@ export default class bitopro extends bitoproRest {
26
26
  },
27
27
  'urls': {
28
28
  'ws': {
29
- 'public': 'wss://stream.bitopro.com:9443/ws/v1/pub',
30
- 'private': 'wss://stream.bitopro.com:9443/ws/v1/pub/auth',
29
+ 'public': 'wss://stream.bitopro.com:443/ws/v1/pub',
30
+ 'private': 'wss://stream.bitopro.com:443/ws/v1/pub/auth',
31
31
  },
32
32
  },
33
33
  'requiredCredentials': {
@@ -56,6 +56,7 @@ export default class bitopro extends bitoproRest {
56
56
  * @method
57
57
  * @name bitopro#watchOrderBook
58
58
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
59
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/public/order_book_stream.md
59
60
  * @param {string} symbol unified symbol of the market to fetch the order book for
60
61
  * @param {int} [limit] the maximum amount of order book entries to return
61
62
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -121,6 +122,7 @@ export default class bitopro extends bitoproRest {
121
122
  * @method
122
123
  * @name bitopro#watchTrades
123
124
  * @description get the list of most recent trades for a particular symbol
125
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/public/trade_stream.md
124
126
  * @param {string} symbol unified symbol of the market to fetch trades for
125
127
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
126
128
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -180,6 +182,7 @@ export default class bitopro extends bitoproRest {
180
182
  * @method
181
183
  * @name bitopro#watchTicker
182
184
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
185
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/public/ticker_stream.md
183
186
  * @param {string} symbol unified symbol of the market to fetch the ticker for
184
187
  * @param {object} [params] extra parameters specific to the exchange API endpoint
185
188
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -233,7 +236,7 @@ export default class bitopro extends bitoproRest {
233
236
  'identity': this.login,
234
237
  });
235
238
  const payload = this.stringToBase64(rawData);
236
- const signature = this.hmac(payload, this.encode(this.secret), sha384);
239
+ const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha384);
237
240
  const defaultOptions = {
238
241
  'ws': {
239
242
  'options': {
@@ -259,6 +262,7 @@ export default class bitopro extends bitoproRest {
259
262
  * @method
260
263
  * @name bitopro#watchBalance
261
264
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
265
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/ws/private/user_balance_stream.md
262
266
  * @param {object} [params] extra parameters specific to the exchange API endpoint
263
267
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
264
268
  */
@@ -349,7 +349,12 @@ export default class bitrue extends bitrueRest {
349
349
  const symbol = market['symbol'];
350
350
  const timestamp = this.safeInteger(message, 'ts');
351
351
  const tick = this.safeValue(message, 'tick', {});
352
- const orderbook = this.parseOrderBook(tick, symbol, timestamp, 'buys', 'asks');
352
+ let orderbook = this.safeValue(this.orderbooks, symbol);
353
+ if (orderbook === undefined) {
354
+ orderbook = this.orderBook();
355
+ }
356
+ const snapshot = this.parseOrderBook(tick, symbol, timestamp, 'buys', 'asks');
357
+ orderbook.reset(snapshot);
353
358
  this.orderbooks[symbol] = orderbook;
354
359
  const messageHash = 'orderbook:' + symbol;
355
360
  client.resolve(orderbook, messageHash);
@@ -1,5 +1,5 @@
1
1
  import bitvavoRest from '../bitvavo.js';
2
- import type { Int, Str, OrderBook, Order, Trade, Ticker, OHLCV } from '../base/types.js';
2
+ import { Int, Str, OrderSide, OrderType, OrderBook, Ticker, Trade, Order, OHLCV, Balances } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class bitvavo extends bitvavoRest {
5
5
  describe(): any;
@@ -9,6 +9,7 @@ export default class bitvavo extends bitvavoRest {
9
9
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
10
10
  handleTrade(client: Client, message: any): void;
11
11
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
12
+ handleFetchOHLCV(client: Client, message: any): void;
12
13
  handleOHLCV(client: Client, message: any): void;
13
14
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
14
15
  handleDelta(bookside: any, delta: any): void;
@@ -21,10 +22,42 @@ export default class bitvavo extends bitvavoRest {
21
22
  handleOrderBookSubscriptions(client: Client, message: any, marketIds: any): void;
22
23
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
23
24
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
25
+ createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
26
+ editOrderWs(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
27
+ cancelOrderWs(id: string, symbol?: string, params?: {}): Promise<any>;
28
+ cancelAllOrdersWs(symbol?: string, params?: {}): Promise<any>;
29
+ handleMultipleOrders(client: Client, message: any): void;
30
+ fetchOrderWs(id: string, symbol?: string, params?: {}): Promise<Order>;
31
+ fetchOrdersWs(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
32
+ watchRequest(action: any, request: any): Promise<any>;
33
+ fetchOpenOrdersWs(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
34
+ fetchMyTradesWs(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
35
+ handleMyTrades(client: Client, message: any): void;
36
+ withdrawWs(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<any>;
37
+ handleWithdraw(client: Client, message: any): void;
38
+ fetchWithdrawalsWs(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
39
+ handleWithdraws(client: Client, message: any): void;
40
+ fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
41
+ fetchDepositsWs(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
42
+ handleDeposits(client: Client, message: any): void;
43
+ fetchTradingFeesWs(params?: {}): Promise<any>;
44
+ fetchMarketsWs(params?: {}): Promise<any>;
45
+ fetchCurrenciesWs(params?: {}): Promise<any>;
46
+ handleFetchCurrencies(client: Client, message: any): void;
47
+ handleTradingFees(client: any, message: any): void;
48
+ fetchBalanceWs(params?: {}): Promise<Balances>;
49
+ handleFetchBalance(client: Client, message: any): void;
50
+ handleSingleOrder(client: Client, message: any): void;
51
+ handleMarkets(client: Client, message: any): void;
52
+ buildMessageHash(action: any, params?: {}): any;
53
+ checkMessageHashDoesNotExist(messageHash: any): void;
54
+ actionAndMarketMessageHash(action: any, params?: {}): string;
55
+ actionAndOrderIdMessageHash(action: any, params?: {}): string;
24
56
  handleOrder(client: Client, message: any): void;
25
57
  handleMyTrade(client: Client, message: any): void;
26
58
  handleSubscriptionStatus(client: Client, message: any): any;
27
59
  authenticate(params?: {}): any;
28
60
  handleAuthenticationMessage(client: Client, message: any): void;
29
- handleMessage(client: Client, message: any): any;
61
+ handleErrorMessage(client: Client, message: any): void;
62
+ handleMessage(client: Client, message: any): void;
30
63
  }