ccxt 4.1.100 → 4.2.2

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.
@@ -54,7 +54,7 @@ export default class bitmart extends bitmartRest {
54
54
  'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
55
55
  },
56
56
  'watchOrderBook': {
57
- 'depth': 'depth50', // depth5, depth20, depth50
57
+ 'depth': 'depth/increase100', // depth/increase100, depth5, depth20, depth50
58
58
  },
59
59
  'ws': {
60
60
  'inflate': true,
@@ -1072,6 +1072,7 @@ export default class bitmart extends bitmartRest {
1072
1072
  * @method
1073
1073
  * @name bitmart#watchOrderBook
1074
1074
  * @see https://developer-pro.bitmart.com/en/spot/#public-depth-all-channel
1075
+ * @see https://developer-pro.bitmart.com/en/spot/#public-depth-increase-channel
1075
1076
  * @see https://developer-pro.bitmart.com/en/futures/#public-depth-channel
1076
1077
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1077
1078
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -1081,11 +1082,14 @@ export default class bitmart extends bitmartRest {
1081
1082
  */
1082
1083
  await this.loadMarkets();
1083
1084
  const options = this.safeValue(this.options, 'watchOrderBook', {});
1084
- const depth = this.safeString(options, 'depth', 'depth50');
1085
+ let depth = this.safeString(options, 'depth', 'depth/increase100');
1085
1086
  symbol = this.symbol(symbol);
1086
1087
  const market = this.market(symbol);
1087
1088
  let type = 'spot';
1088
1089
  [type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
1090
+ if (type === 'swap' && depth === 'depth/increase100') {
1091
+ depth = 'depth50';
1092
+ }
1089
1093
  const orderbook = await this.subscribe(depth, symbol, type, params);
1090
1094
  return orderbook.limit();
1091
1095
  }
@@ -1134,46 +1138,72 @@ export default class bitmart extends bitmartRest {
1134
1138
  }
1135
1139
  handleOrderBook(client, message) {
1136
1140
  //
1137
- // spot
1138
- // {
1139
- // "data": [
1140
- // {
1141
- // "asks": [
1142
- // [ '46828.38', "0.21847" ],
1143
- // [ '46830.68', "0.08232" ],
1144
- // ...
1145
- // ],
1146
- // "bids": [
1147
- // [ '46820.78', "0.00444" ],
1148
- // [ '46814.33', "0.00234" ],
1149
- // ...
1141
+ // spot depth-all
1142
+ // {
1143
+ // "data": [
1144
+ // {
1145
+ // "asks": [
1146
+ // [ '46828.38', "0.21847" ],
1147
+ // [ '46830.68', "0.08232" ],
1148
+ // ...
1149
+ // ],
1150
+ // "bids": [
1151
+ // [ '46820.78', "0.00444" ],
1152
+ // [ '46814.33', "0.00234" ],
1153
+ // ...
1154
+ // ],
1155
+ // "ms_t": 1631044962431,
1156
+ // "symbol": "BTC_USDT"
1157
+ // }
1158
+ // ],
1159
+ // "table": "spot/depth5"
1160
+ // }
1161
+ // spot increse depth snapshot
1162
+ // {
1163
+ // "data":[
1164
+ // {
1165
+ // "asks":[
1166
+ // [
1167
+ // "43652.52",
1168
+ // "0.02039"
1150
1169
  // ],
1151
- // "ms_t": 1631044962431,
1152
- // "symbol": "BTC_USDT"
1153
- // }
1154
- // ],
1155
- // "table": "spot/depth5"
1156
- // }
1170
+ // ...
1171
+ // ],
1172
+ // "bids":[
1173
+ // [
1174
+ // "43652.51",
1175
+ // "0.00500"
1176
+ // ],
1177
+ // ...
1178
+ // ],
1179
+ // "ms_t":1703376836487,
1180
+ // "symbol":"BTC_USDT",
1181
+ // "type":"snapshot", // or update
1182
+ // "version":2141731
1183
+ // }
1184
+ // ],
1185
+ // "table":"spot/depth/increase100"
1186
+ // }
1157
1187
  // swap
1158
- // {
1159
- // "group":"futures/depth50:BTCUSDT",
1160
- // "data":{
1161
- // "symbol":"BTCUSDT",
1162
- // "way":1,
1163
- // "depths":[
1164
- // {
1165
- // "price":"39509.8",
1166
- // "vol":"2379"
1167
- // },
1168
- // {
1169
- // "price":"39509.6",
1170
- // "vol":"6815"
1171
- // },
1172
- // ...
1173
- // ],
1174
- // "ms_t":1701566021194
1175
- // }
1176
- // }
1188
+ // {
1189
+ // "group":"futures/depth50:BTCUSDT",
1190
+ // "data":{
1191
+ // "symbol":"BTCUSDT",
1192
+ // "way":1,
1193
+ // "depths":[
1194
+ // {
1195
+ // "price":"39509.8",
1196
+ // "vol":"2379"
1197
+ // },
1198
+ // {
1199
+ // "price":"39509.6",
1200
+ // "vol":"6815"
1201
+ // },
1202
+ // ...
1203
+ // ],
1204
+ // "ms_t":1701566021194
1205
+ // }
1206
+ // }
1177
1207
  //
1178
1208
  const data = this.safeValue(message, 'data');
1179
1209
  if (data === undefined) {
@@ -1182,12 +1212,16 @@ export default class bitmart extends bitmartRest {
1182
1212
  const depths = this.safeValue(data, 'depths');
1183
1213
  const isSpot = (depths === undefined);
1184
1214
  const table = this.safeString2(message, 'table', 'group');
1185
- const parts = table.split('/');
1186
- const lastPart = this.safeString(parts, 1);
1187
- let limitString = lastPart.replace('depth', '');
1188
- const dotsIndex = limitString.indexOf(':');
1189
- limitString = limitString.slice(0, dotsIndex);
1190
- const limit = this.parseToInt(limitString);
1215
+ // find limit subscribed to
1216
+ const limitsToCheck = ['100', '50', '20', '10', '5'];
1217
+ let limit = 0;
1218
+ for (let i = 0; i < limitsToCheck.length; i++) {
1219
+ const limitString = limitsToCheck[i];
1220
+ if (table.indexOf(limitString) >= 0) {
1221
+ limit = this.parseToInt(limitString);
1222
+ break;
1223
+ }
1224
+ }
1191
1225
  if (isSpot) {
1192
1226
  for (let i = 0; i < data.length; i++) {
1193
1227
  const update = data[i];
@@ -1199,7 +1233,10 @@ export default class bitmart extends bitmartRest {
1199
1233
  orderbook['symbol'] = symbol;
1200
1234
  this.orderbooks[symbol] = orderbook;
1201
1235
  }
1202
- orderbook.reset({});
1236
+ const type = this.safeValue(update, 'type');
1237
+ if ((type === 'snapshot') || (!(table.indexOf('increase') >= 0))) {
1238
+ orderbook.reset({});
1239
+ }
1203
1240
  this.handleOrderBookMessage(client, update, orderbook);
1204
1241
  const timestamp = this.safeInteger(update, 'ms_t');
1205
1242
  orderbook['timestamp'] = timestamp;
@@ -1391,9 +1428,7 @@ export default class bitmart extends bitmartRest {
1391
1428
  }
1392
1429
  else {
1393
1430
  const methods = {
1394
- 'depth5': this.handleOrderBook,
1395
- 'depth20': this.handleOrderBook,
1396
- 'depth50': this.handleOrderBook,
1431
+ 'depth': this.handleOrderBook,
1397
1432
  'ticker': this.handleTicker,
1398
1433
  'trade': this.handleTrade,
1399
1434
  'kline': this.handleOHLCV,
@@ -889,10 +889,15 @@ export default class bybit extends bybitRest {
889
889
  }
890
890
  const trades = this.myTrades;
891
891
  const symbols = {};
892
- const method = spot ? 'parseWsTrade' : 'parseTrade';
893
892
  for (let i = 0; i < data.length; i++) {
894
893
  const rawTrade = data[i];
895
- const parsed = this[method](rawTrade);
894
+ let parsed = undefined;
895
+ if (spot) {
896
+ parsed = this.parseWsTrade(rawTrade);
897
+ }
898
+ else {
899
+ parsed = this.parseTrade(rawTrade);
900
+ }
896
901
  const symbol = parsed['symbol'];
897
902
  symbols[symbol] = true;
898
903
  trades.append(parsed);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.100",
3
+ "version": "4.2.2",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",
package/skip-tests.json CHANGED
@@ -712,7 +712,8 @@
712
712
  "skipMethods": {
713
713
  "proxies": "probably they do not permit our proxy location",
714
714
  "loadMarkets": {
715
- "active":"is undefined"
715
+ "active":"is undefined",
716
+ "currencyIdAndCode": "messes codes"
716
717
  },
717
718
  "fetchOHLCV": "unexpected issue",
718
719
  "fetchCurrencies": {