ccxt 4.2.25 → 4.2.27

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.
@@ -1,8 +1,11 @@
1
1
  import bingxRest from '../bingx.js';
2
- import type { Int, OHLCV, Str, OrderBook, Order, Trade, Balances } from '../base/types.js';
2
+ import type { Int, OHLCV, Str, OrderBook, Order, Trade, Balances, Ticker } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class bingx extends bingxRest {
5
5
  describe(): any;
6
+ watchTicker(symbol: string, params?: {}): Promise<Ticker>;
7
+ handleTicker(client: Client, message: any): void;
8
+ parseWsTicker(message: any, market?: any): Ticker;
6
9
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
7
10
  handleTrades(client: Client, message: any): void;
8
11
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
@@ -20,7 +20,7 @@ export default class bingx extends bingxRest {
20
20
  'watchOHLCV': true,
21
21
  'watchOrders': true,
22
22
  'watchMyTrades': true,
23
- 'watchTicker': false,
23
+ 'watchTicker': true,
24
24
  'watchTickers': false,
25
25
  'watchBalance': true,
26
26
  },
@@ -75,6 +75,151 @@ export default class bingx extends bingxRest {
75
75
  },
76
76
  });
77
77
  }
78
+ async watchTicker(symbol, params = {}) {
79
+ /**
80
+ * @method
81
+ * @name bingx#watchTicker
82
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
83
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/socket/market.html#Subscribe%20to%2024-hour%20price%20changes
84
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
85
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
86
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
87
+ */
88
+ await this.loadMarkets();
89
+ const market = this.market(symbol);
90
+ const [marketType, query] = this.handleMarketTypeAndParams('watchTrades', market, params);
91
+ const url = this.safeValue(this.urls['api']['ws'], marketType);
92
+ if (url === undefined) {
93
+ throw new BadRequest(this.id + ' watchTrades is not supported for ' + marketType + ' markets.');
94
+ }
95
+ const messageHash = market['id'] + '@ticker';
96
+ const uuid = this.uuid();
97
+ const request = {
98
+ 'id': uuid,
99
+ 'dataType': messageHash,
100
+ };
101
+ if (marketType === 'swap') {
102
+ request['reqType'] = 'sub';
103
+ }
104
+ return await this.watch(url, messageHash, this.extend(request, query), messageHash);
105
+ }
106
+ handleTicker(client, message) {
107
+ //
108
+ // swap
109
+ //
110
+ // {
111
+ // "code": 0,
112
+ // "dataType": "BTC-USDT@ticker",
113
+ // "data": {
114
+ // "e": "24hTicker",
115
+ // "E": 1706498923556,
116
+ // "s": "BTC-USDT",
117
+ // "p": "346.4",
118
+ // "P": "0.82",
119
+ // "c": "42432.5",
120
+ // "L": "0.0529",
121
+ // "h": "42855.4",
122
+ // "l": "41578.3",
123
+ // "v": "64310.9754",
124
+ // "q": "2728360284.15",
125
+ // "o": "42086.1",
126
+ // "O": 1706498922655,
127
+ // "C": 1706498883023,
128
+ // "A": "42437.8",
129
+ // "a": "1.4160",
130
+ // "B": "42437.1",
131
+ // "b": "2.5747"
132
+ // }
133
+ // }
134
+ //
135
+ // spot
136
+ //
137
+ // {
138
+ // "code": 0,
139
+ // "timestamp": 1706506795473,
140
+ // "data": {
141
+ // "e": "24hTicker",
142
+ // "E": 1706506795472,
143
+ // "s": "BTC-USDT",
144
+ // "p": -372.12,
145
+ // "P": "-0.87%",
146
+ // "o": 42548.95,
147
+ // "h": 42696.1,
148
+ // "l": 41621.29,
149
+ // "c": 42176.83,
150
+ // "v": 4943.33,
151
+ // "q": 208842236.5,
152
+ // "O": 1706420395472,
153
+ // "C": 1706506795472,
154
+ // "A": 42177.23,
155
+ // "a": 5.14484,
156
+ // "B": 42176.38,
157
+ // "b": 5.36117
158
+ // }
159
+ // }
160
+ //
161
+ const data = this.safeValue(message, 'data', {});
162
+ const marketId = this.safeString(data, 's');
163
+ // const marketId = messageHash.split('@')[0];
164
+ const isSwap = client.url.indexOf('swap') >= 0;
165
+ const marketType = isSwap ? 'swap' : 'spot';
166
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
167
+ const symbol = market['symbol'];
168
+ const ticker = this.parseWsTicker(data, market);
169
+ this.tickers[symbol] = ticker;
170
+ const messageHash = market['id'] + '@ticker';
171
+ client.resolve(ticker, messageHash);
172
+ }
173
+ parseWsTicker(message, market = undefined) {
174
+ //
175
+ // {
176
+ // "e": "24hTicker",
177
+ // "E": 1706498923556,
178
+ // "s": "BTC-USDT",
179
+ // "p": "346.4",
180
+ // "P": "0.82",
181
+ // "c": "42432.5",
182
+ // "L": "0.0529",
183
+ // "h": "42855.4",
184
+ // "l": "41578.3",
185
+ // "v": "64310.9754",
186
+ // "q": "2728360284.15",
187
+ // "o": "42086.1",
188
+ // "O": 1706498922655,
189
+ // "C": 1706498883023,
190
+ // "A": "42437.8",
191
+ // "a": "1.4160",
192
+ // "B": "42437.1",
193
+ // "b": "2.5747"
194
+ // }
195
+ //
196
+ const timestamp = this.safeInteger(message, 'ts');
197
+ const marketId = this.safeString(message, 's');
198
+ market = this.safeMarket(marketId, market);
199
+ const close = this.safeString(message, 'c');
200
+ return this.safeTicker({
201
+ 'symbol': market['symbol'],
202
+ 'timestamp': timestamp,
203
+ 'datetime': this.iso8601(timestamp),
204
+ 'high': this.safeString(message, 'h'),
205
+ 'low': this.safeString(message, 'l'),
206
+ 'bid': this.safeString(message, 'B'),
207
+ 'bidVolume': this.safeString(message, 'b'),
208
+ 'ask': this.safeString(message, 'A'),
209
+ 'askVolume': this.safeString(message, 'a'),
210
+ 'vwap': undefined,
211
+ 'open': this.safeString(message, 'o'),
212
+ 'close': close,
213
+ 'last': close,
214
+ 'previousClose': undefined,
215
+ 'change': this.safeString(message, 'p'),
216
+ 'percentage': undefined,
217
+ 'average': undefined,
218
+ 'baseVolume': this.safeString(message, 'v'),
219
+ 'quoteVolume': this.safeString(message, 'q'),
220
+ 'info': message,
221
+ }, market);
222
+ }
78
223
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
79
224
  /**
80
225
  * @method
@@ -911,6 +1056,10 @@ export default class bingx extends bingxRest {
911
1056
  this.handleOrderBook(client, message);
912
1057
  return;
913
1058
  }
1059
+ if (dataType.indexOf('@ticker') >= 0) {
1060
+ this.handleTicker(client, message);
1061
+ return;
1062
+ }
914
1063
  if (dataType.indexOf('@trade') >= 0) {
915
1064
  this.handleTrades(client, message);
916
1065
  return;
@@ -941,5 +1090,10 @@ export default class bingx extends bingxRest {
941
1090
  this.handleMyTrades(client, message);
942
1091
  }
943
1092
  }
1093
+ const msgData = this.safeValue(message, 'data');
1094
+ const msgEvent = this.safeString(msgData, 'e');
1095
+ if (msgEvent === '24hTicker') {
1096
+ this.handleTicker(client, message);
1097
+ }
944
1098
  }
945
1099
  }
package/js/src/upbit.d.ts CHANGED
@@ -77,21 +77,21 @@ export default class upbit extends Exchange {
77
77
  currency: string;
78
78
  address: string;
79
79
  tag: string;
80
- network: any;
80
+ network: string;
81
81
  info: any;
82
82
  };
83
83
  fetchDepositAddress(code: string, params?: {}): Promise<{
84
84
  currency: string;
85
85
  address: string;
86
86
  tag: string;
87
- network: any;
87
+ network: string;
88
88
  info: any;
89
89
  }>;
90
90
  createDepositAddress(code: string, params?: {}): Promise<{
91
91
  currency: string;
92
92
  address: string;
93
93
  tag: string;
94
- network: any;
94
+ network: string;
95
95
  info: any;
96
96
  }>;
97
97
  withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<Transaction>;
package/js/src/upbit.js CHANGED
@@ -1638,22 +1638,24 @@ export default class upbit extends Exchange {
1638
1638
  }
1639
1639
  parseDepositAddress(depositAddress, currency = undefined) {
1640
1640
  //
1641
- // {
1642
- // "currency": "BTC",
1643
- // "deposit_address": "3EusRwybuZUhVDeHL7gh3HSLmbhLcy7NqD",
1644
- // "secondary_address": null
1645
- // }
1641
+ // {
1642
+ // currency: 'XRP',
1643
+ // net_type: 'XRP',
1644
+ // deposit_address: 'raQwCVAJVqjrVm1Nj5SFRcX8i22BhdC9WA',
1645
+ // secondary_address: '167029435'
1646
+ // }
1646
1647
  //
1647
1648
  const address = this.safeString(depositAddress, 'deposit_address');
1648
1649
  const tag = this.safeString(depositAddress, 'secondary_address');
1649
1650
  const currencyId = this.safeString(depositAddress, 'currency');
1650
1651
  const code = this.safeCurrencyCode(currencyId);
1652
+ const networkId = this.safeString(depositAddress, 'net_type');
1651
1653
  this.checkAddress(address);
1652
1654
  return {
1653
1655
  'currency': code,
1654
1656
  'address': address,
1655
1657
  'tag': tag,
1656
- 'network': undefined,
1658
+ 'network': this.networkIdToCode(networkId),
1657
1659
  'info': depositAddress,
1658
1660
  };
1659
1661
  }
@@ -1665,19 +1667,27 @@ export default class upbit extends Exchange {
1665
1667
  * @description fetch the deposit address for a currency associated with this account
1666
1668
  * @param {string} code unified currency code
1667
1669
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1670
+ * @param {string} params.network deposit chain, can view all chains via this.publicGetWalletAssets, default is eth, unless the currency has a default chain within this.options['networks']
1668
1671
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1669
1672
  */
1670
1673
  await this.loadMarkets();
1671
1674
  const currency = this.currency(code);
1675
+ let networkCode = undefined;
1676
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
1677
+ if (networkCode === undefined) {
1678
+ throw new ArgumentsRequired(this.id + ' fetchDepositAddress requires params["network"]');
1679
+ }
1672
1680
  const response = await this.privateGetDepositsCoinAddress(this.extend({
1673
1681
  'currency': currency['id'],
1682
+ 'net_type': this.networkCodeToId(networkCode, currency['code']),
1674
1683
  }, params));
1675
1684
  //
1676
- // {
1677
- // "currency": "BTC",
1678
- // "deposit_address": "3EusRwybuZUhVDeHL7gh3HSLmbhLcy7NqD",
1679
- // "secondary_address": null
1680
- // }
1685
+ // {
1686
+ // currency: 'XRP',
1687
+ // net_type: 'XRP',
1688
+ // deposit_address: 'raQwCVAJVqjrVm1Nj5SFRcX8i22BhdC9WA',
1689
+ // secondary_address: '167029435'
1690
+ // }
1681
1691
  //
1682
1692
  return this.parseDepositAddress(response);
1683
1693
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.25",
3
+ "version": "4.2.27",
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
@@ -679,6 +679,13 @@
679
679
  }
680
680
  }
681
681
  },
682
+ "coinmetro": {
683
+ "skipMethods": {
684
+ "fetchTrades": {
685
+ "side":"side is undefined"
686
+ }
687
+ }
688
+ },
682
689
  "coinone": {
683
690
  "skipWs": true,
684
691
  "skipMethods": {