ccxt 4.5.2 → 4.5.3
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 +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +11 -0
- package/dist/cjs/src/binance.js +5 -11
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/coincatch.js +2 -2
- 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 +8 -8
- package/dist/cjs/src/mexc.js +30 -1
- package/dist/cjs/src/okx.js +17 -3
- 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 +61 -16
- package/dist/cjs/src/pro/bybit.js +3 -3
- 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/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +11 -0
- package/js/src/binance.js +5 -11
- package/js/src/bitget.js +1 -1
- package/js/src/coincatch.js +2 -2
- 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 +8 -8
- 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 +17 -3
- 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 +6 -0
- package/js/src/pro/bitget.js +61 -16
- package/js/src/pro/bybit.d.ts +2 -2
- package/js/src/pro/bybit.js +3 -3
- 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 +1 -1
package/js/src/pro/bitget.js
CHANGED
|
@@ -929,10 +929,12 @@ export default class bitget extends bitgetRest {
|
|
|
929
929
|
* @description get the list of most recent trades for a particular symbol
|
|
930
930
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
931
931
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
932
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
932
933
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
933
934
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
934
935
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
935
936
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
937
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
936
938
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
937
939
|
*/
|
|
938
940
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -944,10 +946,12 @@ export default class bitget extends bitgetRest {
|
|
|
944
946
|
* @description get the list of most recent trades for a particular symbol
|
|
945
947
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
946
948
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
949
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
947
950
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
948
951
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
949
952
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
950
953
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
954
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
951
955
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
952
956
|
*/
|
|
953
957
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
@@ -957,21 +961,28 @@ export default class bitget extends bitgetRest {
|
|
|
957
961
|
}
|
|
958
962
|
await this.loadMarkets();
|
|
959
963
|
symbols = this.marketSymbols(symbols);
|
|
964
|
+
let uta = undefined;
|
|
965
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'uta', false);
|
|
960
966
|
const topics = [];
|
|
961
967
|
const messageHashes = [];
|
|
962
968
|
for (let i = 0; i < symbols.length; i++) {
|
|
963
969
|
const symbol = symbols[i];
|
|
964
970
|
const market = this.market(symbol);
|
|
965
971
|
let instType = undefined;
|
|
966
|
-
[instType, params] = this.getInstType(market,
|
|
972
|
+
[instType, params] = this.getInstType(market, uta, params);
|
|
967
973
|
const args = {
|
|
968
974
|
'instType': instType,
|
|
969
|
-
'channel': 'trade',
|
|
970
|
-
'instId': market['id'],
|
|
971
975
|
};
|
|
976
|
+
const topicOrChannel = uta ? 'topic' : 'channel';
|
|
977
|
+
const symbolOrInstId = uta ? 'symbol' : 'instId';
|
|
978
|
+
args[topicOrChannel] = uta ? 'publicTrade' : 'trade';
|
|
979
|
+
args[symbolOrInstId] = market['id'];
|
|
972
980
|
topics.push(args);
|
|
973
981
|
messageHashes.push('trade:' + symbol);
|
|
974
982
|
}
|
|
983
|
+
if (uta) {
|
|
984
|
+
params['uta'] = true;
|
|
985
|
+
}
|
|
975
986
|
const trades = await this.watchPublicMultiple(messageHashes, topics, params);
|
|
976
987
|
if (this.newUpdates) {
|
|
977
988
|
const first = this.safeValue(trades, 0);
|
|
@@ -992,13 +1003,17 @@ export default class bitget extends bitgetRest {
|
|
|
992
1003
|
* @description unsubscribe from the trades channel
|
|
993
1004
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
994
1005
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
1006
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
995
1007
|
* @param {string} symbol unified symbol of the market to unwatch the trades for
|
|
996
1008
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1009
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
997
1010
|
* @returns {any} status of the unwatch request
|
|
998
1011
|
*/
|
|
999
1012
|
async unWatchTrades(symbol, params = {}) {
|
|
1000
|
-
|
|
1001
|
-
|
|
1013
|
+
let uta = undefined;
|
|
1014
|
+
[uta, params] = this.handleOptionAndParams(params, 'unWatchTrades', 'uta', false);
|
|
1015
|
+
const channelTopic = uta ? 'publicTrade' : 'trade';
|
|
1016
|
+
return await this.unWatchChannel(symbol, channelTopic, 'trade', params);
|
|
1002
1017
|
}
|
|
1003
1018
|
handleTrades(client, message) {
|
|
1004
1019
|
//
|
|
@@ -1017,10 +1032,28 @@ export default class bitget extends bitgetRest {
|
|
|
1017
1032
|
// "ts": 1701910980730
|
|
1018
1033
|
// }
|
|
1019
1034
|
//
|
|
1035
|
+
// uta
|
|
1036
|
+
//
|
|
1037
|
+
// {
|
|
1038
|
+
// "action": "snapshot",
|
|
1039
|
+
// "arg": { "instType": "spot", "topic": "publicTrade", "symbol": "BTCUSDT" },
|
|
1040
|
+
// "data": [
|
|
1041
|
+
// {
|
|
1042
|
+
// "T": "1756287827920",
|
|
1043
|
+
// "P": "110878.5",
|
|
1044
|
+
// "v": "0.07",
|
|
1045
|
+
// "S": "buy",
|
|
1046
|
+
// "L": "1344534089797185550"
|
|
1047
|
+
// "i": "1344534089797185549"
|
|
1048
|
+
// },
|
|
1049
|
+
// ],
|
|
1050
|
+
// "ts": 1701910980730
|
|
1051
|
+
// }
|
|
1052
|
+
//
|
|
1020
1053
|
const arg = this.safeValue(message, 'arg', {});
|
|
1021
|
-
const instType = this.
|
|
1022
|
-
const marketType = (instType === '
|
|
1023
|
-
const marketId = this.
|
|
1054
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
1055
|
+
const marketType = (instType === 'spot') ? 'spot' : 'contract';
|
|
1056
|
+
const marketId = this.safeString2(arg, 'instId', 'symbol');
|
|
1024
1057
|
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
1025
1058
|
const symbol = market['symbol'];
|
|
1026
1059
|
let stored = this.safeValue(this.trades, symbol);
|
|
@@ -1099,13 +1132,24 @@ export default class bitget extends bitgetRest {
|
|
|
1099
1132
|
// "uTime": "1714471204194"
|
|
1100
1133
|
// }
|
|
1101
1134
|
//
|
|
1135
|
+
// uta
|
|
1136
|
+
//
|
|
1137
|
+
// {
|
|
1138
|
+
// "i": "1344534089797185549", // Fill execution ID
|
|
1139
|
+
// "L": "1344534089797185550", // Execution correlation ID
|
|
1140
|
+
// "p": "110878.5", // Fill price
|
|
1141
|
+
// "v": "0.07", // Fill size
|
|
1142
|
+
// "S": "buy", // Fill side
|
|
1143
|
+
// "T": "1756287827920" // Fill timestamp
|
|
1144
|
+
// }
|
|
1145
|
+
//
|
|
1102
1146
|
const instId = this.safeString2(trade, 'symbol', 'instId');
|
|
1103
1147
|
const posMode = this.safeString(trade, 'posMode');
|
|
1104
1148
|
const defaultType = (posMode !== undefined) ? 'contract' : 'spot';
|
|
1105
1149
|
if (market === undefined) {
|
|
1106
1150
|
market = this.safeMarket(instId, undefined, undefined, defaultType);
|
|
1107
1151
|
}
|
|
1108
|
-
const timestamp = this.safeIntegerN(trade, ['uTime', 'cTime', 'ts']);
|
|
1152
|
+
const timestamp = this.safeIntegerN(trade, ['uTime', 'cTime', 'ts', 'T']);
|
|
1109
1153
|
const feeDetail = this.safeList(trade, 'feeDetail', []);
|
|
1110
1154
|
const first = this.safeDict(feeDetail, 0);
|
|
1111
1155
|
let fee = undefined;
|
|
@@ -1119,16 +1163,16 @@ export default class bitget extends bitgetRest {
|
|
|
1119
1163
|
}
|
|
1120
1164
|
return this.safeTrade({
|
|
1121
1165
|
'info': trade,
|
|
1122
|
-
'id': this.
|
|
1123
|
-
'order': this.
|
|
1166
|
+
'id': this.safeString2(trade, 'tradeId', 'i'),
|
|
1167
|
+
'order': this.safeString2(trade, 'orderId', 'L'),
|
|
1124
1168
|
'timestamp': timestamp,
|
|
1125
1169
|
'datetime': this.iso8601(timestamp),
|
|
1126
1170
|
'symbol': market['symbol'],
|
|
1127
1171
|
'type': this.safeString(trade, 'orderType'),
|
|
1128
|
-
'side': this.
|
|
1172
|
+
'side': this.safeString2(trade, 'side', 'S'),
|
|
1129
1173
|
'takerOrMaker': this.safeString(trade, 'tradeScope'),
|
|
1130
|
-
'price': this.
|
|
1131
|
-
'amount': this.
|
|
1174
|
+
'price': this.safeStringN(trade, ['priceAvg', 'price', 'P']),
|
|
1175
|
+
'amount': this.safeStringN(trade, ['size', 'baseVolume', 'v']),
|
|
1132
1176
|
'cost': this.safeString2(trade, 'amount', 'quoteVolume'),
|
|
1133
1177
|
'fee': fee,
|
|
1134
1178
|
}, market);
|
|
@@ -2260,6 +2304,7 @@ export default class bitget extends bitgetRest {
|
|
|
2260
2304
|
const methods = {
|
|
2261
2305
|
'ticker': this.handleTicker,
|
|
2262
2306
|
'trade': this.handleTrades,
|
|
2307
|
+
'publicTrade': this.handleTrades,
|
|
2263
2308
|
'fill': this.handleMyTrades,
|
|
2264
2309
|
'orders': this.handleOrder,
|
|
2265
2310
|
'ordersAlgo': this.handleOrder,
|
|
@@ -2333,7 +2378,7 @@ export default class bitget extends bitgetRest {
|
|
|
2333
2378
|
const arg = this.safeDict(message, 'arg', {});
|
|
2334
2379
|
const instType = this.safeStringLower(arg, 'instType');
|
|
2335
2380
|
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
2336
|
-
const instId = this.
|
|
2381
|
+
const instId = this.safeString2(arg, 'instId', 'symbol');
|
|
2337
2382
|
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
2338
2383
|
const symbol = market['symbol'];
|
|
2339
2384
|
const messageHash = 'unsubscribe:trade:' + market['symbol'];
|
|
@@ -2450,7 +2495,7 @@ export default class bitget extends bitgetRest {
|
|
|
2450
2495
|
// for now only unWatchOrderBook is supporteod
|
|
2451
2496
|
this.handleOrderBookUnSubscription(client, message);
|
|
2452
2497
|
}
|
|
2453
|
-
else if (channel === 'trade') {
|
|
2498
|
+
else if ((channel === 'trade') || (channel === 'publicTrade')) {
|
|
2454
2499
|
this.handleTradesUnSubscription(client, message);
|
|
2455
2500
|
}
|
|
2456
2501
|
else if (channel === 'ticker') {
|
package/js/src/pro/bybit.d.ts
CHANGED
|
@@ -117,11 +117,11 @@ export default class bybit extends bybitRest {
|
|
|
117
117
|
* @description unWatches a price ticker
|
|
118
118
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
|
|
119
119
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
|
|
120
|
-
* @param {string[]}
|
|
120
|
+
* @param {string[]} symbol unified symbol of the market to fetch the ticker for
|
|
121
121
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
122
122
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
123
123
|
*/
|
|
124
|
-
unWatchTicker(
|
|
124
|
+
unWatchTicker(symbol: string, params?: {}): Promise<any>;
|
|
125
125
|
handleTicker(client: Client, message: any): void;
|
|
126
126
|
/**
|
|
127
127
|
* @method
|
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
|
//
|
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