ccxt 4.5.0 → 4.5.1
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/README.md +4 -4
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +13 -0
- package/dist/cjs/src/coinbase.js +46 -34
- package/dist/cjs/src/gate.js +39 -18
- package/dist/cjs/src/gemini.js +1 -1
- package/dist/cjs/src/hibachi.js +1 -1
- package/dist/cjs/src/hyperliquid.js +16 -2
- package/dist/cjs/src/kraken.js +1 -12
- package/dist/cjs/src/krakenfutures.js +25 -25
- package/dist/cjs/src/mexc.js +2 -1
- package/dist/cjs/src/pro/bitget.js +193 -51
- package/dist/cjs/src/pro/bybit.js +8 -15
- package/dist/cjs/src/pro/gate.js +6 -1
- package/dist/cjs/src/pro/hyperliquid.js +4 -1
- package/dist/cjs/src/pro/kraken.js +1 -0
- package/dist/cjs/src/pro/lbank.js +55 -1
- package/dist/cjs/src/pro/mexc.js +1 -1
- package/dist/cjs/src/timex.js +35 -0
- package/dist/cjs/src/tradeogre.js +32 -0
- package/dist/cjs/src/wavesexchange.js +33 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +14 -1
- package/js/src/coinbase.js +46 -34
- package/js/src/gate.d.ts +2 -1
- package/js/src/gate.js +39 -18
- package/js/src/gemini.js +1 -1
- package/js/src/hibachi.js +1 -1
- package/js/src/hyperliquid.d.ts +1 -0
- package/js/src/hyperliquid.js +16 -2
- package/js/src/kraken.d.ts +0 -1
- package/js/src/kraken.js +1 -12
- package/js/src/krakenfutures.d.ts +24 -24
- package/js/src/krakenfutures.js +25 -25
- package/js/src/mexc.js +2 -1
- package/js/src/pro/bitget.d.ts +8 -2
- package/js/src/pro/bitget.js +193 -51
- package/js/src/pro/bybit.js +8 -15
- package/js/src/pro/gate.d.ts +5 -0
- package/js/src/pro/gate.js +6 -1
- package/js/src/pro/hyperliquid.js +4 -1
- package/js/src/pro/kraken.js +1 -0
- package/js/src/pro/lbank.d.ts +11 -1
- package/js/src/pro/lbank.js +55 -1
- package/js/src/pro/mexc.js +1 -1
- package/js/src/timex.js +35 -0
- package/js/src/tradeogre.js +32 -0
- package/js/src/wavesexchange.js +33 -0
- package/package.json +1 -1
|
@@ -46,10 +46,14 @@ class bitget extends bitget$1["default"] {
|
|
|
46
46
|
'ws': {
|
|
47
47
|
'public': 'wss://ws.bitget.com/v2/ws/public',
|
|
48
48
|
'private': 'wss://ws.bitget.com/v2/ws/private',
|
|
49
|
+
'utaPublic': 'wss://ws.bitget.com/v3/ws/public',
|
|
50
|
+
'utaPrivate': 'wss://ws.bitget.com/v3/ws/private',
|
|
49
51
|
},
|
|
50
52
|
'demo': {
|
|
51
53
|
'public': 'wss://wspap.bitget.com/v2/ws/public',
|
|
52
54
|
'private': 'wss://wspap.bitget.com/v2/ws/private',
|
|
55
|
+
'utaPublic': 'wss://wspap.bitget.com/v3/ws/public',
|
|
56
|
+
'utaPrivate': 'wss://wspap.bitget.com/v3/ws/private',
|
|
53
57
|
},
|
|
54
58
|
},
|
|
55
59
|
},
|
|
@@ -101,7 +105,10 @@ class bitget extends bitget$1["default"] {
|
|
|
101
105
|
},
|
|
102
106
|
});
|
|
103
107
|
}
|
|
104
|
-
getInstType(market, params = {}) {
|
|
108
|
+
getInstType(market, uta = false, params = {}) {
|
|
109
|
+
if ((uta === undefined) || !uta) {
|
|
110
|
+
[uta, params] = this.handleOptionAndParams(params, 'getInstType', 'uta', false);
|
|
111
|
+
}
|
|
105
112
|
let instType = undefined;
|
|
106
113
|
if (market === undefined) {
|
|
107
114
|
[instType, params] = this.handleProductTypeAndParams(undefined, params);
|
|
@@ -115,6 +122,9 @@ class bitget extends bitget$1["default"] {
|
|
|
115
122
|
let instypeAux = undefined;
|
|
116
123
|
[instypeAux, params] = this.handleOptionAndParams(params, 'getInstType', 'instType', instType);
|
|
117
124
|
instType = instypeAux;
|
|
125
|
+
if (uta) {
|
|
126
|
+
instType = instType.toLowerCase();
|
|
127
|
+
}
|
|
118
128
|
return [instType, params];
|
|
119
129
|
}
|
|
120
130
|
/**
|
|
@@ -123,8 +133,10 @@ class bitget extends bitget$1["default"] {
|
|
|
123
133
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
124
134
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
|
|
125
135
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
|
|
136
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/Tickers-Channel
|
|
126
137
|
* @param {string} symbol unified symbol of the market to watch the ticker for
|
|
127
138
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
139
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
128
140
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
129
141
|
*/
|
|
130
142
|
async watchTicker(symbol, params = {}) {
|
|
@@ -133,12 +145,16 @@ class bitget extends bitget$1["default"] {
|
|
|
133
145
|
symbol = market['symbol'];
|
|
134
146
|
const messageHash = 'ticker:' + symbol;
|
|
135
147
|
let instType = undefined;
|
|
136
|
-
|
|
148
|
+
let uta = undefined;
|
|
149
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchTicker', 'uta', false);
|
|
150
|
+
[instType, params] = this.getInstType(market, uta, params);
|
|
137
151
|
const args = {
|
|
138
152
|
'instType': instType,
|
|
139
|
-
'channel': 'ticker',
|
|
140
|
-
'instId': market['id'],
|
|
141
153
|
};
|
|
154
|
+
const topicOrChannel = uta ? 'topic' : 'channel';
|
|
155
|
+
const symbolOrInstId = uta ? 'symbol' : 'instId';
|
|
156
|
+
args[topicOrChannel] = 'ticker';
|
|
157
|
+
args[symbolOrInstId] = market['id'];
|
|
142
158
|
return await this.watchPublic(messageHash, args, params);
|
|
143
159
|
}
|
|
144
160
|
/**
|
|
@@ -161,8 +177,10 @@ class bitget extends bitget$1["default"] {
|
|
|
161
177
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
162
178
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
|
|
163
179
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
|
|
180
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/Tickers-Channel
|
|
164
181
|
* @param {string[]} symbols unified symbol of the market to watch the tickers for
|
|
165
182
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
183
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
166
184
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
167
185
|
*/
|
|
168
186
|
async watchTickers(symbols = undefined, params = {}) {
|
|
@@ -170,7 +188,9 @@ class bitget extends bitget$1["default"] {
|
|
|
170
188
|
symbols = this.marketSymbols(symbols, undefined, false);
|
|
171
189
|
const market = this.market(symbols[0]);
|
|
172
190
|
let instType = undefined;
|
|
173
|
-
|
|
191
|
+
let uta = undefined;
|
|
192
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchTickers', 'uta', false);
|
|
193
|
+
[instType, params] = this.getInstType(market, uta, params);
|
|
174
194
|
const topics = [];
|
|
175
195
|
const messageHashes = [];
|
|
176
196
|
for (let i = 0; i < symbols.length; i++) {
|
|
@@ -178,9 +198,11 @@ class bitget extends bitget$1["default"] {
|
|
|
178
198
|
const marketInner = this.market(symbol);
|
|
179
199
|
const args = {
|
|
180
200
|
'instType': instType,
|
|
181
|
-
'channel': 'ticker',
|
|
182
|
-
'instId': marketInner['id'],
|
|
183
201
|
};
|
|
202
|
+
const topicOrChannel = uta ? 'topic' : 'channel';
|
|
203
|
+
const symbolOrInstId = uta ? 'symbol' : 'instId';
|
|
204
|
+
args[topicOrChannel] = 'ticker';
|
|
205
|
+
args[symbolOrInstId] = marketInner['id'];
|
|
184
206
|
topics.push(args);
|
|
185
207
|
messageHashes.push('ticker:' + symbol);
|
|
186
208
|
}
|
|
@@ -193,6 +215,8 @@ class bitget extends bitget$1["default"] {
|
|
|
193
215
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
194
216
|
}
|
|
195
217
|
handleTicker(client, message) {
|
|
218
|
+
//
|
|
219
|
+
// default
|
|
196
220
|
//
|
|
197
221
|
// {
|
|
198
222
|
// "action": "snapshot",
|
|
@@ -223,6 +247,29 @@ class bitget extends bitget$1["default"] {
|
|
|
223
247
|
// "ts": 1701842994341
|
|
224
248
|
// }
|
|
225
249
|
//
|
|
250
|
+
// uta
|
|
251
|
+
//
|
|
252
|
+
// {
|
|
253
|
+
// "action": "snapshot",
|
|
254
|
+
// "arg": { "instType": "spot", topic: "ticker", symbol: "BTCUSDT" },
|
|
255
|
+
// "data": [
|
|
256
|
+
// {
|
|
257
|
+
// "highPrice24h": "120255.61",
|
|
258
|
+
// "lowPrice24h": "116145.88",
|
|
259
|
+
// "openPrice24h": "118919.38",
|
|
260
|
+
// "lastPrice": "119818.83",
|
|
261
|
+
// "turnover24h": "215859996.272276",
|
|
262
|
+
// "volume24h": "1819.756798",
|
|
263
|
+
// "bid1Price": "119811.26",
|
|
264
|
+
// "ask1Price": "119831.18",
|
|
265
|
+
// "bid1Size": "0.008732",
|
|
266
|
+
// "ask1Size": "0.004297",
|
|
267
|
+
// "price24hPcnt": "0.02002"
|
|
268
|
+
// }
|
|
269
|
+
// ],
|
|
270
|
+
// "ts": 1753230479687
|
|
271
|
+
// }
|
|
272
|
+
//
|
|
226
273
|
this.handleBidAsk(client, message);
|
|
227
274
|
const ticker = this.parseWsTicker(message);
|
|
228
275
|
const symbol = ticker['symbol'];
|
|
@@ -301,48 +348,75 @@ class bitget extends bitget$1["default"] {
|
|
|
301
348
|
// "ts": 1701843962812
|
|
302
349
|
// }
|
|
303
350
|
//
|
|
351
|
+
// uta
|
|
352
|
+
//
|
|
353
|
+
// {
|
|
354
|
+
// "action": "snapshot",
|
|
355
|
+
// "arg": { "instType": "spot", topic: "ticker", symbol: "BTCUSDT" },
|
|
356
|
+
// "data": [
|
|
357
|
+
// {
|
|
358
|
+
// "highPrice24h": "120255.61",
|
|
359
|
+
// "lowPrice24h": "116145.88",
|
|
360
|
+
// "openPrice24h": "118919.38",
|
|
361
|
+
// "lastPrice": "119818.83",
|
|
362
|
+
// "turnover24h": "215859996.272276",
|
|
363
|
+
// "volume24h": "1819.756798",
|
|
364
|
+
// "bid1Price": "119811.26",
|
|
365
|
+
// "ask1Price": "119831.18",
|
|
366
|
+
// "bid1Size": "0.008732",
|
|
367
|
+
// "ask1Size": "0.004297",
|
|
368
|
+
// "price24hPcnt": "0.02002"
|
|
369
|
+
// }
|
|
370
|
+
// ],
|
|
371
|
+
// "ts": 1753230479687
|
|
372
|
+
// }
|
|
373
|
+
//
|
|
304
374
|
const arg = this.safeValue(message, 'arg', {});
|
|
305
375
|
const data = this.safeValue(message, 'data', []);
|
|
306
376
|
const ticker = this.safeValue(data, 0, {});
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const
|
|
377
|
+
const utaTimestamp = this.safeInteger(message, 'ts');
|
|
378
|
+
const timestamp = this.safeInteger(ticker, 'ts', utaTimestamp);
|
|
379
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
380
|
+
const marketType = (instType === 'spot') ? 'spot' : 'contract';
|
|
381
|
+
const utaMarketId = this.safeString(arg, 'symbol');
|
|
382
|
+
const marketId = this.safeString(ticker, 'instId', utaMarketId);
|
|
311
383
|
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
312
|
-
const close = this.
|
|
313
|
-
const changeDecimal = this.safeString(ticker, 'change24h');
|
|
314
|
-
const change = Precise["default"].stringMul(changeDecimal, '100');
|
|
384
|
+
const close = this.safeString2(ticker, 'lastPr', 'lastPrice');
|
|
385
|
+
const changeDecimal = this.safeString(ticker, 'change24h', '');
|
|
386
|
+
const change = this.safeString(ticker, 'price24hPcnt', Precise["default"].stringMul(changeDecimal, '100'));
|
|
315
387
|
return this.safeTicker({
|
|
316
388
|
'symbol': market['symbol'],
|
|
317
389
|
'timestamp': timestamp,
|
|
318
390
|
'datetime': this.iso8601(timestamp),
|
|
319
|
-
'high': this.
|
|
320
|
-
'low': this.
|
|
321
|
-
'bid': this.
|
|
322
|
-
'bidVolume': this.
|
|
323
|
-
'ask': this.
|
|
324
|
-
'askVolume': this.
|
|
391
|
+
'high': this.safeString2(ticker, 'high24h', 'highPrice24h'),
|
|
392
|
+
'low': this.safeString2(ticker, 'low24h', 'lowPrice24h'),
|
|
393
|
+
'bid': this.safeString2(ticker, 'bidPr', 'bid1Price'),
|
|
394
|
+
'bidVolume': this.safeString2(ticker, 'bidSz', 'bid1Size'),
|
|
395
|
+
'ask': this.safeString2(ticker, 'askPr', 'ask1Price'),
|
|
396
|
+
'askVolume': this.safeString2(ticker, 'askSz', 'ask1Size'),
|
|
325
397
|
'vwap': undefined,
|
|
326
|
-
'open': this.
|
|
398
|
+
'open': this.safeString2(ticker, 'open24h', 'openPrice24h'),
|
|
327
399
|
'close': close,
|
|
328
400
|
'last': close,
|
|
329
401
|
'previousClose': undefined,
|
|
330
402
|
'change': undefined,
|
|
331
403
|
'percentage': change,
|
|
332
404
|
'average': undefined,
|
|
333
|
-
'baseVolume': this.
|
|
334
|
-
'quoteVolume': this.
|
|
405
|
+
'baseVolume': this.safeString2(ticker, 'baseVolume', 'volume24h'),
|
|
406
|
+
'quoteVolume': this.safeString2(ticker, 'quoteVolume', 'turnover24h'),
|
|
335
407
|
'info': ticker,
|
|
336
408
|
}, market);
|
|
337
409
|
}
|
|
338
410
|
/**
|
|
339
411
|
* @method
|
|
340
412
|
* @name bitget#watchBidsAsks
|
|
413
|
+
* @description watches best bid & ask for symbols
|
|
341
414
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
|
|
342
415
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
|
|
343
|
-
* @
|
|
416
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/Tickers-Channel
|
|
344
417
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
345
418
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
419
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
346
420
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
347
421
|
*/
|
|
348
422
|
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
@@ -350,7 +424,9 @@ class bitget extends bitget$1["default"] {
|
|
|
350
424
|
symbols = this.marketSymbols(symbols, undefined, false);
|
|
351
425
|
const market = this.market(symbols[0]);
|
|
352
426
|
let instType = undefined;
|
|
353
|
-
|
|
427
|
+
let uta = undefined;
|
|
428
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchBidsAsks', 'uta', false);
|
|
429
|
+
[instType, params] = this.getInstType(market, uta, params);
|
|
354
430
|
const topics = [];
|
|
355
431
|
const messageHashes = [];
|
|
356
432
|
for (let i = 0; i < symbols.length; i++) {
|
|
@@ -358,9 +434,11 @@ class bitget extends bitget$1["default"] {
|
|
|
358
434
|
const marketInner = this.market(symbol);
|
|
359
435
|
const args = {
|
|
360
436
|
'instType': instType,
|
|
361
|
-
'channel': 'ticker',
|
|
362
|
-
'instId': marketInner['id'],
|
|
363
437
|
};
|
|
438
|
+
const topicOrChannel = uta ? 'topic' : 'channel';
|
|
439
|
+
const symbolOrInstId = uta ? 'symbol' : 'instId';
|
|
440
|
+
args[topicOrChannel] = 'ticker';
|
|
441
|
+
args[symbolOrInstId] = marketInner['id'];
|
|
364
442
|
topics.push(args);
|
|
365
443
|
messageHashes.push('bidask:' + symbol);
|
|
366
444
|
}
|
|
@@ -383,19 +461,21 @@ class bitget extends bitget$1["default"] {
|
|
|
383
461
|
const arg = this.safeValue(message, 'arg', {});
|
|
384
462
|
const data = this.safeValue(message, 'data', []);
|
|
385
463
|
const ticker = this.safeValue(data, 0, {});
|
|
386
|
-
const
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
const
|
|
464
|
+
const utaTimestamp = this.safeInteger(message, 'ts');
|
|
465
|
+
const timestamp = this.safeInteger(ticker, 'ts', utaTimestamp);
|
|
466
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
467
|
+
const marketType = (instType === 'spot') ? 'spot' : 'contract';
|
|
468
|
+
const utaMarketId = this.safeString(arg, 'symbol');
|
|
469
|
+
const marketId = this.safeString(ticker, 'instId', utaMarketId);
|
|
390
470
|
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
391
471
|
return this.safeTicker({
|
|
392
472
|
'symbol': market['symbol'],
|
|
393
473
|
'timestamp': timestamp,
|
|
394
474
|
'datetime': this.iso8601(timestamp),
|
|
395
|
-
'ask': this.
|
|
396
|
-
'askVolume': this.
|
|
397
|
-
'bid': this.
|
|
398
|
-
'bidVolume': this.
|
|
475
|
+
'ask': this.safeString2(ticker, 'askPr', 'ask1Price'),
|
|
476
|
+
'askVolume': this.safeString2(ticker, 'askSz', 'ask1Size'),
|
|
477
|
+
'bid': this.safeString2(ticker, 'bidPr', 'bid1Price'),
|
|
478
|
+
'bidVolume': this.safeString2(ticker, 'bidSz', 'bid1Size'),
|
|
399
479
|
'info': ticker,
|
|
400
480
|
}, market);
|
|
401
481
|
}
|
|
@@ -420,7 +500,7 @@ class bitget extends bitget$1["default"] {
|
|
|
420
500
|
const interval = this.safeString(timeframes, timeframe);
|
|
421
501
|
const messageHash = 'candles:' + timeframe + ':' + symbol;
|
|
422
502
|
let instType = undefined;
|
|
423
|
-
[instType, params] = this.getInstType(market, params);
|
|
503
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
424
504
|
const args = {
|
|
425
505
|
'instType': instType,
|
|
426
506
|
'channel': 'candle' + interval,
|
|
@@ -572,7 +652,7 @@ class bitget extends bitget$1["default"] {
|
|
|
572
652
|
const market = this.market(symbol);
|
|
573
653
|
const messageHash = 'unsubscribe:' + messageHashTopic + ':' + market['symbol'];
|
|
574
654
|
let instType = undefined;
|
|
575
|
-
[instType, params] = this.getInstType(market, params);
|
|
655
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
576
656
|
const args = {
|
|
577
657
|
'instType': instType,
|
|
578
658
|
'channel': channel,
|
|
@@ -606,7 +686,7 @@ class bitget extends bitget$1["default"] {
|
|
|
606
686
|
const symbol = symbols[i];
|
|
607
687
|
const market = this.market(symbol);
|
|
608
688
|
let instType = undefined;
|
|
609
|
-
[instType, params] = this.getInstType(market, params);
|
|
689
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
610
690
|
const args = {
|
|
611
691
|
'instType': instType,
|
|
612
692
|
'channel': channel,
|
|
@@ -777,7 +857,7 @@ class bitget extends bitget$1["default"] {
|
|
|
777
857
|
const symbol = symbols[i];
|
|
778
858
|
const market = this.market(symbol);
|
|
779
859
|
let instType = undefined;
|
|
780
|
-
[instType, params] = this.getInstType(market, params);
|
|
860
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
781
861
|
const args = {
|
|
782
862
|
'instType': instType,
|
|
783
863
|
'channel': 'trade',
|
|
@@ -968,7 +1048,7 @@ class bitget extends bitget$1["default"] {
|
|
|
968
1048
|
symbols = this.marketSymbols(symbols);
|
|
969
1049
|
if (!this.isEmpty(symbols)) {
|
|
970
1050
|
market = this.getMarketFromSymbols(symbols);
|
|
971
|
-
[instType, params] = this.getInstType(market, params);
|
|
1051
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
972
1052
|
}
|
|
973
1053
|
messageHash = instType + ':positions' + messageHash;
|
|
974
1054
|
const args = {
|
|
@@ -1178,7 +1258,7 @@ class bitget extends bitget$1["default"] {
|
|
|
1178
1258
|
instType = 'SPOT';
|
|
1179
1259
|
}
|
|
1180
1260
|
else {
|
|
1181
|
-
[instType, params] = this.getInstType(market, params);
|
|
1261
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
1182
1262
|
}
|
|
1183
1263
|
if (type === 'spot' && (symbol !== undefined)) {
|
|
1184
1264
|
subscriptionHash = subscriptionHash + ':' + symbol;
|
|
@@ -1562,7 +1642,7 @@ class bitget extends bitget$1["default"] {
|
|
|
1562
1642
|
instType = 'spot';
|
|
1563
1643
|
}
|
|
1564
1644
|
else {
|
|
1565
|
-
[instType, params] = this.getInstType(market, params);
|
|
1645
|
+
[instType, params] = this.getInstType(market, false, params);
|
|
1566
1646
|
}
|
|
1567
1647
|
const subscriptionHash = 'fill:' + instType;
|
|
1568
1648
|
const args = {
|
|
@@ -1794,12 +1874,25 @@ class bitget extends bitget$1["default"] {
|
|
|
1794
1874
|
client.resolve(this.balance, messageHash);
|
|
1795
1875
|
}
|
|
1796
1876
|
async watchPublic(messageHash, args, params = {}) {
|
|
1797
|
-
let
|
|
1877
|
+
let uta = undefined;
|
|
1878
|
+
let url = undefined;
|
|
1879
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchPublic', 'uta', false);
|
|
1880
|
+
if (uta) {
|
|
1881
|
+
url = this.urls['api']['ws']['utaPublic'];
|
|
1882
|
+
}
|
|
1883
|
+
else {
|
|
1884
|
+
url = this.urls['api']['ws']['public'];
|
|
1885
|
+
}
|
|
1798
1886
|
const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
|
|
1799
1887
|
if (sandboxMode) {
|
|
1800
1888
|
const instType = this.safeString(args, 'instType');
|
|
1801
1889
|
if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
|
|
1802
|
-
|
|
1890
|
+
if (uta) {
|
|
1891
|
+
url = this.urls['api']['demo']['utaPublic'];
|
|
1892
|
+
}
|
|
1893
|
+
else {
|
|
1894
|
+
url = this.urls['api']['demo']['public'];
|
|
1895
|
+
}
|
|
1803
1896
|
}
|
|
1804
1897
|
}
|
|
1805
1898
|
const request = {
|
|
@@ -1810,12 +1903,25 @@ class bitget extends bitget$1["default"] {
|
|
|
1810
1903
|
return await this.watch(url, messageHash, message, messageHash);
|
|
1811
1904
|
}
|
|
1812
1905
|
async unWatchPublic(messageHash, args, params = {}) {
|
|
1813
|
-
let
|
|
1906
|
+
let uta = undefined;
|
|
1907
|
+
let url = undefined;
|
|
1908
|
+
[uta, params] = this.handleOptionAndParams(params, 'unWatchPublic', 'uta', false);
|
|
1909
|
+
if (uta) {
|
|
1910
|
+
url = this.urls['api']['ws']['utaPublic'];
|
|
1911
|
+
}
|
|
1912
|
+
else {
|
|
1913
|
+
url = this.urls['api']['ws']['public'];
|
|
1914
|
+
}
|
|
1814
1915
|
const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
|
|
1815
1916
|
if (sandboxMode) {
|
|
1816
1917
|
const instType = this.safeString(args, 'instType');
|
|
1817
1918
|
if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
|
|
1818
|
-
|
|
1919
|
+
if (uta) {
|
|
1920
|
+
url = this.urls['api']['demo']['utaPublic'];
|
|
1921
|
+
}
|
|
1922
|
+
else {
|
|
1923
|
+
url = this.urls['api']['demo']['public'];
|
|
1924
|
+
}
|
|
1819
1925
|
}
|
|
1820
1926
|
}
|
|
1821
1927
|
const request = {
|
|
@@ -1826,13 +1932,26 @@ class bitget extends bitget$1["default"] {
|
|
|
1826
1932
|
return await this.watch(url, messageHash, message, messageHash);
|
|
1827
1933
|
}
|
|
1828
1934
|
async watchPublicMultiple(messageHashes, argsArray, params = {}) {
|
|
1829
|
-
let
|
|
1935
|
+
let uta = undefined;
|
|
1936
|
+
let url = undefined;
|
|
1937
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchPublicMultiple', 'uta', false);
|
|
1938
|
+
if (uta) {
|
|
1939
|
+
url = this.urls['api']['ws']['utaPublic'];
|
|
1940
|
+
}
|
|
1941
|
+
else {
|
|
1942
|
+
url = this.urls['api']['ws']['public'];
|
|
1943
|
+
}
|
|
1830
1944
|
const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
|
|
1831
1945
|
if (sandboxMode) {
|
|
1832
1946
|
const argsArrayFirst = this.safeDict(argsArray, 0, {});
|
|
1833
1947
|
const instType = this.safeString(argsArrayFirst, 'instType');
|
|
1834
1948
|
if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
|
|
1835
|
-
|
|
1949
|
+
if (uta) {
|
|
1950
|
+
url = this.urls['api']['demo']['utaPublic'];
|
|
1951
|
+
}
|
|
1952
|
+
else {
|
|
1953
|
+
url = this.urls['api']['demo']['public'];
|
|
1954
|
+
}
|
|
1836
1955
|
}
|
|
1837
1956
|
}
|
|
1838
1957
|
const request = {
|
|
@@ -1972,6 +2091,29 @@ class bitget extends bitget$1["default"] {
|
|
|
1972
2091
|
// ]
|
|
1973
2092
|
// }
|
|
1974
2093
|
//
|
|
2094
|
+
// uta
|
|
2095
|
+
//
|
|
2096
|
+
// {
|
|
2097
|
+
// "action": "snapshot",
|
|
2098
|
+
// "arg": { "instType": "spot", topic: "ticker", symbol: "BTCUSDT" },
|
|
2099
|
+
// "data": [
|
|
2100
|
+
// {
|
|
2101
|
+
// "highPrice24h": "120255.61",
|
|
2102
|
+
// "lowPrice24h": "116145.88",
|
|
2103
|
+
// "openPrice24h": "118919.38",
|
|
2104
|
+
// "lastPrice": "119818.83",
|
|
2105
|
+
// "turnover24h": "215859996.272276",
|
|
2106
|
+
// "volume24h": "1819.756798",
|
|
2107
|
+
// "bid1Price": "119811.26",
|
|
2108
|
+
// "ask1Price": "119831.18",
|
|
2109
|
+
// "bid1Size": "0.008732",
|
|
2110
|
+
// "ask1Size": "0.004297",
|
|
2111
|
+
// "price24hPcnt": "0.02002"
|
|
2112
|
+
// }
|
|
2113
|
+
// ],
|
|
2114
|
+
// "ts": 1753230479687
|
|
2115
|
+
// }
|
|
2116
|
+
//
|
|
1975
2117
|
if (this.handleErrorMessage(client, message)) {
|
|
1976
2118
|
return;
|
|
1977
2119
|
}
|
|
@@ -2012,7 +2154,7 @@ class bitget extends bitget$1["default"] {
|
|
|
2012
2154
|
'account-crossed': this.handleBalance,
|
|
2013
2155
|
};
|
|
2014
2156
|
const arg = this.safeValue(message, 'arg', {});
|
|
2015
|
-
const topic = this.
|
|
2157
|
+
const topic = this.safeValue2(arg, 'channel', 'topic', '');
|
|
2016
2158
|
const method = this.safeValue(methods, topic);
|
|
2017
2159
|
if (method !== undefined) {
|
|
2018
2160
|
method.call(this, client, message);
|
|
@@ -2097,7 +2239,7 @@ class bitget extends bitget$1["default"] {
|
|
|
2097
2239
|
const arg = this.safeDict(message, 'arg', {});
|
|
2098
2240
|
const instType = this.safeStringLower(arg, 'instType');
|
|
2099
2241
|
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
2100
|
-
const instId = this.
|
|
2242
|
+
const instId = this.safeString2(arg, 'instId', 'symbol');
|
|
2101
2243
|
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
2102
2244
|
const symbol = market['symbol'];
|
|
2103
2245
|
const messageHash = 'unsubscribe:ticker:' + market['symbol'];
|
|
@@ -2164,7 +2306,7 @@ class bitget extends bitget$1["default"] {
|
|
|
2164
2306
|
}
|
|
2165
2307
|
for (let i = 0; i < argsList.length; i++) {
|
|
2166
2308
|
const arg = argsList[i];
|
|
2167
|
-
const channel = this.
|
|
2309
|
+
const channel = this.safeString2(arg, 'channel', 'topic');
|
|
2168
2310
|
if (channel === 'books') {
|
|
2169
2311
|
// for now only unWatchOrderBook is supporteod
|
|
2170
2312
|
this.handleOrderBookUnSubscription(client, message);
|
|
@@ -866,21 +866,14 @@ class bybit extends bybit$1["default"] {
|
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
868
|
else {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
throw new errors.BadRequest(this.id + ' watchOrderBookForSymbols() can only use limit 1, 50, 200 and 500 for swap and future markets.');
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
else {
|
|
881
|
-
if ((limit !== 1) && (limit !== 50) && (limit !== 200)) {
|
|
882
|
-
throw new errors.BadRequest(this.id + ' watchOrderBookForSymbols() can only use limit 1,50, and 200 for spot markets.');
|
|
883
|
-
}
|
|
869
|
+
const limits = {
|
|
870
|
+
'spot': [1, 50, 200, 1000],
|
|
871
|
+
'option': [25, 100],
|
|
872
|
+
'default': [1, 50, 200, 500, 1000],
|
|
873
|
+
};
|
|
874
|
+
const selectedLimits = this.safeList2(limits, market['type'], 'default');
|
|
875
|
+
if (!this.inArray(limit, selectedLimits)) {
|
|
876
|
+
throw new errors.BadRequest(this.id + ' watchOrderBookForSymbols(): for ' + market['type'] + ' markets limit can be one of: ' + this.json(selectedLimits));
|
|
884
877
|
}
|
|
885
878
|
}
|
|
886
879
|
const topics = [];
|
package/dist/cjs/src/pro/gate.js
CHANGED
|
@@ -360,6 +360,11 @@ class gate extends gate$1["default"] {
|
|
|
360
360
|
* @method
|
|
361
361
|
* @name gate#watchOrderBook
|
|
362
362
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
363
|
+
* @see https://www.gate.com/docs/developers/apiv4/ws/en/#order-book-channel
|
|
364
|
+
* @see https://www.gate.com/docs/developers/apiv4/ws/en/#order-book-v2-api
|
|
365
|
+
* @see https://www.gate.com/docs/developers/futures/ws/en/#order-book-api
|
|
366
|
+
* @see https://www.gate.com/docs/developers/futures/ws/en/#order-book-v2-api
|
|
367
|
+
* @see https://www.gate.com/docs/developers/delivery/ws/en/#order-book-api
|
|
363
368
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
364
369
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
365
370
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -377,7 +382,7 @@ class gate extends gate$1["default"] {
|
|
|
377
382
|
const url = this.getUrlByMarket(market);
|
|
378
383
|
const payload = [marketId, interval];
|
|
379
384
|
if (limit === undefined) {
|
|
380
|
-
limit = 100;
|
|
385
|
+
limit = 100; // max 100 atm
|
|
381
386
|
}
|
|
382
387
|
if (market['contract']) {
|
|
383
388
|
const stringLimit = limit.toString();
|
|
@@ -920,7 +920,10 @@ class hyperliquid extends hyperliquid$1["default"] {
|
|
|
920
920
|
return true;
|
|
921
921
|
}
|
|
922
922
|
const data = this.safeDict(message, 'data', {});
|
|
923
|
-
|
|
923
|
+
let id = this.safeString(message, 'id');
|
|
924
|
+
if (id === undefined) {
|
|
925
|
+
id = this.safeString(data, 'id');
|
|
926
|
+
}
|
|
924
927
|
const response = this.safeDict(data, 'response', {});
|
|
925
928
|
const payload = this.safeDict(response, 'payload', {});
|
|
926
929
|
const status = this.safeString(payload, 'status');
|
|
@@ -69,6 +69,7 @@ class kraken extends kraken$1["default"] {
|
|
|
69
69
|
'broad': {
|
|
70
70
|
'Already subscribed': errors.BadRequest,
|
|
71
71
|
'Currency pair not in ISO 4217-A3 format': errors.BadSymbol,
|
|
72
|
+
'Currency pair not supported': errors.BadSymbol,
|
|
72
73
|
'Malformed request': errors.BadRequest,
|
|
73
74
|
'Pair field must be an array': errors.BadRequest,
|
|
74
75
|
'Pair field unsupported for this subscription type': errors.BadRequest,
|
|
@@ -17,7 +17,7 @@ class lbank extends lbank$1["default"] {
|
|
|
17
17
|
'fetchOrderBookWs': true,
|
|
18
18
|
'fetchTickerWs': true,
|
|
19
19
|
'fetchTradesWs': true,
|
|
20
|
-
'watchBalance':
|
|
20
|
+
'watchBalance': true,
|
|
21
21
|
'watchTicker': true,
|
|
22
22
|
'watchTickers': false,
|
|
23
23
|
'watchTrades': true,
|
|
@@ -669,6 +669,59 @@ class lbank extends lbank$1["default"] {
|
|
|
669
669
|
};
|
|
670
670
|
return this.safeString(statuses, status, status);
|
|
671
671
|
}
|
|
672
|
+
/**
|
|
673
|
+
* @method
|
|
674
|
+
* @name lbank#watchBalance
|
|
675
|
+
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
676
|
+
* @see https://www.lbank.com/docs/index.html#update-subscribed-asset
|
|
677
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
678
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
679
|
+
*/
|
|
680
|
+
async watchBalance(params = {}) {
|
|
681
|
+
await this.loadMarkets();
|
|
682
|
+
const key = await this.authenticate(params);
|
|
683
|
+
const url = this.urls['api']['ws'];
|
|
684
|
+
const messageHash = 'balance';
|
|
685
|
+
const message = {
|
|
686
|
+
'action': 'subscribe',
|
|
687
|
+
'subscribe': 'assetUpdate',
|
|
688
|
+
'subscribeKey': key,
|
|
689
|
+
};
|
|
690
|
+
const request = this.deepExtend(message, params);
|
|
691
|
+
return await this.watch(url, messageHash, request, messageHash, request);
|
|
692
|
+
}
|
|
693
|
+
handleBalance(client, message) {
|
|
694
|
+
//
|
|
695
|
+
// {
|
|
696
|
+
// "data": {
|
|
697
|
+
// "asset": "114548.31881315",
|
|
698
|
+
// "assetCode": "usdt",
|
|
699
|
+
// "free": "97430.6739041",
|
|
700
|
+
// "freeze": "17117.64490905",
|
|
701
|
+
// "time": 1627300043270,
|
|
702
|
+
// "type": "ORDER_CREATE"
|
|
703
|
+
// },
|
|
704
|
+
// "SERVER": "V2",
|
|
705
|
+
// "type": "assetUpdate",
|
|
706
|
+
// "TS": "2021-07-26T19:48:03.548"
|
|
707
|
+
// }
|
|
708
|
+
//
|
|
709
|
+
const data = this.safeDict(message, 'data', {});
|
|
710
|
+
const timestamp = this.parse8601(this.safeString(message, 'TS'));
|
|
711
|
+
const datetime = this.iso8601(timestamp);
|
|
712
|
+
this.balance['info'] = data;
|
|
713
|
+
this.balance['timestamp'] = timestamp;
|
|
714
|
+
this.balance['datetime'] = datetime;
|
|
715
|
+
const currencyId = this.safeString(data, 'assetCode');
|
|
716
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
717
|
+
const account = this.account();
|
|
718
|
+
account['free'] = this.safeString(data, 'free');
|
|
719
|
+
account['used'] = this.safeString(data, 'freeze');
|
|
720
|
+
account['total'] = this.safeString(data, 'asset');
|
|
721
|
+
this.balance[code] = account;
|
|
722
|
+
this.balance = this.safeBalance(this.balance);
|
|
723
|
+
client.resolve(this.balance, 'balance');
|
|
724
|
+
}
|
|
672
725
|
/**
|
|
673
726
|
* @method
|
|
674
727
|
* @name lbank#fetchOrderBookWs
|
|
@@ -845,6 +898,7 @@ class lbank extends lbank$1["default"] {
|
|
|
845
898
|
'trade': this.handleTrades,
|
|
846
899
|
'tick': this.handleTicker,
|
|
847
900
|
'orderUpdate': this.handleOrders,
|
|
901
|
+
'assetUpdate': this.handleBalance,
|
|
848
902
|
};
|
|
849
903
|
const handler = this.safeValue(handlers, type);
|
|
850
904
|
if (handler !== undefined) {
|
package/dist/cjs/src/pro/mexc.js
CHANGED
|
@@ -1421,7 +1421,7 @@ class mexc extends mexc$1["default"] {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
return this.safeOrder({
|
|
1423
1423
|
'id': this.safeString(order, 'id'),
|
|
1424
|
-
'clientOrderId': this.safeString(order, '
|
|
1424
|
+
'clientOrderId': this.safeString(order, 'clientId'),
|
|
1425
1425
|
'timestamp': timestamp,
|
|
1426
1426
|
'datetime': this.iso8601(timestamp),
|
|
1427
1427
|
'lastTradeTimestamp': undefined,
|