ccxt 4.2.52 → 4.2.54

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 (49) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +511 -102
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +136 -9
  7. package/dist/cjs/src/bingx.js +32 -1
  8. package/dist/cjs/src/bitget.js +1 -0
  9. package/dist/cjs/src/bitvavo.js +1 -1
  10. package/dist/cjs/src/bybit.js +19 -0
  11. package/dist/cjs/src/coinbase.js +186 -12
  12. package/dist/cjs/src/htx.js +10 -4
  13. package/dist/cjs/src/pro/binance.js +92 -38
  14. package/dist/cjs/src/pro/bitvavo.js +1 -1
  15. package/dist/cjs/src/pro/blockchaincom.js +7 -25
  16. package/dist/cjs/src/pro/deribit.js +2 -2
  17. package/dist/cjs/src/pro/gemini.js +1 -1
  18. package/dist/cjs/src/pro/okx.js +18 -4
  19. package/dist/cjs/src/whitebit.js +4 -3
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/binance.d.ts +9 -3
  23. package/js/src/abstract/binancecoinm.d.ts +9 -3
  24. package/js/src/abstract/binanceus.d.ts +9 -3
  25. package/js/src/abstract/binanceusdm.d.ts +9 -3
  26. package/js/src/abstract/coinbase.d.ts +1 -1
  27. package/js/src/binance.d.ts +4 -0
  28. package/js/src/binance.js +136 -9
  29. package/js/src/bingx.d.ts +4 -0
  30. package/js/src/bingx.js +32 -1
  31. package/js/src/bitget.js +1 -0
  32. package/js/src/bitvavo.js +1 -1
  33. package/js/src/bybit.d.ts +5 -0
  34. package/js/src/bybit.js +19 -0
  35. package/js/src/coinbase.d.ts +2 -0
  36. package/js/src/coinbase.js +186 -12
  37. package/js/src/htx.js +10 -4
  38. package/js/src/pro/binance.d.ts +4 -4
  39. package/js/src/pro/binance.js +92 -38
  40. package/js/src/pro/bitvavo.js +1 -1
  41. package/js/src/pro/blockchaincom.d.ts +0 -1
  42. package/js/src/pro/blockchaincom.js +7 -25
  43. package/js/src/pro/deribit.js +2 -2
  44. package/js/src/pro/gemini.js +1 -1
  45. package/js/src/pro/okx.js +18 -4
  46. package/js/src/whitebit.js +4 -3
  47. package/jsdoc2md.js +3 -2
  48. package/package.json +2 -1
  49. package/skip-tests.json +26 -9
@@ -63,6 +63,7 @@ class binance extends binance$1 {
63
63
  'future': 'wss://fstream.binance.com/ws',
64
64
  'delivery': 'wss://dstream.binance.com/ws',
65
65
  'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
66
+ 'papi': 'wss://fstream.binance.com/pm/ws',
66
67
  },
67
68
  },
68
69
  },
@@ -1238,11 +1239,12 @@ class binance extends binance$1 {
1238
1239
  }
1239
1240
  async authenticate(params = {}) {
1240
1241
  const time = this.milliseconds();
1241
- let query = undefined;
1242
1242
  let type = undefined;
1243
- [type, query] = this.handleMarketTypeAndParams('authenticate', undefined, params);
1243
+ [type, params] = this.handleMarketTypeAndParams('authenticate', undefined, params);
1244
1244
  let subType = undefined;
1245
- [subType, query] = this.handleSubTypeAndParams('authenticate', undefined, query);
1245
+ [subType, params] = this.handleSubTypeAndParams('authenticate', undefined, params);
1246
+ let isPortfolioMargin = undefined;
1247
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'authenticate', 'papi', 'portfolioMargin', false);
1246
1248
  if (this.isLinear(type, subType)) {
1247
1249
  type = 'future';
1248
1250
  }
@@ -1250,36 +1252,39 @@ class binance extends binance$1 {
1250
1252
  type = 'delivery';
1251
1253
  }
1252
1254
  let marginMode = undefined;
1253
- [marginMode, query] = this.handleMarginModeAndParams('authenticate', query);
1255
+ [marginMode, params] = this.handleMarginModeAndParams('authenticate', params);
1254
1256
  const isIsolatedMargin = (marginMode === 'isolated');
1255
1257
  const isCrossMargin = (marginMode === 'cross') || (marginMode === undefined);
1256
- const symbol = this.safeString(query, 'symbol');
1257
- query = this.omit(query, 'symbol');
1258
+ const symbol = this.safeString(params, 'symbol');
1259
+ params = this.omit(params, 'symbol');
1258
1260
  const options = this.safeValue(this.options, type, {});
1259
1261
  const lastAuthenticatedTime = this.safeInteger(options, 'lastAuthenticatedTime', 0);
1260
1262
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
1261
1263
  const delay = this.sum(listenKeyRefreshRate, 10000);
1262
1264
  if (time - lastAuthenticatedTime > delay) {
1263
1265
  let response = undefined;
1264
- if (type === 'future') {
1265
- response = await this.fapiPrivatePostListenKey(query);
1266
+ if (isPortfolioMargin) {
1267
+ response = await this.papiPostListenKey(params);
1268
+ }
1269
+ else if (type === 'future') {
1270
+ response = await this.fapiPrivatePostListenKey(params);
1266
1271
  }
1267
1272
  else if (type === 'delivery') {
1268
- response = await this.dapiPrivatePostListenKey(query);
1273
+ response = await this.dapiPrivatePostListenKey(params);
1269
1274
  }
1270
1275
  else if (type === 'margin' && isCrossMargin) {
1271
- response = await this.sapiPostUserDataStream(query);
1276
+ response = await this.sapiPostUserDataStream(params);
1272
1277
  }
1273
1278
  else if (isIsolatedMargin) {
1274
1279
  if (symbol === undefined) {
1275
1280
  throw new errors.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
1276
1281
  }
1277
1282
  const marketId = this.marketId(symbol);
1278
- query = this.extend(query, { 'symbol': marketId });
1279
- response = await this.sapiPostUserDataStreamIsolated(query);
1283
+ params = this.extend(params, { 'symbol': marketId });
1284
+ response = await this.sapiPostUserDataStreamIsolated(params);
1280
1285
  }
1281
1286
  else {
1282
- response = await this.publicPostUserDataStream(query);
1287
+ response = await this.publicPostUserDataStream(params);
1283
1288
  }
1284
1289
  this.options[type] = this.extend(options, {
1285
1290
  'listenKey': this.safeString(response, 'listenKey'),
@@ -1292,6 +1297,8 @@ class binance extends binance$1 {
1292
1297
  // https://binance-docs.github.io/apidocs/spot/en/#listen-key-spot
1293
1298
  let type = this.safeString2(this.options, 'defaultType', 'authenticate', 'spot');
1294
1299
  type = this.safeString(params, 'type', type);
1300
+ let isPortfolioMargin = undefined;
1301
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'keepAliveListenKey', 'papi', 'portfolioMargin', false);
1295
1302
  const subTypeInfo = this.handleSubTypeAndParams('keepAliveListenKey', undefined, params);
1296
1303
  const subType = subTypeInfo[0];
1297
1304
  if (this.isLinear(type, subType)) {
@@ -1308,28 +1315,35 @@ class binance extends binance$1 {
1308
1315
  }
1309
1316
  const request = {};
1310
1317
  const symbol = this.safeString(params, 'symbol');
1311
- const sendParams = this.omit(params, ['type', 'symbol']);
1318
+ params = this.omit(params, ['type', 'symbol']);
1312
1319
  const time = this.milliseconds();
1313
1320
  try {
1314
- if (type === 'future') {
1315
- await this.fapiPrivatePutListenKey(this.extend(request, sendParams));
1321
+ if (isPortfolioMargin) {
1322
+ await this.papiPutListenKey(this.extend(request, params));
1323
+ }
1324
+ else if (type === 'future') {
1325
+ await this.fapiPrivatePutListenKey(this.extend(request, params));
1316
1326
  }
1317
1327
  else if (type === 'delivery') {
1318
- await this.dapiPrivatePutListenKey(this.extend(request, sendParams));
1328
+ await this.dapiPrivatePutListenKey(this.extend(request, params));
1319
1329
  }
1320
1330
  else {
1321
1331
  request['listenKey'] = listenKey;
1322
1332
  if (type === 'margin') {
1323
1333
  request['symbol'] = symbol;
1324
- await this.sapiPutUserDataStream(this.extend(request, sendParams));
1334
+ await this.sapiPutUserDataStream(this.extend(request, params));
1325
1335
  }
1326
1336
  else {
1327
- await this.publicPutUserDataStream(this.extend(request, sendParams));
1337
+ await this.publicPutUserDataStream(this.extend(request, params));
1328
1338
  }
1329
1339
  }
1330
1340
  }
1331
1341
  catch (error) {
1332
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
1342
+ let urlType = type;
1343
+ if (isPortfolioMargin) {
1344
+ urlType = 'papi';
1345
+ }
1346
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
1333
1347
  const client = this.client(url);
1334
1348
  const messageHashes = Object.keys(client.futures);
1335
1349
  for (let i = 0; i < messageHashes.length; i++) {
@@ -1361,7 +1375,7 @@ class binance extends binance$1 {
1361
1375
  }
1362
1376
  }
1363
1377
  }
1364
- setBalanceCache(client, type) {
1378
+ setBalanceCache(client, type, isPortfolioMargin = false) {
1365
1379
  if (type in client.subscriptions) {
1366
1380
  return;
1367
1381
  }
@@ -1371,15 +1385,21 @@ class binance extends binance$1 {
1371
1385
  const messageHash = type + ':fetchBalanceSnapshot';
1372
1386
  if (!(messageHash in client.futures)) {
1373
1387
  client.future(messageHash);
1374
- this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
1388
+ this.spawn(this.loadBalanceSnapshot, client, messageHash, type, isPortfolioMargin);
1375
1389
  }
1376
1390
  }
1377
1391
  else {
1378
1392
  this.balance[type] = {};
1379
1393
  }
1380
1394
  }
1381
- async loadBalanceSnapshot(client, messageHash, type) {
1382
- const response = await this.fetchBalance({ 'type': type });
1395
+ async loadBalanceSnapshot(client, messageHash, type, isPortfolioMargin) {
1396
+ const params = {
1397
+ 'type': type,
1398
+ };
1399
+ if (isPortfolioMargin) {
1400
+ params['portfolioMargin'] = true;
1401
+ }
1402
+ const response = await this.fetchBalance(params);
1383
1403
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
1384
1404
  // don't remove the future from the .futures cache
1385
1405
  const future = client.futures[messageHash];
@@ -1473,6 +1493,7 @@ class binance extends binance$1 {
1473
1493
  * @name binance#watchBalance
1474
1494
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
1475
1495
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1496
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch the balance of a portfolio margin account
1476
1497
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1477
1498
  */
1478
1499
  await this.loadMarkets();
@@ -1481,16 +1502,22 @@ class binance extends binance$1 {
1481
1502
  let type = this.safeString(params, 'type', defaultType);
1482
1503
  let subType = undefined;
1483
1504
  [subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
1505
+ let isPortfolioMargin = undefined;
1506
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchBalance', 'papi', 'portfolioMargin', false);
1507
+ let urlType = type;
1508
+ if (isPortfolioMargin) {
1509
+ urlType = 'papi';
1510
+ }
1484
1511
  if (this.isLinear(type, subType)) {
1485
1512
  type = 'future';
1486
1513
  }
1487
1514
  else if (this.isInverse(type, subType)) {
1488
1515
  type = 'delivery';
1489
1516
  }
1490
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
1517
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
1491
1518
  const client = this.client(url);
1492
- this.setBalanceCache(client, type);
1493
- this.setPositionsCache(client, type);
1519
+ this.setBalanceCache(client, type, isPortfolioMargin);
1520
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
1494
1521
  const options = this.safeValue(this.options, 'watchBalance');
1495
1522
  const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
1496
1523
  const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
@@ -2097,11 +2124,14 @@ class binance extends binance$1 {
2097
2124
  * @name binance#watchOrders
2098
2125
  * @description watches information on multiple orders made by the user
2099
2126
  * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
2127
+ * @see https://binance-docs.github.io/apidocs/pm/en/#event-futures-order-update
2128
+ * @see https://binance-docs.github.io/apidocs/pm/en/#event-margin-order-update
2100
2129
  * @param {string} symbol unified market symbol of the market the orders were made in
2101
2130
  * @param {int} [since] the earliest time in ms to fetch orders for
2102
2131
  * @param {int} [limit] the maximum number of order structures to retrieve
2103
2132
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2104
2133
  * @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
2134
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch portfolio margin account orders
2105
2135
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2106
2136
  */
2107
2137
  await this.loadMarkets();
@@ -2130,10 +2160,15 @@ class binance extends binance$1 {
2130
2160
  if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
2131
2161
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
2132
2162
  }
2163
+ let isPortfolioMargin = undefined;
2164
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchOrders', 'papi', 'portfolioMargin', false);
2165
+ if (isPortfolioMargin) {
2166
+ urlType = 'papi';
2167
+ }
2133
2168
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
2134
2169
  const client = this.client(url);
2135
- this.setBalanceCache(client, type);
2136
- this.setPositionsCache(client, type);
2170
+ this.setBalanceCache(client, type, isPortfolioMargin);
2171
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
2137
2172
  const message = undefined;
2138
2173
  const orders = await this.watch(url, messageHash, message, type);
2139
2174
  if (this.newUpdates) {
@@ -2388,6 +2423,7 @@ class binance extends binance$1 {
2388
2423
  * @description watch all open positions
2389
2424
  * @param {string[]|undefined} symbols list of unified market symbols
2390
2425
  * @param {object} params extra parameters specific to the exchange API endpoint
2426
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch positions in a portfolio margin account
2391
2427
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
2392
2428
  */
2393
2429
  await this.loadMarkets();
@@ -2418,10 +2454,16 @@ class binance extends binance$1 {
2418
2454
  type = 'delivery';
2419
2455
  }
2420
2456
  messageHash = type + ':positions' + messageHash;
2421
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
2457
+ let isPortfolioMargin = undefined;
2458
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchPositions', 'papi', 'portfolioMargin', false);
2459
+ let urlType = type;
2460
+ if (isPortfolioMargin) {
2461
+ urlType = 'papi';
2462
+ }
2463
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
2422
2464
  const client = this.client(url);
2423
- this.setBalanceCache(client, type);
2424
- this.setPositionsCache(client, type, symbols);
2465
+ this.setBalanceCache(client, type, isPortfolioMargin);
2466
+ this.setPositionsCache(client, type, symbols, isPortfolioMargin);
2425
2467
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
2426
2468
  const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
2427
2469
  const cache = this.safeValue(this.positions, type);
@@ -2435,7 +2477,7 @@ class binance extends binance$1 {
2435
2477
  }
2436
2478
  return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
2437
2479
  }
2438
- setPositionsCache(client, type, symbols = undefined) {
2480
+ setPositionsCache(client, type, symbols = undefined, isPortfolioMargin = false) {
2439
2481
  if (type === 'spot') {
2440
2482
  return;
2441
2483
  }
@@ -2450,15 +2492,21 @@ class binance extends binance$1 {
2450
2492
  const messageHash = type + ':fetchPositionsSnapshot';
2451
2493
  if (!(messageHash in client.futures)) {
2452
2494
  client.future(messageHash);
2453
- this.spawn(this.loadPositionsSnapshot, client, messageHash, type);
2495
+ this.spawn(this.loadPositionsSnapshot, client, messageHash, type, isPortfolioMargin);
2454
2496
  }
2455
2497
  }
2456
2498
  else {
2457
2499
  this.positions[type] = new Cache.ArrayCacheBySymbolBySide();
2458
2500
  }
2459
2501
  }
2460
- async loadPositionsSnapshot(client, messageHash, type) {
2461
- const positions = await this.fetchPositions(undefined, { 'type': type });
2502
+ async loadPositionsSnapshot(client, messageHash, type, isPortfolioMargin) {
2503
+ const params = {
2504
+ 'type': type,
2505
+ };
2506
+ if (isPortfolioMargin) {
2507
+ params['portfolioMargin'] = true;
2508
+ }
2509
+ const positions = await this.fetchPositions(undefined, params);
2462
2510
  this.positions[type] = new Cache.ArrayCacheBySymbolBySide();
2463
2511
  const cache = this.positions[type];
2464
2512
  for (let i = 0; i < positions.length; i++) {
@@ -2731,6 +2779,7 @@ class binance extends binance$1 {
2731
2779
  * @param {int} [since] the earliest time in ms to fetch orders for
2732
2780
  * @param {int} [limit] the maximum number of order structures to retrieve
2733
2781
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2782
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
2734
2783
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
2735
2784
  */
2736
2785
  await this.loadMarkets();
@@ -2760,10 +2809,15 @@ class binance extends binance$1 {
2760
2809
  if (type === 'margin') {
2761
2810
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
2762
2811
  }
2812
+ let isPortfolioMargin = undefined;
2813
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchMyTrades', 'papi', 'portfolioMargin', false);
2814
+ if (isPortfolioMargin) {
2815
+ urlType = 'papi';
2816
+ }
2763
2817
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
2764
2818
  const client = this.client(url);
2765
- this.setBalanceCache(client, type);
2766
- this.setPositionsCache(client, type);
2819
+ this.setBalanceCache(client, type, isPortfolioMargin);
2820
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
2767
2821
  const message = undefined;
2768
2822
  const trades = await this.watch(url, messageHash, message, type);
2769
2823
  if (this.newUpdates) {
@@ -102,7 +102,7 @@ class bitvavo extends bitvavo$1 {
102
102
  // "volume": "3587.05020246",
103
103
  // "volumeQuote": "708030.17",
104
104
  // "bid": "199.56",
105
- // "bidSize": "4.14730803",
105
+ // "bidSize": "4.14730802",
106
106
  // "ask": "199.57",
107
107
  // "askSize": "6.13642074",
108
108
  // "timestamp": 1590770885217
@@ -34,7 +34,6 @@ class blockchaincom extends blockchaincom$1 {
34
34
  },
35
35
  'noOriginHeader': false,
36
36
  },
37
- 'sequenceNumbers': {},
38
37
  },
39
38
  'streaming': {},
40
39
  'exceptions': {},
@@ -678,21 +677,20 @@ class blockchaincom extends blockchaincom$1 {
678
677
  // }
679
678
  //
680
679
  const event = this.safeString(message, 'event');
680
+ if (event === 'subscribed') {
681
+ return;
682
+ }
681
683
  const type = this.safeString(message, 'channel');
682
684
  const marketId = this.safeString(message, 'symbol');
683
685
  const symbol = this.safeSymbol(marketId);
684
686
  const messageHash = 'orderbook:' + symbol + ':' + type;
685
687
  const datetime = this.safeString(message, 'timestamp');
686
688
  const timestamp = this.parse8601(datetime);
687
- let orderbook = this.safeValue(this.orderbooks, symbol);
688
- if (orderbook === undefined) {
689
- orderbook = this.countedOrderBook({});
690
- this.orderbooks[symbol] = orderbook;
691
- }
692
- if (event === 'subscribed') {
693
- return;
689
+ if (this.safeValue(this.orderbooks, symbol) === undefined) {
690
+ this.orderbooks[symbol] = this.countedOrderBook();
694
691
  }
695
- else if (event === 'snapshot') {
692
+ const orderbook = this.orderbooks[symbol];
693
+ if (event === 'snapshot') {
696
694
  const snapshot = this.parseOrderBook(message, symbol, timestamp, 'bids', 'asks', 'px', 'qty', 'num');
697
695
  orderbook.reset(snapshot);
698
696
  }
@@ -718,23 +716,7 @@ class blockchaincom extends blockchaincom$1 {
718
716
  this.handleDelta(bookside, deltas[i]);
719
717
  }
720
718
  }
721
- checkSequenceNumber(client, message) {
722
- const seqnum = this.safeInteger(message, 'seqnum', 0);
723
- const channel = this.safeString(message, 'channel', '');
724
- const sequenceNumbersByChannel = this.safeValue(this.options, 'sequenceNumbers', {});
725
- const lastSeqnum = this.safeInteger(sequenceNumbersByChannel, channel);
726
- if (lastSeqnum === undefined) {
727
- this.options['sequenceNumbers'][channel] = seqnum;
728
- }
729
- else {
730
- if (seqnum !== lastSeqnum + 1) {
731
- throw new errors.ExchangeError(this.id + ' ' + channel + ' seqnum ' + seqnum + ' is not the expected ' + (lastSeqnum + 1));
732
- }
733
- this.options['sequenceNumbers'][channel] = seqnum;
734
- }
735
- }
736
719
  handleMessage(client, message) {
737
- this.checkSequenceNumber(client, message);
738
720
  const channel = this.safeString(message, 'channel');
739
721
  const handlers = {
740
722
  'ticker': this.handleTicker,
@@ -177,7 +177,7 @@ class deribit extends deribit$1 {
177
177
  // "params": {
178
178
  // "channel": "ticker.BTC_USDC-PERPETUAL.raw",
179
179
  // "data": {
180
- // "timestamp": 1655393725041,
180
+ // "timestamp": 1655393725040,
181
181
  // "stats": [Object],
182
182
  // "state": "open",
183
183
  // "settlement_price": 21729.5891,
@@ -658,7 +658,7 @@ class deribit extends deribit$1 {
658
658
  const symbol = this.safeSymbol(marketId);
659
659
  const ohlcv = this.safeValue(params, 'data', {});
660
660
  const parsed = [
661
- this.safeNumber(ohlcv, 'tick'),
661
+ this.safeInteger(ohlcv, 'tick'),
662
662
  this.safeNumber(ohlcv, 'open'),
663
663
  this.safeNumber(ohlcv, 'high'),
664
664
  this.safeNumber(ohlcv, 'low'),
@@ -203,7 +203,7 @@ class gemini extends gemini$1 {
203
203
  // "time_ms": 1655323185000,
204
204
  // "result": "failure",
205
205
  // "highest_bid_price": "21661.90",
206
- // "lowest_ask_price": "21663.79",
206
+ // "lowest_ask_price": "21663.78",
207
207
  // "collar_price": "21662.845"
208
208
  // },
209
209
  // ]
@@ -907,9 +907,6 @@ class okx extends okx$1 {
907
907
  * @param {object} params extra parameters specific to the exchange API endpoint
908
908
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
909
909
  */
910
- if (this.isEmpty(symbols)) {
911
- throw new errors.ArgumentsRequired(this.id + ' watchPositions requires a list of symbols');
912
- }
913
910
  await this.loadMarkets();
914
911
  await this.authenticate(params);
915
912
  symbols = this.marketSymbols(symbols);
@@ -917,7 +914,23 @@ class okx extends okx$1 {
917
914
  'instType': 'ANY',
918
915
  };
919
916
  const channel = 'positions';
920
- const newPositions = await this.subscribeMultiple('private', channel, symbols, this.extend(request, params));
917
+ let newPositions = undefined;
918
+ if (symbols === undefined) {
919
+ const arg = {
920
+ 'channel': 'positions',
921
+ 'instType': 'ANY',
922
+ };
923
+ const args = [arg];
924
+ const nonSymbolRequest = {
925
+ 'op': 'subscribe',
926
+ 'args': args,
927
+ };
928
+ const url = this.getUrl(channel, 'private');
929
+ newPositions = await this.watch(url, channel, nonSymbolRequest, channel);
930
+ }
931
+ else {
932
+ newPositions = await this.subscribeMultiple('private', channel, symbols, this.extend(request, params));
933
+ }
921
934
  if (this.newUpdates) {
922
935
  return newPositions;
923
936
  }
@@ -1015,6 +1028,7 @@ class okx extends okx$1 {
1015
1028
  client.resolve(positions, messageHash);
1016
1029
  }
1017
1030
  }
1031
+ client.resolve(newPositions, channel);
1018
1032
  }
1019
1033
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1020
1034
  /**
@@ -227,6 +227,7 @@ class whitebit extends whitebit$1 {
227
227
  'account': 'spot',
228
228
  },
229
229
  'accountsByType': {
230
+ 'funding': 'main',
230
231
  'main': 'main',
231
232
  'spot': 'spot',
232
233
  'margin': 'collateral',
@@ -1320,9 +1321,9 @@ class whitebit extends whitebit$1 {
1320
1321
  else {
1321
1322
  const options = this.safeValue(this.options, 'fetchBalance', {});
1322
1323
  const defaultAccount = this.safeString(options, 'account');
1323
- const account = this.safeString(params, 'account', defaultAccount);
1324
- params = this.omit(params, 'account');
1325
- if (account === 'main') {
1324
+ const account = this.safeString2(params, 'account', 'type', defaultAccount);
1325
+ params = this.omit(params, ['account', 'type']);
1326
+ if (account === 'main' || account === 'funding') {
1326
1327
  response = await this.v4PrivatePostMainAccountBalance(params);
1327
1328
  }
1328
1329
  else {
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.51";
7
+ declare const version = "4.2.53";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.52';
41
+ const version = '4.2.54';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -71,8 +71,6 @@ interface Exchange {
71
71
  sapiGetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
72
72
  sapiGetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
73
73
  sapiGetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
74
- sapiGetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
75
- sapiGetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
76
74
  sapiGetLoanVipOngoingOrders(params?: {}): Promise<implicitReturnType>;
77
75
  sapiGetLoanVipRepayHistory(params?: {}): Promise<implicitReturnType>;
78
76
  sapiGetLoanVipCollateralAccount(params?: {}): Promise<implicitReturnType>;
@@ -336,7 +334,6 @@ interface Exchange {
336
334
  sapiPostLoanRepay(params?: {}): Promise<implicitReturnType>;
337
335
  sapiPostLoanAdjustLtv(params?: {}): Promise<implicitReturnType>;
338
336
  sapiPostLoanCustomizeMarginCall(params?: {}): Promise<implicitReturnType>;
339
- sapiPostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
340
337
  sapiPostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
341
338
  sapiPostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
342
339
  sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
@@ -379,8 +376,17 @@ interface Exchange {
379
376
  sapiV2GetSubAccountFuturesAccount(params?: {}): Promise<implicitReturnType>;
380
377
  sapiV2GetSubAccountFuturesAccountSummary(params?: {}): Promise<implicitReturnType>;
381
378
  sapiV2GetSubAccountFuturesPositionRisk(params?: {}): Promise<implicitReturnType>;
379
+ sapiV2GetLoanFlexibleOngoingOrders(params?: {}): Promise<implicitReturnType>;
380
+ sapiV2GetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
381
+ sapiV2GetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
382
+ sapiV2GetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
383
+ sapiV2GetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
384
+ sapiV2GetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
382
385
  sapiV2PostEthStakingEthStake(params?: {}): Promise<implicitReturnType>;
383
386
  sapiV2PostSubAccountSubAccountApiIpRestriction(params?: {}): Promise<implicitReturnType>;
387
+ sapiV2PostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
388
+ sapiV2PostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
389
+ sapiV2PostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
384
390
  sapiV3GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
385
391
  sapiV3PostAssetGetUserAsset(params?: {}): Promise<implicitReturnType>;
386
392
  sapiV4GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
@@ -71,8 +71,6 @@ interface binance {
71
71
  sapiGetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
72
72
  sapiGetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
73
73
  sapiGetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
74
- sapiGetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
75
- sapiGetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
76
74
  sapiGetLoanVipOngoingOrders(params?: {}): Promise<implicitReturnType>;
77
75
  sapiGetLoanVipRepayHistory(params?: {}): Promise<implicitReturnType>;
78
76
  sapiGetLoanVipCollateralAccount(params?: {}): Promise<implicitReturnType>;
@@ -336,7 +334,6 @@ interface binance {
336
334
  sapiPostLoanRepay(params?: {}): Promise<implicitReturnType>;
337
335
  sapiPostLoanAdjustLtv(params?: {}): Promise<implicitReturnType>;
338
336
  sapiPostLoanCustomizeMarginCall(params?: {}): Promise<implicitReturnType>;
339
- sapiPostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
340
337
  sapiPostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
341
338
  sapiPostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
342
339
  sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
@@ -379,8 +376,17 @@ interface binance {
379
376
  sapiV2GetSubAccountFuturesAccount(params?: {}): Promise<implicitReturnType>;
380
377
  sapiV2GetSubAccountFuturesAccountSummary(params?: {}): Promise<implicitReturnType>;
381
378
  sapiV2GetSubAccountFuturesPositionRisk(params?: {}): Promise<implicitReturnType>;
379
+ sapiV2GetLoanFlexibleOngoingOrders(params?: {}): Promise<implicitReturnType>;
380
+ sapiV2GetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
381
+ sapiV2GetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
382
+ sapiV2GetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
383
+ sapiV2GetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
384
+ sapiV2GetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
382
385
  sapiV2PostEthStakingEthStake(params?: {}): Promise<implicitReturnType>;
383
386
  sapiV2PostSubAccountSubAccountApiIpRestriction(params?: {}): Promise<implicitReturnType>;
387
+ sapiV2PostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
388
+ sapiV2PostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
389
+ sapiV2PostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
384
390
  sapiV3GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
385
391
  sapiV3PostAssetGetUserAsset(params?: {}): Promise<implicitReturnType>;
386
392
  sapiV4GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
@@ -71,8 +71,6 @@ interface binance {
71
71
  sapiGetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
72
72
  sapiGetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
73
73
  sapiGetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
74
- sapiGetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
75
- sapiGetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
76
74
  sapiGetLoanVipOngoingOrders(params?: {}): Promise<implicitReturnType>;
77
75
  sapiGetLoanVipRepayHistory(params?: {}): Promise<implicitReturnType>;
78
76
  sapiGetLoanVipCollateralAccount(params?: {}): Promise<implicitReturnType>;
@@ -367,7 +365,6 @@ interface binance {
367
365
  sapiPostLoanRepay(params?: {}): Promise<implicitReturnType>;
368
366
  sapiPostLoanAdjustLtv(params?: {}): Promise<implicitReturnType>;
369
367
  sapiPostLoanCustomizeMarginCall(params?: {}): Promise<implicitReturnType>;
370
- sapiPostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
371
368
  sapiPostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
372
369
  sapiPostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
373
370
  sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
@@ -424,10 +421,19 @@ interface binance {
424
421
  sapiV2GetSubAccountFuturesAccount(params?: {}): Promise<implicitReturnType>;
425
422
  sapiV2GetSubAccountFuturesAccountSummary(params?: {}): Promise<implicitReturnType>;
426
423
  sapiV2GetSubAccountFuturesPositionRisk(params?: {}): Promise<implicitReturnType>;
424
+ sapiV2GetLoanFlexibleOngoingOrders(params?: {}): Promise<implicitReturnType>;
425
+ sapiV2GetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
426
+ sapiV2GetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
427
+ sapiV2GetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
428
+ sapiV2GetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
429
+ sapiV2GetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
427
430
  sapiV2GetClAccount(params?: {}): Promise<implicitReturnType>;
428
431
  sapiV2GetClAlertHistory(params?: {}): Promise<implicitReturnType>;
429
432
  sapiV2PostEthStakingEthStake(params?: {}): Promise<implicitReturnType>;
430
433
  sapiV2PostSubAccountSubAccountApiIpRestriction(params?: {}): Promise<implicitReturnType>;
434
+ sapiV2PostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
435
+ sapiV2PostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
436
+ sapiV2PostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
431
437
  sapiV3GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
432
438
  sapiV3GetAccountStatus(params?: {}): Promise<implicitReturnType>;
433
439
  sapiV3GetApiTradingStatus(params?: {}): Promise<implicitReturnType>;
@@ -71,8 +71,6 @@ interface binance {
71
71
  sapiGetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
72
72
  sapiGetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
73
73
  sapiGetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
74
- sapiGetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
75
- sapiGetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
76
74
  sapiGetLoanVipOngoingOrders(params?: {}): Promise<implicitReturnType>;
77
75
  sapiGetLoanVipRepayHistory(params?: {}): Promise<implicitReturnType>;
78
76
  sapiGetLoanVipCollateralAccount(params?: {}): Promise<implicitReturnType>;
@@ -336,7 +334,6 @@ interface binance {
336
334
  sapiPostLoanRepay(params?: {}): Promise<implicitReturnType>;
337
335
  sapiPostLoanAdjustLtv(params?: {}): Promise<implicitReturnType>;
338
336
  sapiPostLoanCustomizeMarginCall(params?: {}): Promise<implicitReturnType>;
339
- sapiPostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
340
337
  sapiPostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
341
338
  sapiPostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
342
339
  sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
@@ -379,8 +376,17 @@ interface binance {
379
376
  sapiV2GetSubAccountFuturesAccount(params?: {}): Promise<implicitReturnType>;
380
377
  sapiV2GetSubAccountFuturesAccountSummary(params?: {}): Promise<implicitReturnType>;
381
378
  sapiV2GetSubAccountFuturesPositionRisk(params?: {}): Promise<implicitReturnType>;
379
+ sapiV2GetLoanFlexibleOngoingOrders(params?: {}): Promise<implicitReturnType>;
380
+ sapiV2GetLoanFlexibleBorrowHistory(params?: {}): Promise<implicitReturnType>;
381
+ sapiV2GetLoanFlexibleRepayHistory(params?: {}): Promise<implicitReturnType>;
382
+ sapiV2GetLoanFlexibleLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
383
+ sapiV2GetLoanFlexibleLoanableData(params?: {}): Promise<implicitReturnType>;
384
+ sapiV2GetLoanFlexibleCollateralData(params?: {}): Promise<implicitReturnType>;
382
385
  sapiV2PostEthStakingEthStake(params?: {}): Promise<implicitReturnType>;
383
386
  sapiV2PostSubAccountSubAccountApiIpRestriction(params?: {}): Promise<implicitReturnType>;
387
+ sapiV2PostLoanFlexibleBorrow(params?: {}): Promise<implicitReturnType>;
388
+ sapiV2PostLoanFlexibleRepay(params?: {}): Promise<implicitReturnType>;
389
+ sapiV2PostLoanFlexibleAdjustLtv(params?: {}): Promise<implicitReturnType>;
384
390
  sapiV3GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
385
391
  sapiV3PostAssetGetUserAsset(params?: {}): Promise<implicitReturnType>;
386
392
  sapiV4GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;