ccxt 4.3.94 → 4.3.96
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 +8 -8
- package/dist/cjs/ccxt.js +1 -7
- package/dist/cjs/src/ascendex.js +8 -6
- package/dist/cjs/src/base/Exchange.js +3 -7
- package/dist/cjs/src/bingx.js +2 -1
- package/dist/cjs/src/bitfinex.js +3 -2
- package/dist/cjs/src/bitfinex2.js +6 -5
- package/dist/cjs/src/blofin.js +0 -1
- package/dist/cjs/src/btcturk.js +2 -2
- package/dist/cjs/src/bybit.js +8 -2
- package/dist/cjs/src/gate.js +3 -2
- package/dist/cjs/src/gemini.js +3 -2
- package/dist/cjs/src/hyperliquid.js +337 -42
- package/dist/cjs/src/independentreserve.js +4 -3
- package/dist/cjs/src/indodax.js +3 -0
- package/dist/cjs/src/kucoin.js +12 -12
- package/dist/cjs/src/mexc.js +78 -154
- package/dist/cjs/src/okx.js +2 -1
- package/dist/cjs/src/p2b.js +0 -1
- package/dist/cjs/src/pro/binance.js +100 -2
- package/dist/cjs/src/pro/bybit.js +65 -4
- package/dist/cjs/src/pro/cryptocom.js +224 -0
- package/dist/cjs/src/pro/okx.js +264 -35
- package/dist/cjs/src/tradeogre.js +0 -1
- package/js/ccxt.d.ts +2 -8
- package/js/ccxt.js +2 -6
- package/js/src/abstract/okx.d.ts +2 -0
- package/js/src/ascendex.js +8 -6
- package/js/src/base/Exchange.d.ts +1 -3
- package/js/src/base/Exchange.js +3 -7
- package/js/src/bingx.js +2 -1
- package/js/src/bitfinex.js +3 -2
- package/js/src/bitfinex2.js +6 -5
- package/js/src/blofin.js +0 -1
- package/js/src/btcturk.d.ts +2 -2
- package/js/src/btcturk.js +2 -2
- package/js/src/bybit.js +8 -2
- package/js/src/gate.js +3 -2
- package/js/src/gemini.js +3 -2
- package/js/src/hyperliquid.d.ts +25 -0
- package/js/src/hyperliquid.js +337 -42
- package/js/src/independentreserve.js +4 -3
- package/js/src/indodax.js +3 -0
- package/js/src/kucoin.d.ts +1 -1
- package/js/src/kucoin.js +12 -12
- package/js/src/mexc.js +78 -154
- package/js/src/okx.js +2 -1
- package/js/src/p2b.js +0 -1
- package/js/src/pro/binance.d.ts +2 -0
- package/js/src/pro/binance.js +100 -2
- package/js/src/pro/bybit.d.ts +3 -1
- package/js/src/pro/bybit.js +65 -4
- package/js/src/pro/cryptocom.d.ts +10 -1
- package/js/src/pro/cryptocom.js +225 -1
- package/js/src/pro/okx.d.ts +10 -1
- package/js/src/pro/okx.js +264 -35
- package/js/src/tradeogre.js +0 -1
- package/package.json +1 -1
- package/js/src/abstract/bitbay.d.ts +0 -56
- package/js/src/abstract/bitbay.js +0 -11
- package/js/src/abstract/hitbtc3.d.ts +0 -118
- package/js/src/abstract/hitbtc3.js +0 -11
|
@@ -80,6 +80,20 @@ class cryptocom extends cryptocom$1 {
|
|
|
80
80
|
*/
|
|
81
81
|
return await this.watchOrderBookForSymbols([symbol], limit, params);
|
|
82
82
|
}
|
|
83
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
84
|
+
/**
|
|
85
|
+
* @method
|
|
86
|
+
* @name cryptocom#unWatchOrderBook
|
|
87
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
88
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#book-instrument_name
|
|
89
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
90
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
91
|
+
* @param {string} [params.bookSubscriptionType] The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
|
|
92
|
+
* @param {int} [params.bookUpdateFrequency] Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
|
|
93
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
94
|
+
*/
|
|
95
|
+
return await this.unWatchOrderBookForSymbols([symbol], params);
|
|
96
|
+
}
|
|
83
97
|
async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
|
|
84
98
|
/**
|
|
85
99
|
* @method
|
|
@@ -127,6 +141,52 @@ class cryptocom extends cryptocom$1 {
|
|
|
127
141
|
const orderbook = await this.watchPublicMultiple(messageHashes, topics, params);
|
|
128
142
|
return orderbook.limit();
|
|
129
143
|
}
|
|
144
|
+
async unWatchOrderBookForSymbols(symbols, params = {}) {
|
|
145
|
+
/**
|
|
146
|
+
* @method
|
|
147
|
+
* @name cryptocom#unWatchOrderBookForSymbols
|
|
148
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
149
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#book-instrument_name
|
|
150
|
+
* @param {string[]} symbols unified array of symbols
|
|
151
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
152
|
+
* @param {int} [params.limit] orderbook limit, default is 50
|
|
153
|
+
* @param {string} [params.bookSubscriptionType] The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
|
|
154
|
+
* @param {int} [params.bookUpdateFrequency] Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
|
|
155
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
156
|
+
*/
|
|
157
|
+
await this.loadMarkets();
|
|
158
|
+
symbols = this.marketSymbols(symbols);
|
|
159
|
+
const topics = [];
|
|
160
|
+
const subMessageHashes = [];
|
|
161
|
+
const messageHashes = [];
|
|
162
|
+
const limit = this.safeInteger(params, 'limit', 50);
|
|
163
|
+
const topicParams = this.safeValue(params, 'params');
|
|
164
|
+
if (topicParams === undefined) {
|
|
165
|
+
params['params'] = {};
|
|
166
|
+
}
|
|
167
|
+
let bookSubscriptionType = undefined;
|
|
168
|
+
let bookSubscriptionType2 = undefined;
|
|
169
|
+
[bookSubscriptionType, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'bookSubscriptionType', 'SNAPSHOT_AND_UPDATE');
|
|
170
|
+
[bookSubscriptionType2, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'bookSubscriptionType', bookSubscriptionType);
|
|
171
|
+
params['params']['bookSubscriptionType'] = bookSubscriptionType2;
|
|
172
|
+
let bookUpdateFrequency = undefined;
|
|
173
|
+
let bookUpdateFrequency2 = undefined;
|
|
174
|
+
[bookUpdateFrequency, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'bookUpdateFrequency');
|
|
175
|
+
[bookUpdateFrequency2, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'bookUpdateFrequency', bookUpdateFrequency);
|
|
176
|
+
if (bookUpdateFrequency2 !== undefined) {
|
|
177
|
+
params['params']['bookSubscriptionType'] = bookUpdateFrequency2;
|
|
178
|
+
}
|
|
179
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
180
|
+
const symbol = symbols[i];
|
|
181
|
+
const market = this.market(symbol);
|
|
182
|
+
const currentTopic = 'book' + '.' + market['id'] + '.' + limit.toString();
|
|
183
|
+
const messageHash = 'orderbook:' + market['symbol'];
|
|
184
|
+
subMessageHashes.push(messageHash);
|
|
185
|
+
messageHashes.push('unsubscribe:' + messageHash);
|
|
186
|
+
topics.push(currentTopic);
|
|
187
|
+
}
|
|
188
|
+
return await this.unWatchPublicMultiple('orderbook', symbols, messageHashes, subMessageHashes, topics, params);
|
|
189
|
+
}
|
|
130
190
|
handleDelta(bookside, delta) {
|
|
131
191
|
const price = this.safeFloat(delta, 0);
|
|
132
192
|
const amount = this.safeFloat(delta, 1);
|
|
@@ -247,6 +307,20 @@ class cryptocom extends cryptocom$1 {
|
|
|
247
307
|
*/
|
|
248
308
|
return await this.watchTradesForSymbols([symbol], since, limit, params);
|
|
249
309
|
}
|
|
310
|
+
async unWatchTrades(symbol, params = {}) {
|
|
311
|
+
/**
|
|
312
|
+
* @method
|
|
313
|
+
* @name cryptocom#unWatchTrades
|
|
314
|
+
* @description get the list of most recent trades for a particular symbol
|
|
315
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#trade-instrument_name
|
|
316
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
317
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
318
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
319
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
320
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
321
|
+
*/
|
|
322
|
+
return await this.unWatchTradesForSymbols([symbol], params);
|
|
323
|
+
}
|
|
250
324
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
251
325
|
/**
|
|
252
326
|
* @method
|
|
@@ -276,6 +350,29 @@ class cryptocom extends cryptocom$1 {
|
|
|
276
350
|
}
|
|
277
351
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
278
352
|
}
|
|
353
|
+
async unWatchTradesForSymbols(symbols, params = {}) {
|
|
354
|
+
/**
|
|
355
|
+
* @method
|
|
356
|
+
* @name cryptocom#unWatchTradesForSymbols
|
|
357
|
+
* @description get the list of most recent trades for a particular symbol
|
|
358
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#trade-instrument_name
|
|
359
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
360
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
361
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
362
|
+
*/
|
|
363
|
+
await this.loadMarkets();
|
|
364
|
+
symbols = this.marketSymbols(symbols);
|
|
365
|
+
const topics = [];
|
|
366
|
+
const messageHashes = [];
|
|
367
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
368
|
+
const symbol = symbols[i];
|
|
369
|
+
const market = this.market(symbol);
|
|
370
|
+
const currentTopic = 'trade' + '.' + market['id'];
|
|
371
|
+
messageHashes.push('unsubscribe:trades:' + market['symbol']);
|
|
372
|
+
topics.push(currentTopic);
|
|
373
|
+
}
|
|
374
|
+
return await this.unWatchPublicMultiple('trade', symbols, messageHashes, topics, topics, params);
|
|
375
|
+
}
|
|
279
376
|
handleTrades(client, message) {
|
|
280
377
|
//
|
|
281
378
|
// {
|
|
@@ -364,6 +461,22 @@ class cryptocom extends cryptocom$1 {
|
|
|
364
461
|
const messageHash = 'ticker' + '.' + market['id'];
|
|
365
462
|
return await this.watchPublic(messageHash, params);
|
|
366
463
|
}
|
|
464
|
+
async unWatchTicker(symbol, params = {}) {
|
|
465
|
+
/**
|
|
466
|
+
* @method
|
|
467
|
+
* @name cryptocom#unWatchTicker
|
|
468
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
469
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
|
|
470
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
471
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
472
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
473
|
+
*/
|
|
474
|
+
await this.loadMarkets();
|
|
475
|
+
const market = this.market(symbol);
|
|
476
|
+
const subMessageHash = 'ticker' + '.' + market['id'];
|
|
477
|
+
const messageHash = 'unsubscribe:ticker:' + market['symbol'];
|
|
478
|
+
return await this.unWatchPublicMultiple('ticker', [market['symbol']], [messageHash], [subMessageHash], [subMessageHash], params);
|
|
479
|
+
}
|
|
367
480
|
handleTicker(client, message) {
|
|
368
481
|
//
|
|
369
482
|
// {
|
|
@@ -423,6 +536,28 @@ class cryptocom extends cryptocom$1 {
|
|
|
423
536
|
}
|
|
424
537
|
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
425
538
|
}
|
|
539
|
+
async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
|
|
540
|
+
/**
|
|
541
|
+
* @method
|
|
542
|
+
* @name cryptocom#unWatchOHLCV
|
|
543
|
+
* @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
544
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#candlestick-time_frame-instrument_name
|
|
545
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
546
|
+
* @param {string} timeframe the length of time each candle represents
|
|
547
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
548
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
549
|
+
*/
|
|
550
|
+
await this.loadMarkets();
|
|
551
|
+
const market = this.market(symbol);
|
|
552
|
+
symbol = market['symbol'];
|
|
553
|
+
const interval = this.safeString(this.timeframes, timeframe, timeframe);
|
|
554
|
+
const subMessageHash = 'candlestick' + '.' + interval + '.' + market['id'];
|
|
555
|
+
const messageHash = 'unsubscribe:ohlcv:' + market['symbol'] + ':' + timeframe;
|
|
556
|
+
const subExtend = {
|
|
557
|
+
'symbolsAndTimeframes': [[market['symbol'], timeframe]],
|
|
558
|
+
};
|
|
559
|
+
return await this.unWatchPublicMultiple('ohlcv', [market['symbol']], [messageHash], [subMessageHash], [subMessageHash], params, subExtend);
|
|
560
|
+
}
|
|
426
561
|
handleOHLCV(client, message) {
|
|
427
562
|
//
|
|
428
563
|
// {
|
|
@@ -853,6 +988,27 @@ class cryptocom extends cryptocom$1 {
|
|
|
853
988
|
const message = this.deepExtend(request, params);
|
|
854
989
|
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
855
990
|
}
|
|
991
|
+
async unWatchPublicMultiple(topic, symbols, messageHashes, subMessageHashes, topics, params = {}, subExtend = {}) {
|
|
992
|
+
const url = this.urls['api']['ws']['public'];
|
|
993
|
+
const id = this.nonce();
|
|
994
|
+
const request = {
|
|
995
|
+
'method': 'unsubscribe',
|
|
996
|
+
'params': {
|
|
997
|
+
'channels': topics,
|
|
998
|
+
},
|
|
999
|
+
'nonce': id,
|
|
1000
|
+
'id': id.toString(),
|
|
1001
|
+
};
|
|
1002
|
+
const subscription = {
|
|
1003
|
+
'id': id.toString(),
|
|
1004
|
+
'topic': topic,
|
|
1005
|
+
'symbols': symbols,
|
|
1006
|
+
'subMessageHashes': subMessageHashes,
|
|
1007
|
+
'messageHashes': messageHashes,
|
|
1008
|
+
};
|
|
1009
|
+
const message = this.deepExtend(request, params);
|
|
1010
|
+
return await this.watchMultiple(url, messageHashes, message, messageHashes, this.extend(subscription, subExtend));
|
|
1011
|
+
}
|
|
856
1012
|
async watchPrivateRequest(nonce, params = {}) {
|
|
857
1013
|
await this.authenticate();
|
|
858
1014
|
const url = this.urls['api']['ws']['private'];
|
|
@@ -972,6 +1128,9 @@ class cryptocom extends cryptocom$1 {
|
|
|
972
1128
|
// "channel":"ticker",
|
|
973
1129
|
// "data":[ { } ]
|
|
974
1130
|
//
|
|
1131
|
+
// handle unsubscribe
|
|
1132
|
+
// {"id":1725448572836,"method":"unsubscribe","code":0}
|
|
1133
|
+
//
|
|
975
1134
|
if (this.handleErrorMessage(client, message)) {
|
|
976
1135
|
return;
|
|
977
1136
|
}
|
|
@@ -985,6 +1144,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
985
1144
|
'private/cancel-all-orders': this.handleCancelAllOrders,
|
|
986
1145
|
'private/close-position': this.handleOrder,
|
|
987
1146
|
'subscribe': this.handleSubscribe,
|
|
1147
|
+
'unsubscribe': this.handleUnsubscribe,
|
|
988
1148
|
};
|
|
989
1149
|
const callMethod = this.safeValue(methods, method);
|
|
990
1150
|
if (callMethod !== undefined) {
|
|
@@ -1025,6 +1185,70 @@ class cryptocom extends cryptocom$1 {
|
|
|
1025
1185
|
const future = this.safeValue(client.futures, 'authenticated');
|
|
1026
1186
|
future.resolve(true);
|
|
1027
1187
|
}
|
|
1188
|
+
handleUnsubscribe(client, message) {
|
|
1189
|
+
const id = this.safeString(message, 'id');
|
|
1190
|
+
const keys = Object.keys(client.subscriptions);
|
|
1191
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1192
|
+
const messageHash = keys[i];
|
|
1193
|
+
if (!(messageHash in client.subscriptions)) {
|
|
1194
|
+
continue;
|
|
1195
|
+
// the previous iteration can have deleted the messageHash from the subscriptions
|
|
1196
|
+
}
|
|
1197
|
+
if (messageHash.startsWith('unsubscribe')) {
|
|
1198
|
+
const subscription = client.subscriptions[messageHash];
|
|
1199
|
+
const subId = this.safeString(subscription, 'id');
|
|
1200
|
+
if (id !== subId) {
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
1204
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
1205
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
1206
|
+
const unsubHash = messageHashes[j];
|
|
1207
|
+
const subHash = subMessageHashes[j];
|
|
1208
|
+
if (unsubHash in client.subscriptions) {
|
|
1209
|
+
delete client.subscriptions[unsubHash];
|
|
1210
|
+
}
|
|
1211
|
+
if (subHash in client.subscriptions) {
|
|
1212
|
+
delete client.subscriptions[subHash];
|
|
1213
|
+
}
|
|
1214
|
+
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
1215
|
+
client.reject(error, subHash);
|
|
1216
|
+
client.resolve(true, unsubHash);
|
|
1217
|
+
}
|
|
1218
|
+
this.cleanCache(subscription);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
cleanCache(subscription) {
|
|
1223
|
+
const topic = this.safeString(subscription, 'topic');
|
|
1224
|
+
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1225
|
+
const symbolsLength = symbols.length;
|
|
1226
|
+
if (topic === 'ohlcv') {
|
|
1227
|
+
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1228
|
+
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1229
|
+
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1230
|
+
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1231
|
+
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1232
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
1233
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
else if (symbolsLength > 0) {
|
|
1238
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
1239
|
+
const symbol = symbols[i];
|
|
1240
|
+
if (topic === 'trade') {
|
|
1241
|
+
delete this.trades[symbol];
|
|
1242
|
+
}
|
|
1243
|
+
else if (topic === 'orderbook') {
|
|
1244
|
+
delete this.orderbooks[symbol];
|
|
1245
|
+
}
|
|
1246
|
+
else if (topic === 'ticker') {
|
|
1247
|
+
delete this.tickers[symbol];
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1028
1252
|
}
|
|
1029
1253
|
|
|
1030
1254
|
module.exports = cryptocom;
|