ccxt 4.5.2 → 4.5.4
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 +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +78 -5
- package/dist/cjs/src/base/functions/encode.js +8 -0
- package/dist/cjs/src/base/functions/rsa.js +14 -1
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/binance.js +12 -15
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/bitvavo.js +8 -0
- package/dist/cjs/src/bybit.js +20 -6
- package/dist/cjs/src/coinbase.js +28 -10
- package/dist/cjs/src/coincatch.js +34 -21
- package/dist/cjs/src/delta.js +1 -0
- package/dist/cjs/src/gate.js +27 -12
- package/dist/cjs/src/gemini.js +3 -3
- package/dist/cjs/src/htx.js +4 -4
- package/dist/cjs/src/kucoinfutures.js +11 -10
- package/dist/cjs/src/mexc.js +30 -1
- package/dist/cjs/src/okx.js +19 -4
- package/dist/cjs/src/pro/binance.js +3 -3
- package/dist/cjs/src/pro/bitfinex.js +140 -0
- package/dist/cjs/src/pro/bitget.js +168 -26
- package/dist/cjs/src/pro/bybit.js +67 -11
- package/dist/cjs/src/pro/coinex.js +10 -11
- package/dist/cjs/src/pro/kucoin.js +64 -0
- package/dist/cjs/src/pro/mexc.js +7 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/myokx.d.ts +1 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/abstract/okxus.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +6 -0
- package/js/src/base/Exchange.js +78 -5
- package/js/src/base/functions/encode.d.ts +2 -1
- package/js/src/base/functions/encode.js +8 -1
- package/js/src/base/functions/rsa.js +16 -3
- package/js/src/binance.js +12 -15
- package/js/src/bitget.js +1 -1
- package/js/src/bitvavo.js +8 -0
- package/js/src/bybit.js +20 -6
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +28 -10
- package/js/src/coincatch.d.ts +2 -0
- package/js/src/coincatch.js +34 -21
- package/js/src/delta.js +1 -0
- package/js/src/gate.js +27 -12
- package/js/src/gemini.js +3 -3
- package/js/src/htx.js +4 -4
- package/js/src/kucoinfutures.js +11 -10
- package/js/src/mexc.d.ts +3 -0
- package/js/src/mexc.js +30 -1
- package/js/src/okx.d.ts +4 -2
- package/js/src/okx.js +19 -4
- package/js/src/pro/binance.js +3 -3
- package/js/src/pro/bitfinex.d.ts +30 -0
- package/js/src/pro/bitfinex.js +140 -0
- package/js/src/pro/bitget.d.ts +9 -1
- package/js/src/pro/bitget.js +168 -26
- package/js/src/pro/bybit.d.ts +6 -2
- package/js/src/pro/bybit.js +67 -11
- package/js/src/pro/coinex.js +11 -12
- package/js/src/pro/kucoin.d.ts +22 -0
- package/js/src/pro/kucoin.js +64 -0
- package/js/src/pro/mexc.js +7 -3
- package/package.json +3 -3
package/js/src/pro/bybit.js
CHANGED
|
@@ -446,13 +446,13 @@ export default class bybit extends bybitRest {
|
|
|
446
446
|
* @description unWatches a price ticker
|
|
447
447
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
|
|
448
448
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
|
|
449
|
-
* @param {string[]}
|
|
449
|
+
* @param {string[]} symbol unified symbol of the market to fetch the ticker for
|
|
450
450
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
451
451
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
452
452
|
*/
|
|
453
|
-
async unWatchTicker(
|
|
453
|
+
async unWatchTicker(symbol, params = {}) {
|
|
454
454
|
await this.loadMarkets();
|
|
455
|
-
return await this.unWatchTickers([
|
|
455
|
+
return await this.unWatchTickers([symbol], params);
|
|
456
456
|
}
|
|
457
457
|
handleTicker(client, message) {
|
|
458
458
|
//
|
|
@@ -1244,11 +1244,13 @@ export default class bybit extends bybitRest {
|
|
|
1244
1244
|
* @name bybit#watchMyTrades
|
|
1245
1245
|
* @description watches information on multiple trades made by the user
|
|
1246
1246
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/execution
|
|
1247
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/fast-execution
|
|
1247
1248
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1248
1249
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1249
1250
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1250
1251
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1251
1252
|
* @param {boolean} [params.unifiedMargin] use unified margin account
|
|
1253
|
+
* @param {boolean} [params.executionFast] use fast execution
|
|
1252
1254
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1253
1255
|
*/
|
|
1254
1256
|
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -1266,7 +1268,12 @@ export default class bybit extends bybitRest {
|
|
|
1266
1268
|
'unified': 'execution',
|
|
1267
1269
|
'usdc': 'user.openapi.perp.trade',
|
|
1268
1270
|
};
|
|
1269
|
-
|
|
1271
|
+
let topic = this.safeValue(topicByMarket, this.getPrivateType(url));
|
|
1272
|
+
let executionFast = false;
|
|
1273
|
+
[executionFast, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'executionFast', false);
|
|
1274
|
+
if (executionFast) {
|
|
1275
|
+
topic = 'execution.fast';
|
|
1276
|
+
}
|
|
1270
1277
|
const trades = await this.watchTopics(url, [messageHash], [topic], params);
|
|
1271
1278
|
if (this.newUpdates) {
|
|
1272
1279
|
limit = trades.getLimit(symbol, limit);
|
|
@@ -1278,9 +1285,11 @@ export default class bybit extends bybitRest {
|
|
|
1278
1285
|
* @name bybit#unWatchMyTrades
|
|
1279
1286
|
* @description unWatches information on multiple trades made by the user
|
|
1280
1287
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/execution
|
|
1288
|
+
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/fast-execution
|
|
1281
1289
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1282
1290
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1283
1291
|
* @param {boolean} [params.unifiedMargin] use unified margin account
|
|
1292
|
+
* @param {boolean} [params.executionFast] use fast execution
|
|
1284
1293
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1285
1294
|
*/
|
|
1286
1295
|
async unWatchMyTrades(symbol = undefined, params = {}) {
|
|
@@ -1298,7 +1307,12 @@ export default class bybit extends bybitRest {
|
|
|
1298
1307
|
'unified': 'execution',
|
|
1299
1308
|
'usdc': 'user.openapi.perp.trade',
|
|
1300
1309
|
};
|
|
1301
|
-
|
|
1310
|
+
let topic = this.safeValue(topicByMarket, this.getPrivateType(url));
|
|
1311
|
+
let executionFast = false;
|
|
1312
|
+
[executionFast, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'executionFast', false);
|
|
1313
|
+
if (executionFast) {
|
|
1314
|
+
topic = 'execution.fast';
|
|
1315
|
+
}
|
|
1302
1316
|
return await this.unWatchTopics(url, 'myTrades', [], [messageHash], [subHash], [topic], params);
|
|
1303
1317
|
}
|
|
1304
1318
|
handleMyTrades(client, message) {
|
|
@@ -1364,8 +1378,31 @@ export default class bybit extends bybitRest {
|
|
|
1364
1378
|
// ]
|
|
1365
1379
|
// }
|
|
1366
1380
|
//
|
|
1381
|
+
// execution.fast
|
|
1382
|
+
//
|
|
1383
|
+
// {
|
|
1384
|
+
// "topic": "execution.fast",
|
|
1385
|
+
// "creationTime": 1757405601981,
|
|
1386
|
+
// "data": [
|
|
1387
|
+
// {
|
|
1388
|
+
// "category": "linear",
|
|
1389
|
+
// "symbol": "BTCUSDT",
|
|
1390
|
+
// "execId": "ffcac6ac-7571-536d-a28a-847dd7d08a0f",
|
|
1391
|
+
// "execPrice": "112529.6",
|
|
1392
|
+
// "execQty": "0.001",
|
|
1393
|
+
// "orderId": "6e25ab73-7a55-4ae7-adc2-8ea95f167c85",
|
|
1394
|
+
// "isMaker": false,
|
|
1395
|
+
// "orderLinkId": "test-00001",
|
|
1396
|
+
// "side": "Buy",
|
|
1397
|
+
// "execTime": "1757405601977",
|
|
1398
|
+
// "seq": 9515624038
|
|
1399
|
+
// }
|
|
1400
|
+
// ]
|
|
1401
|
+
// }
|
|
1402
|
+
//
|
|
1367
1403
|
const topic = this.safeString(message, 'topic');
|
|
1368
1404
|
const spot = topic === 'ticketInfo';
|
|
1405
|
+
const executionFast = topic === 'execution.fast';
|
|
1369
1406
|
let data = this.safeValue(message, 'data', []);
|
|
1370
1407
|
if (!Array.isArray(data)) {
|
|
1371
1408
|
data = this.safeValue(data, 'result', []);
|
|
@@ -1380,12 +1417,15 @@ export default class bybit extends bybitRest {
|
|
|
1380
1417
|
for (let i = 0; i < data.length; i++) {
|
|
1381
1418
|
const rawTrade = data[i];
|
|
1382
1419
|
let parsed = undefined;
|
|
1383
|
-
if (spot) {
|
|
1420
|
+
if (spot && !executionFast) {
|
|
1384
1421
|
parsed = this.parseWsTrade(rawTrade);
|
|
1385
1422
|
}
|
|
1386
1423
|
else {
|
|
1387
1424
|
// filter unified trades
|
|
1388
|
-
|
|
1425
|
+
let execType = this.safeString(rawTrade, 'execType', '');
|
|
1426
|
+
if (executionFast) {
|
|
1427
|
+
execType = 'Trade';
|
|
1428
|
+
}
|
|
1389
1429
|
if (!this.inArray(execType, filterExecTypes)) {
|
|
1390
1430
|
continue;
|
|
1391
1431
|
}
|
|
@@ -2341,12 +2381,13 @@ export default class bybit extends bybitRest {
|
|
|
2341
2381
|
}
|
|
2342
2382
|
}
|
|
2343
2383
|
handleMessage(client, message) {
|
|
2384
|
+
const topic = this.safeString2(message, 'topic', 'op', '');
|
|
2344
2385
|
if (this.handleErrorMessage(client, message)) {
|
|
2345
2386
|
return;
|
|
2346
2387
|
}
|
|
2347
2388
|
// contract pong
|
|
2348
2389
|
const ret_msg = this.safeString(message, 'ret_msg');
|
|
2349
|
-
if (ret_msg === 'pong') {
|
|
2390
|
+
if ((ret_msg === 'pong') || (topic === 'pong')) {
|
|
2350
2391
|
this.handlePong(client, message);
|
|
2351
2392
|
return;
|
|
2352
2393
|
}
|
|
@@ -2358,11 +2399,10 @@ export default class bybit extends bybitRest {
|
|
|
2358
2399
|
}
|
|
2359
2400
|
// pong
|
|
2360
2401
|
const event = this.safeString(message, 'event');
|
|
2361
|
-
if (event === 'sub') {
|
|
2402
|
+
if (event === 'sub' || (topic === 'subscribe')) {
|
|
2362
2403
|
this.handleSubscriptionStatus(client, message);
|
|
2363
2404
|
return;
|
|
2364
2405
|
}
|
|
2365
|
-
const topic = this.safeString2(message, 'topic', 'op', '');
|
|
2366
2406
|
const methods = {
|
|
2367
2407
|
'orderbook': this.handleOrderBook,
|
|
2368
2408
|
'kline': this.handleOHLCV,
|
|
@@ -2375,6 +2415,7 @@ export default class bybit extends bybitRest {
|
|
|
2375
2415
|
'wallet': this.handleBalance,
|
|
2376
2416
|
'outboundAccountInfo': this.handleBalance,
|
|
2377
2417
|
'execution': this.handleMyTrades,
|
|
2418
|
+
'execution.fast': this.handleMyTrades,
|
|
2378
2419
|
'ticketInfo': this.handleMyTrades,
|
|
2379
2420
|
'user.openapi.perp.trade': this.handleMyTrades,
|
|
2380
2421
|
'position': this.handlePositions,
|
|
@@ -2424,6 +2465,14 @@ export default class bybit extends bybitRest {
|
|
|
2424
2465
|
//
|
|
2425
2466
|
// { pong: 1653296711335 }
|
|
2426
2467
|
//
|
|
2468
|
+
//
|
|
2469
|
+
// {
|
|
2470
|
+
// "req_id": "2",
|
|
2471
|
+
// "op": "pong",
|
|
2472
|
+
// "args": [ "1757405570352" ],
|
|
2473
|
+
// "conn_id": "d266o6hqo29sqmnq4vk0-1yus1"
|
|
2474
|
+
// }
|
|
2475
|
+
//
|
|
2427
2476
|
client.lastPong = this.safeInteger(message, 'pong');
|
|
2428
2477
|
return message;
|
|
2429
2478
|
}
|
|
@@ -2443,6 +2492,13 @@ export default class bybit extends bybitRest {
|
|
|
2443
2492
|
// "connId":"cojifin88smerbj9t560-404"
|
|
2444
2493
|
// }
|
|
2445
2494
|
//
|
|
2495
|
+
// {
|
|
2496
|
+
// "success": true,
|
|
2497
|
+
// "ret_msg": "",
|
|
2498
|
+
// "op": "auth",
|
|
2499
|
+
// "conn_id": "d266o6hqo29sqmnq4vk0-1yus1"
|
|
2500
|
+
// }
|
|
2501
|
+
//
|
|
2446
2502
|
const success = this.safeValue(message, 'success');
|
|
2447
2503
|
const code = this.safeInteger(message, 'retCode');
|
|
2448
2504
|
const messageHash = 'authenticated';
|
|
@@ -2508,7 +2564,7 @@ export default class bybit extends bybitRest {
|
|
|
2508
2564
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
2509
2565
|
const unsubHash = messageHashes[j];
|
|
2510
2566
|
const subHash = subMessageHashes[j];
|
|
2511
|
-
const usePrefix = (subHash === 'orders') || (subHash === 'myTrades');
|
|
2567
|
+
const usePrefix = (subHash === 'orders') || (subHash === 'myTrades') || (subHash === 'positions');
|
|
2512
2568
|
this.cleanUnsubscription(client, subHash, unsubHash, usePrefix);
|
|
2513
2569
|
}
|
|
2514
2570
|
this.cleanCache(subscription);
|
package/js/src/pro/coinex.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import coinexRest from '../coinex.js';
|
|
9
|
-
import { AuthenticationError, BadRequest, RateLimitExceeded, NotSupported, RequestTimeout, ExchangeError, ExchangeNotAvailable } from '../base/errors.js';
|
|
9
|
+
import { AuthenticationError, BadRequest, RateLimitExceeded, NotSupported, RequestTimeout, ExchangeError, ExchangeNotAvailable, ArgumentsRequired } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -756,7 +756,6 @@ export default class coinex extends coinexRest {
|
|
|
756
756
|
let type = undefined;
|
|
757
757
|
let callerMethodName = undefined;
|
|
758
758
|
[callerMethodName, params] = this.handleParamString(params, 'callerMethodName', 'watchOrderBookForSymbols');
|
|
759
|
-
[type, params] = this.handleMarketTypeAndParams(callerMethodName, undefined, params);
|
|
760
759
|
const options = this.safeDict(this.options, 'watchOrderBook', {});
|
|
761
760
|
const limits = this.safeList(options, 'limits', []);
|
|
762
761
|
if (limit === undefined) {
|
|
@@ -773,17 +772,16 @@ export default class coinex extends coinexRest {
|
|
|
773
772
|
}
|
|
774
773
|
params = this.omit(params, 'aggregation');
|
|
775
774
|
const symbolsDefined = (symbols !== undefined);
|
|
776
|
-
if (symbolsDefined) {
|
|
777
|
-
|
|
778
|
-
const symbol = symbols[i];
|
|
779
|
-
market = this.market(symbol);
|
|
780
|
-
messageHashes.push('orderbook:' + market['symbol']);
|
|
781
|
-
watchOrderBookSubscriptions[symbol] = [market['id'], limit, aggregation, true];
|
|
782
|
-
}
|
|
775
|
+
if (!symbolsDefined) {
|
|
776
|
+
throw new ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a symbol argument');
|
|
783
777
|
}
|
|
784
|
-
|
|
785
|
-
|
|
778
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
779
|
+
const symbol = symbols[i];
|
|
780
|
+
market = this.market(symbol);
|
|
781
|
+
messageHashes.push('orderbook:' + market['symbol']);
|
|
782
|
+
watchOrderBookSubscriptions[symbol] = [market['id'], limit, aggregation, true];
|
|
786
783
|
}
|
|
784
|
+
[type, params] = this.handleMarketTypeAndParams(callerMethodName, market, params);
|
|
787
785
|
const marketList = Object.values(watchOrderBookSubscriptions);
|
|
788
786
|
const subscribe = {
|
|
789
787
|
'method': 'depth.subscribe',
|
|
@@ -850,7 +848,8 @@ export default class coinex extends coinexRest {
|
|
|
850
848
|
// "id": null
|
|
851
849
|
// }
|
|
852
850
|
//
|
|
853
|
-
const
|
|
851
|
+
const isSpot = client.url.indexOf('spot') > -1;
|
|
852
|
+
const defaultType = isSpot ? 'spot' : 'swap';
|
|
854
853
|
const data = this.safeDict(message, 'data', {});
|
|
855
854
|
const depth = this.safeDict(data, 'depth', {});
|
|
856
855
|
const marketId = this.safeString(data, 'market');
|
package/js/src/pro/kucoin.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export default class kucoin extends kucoinRest {
|
|
|
7
7
|
negotiateHelper(privateChannel: any, params?: {}): Promise<string>;
|
|
8
8
|
requestId(): any;
|
|
9
9
|
subscribe(url: any, messageHash: any, subscriptionHash: any, params?: {}, subscription?: any): Promise<any>;
|
|
10
|
+
unSubscribe(url: any, messageHash: any, topic: any, subscriptionHash: any, params?: {}, subscription?: Dict): Promise<any>;
|
|
10
11
|
subscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, params?: {}, subscription?: any): Promise<any>;
|
|
11
12
|
unSubscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, params?: {}, subscription?: Dict): Promise<any>;
|
|
12
13
|
/**
|
|
@@ -19,6 +20,16 @@ export default class kucoin extends kucoinRest {
|
|
|
19
20
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
20
21
|
*/
|
|
21
22
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
23
|
+
/**
|
|
24
|
+
* @method
|
|
25
|
+
* @name kucoin#unWatchTicker
|
|
26
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
27
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/market-snapshot
|
|
28
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
29
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
30
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
31
|
+
*/
|
|
32
|
+
unWatchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
22
33
|
/**
|
|
23
34
|
* @method
|
|
24
35
|
* @name kucoin#watchTickers
|
|
@@ -57,6 +68,17 @@ export default class kucoin extends kucoinRest {
|
|
|
57
68
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
58
69
|
*/
|
|
59
70
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
71
|
+
/**
|
|
72
|
+
* @method
|
|
73
|
+
* @name kucoin#unWatchOHLCV
|
|
74
|
+
* @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
75
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/klines
|
|
76
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
77
|
+
* @param {string} timeframe the length of time each candle represents
|
|
78
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
79
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
80
|
+
*/
|
|
81
|
+
unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<OHLCV[]>;
|
|
60
82
|
handleOHLCV(client: Client, message: any): void;
|
|
61
83
|
/**
|
|
62
84
|
* @method
|
package/js/src/pro/kucoin.js
CHANGED
|
@@ -32,6 +32,11 @@ export default class kucoin extends kucoinRest {
|
|
|
32
32
|
'watchOrderBookForSymbols': true,
|
|
33
33
|
'watchBalance': true,
|
|
34
34
|
'watchOHLCV': true,
|
|
35
|
+
'unWatchTicker': true,
|
|
36
|
+
'unWatchOHLCV': true,
|
|
37
|
+
'unWatchOrderBook': true,
|
|
38
|
+
'unWatchTrades': true,
|
|
39
|
+
'unWatchhTradesForSymbols': true,
|
|
35
40
|
},
|
|
36
41
|
'options': {
|
|
37
42
|
'tradesLimit': 1000,
|
|
@@ -139,6 +144,9 @@ export default class kucoin extends kucoinRest {
|
|
|
139
144
|
}
|
|
140
145
|
return await this.watch(url, messageHash, message, subscriptionHash, subscription);
|
|
141
146
|
}
|
|
147
|
+
async unSubscribe(url, messageHash, topic, subscriptionHash, params = {}, subscription = undefined) {
|
|
148
|
+
return await this.unSubscribeMultiple(url, [messageHash], topic, [subscriptionHash], params, subscription);
|
|
149
|
+
}
|
|
142
150
|
async subscribeMultiple(url, messageHashes, topic, subscriptionHashes, params = {}, subscription = undefined) {
|
|
143
151
|
const requestId = this.requestId().toString();
|
|
144
152
|
const request = {
|
|
@@ -197,6 +205,34 @@ export default class kucoin extends kucoinRest {
|
|
|
197
205
|
const messageHash = 'ticker:' + symbol;
|
|
198
206
|
return await this.subscribe(url, messageHash, topic, query);
|
|
199
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* @method
|
|
210
|
+
* @name kucoin#unWatchTicker
|
|
211
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
212
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/market-snapshot
|
|
213
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
214
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
215
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
216
|
+
*/
|
|
217
|
+
async unWatchTicker(symbol, params = {}) {
|
|
218
|
+
await this.loadMarkets();
|
|
219
|
+
const market = this.market(symbol);
|
|
220
|
+
symbol = market['symbol'];
|
|
221
|
+
const url = await this.negotiate(false);
|
|
222
|
+
let method = undefined;
|
|
223
|
+
[method, params] = this.handleOptionAndParams(params, 'watchTicker', 'method', '/market/snapshot');
|
|
224
|
+
const topic = method + ':' + market['id'];
|
|
225
|
+
const messageHash = 'unsubscribe:ticker:' + symbol;
|
|
226
|
+
const subMessageHash = 'ticker:' + symbol;
|
|
227
|
+
const subscription = {
|
|
228
|
+
'messageHashes': [messageHash],
|
|
229
|
+
'subMessageHashes': [subMessageHash],
|
|
230
|
+
'topic': 'trades',
|
|
231
|
+
'unsubscribe': true,
|
|
232
|
+
'symbols': [symbol],
|
|
233
|
+
};
|
|
234
|
+
return await this.unSubscribe(url, messageHash, topic, subMessageHash, params, subscription);
|
|
235
|
+
}
|
|
200
236
|
/**
|
|
201
237
|
* @method
|
|
202
238
|
* @name kucoin#watchTickers
|
|
@@ -437,6 +473,34 @@ export default class kucoin extends kucoinRest {
|
|
|
437
473
|
}
|
|
438
474
|
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
439
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* @method
|
|
478
|
+
* @name kucoin#unWatchOHLCV
|
|
479
|
+
* @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
480
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/klines
|
|
481
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
482
|
+
* @param {string} timeframe the length of time each candle represents
|
|
483
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
484
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
485
|
+
*/
|
|
486
|
+
async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
|
|
487
|
+
await this.loadMarkets();
|
|
488
|
+
const url = await this.negotiate(false);
|
|
489
|
+
const market = this.market(symbol);
|
|
490
|
+
symbol = market['symbol'];
|
|
491
|
+
const period = this.safeString(this.timeframes, timeframe, timeframe);
|
|
492
|
+
const topic = '/market/candles:' + market['id'] + '_' + period;
|
|
493
|
+
const messageHash = 'unsubscribe:candles:' + symbol + ':' + timeframe;
|
|
494
|
+
const subMessageHash = 'candles:' + symbol + ':' + timeframe;
|
|
495
|
+
const subscription = {
|
|
496
|
+
'messageHashes': [messageHash],
|
|
497
|
+
'subMessageHashes': [subMessageHash],
|
|
498
|
+
'topic': 'ohlcv',
|
|
499
|
+
'unsubscribe': true,
|
|
500
|
+
'symbols': [symbol],
|
|
501
|
+
};
|
|
502
|
+
return await this.unSubscribe(url, messageHash, topic, messageHash, params, subscription);
|
|
503
|
+
}
|
|
440
504
|
handleOHLCV(client, message) {
|
|
441
505
|
//
|
|
442
506
|
// {
|
package/js/src/pro/mexc.js
CHANGED
|
@@ -177,7 +177,7 @@ export default class mexc extends mexcRest {
|
|
|
177
177
|
this.handleBidAsk(client, message);
|
|
178
178
|
const rawTicker = this.safeDictN(message, ['d', 'data', 'publicAggreBookTicker']);
|
|
179
179
|
const marketId = this.safeString2(message, 's', 'symbol');
|
|
180
|
-
const timestamp = this.safeInteger2(message, 't', '
|
|
180
|
+
const timestamp = this.safeInteger2(message, 't', 'sendTime');
|
|
181
181
|
const market = this.safeMarket(marketId);
|
|
182
182
|
const symbol = market['symbol'];
|
|
183
183
|
let ticker = undefined;
|
|
@@ -1533,7 +1533,7 @@ export default class mexc extends mexcRest {
|
|
|
1533
1533
|
// "ts": 1680059188190
|
|
1534
1534
|
// }
|
|
1535
1535
|
//
|
|
1536
|
-
const c = this.
|
|
1536
|
+
const c = this.safeString(message, 'c'); // do not add 'channel' here, this is especially for spot
|
|
1537
1537
|
const type = (c === undefined) ? 'swap' : 'spot';
|
|
1538
1538
|
const messageHash = 'balance:' + type;
|
|
1539
1539
|
const data = this.safeDictN(message, ['d', 'data', 'privateAccount']);
|
|
@@ -1548,7 +1548,11 @@ export default class mexc extends mexcRest {
|
|
|
1548
1548
|
const currencyId = this.safeStringN(data, ['a', 'currency', 'vcoinName']);
|
|
1549
1549
|
const code = this.safeCurrencyCode(currencyId);
|
|
1550
1550
|
const account = this.account();
|
|
1551
|
-
|
|
1551
|
+
const balanceAmount = this.safeString(data, 'balanceAmount');
|
|
1552
|
+
if (balanceAmount !== undefined) {
|
|
1553
|
+
account['free'] = balanceAmount;
|
|
1554
|
+
}
|
|
1555
|
+
account['total'] = this.safeStringN(data, ['f', 'availableBalance']);
|
|
1552
1556
|
account['used'] = this.safeStringN(data, ['l', 'frozenBalance', 'frozenAmount']);
|
|
1553
1557
|
this.balance[type][code] = account;
|
|
1554
1558
|
this.balance[type] = this.safeBalance(this.balance[type]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccxt",
|
|
3
|
-
"version": "4.5.
|
|
4
|
-
"description": "A JavaScript / TypeScript / Python / C# / PHP
|
|
3
|
+
"version": "4.5.4",
|
|
4
|
+
"description": "A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go",
|
|
5
5
|
"unpkg": "dist/ccxt.browser.min.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"cli.py": "python3 ./examples/py/cli.py",
|
|
69
69
|
"cli.php": "php ./examples/php/cli.php",
|
|
70
70
|
"cli.cs": "dotnet run --project \"./cs/cli/cli.csproj\"",
|
|
71
|
-
"cli.go": "go run ./
|
|
71
|
+
"cli.go": "go run -C go ./cli/main.go",
|
|
72
72
|
"export-exchanges": "node build/export-exchanges",
|
|
73
73
|
"capabilities": "node ./examples/js/exchange-capabilities.js",
|
|
74
74
|
"git-ignore-generated-files": "node build/git-ignore-generated-files.cjs",
|