ccxt 4.4.2 → 4.4.3

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.
@@ -24,6 +24,7 @@ export default class woofipro extends woofiproRest {
24
24
  'watchOrders': true,
25
25
  'watchTicker': true,
26
26
  'watchTickers': true,
27
+ 'watchBidsAsks': true,
27
28
  'watchTrades': true,
28
29
  'watchTradesForSymbols': false,
29
30
  'watchPositions': true,
@@ -291,6 +292,71 @@ export default class woofipro extends woofiproRest {
291
292
  }
292
293
  client.resolve(result, topic);
293
294
  }
295
+ async watchBidsAsks(symbols = undefined, params = {}) {
296
+ /**
297
+ * @method
298
+ * @name woofipro#watchBidsAsks
299
+ * @see https://orderly.network/docs/build-on-evm/evm-api/websocket-api/public/bbos
300
+ * @description watches best bid & ask for symbols
301
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
302
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
303
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
304
+ */
305
+ await this.loadMarkets();
306
+ symbols = this.marketSymbols(symbols);
307
+ const name = 'bbos';
308
+ const topic = name;
309
+ const request = {
310
+ 'event': 'subscribe',
311
+ 'topic': topic,
312
+ };
313
+ const message = this.extend(request, params);
314
+ const tickers = await this.watchPublic(topic, message);
315
+ return this.filterByArray(tickers, 'symbol', symbols);
316
+ }
317
+ handleBidAsk(client, message) {
318
+ //
319
+ // {
320
+ // "topic": "bbos",
321
+ // "ts": 1726212495000,
322
+ // "data": [
323
+ // {
324
+ // "symbol": "PERP_WOO_USDC",
325
+ // "ask": 0.16570,
326
+ // "askSize": 4224,
327
+ // "bid": 0.16553,
328
+ // "bidSize": 6645
329
+ // }
330
+ // ]
331
+ // }
332
+ //
333
+ const topic = this.safeString(message, 'topic');
334
+ const data = this.safeList(message, 'data', []);
335
+ const timestamp = this.safeInteger(message, 'ts');
336
+ const result = [];
337
+ for (let i = 0; i < data.length; i++) {
338
+ const ticker = this.parseWsBidAsk(this.extend(data[i], { 'ts': timestamp }));
339
+ this.tickers[ticker['symbol']] = ticker;
340
+ result.push(ticker);
341
+ }
342
+ client.resolve(result, topic);
343
+ }
344
+ parseWsBidAsk(ticker, market = undefined) {
345
+ const marketId = this.safeString(ticker, 'symbol');
346
+ market = this.safeMarket(marketId, market);
347
+ const symbol = this.safeString(market, 'symbol');
348
+ const timestamp = this.safeInteger(ticker, 'ts');
349
+ return this.safeTicker({
350
+ 'symbol': symbol,
351
+ 'timestamp': timestamp,
352
+ 'datetime': this.iso8601(timestamp),
353
+ 'ask': this.safeString(ticker, 'ask'),
354
+ 'askVolume': this.safeString(ticker, 'askSize'),
355
+ 'bid': this.safeString(ticker, 'bid'),
356
+ 'bidVolume': this.safeString(ticker, 'bidSize'),
357
+ 'info': ticker,
358
+ }, market);
359
+ }
294
360
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
295
361
  /**
296
362
  * @method
@@ -1205,6 +1271,7 @@ export default class woofipro extends woofiproRest {
1205
1271
  'algoexecutionreport': this.handleOrderUpdate,
1206
1272
  'position': this.handlePositions,
1207
1273
  'balance': this.handleBalance,
1274
+ 'bbos': this.handleBidAsk,
1208
1275
  };
1209
1276
  const event = this.safeString(message, 'event');
1210
1277
  let method = this.safeValue(methods, event);
package/js/src/xt.js CHANGED
@@ -1138,12 +1138,14 @@ export default class xt extends Exchange {
1138
1138
  let maxCost = undefined;
1139
1139
  let minPrice = undefined;
1140
1140
  let maxPrice = undefined;
1141
+ let amountPrecision = undefined;
1141
1142
  for (let i = 0; i < filters.length; i++) {
1142
1143
  const entry = filters[i];
1143
1144
  const filter = this.safeString(entry, 'filter');
1144
1145
  if (filter === 'QUANTITY') {
1145
1146
  minAmount = this.safeNumber(entry, 'min');
1146
1147
  maxAmount = this.safeNumber(entry, 'max');
1148
+ amountPrecision = this.safeNumber(entry, 'tickSize');
1147
1149
  }
1148
1150
  if (filter === 'QUOTE_QTY') {
1149
1151
  minCost = this.safeNumber(entry, 'min');
@@ -1153,6 +1155,9 @@ export default class xt extends Exchange {
1153
1155
  maxPrice = this.safeNumber(entry, 'max');
1154
1156
  }
1155
1157
  }
1158
+ if (amountPrecision === undefined) {
1159
+ amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
1160
+ }
1156
1161
  const underlyingType = this.safeString(market, 'underlyingType');
1157
1162
  let linear = undefined;
1158
1163
  let inverse = undefined;
@@ -1235,7 +1240,7 @@ export default class xt extends Exchange {
1235
1240
  'optionType': undefined,
1236
1241
  'precision': {
1237
1242
  'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision'))),
1238
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision'))),
1243
+ 'amount': amountPrecision,
1239
1244
  'base': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseCoinPrecision'))),
1240
1245
  'quote': this.parseNumber(this.parsePrecision(this.safeString(market, 'quoteCoinPrecision'))),
1241
1246
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",