ccxt 4.0.107 → 4.0.109

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,8 @@ export default class woo extends wooRest {
24
24
  parseWsOrder(order: any, market?: any): import("../base/types.js").Order;
25
25
  handleOrderUpdate(client: Client, message: any): void;
26
26
  handleOrder(client: Client, message: any): void;
27
+ watchBalance(params?: {}): Promise<any>;
28
+ handleBalance(client: any, message: any): void;
27
29
  handleMessage(client: Client, message: any): any;
28
30
  ping(client: any): {
29
31
  event: string;
package/js/src/pro/woo.js CHANGED
@@ -16,7 +16,7 @@ export default class woo extends wooRest {
16
16
  return this.deepExtend(super.describe(), {
17
17
  'has': {
18
18
  'ws': true,
19
- 'watchBalance': false,
19
+ 'watchBalance': true,
20
20
  'watchMyTrades': false,
21
21
  'watchOHLCV': true,
22
22
  'watchOrderBook': true,
@@ -607,6 +607,73 @@ export default class woo extends wooRest {
607
607
  client.resolve(this.orders, messageHashSymbol);
608
608
  }
609
609
  }
610
+ async watchBalance(params = {}) {
611
+ /**
612
+ * @method
613
+ * @see https://docs.woo.org/#balance
614
+ * @name woo#watchBalance
615
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
616
+ * @param {object} [params] extra parameters specific to the woo api endpoint
617
+ * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
618
+ */
619
+ await this.loadMarkets();
620
+ const topic = 'balance';
621
+ const messageHash = topic;
622
+ const request = {
623
+ 'event': 'subscribe',
624
+ 'topic': topic,
625
+ };
626
+ const message = this.extend(request, params);
627
+ return await this.watchPrivate(messageHash, message);
628
+ }
629
+ handleBalance(client, message) {
630
+ //
631
+ // {
632
+ // "topic": "balance",
633
+ // "ts": 1695716888789,
634
+ // "data": {
635
+ // "balances": {
636
+ // "USDT": {
637
+ // "holding": 266.56059176,
638
+ // "frozen": 0,
639
+ // "interest": 0,
640
+ // "pendingShortQty": 0,
641
+ // "pendingExposure": 0,
642
+ // "pendingLongQty": 0,
643
+ // "pendingLongExposure": 0,
644
+ // "version": 37,
645
+ // "staked": 0,
646
+ // "unbonding": 0,
647
+ // "vault": 0,
648
+ // "averageOpenPrice": 0,
649
+ // "pnl24H": 0,
650
+ // "fee24H": 0,
651
+ // "markPrice": 1,
652
+ // "pnl24HPercentage": 0
653
+ // }
654
+ // }
655
+ //
656
+ // }
657
+ //
658
+ const data = this.safeValue(message, 'data');
659
+ const balances = this.safeValue(data, 'balances');
660
+ const keys = Object.keys(balances);
661
+ const ts = this.safeInteger(message, 'ts');
662
+ this.balance['info'] = data;
663
+ this.balance['timestamp'] = ts;
664
+ this.balance['datetime'] = this.iso8601(ts);
665
+ for (let i = 0; i < keys.length; i++) {
666
+ const key = keys[i];
667
+ const value = balances[key];
668
+ const code = this.safeCurrencyCode(key);
669
+ const account = (code in this.balance) ? this.balance[code] : this.account();
670
+ account['total'] = this.safeString(value, 'holding');
671
+ account['used'] = this.safeString(value, 'frozen');
672
+ this.balance[code] = account;
673
+ }
674
+ this.balance = this.safeBalance(this.balance);
675
+ client.resolve(this.balance, 'balance');
676
+ }
610
677
  handleMessage(client, message) {
611
678
  const methods = {
612
679
  'ping': this.handlePing,
@@ -619,6 +686,7 @@ export default class woo extends wooRest {
619
686
  'auth': this.handleAuth,
620
687
  'executionreport': this.handleOrderUpdate,
621
688
  'trade': this.handleTrade,
689
+ 'balance': this.handleBalance,
622
690
  };
623
691
  const event = this.safeString(message, 'event');
624
692
  let method = this.safeValue(methods, event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.0.107",
3
+ "version": "4.0.109",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",