ccxt 4.3.12 → 4.3.14

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.
package/js/src/okx.js CHANGED
@@ -5578,7 +5578,7 @@ export default class okx extends Exchange {
5578
5578
  // }
5579
5579
  //
5580
5580
  const marketId = this.safeString(position, 'instId');
5581
- market = this.safeMarket(marketId, market);
5581
+ market = this.safeMarket(marketId, market, undefined, 'contract');
5582
5582
  const symbol = market['symbol'];
5583
5583
  const pos = this.safeString(position, 'pos'); // 'pos' field: One way mode: 0 if position is not open, 1 if open | Two way (hedge) mode: -1 if short, 1 if long, 0 if position is not open
5584
5584
  const contractsAbs = Precise.stringAbs(pos);
@@ -21,9 +21,11 @@ export default class woo extends wooRest {
21
21
  authenticate(params?: {}): Promise<any>;
22
22
  watchPrivate(messageHash: any, message: any, params?: {}): Promise<any>;
23
23
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
24
+ watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
24
25
  parseWsOrder(order: any, market?: any): Order;
25
26
  handleOrderUpdate(client: Client, message: any): void;
26
27
  handleOrder(client: Client, message: any): void;
28
+ handleMyTrade(client: Client, message: any): void;
27
29
  watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
28
30
  setPositionsCache(client: Client, type: any, symbols?: Strings): void;
29
31
  loadPositionsSnapshot(client: any, messageHash: any): Promise<void>;
package/js/src/pro/woo.js CHANGED
@@ -17,7 +17,7 @@ export default class woo extends wooRest {
17
17
  'has': {
18
18
  'ws': true,
19
19
  'watchBalance': true,
20
- 'watchMyTrades': false,
20
+ 'watchMyTrades': true,
21
21
  'watchOHLCV': true,
22
22
  'watchOrderBook': true,
23
23
  'watchOrders': true,
@@ -87,6 +87,7 @@ export default class woo extends wooRest {
87
87
  /**
88
88
  * @method
89
89
  * @name woo#watchOrderBook
90
+ * @see https://docs.woo.org/#orderbook
90
91
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
91
92
  * @param {string} symbol unified symbol of the market to fetch the order book for
92
93
  * @param {int} [limit] the maximum amount of order book entries to return.
@@ -231,6 +232,7 @@ export default class woo extends wooRest {
231
232
  /**
232
233
  * @method
233
234
  * @name woo#watchTickers
235
+ * @see https://docs.woo.org/#24h-tickers
234
236
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
235
237
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
236
238
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -292,6 +294,18 @@ export default class woo extends wooRest {
292
294
  client.resolve(result, topic);
293
295
  }
294
296
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
297
+ /**
298
+ * @method
299
+ * @name woo#watchOHLCV
300
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
301
+ * @see https://docs.woo.org/#k-line
302
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
303
+ * @param {string} timeframe the length of time each candle represents
304
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
305
+ * @param {int} [limit] the maximum amount of candles to fetch
306
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
307
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
308
+ */
295
309
  await this.loadMarkets();
296
310
  if ((timeframe !== '1m') && (timeframe !== '5m') && (timeframe !== '15m') && (timeframe !== '30m') && (timeframe !== '1h') && (timeframe !== '1d') && (timeframe !== '1w') && (timeframe !== '1M')) {
297
311
  throw new ExchangeError(this.id + ' watchOHLCV timeframe argument must be 1m, 5m, 15m, 30m, 1h, 1d, 1w, 1M');
@@ -360,6 +374,7 @@ export default class woo extends wooRest {
360
374
  * @method
361
375
  * @name woo#watchTrades
362
376
  * @description watches information on multiple trades made in a market
377
+ * @see https://docs.woo.org/#trade
363
378
  * @param {string} symbol unified market symbol of the market trades were made in
364
379
  * @param {int} [since] the earliest time in ms to fetch trades for
365
380
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -421,17 +436,60 @@ export default class woo extends wooRest {
421
436
  // "side":"BUY",
422
437
  // "source":0
423
438
  // }
439
+ // private trade
440
+ // {
441
+ // "msgType": 0, // execution report
442
+ // "symbol": "SPOT_BTC_USDT",
443
+ // "clientOrderId": 0,
444
+ // "orderId": 54774393,
445
+ // "type": "MARKET",
446
+ // "side": "BUY",
447
+ // "quantity": 0.0,
448
+ // "price": 0.0,
449
+ // "tradeId": 56201985,
450
+ // "executedPrice": 23534.06,
451
+ // "executedQuantity": 0.00040791,
452
+ // "fee": 2.1E-7,
453
+ // "feeAsset": "BTC",
454
+ // "totalExecutedQuantity": 0.00040791,
455
+ // "avgPrice": 23534.06,
456
+ // "status": "FILLED",
457
+ // "reason": "",
458
+ // "orderTag": "default",
459
+ // "totalFee": 2.1E-7,
460
+ // "feeCurrency": "BTC",
461
+ // "totalRebate": 0,
462
+ // "rebateCurrency": "USDT",
463
+ // "visible": 0.0,
464
+ // "timestamp": 1675406261689,
465
+ // "reduceOnly": false,
466
+ // "maker": false
467
+ // }
424
468
  //
425
469
  const marketId = this.safeString(trade, 'symbol');
426
470
  market = this.safeMarket(marketId, market);
427
471
  const symbol = market['symbol'];
428
- const price = this.safeString(trade, 'price');
429
- const amount = this.safeString(trade, 'size');
472
+ const price = this.safeString(trade, 'executedPrice', 'price');
473
+ const amount = this.safeString2(trade, 'executedQuantity', 'size');
430
474
  const cost = Precise.stringMul(price, amount);
431
475
  const side = this.safeStringLower(trade, 'side');
432
476
  const timestamp = this.safeInteger(trade, 'timestamp');
477
+ const maker = this.safeBool(trade, 'marker');
478
+ let takerOrMaker = undefined;
479
+ if (maker !== undefined) {
480
+ takerOrMaker = maker ? 'maker' : 'taker';
481
+ }
482
+ const type = this.safeStringLower(trade, 'type');
483
+ let fee = undefined;
484
+ const feeCost = this.safeNumber(trade, 'fee');
485
+ if (feeCost !== undefined) {
486
+ fee = {
487
+ 'cost': feeCost,
488
+ 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeCurrency')),
489
+ };
490
+ }
433
491
  return this.safeTrade({
434
- 'id': undefined,
492
+ 'id': this.safeString(trade, 'tradeId'),
435
493
  'timestamp': timestamp,
436
494
  'datetime': this.iso8601(timestamp),
437
495
  'symbol': symbol,
@@ -439,10 +497,10 @@ export default class woo extends wooRest {
439
497
  'price': price,
440
498
  'amount': amount,
441
499
  'cost': cost,
442
- 'order': undefined,
443
- 'takerOrMaker': undefined,
444
- 'type': undefined,
445
- 'fee': undefined,
500
+ 'order': this.safeString(trade, 'orderId'),
501
+ 'takerOrMaker': takerOrMaker,
502
+ 'type': type,
503
+ 'fee': fee,
446
504
  'info': trade,
447
505
  }, market);
448
506
  }
@@ -496,6 +554,8 @@ export default class woo extends wooRest {
496
554
  /**
497
555
  * @method
498
556
  * @name woo#watchOrders
557
+ * @see https://docs.woo.org/#executionreport
558
+ * @see https://docs.woo.org/#algoexecutionreportv2
499
559
  * @description watches information on multiple orders made by the user
500
560
  * @param {string} symbol unified market symbol of the market orders were made in
501
561
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -522,6 +582,37 @@ export default class woo extends wooRest {
522
582
  }
523
583
  return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
524
584
  }
585
+ async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
586
+ /**
587
+ * @method
588
+ * @name woo#watchOrders
589
+ * @see https://docs.woo.org/#executionreport
590
+ * @description watches information on multiple trades made by the user
591
+ * @param {string} symbol unified market symbol of the market orders were made in
592
+ * @param {int} [since] the earliest time in ms to fetch orders for
593
+ * @param {int} [limit] the maximum number of order structures to retrieve
594
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
595
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
596
+ */
597
+ await this.loadMarkets();
598
+ const topic = 'executionreport';
599
+ let messageHash = 'myTrades';
600
+ if (symbol !== undefined) {
601
+ const market = this.market(symbol);
602
+ symbol = market['symbol'];
603
+ messageHash += ':' + symbol;
604
+ }
605
+ const request = {
606
+ 'event': 'subscribe',
607
+ 'topic': topic,
608
+ };
609
+ const message = this.extend(request, params);
610
+ const trades = await this.watchPrivate(messageHash, message);
611
+ if (this.newUpdates) {
612
+ limit = trades.getLimit(symbol, limit);
613
+ }
614
+ return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
615
+ }
525
616
  parseWsOrder(order, market = undefined) {
526
617
  //
527
618
  // {
@@ -630,7 +721,11 @@ export default class woo extends wooRest {
630
721
  // }
631
722
  // }
632
723
  //
633
- const order = this.safeValue(message, 'data');
724
+ const order = this.safeDict(message, 'data');
725
+ const tradeId = this.safeString(order, 'tradeId');
726
+ if ((tradeId !== undefined) && (tradeId !== '0')) {
727
+ this.handleMyTrade(client, order);
728
+ }
634
729
  this.handleOrder(client, order);
635
730
  }
636
731
  handleOrder(client, message) {
@@ -665,6 +760,49 @@ export default class woo extends wooRest {
665
760
  client.resolve(this.orders, messageHashSymbol);
666
761
  }
667
762
  }
763
+ handleMyTrade(client, message) {
764
+ //
765
+ // {
766
+ // "msgType": 0, // execution report
767
+ // "symbol": "SPOT_BTC_USDT",
768
+ // "clientOrderId": 0,
769
+ // "orderId": 54774393,
770
+ // "type": "MARKET",
771
+ // "side": "BUY",
772
+ // "quantity": 0.0,
773
+ // "price": 0.0,
774
+ // "tradeId": 56201985,
775
+ // "executedPrice": 23534.06,
776
+ // "executedQuantity": 0.00040791,
777
+ // "fee": 2.1E-7,
778
+ // "feeAsset": "BTC",
779
+ // "totalExecutedQuantity": 0.00040791,
780
+ // "avgPrice": 23534.06,
781
+ // "status": "FILLED",
782
+ // "reason": "",
783
+ // "orderTag": "default",
784
+ // "totalFee": 2.1E-7,
785
+ // "feeCurrency": "BTC",
786
+ // "totalRebate": 0,
787
+ // "rebateCurrency": "USDT",
788
+ // "visible": 0.0,
789
+ // "timestamp": 1675406261689,
790
+ // "reduceOnly": false,
791
+ // "maker": false
792
+ // }
793
+ //
794
+ let myTrades = this.myTrades;
795
+ if (myTrades === undefined) {
796
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
797
+ myTrades = new ArrayCacheBySymbolById(limit);
798
+ }
799
+ const trade = this.parseWsTrade(message);
800
+ myTrades.append(trade);
801
+ let messageHash = 'myTrades:' + trade['symbol'];
802
+ client.resolve(myTrades, messageHash);
803
+ messageHash = 'myTrades';
804
+ client.resolve(myTrades, messageHash);
805
+ }
668
806
  async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
669
807
  /**
670
808
  * @method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.12",
3
+ "version": "4.3.14",
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",