ccxt 4.3.98 → 4.4.2
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 +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +69 -0
- package/dist/cjs/src/binance.js +78 -8
- package/dist/cjs/src/bitget.js +3 -2
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/currencycom.js +1 -2
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/mexc.js +69 -1
- package/dist/cjs/src/pro/binance.js +3 -63
- package/dist/cjs/src/pro/bitget.js +1 -9
- package/dist/cjs/src/pro/bitmex.js +11 -1
- package/dist/cjs/src/pro/bybit.js +2 -54
- package/dist/cjs/src/pro/cryptocom.js +2 -40
- package/dist/cjs/src/pro/gate.js +1 -9
- package/dist/cjs/src/pro/hyperliquid.js +232 -11
- package/dist/cjs/src/pro/kucoin.js +2 -59
- package/dist/cjs/src/pro/kucoinfutures.js +139 -1
- package/dist/cjs/src/pro/okx.js +8 -36
- package/dist/cjs/src/xt.js +1 -1
- package/examples/js/cli.js +9 -5
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +70 -1
- package/js/src/base/types.d.ts +5 -4
- package/js/src/binance.js +78 -8
- package/js/src/bitget.js +3 -2
- package/js/src/cryptocom.js +1 -1
- package/js/src/currencycom.js +1 -2
- package/js/src/gate.js +1 -0
- package/js/src/htx.js +1 -1
- package/js/src/mexc.js +69 -1
- package/js/src/pro/binance.d.ts +0 -1
- package/js/src/pro/binance.js +4 -64
- package/js/src/pro/bitget.js +1 -9
- package/js/src/pro/bitmex.js +11 -1
- package/js/src/pro/bybit.d.ts +1 -2
- package/js/src/pro/bybit.js +3 -55
- package/js/src/pro/cryptocom.d.ts +1 -2
- package/js/src/pro/cryptocom.js +3 -41
- package/js/src/pro/gate.js +2 -10
- package/js/src/pro/hyperliquid.d.ts +10 -1
- package/js/src/pro/hyperliquid.js +232 -11
- package/js/src/pro/kucoin.d.ts +0 -1
- package/js/src/pro/kucoin.js +3 -60
- package/js/src/pro/kucoinfutures.d.ts +7 -1
- package/js/src/pro/kucoinfutures.js +139 -1
- package/js/src/pro/okx.js +9 -37
- package/js/src/xt.js +1 -1
- package/package.json +1 -1
package/js/src/bitget.js
CHANGED
|
@@ -1311,10 +1311,11 @@ export default class bitget extends Exchange {
|
|
|
1311
1311
|
},
|
|
1312
1312
|
'precisionMode': TICK_SIZE,
|
|
1313
1313
|
'commonCurrencies': {
|
|
1314
|
-
'
|
|
1314
|
+
'APX': 'AstroPepeX',
|
|
1315
1315
|
'DEGEN': 'DegenReborn',
|
|
1316
|
+
'JADE': 'Jade Protocol',
|
|
1317
|
+
'OMNI': 'omni',
|
|
1316
1318
|
'TONCOIN': 'TON',
|
|
1317
|
-
'OMNI': 'omni', // conflict with Omni Network
|
|
1318
1319
|
},
|
|
1319
1320
|
'options': {
|
|
1320
1321
|
'timeframes': {
|
package/js/src/cryptocom.js
CHANGED
|
@@ -141,7 +141,7 @@ export default class cryptocom extends Exchange {
|
|
|
141
141
|
'www': 'https://crypto.com/',
|
|
142
142
|
'referral': {
|
|
143
143
|
'url': 'https://crypto.com/exch/kdacthrnxt',
|
|
144
|
-
'discount': 0.
|
|
144
|
+
'discount': 0.75,
|
|
145
145
|
},
|
|
146
146
|
'doc': [
|
|
147
147
|
'https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html',
|
package/js/src/currencycom.js
CHANGED
|
@@ -1992,7 +1992,7 @@ export default class currencycom extends Exchange {
|
|
|
1992
1992
|
'collateral': undefined,
|
|
1993
1993
|
'side': side,
|
|
1994
1994
|
// 'realizedProfit': this.safeNumber (position, 'rpl'),
|
|
1995
|
-
'
|
|
1995
|
+
'unrealizedPnl': unrealizedProfit,
|
|
1996
1996
|
'leverage': leverage,
|
|
1997
1997
|
'percentage': undefined,
|
|
1998
1998
|
'marginMode': undefined,
|
|
@@ -2006,7 +2006,6 @@ export default class currencycom extends Exchange {
|
|
|
2006
2006
|
'maintenanceMarginPercentage': undefined,
|
|
2007
2007
|
'marginRatio': undefined,
|
|
2008
2008
|
'id': undefined,
|
|
2009
|
-
'unrealizedPnl': undefined,
|
|
2010
2009
|
'hedged': undefined,
|
|
2011
2010
|
'stopLossPrice': undefined,
|
|
2012
2011
|
'takeProfitPrice': undefined,
|
package/js/src/gate.js
CHANGED
package/js/src/htx.js
CHANGED
|
@@ -7645,7 +7645,7 @@ export default class htx extends Exchange {
|
|
|
7645
7645
|
'entryPrice': entryPrice,
|
|
7646
7646
|
'collateral': this.parseNumber(collateral),
|
|
7647
7647
|
'side': side,
|
|
7648
|
-
'
|
|
7648
|
+
'unrealizedPnl': unrealizedProfit,
|
|
7649
7649
|
'leverage': this.parseNumber(leverage),
|
|
7650
7650
|
'percentage': this.parseNumber(percentage),
|
|
7651
7651
|
'marginMode': marginMode,
|
package/js/src/mexc.js
CHANGED
|
@@ -1022,6 +1022,15 @@ export default class mexc extends Exchange {
|
|
|
1022
1022
|
return this.arrayConcat(spotMarket, swapMarket);
|
|
1023
1023
|
}
|
|
1024
1024
|
async fetchSpotMarkets(params = {}) {
|
|
1025
|
+
/**
|
|
1026
|
+
* @ignore
|
|
1027
|
+
* @method
|
|
1028
|
+
* @name mexc#fetchMarkets
|
|
1029
|
+
* @description retrieves data on all spot markets for mexc
|
|
1030
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
|
|
1031
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1032
|
+
* @returns {object[]} an array of objects representing market data
|
|
1033
|
+
*/
|
|
1025
1034
|
const response = await this.spotPublicGetExchangeInfo(params);
|
|
1026
1035
|
//
|
|
1027
1036
|
// {
|
|
@@ -1139,6 +1148,15 @@ export default class mexc extends Exchange {
|
|
|
1139
1148
|
return result;
|
|
1140
1149
|
}
|
|
1141
1150
|
async fetchSwapMarkets(params = {}) {
|
|
1151
|
+
/**
|
|
1152
|
+
* @ignore
|
|
1153
|
+
* @method
|
|
1154
|
+
* @name mexc#fetchMarkets
|
|
1155
|
+
* @description retrieves data on all swap markets for mexc
|
|
1156
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
|
|
1157
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1158
|
+
* @returns {object[]} an array of objects representing market data
|
|
1159
|
+
*/
|
|
1142
1160
|
const response = await this.contractPublicGetDetail(params);
|
|
1143
1161
|
//
|
|
1144
1162
|
// {
|
|
@@ -1730,6 +1748,8 @@ export default class mexc extends Exchange {
|
|
|
1730
1748
|
* @method
|
|
1731
1749
|
* @name mexc#fetchTickers
|
|
1732
1750
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1751
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
1752
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
|
1733
1753
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1734
1754
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1735
1755
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -1818,6 +1838,8 @@ export default class mexc extends Exchange {
|
|
|
1818
1838
|
* @method
|
|
1819
1839
|
* @name mexc#fetchTicker
|
|
1820
1840
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1841
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
1842
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
|
1821
1843
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1822
1844
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1823
1845
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2008,6 +2030,7 @@ export default class mexc extends Exchange {
|
|
|
2008
2030
|
* @method
|
|
2009
2031
|
* @name mexc#fetchBidsAsks
|
|
2010
2032
|
* @description fetches the bid and ask price and volume for multiple markets
|
|
2033
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
|
|
2011
2034
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
2012
2035
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2013
2036
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2153,6 +2176,23 @@ export default class mexc extends Exchange {
|
|
|
2153
2176
|
return this.extend(request, params);
|
|
2154
2177
|
}
|
|
2155
2178
|
async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2179
|
+
/**
|
|
2180
|
+
* @ignore
|
|
2181
|
+
* @method
|
|
2182
|
+
* @name mexc#createSpotOrder
|
|
2183
|
+
* @description create a trade order
|
|
2184
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
2185
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2186
|
+
* @param {string} type 'market' or 'limit'
|
|
2187
|
+
* @param {string} side 'buy' or 'sell'
|
|
2188
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2189
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
2190
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2191
|
+
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2192
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2193
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2194
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2195
|
+
*/
|
|
2156
2196
|
await this.loadMarkets();
|
|
2157
2197
|
const request = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, params);
|
|
2158
2198
|
const response = await this.spotPrivatePostOrder(this.extend(request, params));
|
|
@@ -2183,6 +2223,32 @@ export default class mexc extends Exchange {
|
|
|
2183
2223
|
return order;
|
|
2184
2224
|
}
|
|
2185
2225
|
async createSwapOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2226
|
+
/**
|
|
2227
|
+
* @ignore
|
|
2228
|
+
* @method
|
|
2229
|
+
* @name mexc#createOrder
|
|
2230
|
+
* @description create a trade order
|
|
2231
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
2232
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
|
|
2233
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
|
|
2234
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2235
|
+
* @param {string} type 'market' or 'limit'
|
|
2236
|
+
* @param {string} side 'buy' or 'sell'
|
|
2237
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2238
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
2239
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2240
|
+
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2241
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2242
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2243
|
+
* @param {bool} [params.reduceOnly] indicates if this order is to reduce the size of a position
|
|
2244
|
+
*
|
|
2245
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
2246
|
+
* @param {int} [params.leverage] leverage is necessary on isolated margin
|
|
2247
|
+
* @param {long} [params.positionId] it is recommended to fill in this parameter when closing a position
|
|
2248
|
+
* @param {string} [params.externalOid] external order ID
|
|
2249
|
+
* @param {int} [params.positionMode] 1:hedge, 2:one-way, default: the user's current config
|
|
2250
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2251
|
+
*/
|
|
2186
2252
|
await this.loadMarkets();
|
|
2187
2253
|
const symbol = market['symbol'];
|
|
2188
2254
|
const unavailableContracts = this.safeValue(this.options, 'unavailableContracts', {});
|
|
@@ -2358,6 +2424,8 @@ export default class mexc extends Exchange {
|
|
|
2358
2424
|
* @method
|
|
2359
2425
|
* @name mexc#fetchOrder
|
|
2360
2426
|
* @description fetches information on an order made by the user
|
|
2427
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
|
|
2428
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
|
|
2361
2429
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2362
2430
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2363
2431
|
* @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
|
|
@@ -4816,7 +4884,7 @@ export default class mexc extends Exchange {
|
|
|
4816
4884
|
'entryPrice': entryPrice,
|
|
4817
4885
|
'collateral': undefined,
|
|
4818
4886
|
'side': side,
|
|
4819
|
-
'
|
|
4887
|
+
'unrealizedPnl': undefined,
|
|
4820
4888
|
'leverage': this.parseNumber(leverage),
|
|
4821
4889
|
'percentage': undefined,
|
|
4822
4890
|
'marginMode': marginType,
|
package/js/src/pro/binance.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ export default class binance extends binanceRest {
|
|
|
26
26
|
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
27
27
|
handleSubscriptionStatus(client: Client, message: any): any;
|
|
28
28
|
handleUnSubscription(client: Client, subscription: Dict): void;
|
|
29
|
-
cleanCache(subscription: Dict): void;
|
|
30
29
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
31
30
|
unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
32
31
|
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
package/js/src/pro/binance.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ----------------------------------------------------------------------------
|
|
8
8
|
import binanceRest from '../binance.js';
|
|
9
9
|
import { Precise } from '../base/Precise.js';
|
|
10
|
-
import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported
|
|
10
|
+
import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
|
|
11
11
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
12
12
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
13
13
|
import { rsa } from '../base/functions/rsa.js';
|
|
@@ -1026,70 +1026,10 @@ export default class binance extends binanceRest {
|
|
|
1026
1026
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1027
1027
|
const unsubHash = messageHashes[j];
|
|
1028
1028
|
const subHash = subMessageHashes[j];
|
|
1029
|
-
|
|
1030
|
-
delete client.subscriptions[unsubHash];
|
|
1031
|
-
}
|
|
1032
|
-
if (subHash in client.subscriptions) {
|
|
1033
|
-
delete client.subscriptions[subHash];
|
|
1034
|
-
}
|
|
1035
|
-
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
1036
|
-
client.reject(error, subHash);
|
|
1037
|
-
client.resolve(true, unsubHash);
|
|
1029
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1038
1030
|
}
|
|
1039
1031
|
this.cleanCache(subscription);
|
|
1040
1032
|
}
|
|
1041
|
-
cleanCache(subscription) {
|
|
1042
|
-
const topic = this.safeString(subscription, 'topic');
|
|
1043
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1044
|
-
const symbolsLength = symbols.length;
|
|
1045
|
-
if (topic === 'ohlcv') {
|
|
1046
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1047
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1048
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1049
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1050
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1051
|
-
if (timeframe in this.ohlcvs[symbol]) {
|
|
1052
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
else if (symbolsLength > 0) {
|
|
1057
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
1058
|
-
const symbol = symbols[i];
|
|
1059
|
-
if (topic === 'trade') {
|
|
1060
|
-
delete this.trades[symbol];
|
|
1061
|
-
}
|
|
1062
|
-
else if (topic === 'orderbook') {
|
|
1063
|
-
delete this.orderbooks[symbol];
|
|
1064
|
-
}
|
|
1065
|
-
else if (topic === 'ticker') {
|
|
1066
|
-
delete this.tickers[symbol];
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
else {
|
|
1071
|
-
if (topic === 'myTrades') {
|
|
1072
|
-
// don't reset this.myTrades directly here
|
|
1073
|
-
// because in c# we need to use a different object
|
|
1074
|
-
const keys = Object.keys(this.myTrades);
|
|
1075
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1076
|
-
delete this.myTrades[keys[i]];
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
else if (topic === 'orders') {
|
|
1080
|
-
const orderSymbols = Object.keys(this.orders);
|
|
1081
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
1082
|
-
delete this.orders[orderSymbols[i]];
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
else if (topic === 'ticker') {
|
|
1086
|
-
const tickerSymbols = Object.keys(this.tickers);
|
|
1087
|
-
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
1088
|
-
delete this.tickers[tickerSymbols[i]];
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
1033
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
1094
1034
|
/**
|
|
1095
1035
|
* @method
|
|
@@ -1211,7 +1151,7 @@ export default class binance extends binanceRest {
|
|
|
1211
1151
|
'subMessageHashes': subMessageHashes,
|
|
1212
1152
|
'messageHashes': messageHashes,
|
|
1213
1153
|
'symbols': symbols,
|
|
1214
|
-
'topic': '
|
|
1154
|
+
'topic': 'trades',
|
|
1215
1155
|
};
|
|
1216
1156
|
return await this.watchMultiple(url, messageHashes, this.extend(request, query), messageHashes, subscription);
|
|
1217
1157
|
}
|
|
@@ -1979,7 +1919,7 @@ export default class binance extends binanceRest {
|
|
|
1979
1919
|
if (this.newUpdates) {
|
|
1980
1920
|
return result;
|
|
1981
1921
|
}
|
|
1982
|
-
return this.filterByArray(this.
|
|
1922
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
1983
1923
|
}
|
|
1984
1924
|
async watchMultiTickerHelper(methodName, channelName, symbols = undefined, params = {}) {
|
|
1985
1925
|
await this.loadMarkets();
|
package/js/src/pro/bitget.js
CHANGED
|
@@ -2013,15 +2013,7 @@ export default class bitget extends bitgetRest {
|
|
|
2013
2013
|
delete this.ohlcvs[symbol][timeframe];
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
|
-
|
|
2017
|
-
delete client.subscriptions[subMessageHash];
|
|
2018
|
-
}
|
|
2019
|
-
if (messageHash in client.subscriptions) {
|
|
2020
|
-
delete client.subscriptions[messageHash];
|
|
2021
|
-
}
|
|
2022
|
-
const error = new UnsubscribeError(this.id + ' ohlcv ' + timeframe + ' ' + symbol);
|
|
2023
|
-
client.reject(error, subMessageHash);
|
|
2024
|
-
client.resolve(true, messageHash);
|
|
2016
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2025
2017
|
}
|
|
2026
2018
|
handleUnSubscriptionStatus(client, message) {
|
|
2027
2019
|
//
|
package/js/src/pro/bitmex.js
CHANGED
|
@@ -62,6 +62,7 @@ export default class bitmex extends bitmexRest {
|
|
|
62
62
|
* @method
|
|
63
63
|
* @name bitmex#watchTicker
|
|
64
64
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
65
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
65
66
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
66
67
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
67
68
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -76,6 +77,7 @@ export default class bitmex extends bitmexRest {
|
|
|
76
77
|
* @method
|
|
77
78
|
* @name bitmex#watchTickers
|
|
78
79
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
80
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
79
81
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
80
82
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
81
83
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -466,6 +468,7 @@ export default class bitmex extends bitmexRest {
|
|
|
466
468
|
* @method
|
|
467
469
|
* @name bitmex#watchBalance
|
|
468
470
|
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
471
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
469
472
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
470
473
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
471
474
|
*/
|
|
@@ -673,6 +676,7 @@ export default class bitmex extends bitmexRest {
|
|
|
673
676
|
* @method
|
|
674
677
|
* @name bitmex#watchTrades
|
|
675
678
|
* @description get the list of most recent trades for a particular symbol
|
|
679
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
676
680
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
677
681
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
678
682
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -725,8 +729,8 @@ export default class bitmex extends bitmexRest {
|
|
|
725
729
|
/**
|
|
726
730
|
* @method
|
|
727
731
|
* @name bitmex#watchPositions
|
|
728
|
-
* @see https://www.bitmex.com/app/wsAPI
|
|
729
732
|
* @description watch all open positions
|
|
733
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
730
734
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
731
735
|
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
732
736
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
@@ -930,6 +934,7 @@ export default class bitmex extends bitmexRest {
|
|
|
930
934
|
* @method
|
|
931
935
|
* @name bitmex#watchOrders
|
|
932
936
|
* @description watches information on multiple orders made by the user
|
|
937
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
933
938
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
934
939
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
935
940
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -1145,6 +1150,7 @@ export default class bitmex extends bitmexRest {
|
|
|
1145
1150
|
* @method
|
|
1146
1151
|
* @name bitmex#watchMyTrades
|
|
1147
1152
|
* @description watches information on multiple trades made by the user
|
|
1153
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
1148
1154
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
1149
1155
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1150
1156
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -1262,6 +1268,7 @@ export default class bitmex extends bitmexRest {
|
|
|
1262
1268
|
* @method
|
|
1263
1269
|
* @name bitmex#watchOrderBook
|
|
1264
1270
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1271
|
+
* @see https://www.bitmex.com/app/wsAPI#OrderBookL2
|
|
1265
1272
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1266
1273
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1267
1274
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1274,6 +1281,7 @@ export default class bitmex extends bitmexRest {
|
|
|
1274
1281
|
* @method
|
|
1275
1282
|
* @name bitmex#watchOrderBookForSymbols
|
|
1276
1283
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1284
|
+
* @see https://www.bitmex.com/app/wsAPI#OrderBookL2
|
|
1277
1285
|
* @param {string[]} symbols unified array of symbols
|
|
1278
1286
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1279
1287
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1317,6 +1325,7 @@ export default class bitmex extends bitmexRest {
|
|
|
1317
1325
|
* @method
|
|
1318
1326
|
* @name bitmex#watchTradesForSymbols
|
|
1319
1327
|
* @description get the list of most recent trades for a list of symbols
|
|
1328
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
1320
1329
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
1321
1330
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1322
1331
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -1354,6 +1363,7 @@ export default class bitmex extends bitmexRest {
|
|
|
1354
1363
|
* @method
|
|
1355
1364
|
* @name bitmex#watchOHLCV
|
|
1356
1365
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1366
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
1357
1367
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1358
1368
|
* @param {string} timeframe the length of time each candle represents
|
|
1359
1369
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
package/js/src/pro/bybit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import bybitRest from '../bybit.js';
|
|
2
|
-
import type { Int, OHLCV, Str, Strings, Ticker, OrderBook, Order, Trade, Tickers, Position, Balances, OrderType, OrderSide, Num,
|
|
2
|
+
import type { Int, OHLCV, Str, Strings, Ticker, OrderBook, Order, Trade, Tickers, Position, Balances, OrderType, OrderSide, Num, Liquidation } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class bybit extends bybitRest {
|
|
5
5
|
describe(): any;
|
|
@@ -65,5 +65,4 @@ export default class bybit extends bybitRest {
|
|
|
65
65
|
handleAuthenticate(client: Client, message: any): any;
|
|
66
66
|
handleSubscriptionStatus(client: Client, message: any): any;
|
|
67
67
|
handleUnSubscribe(client: Client, message: any): any;
|
|
68
|
-
cleanCache(subscription: Dict): void;
|
|
69
68
|
}
|
package/js/src/pro/bybit.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import bybitRest from '../bybit.js';
|
|
9
|
-
import { ArgumentsRequired, AuthenticationError, ExchangeError, BadRequest
|
|
9
|
+
import { ArgumentsRequired, AuthenticationError, ExchangeError, BadRequest } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -1019,7 +1019,7 @@ export default class bybit extends bybitRest {
|
|
|
1019
1019
|
messageHashes.push(messageHash);
|
|
1020
1020
|
subMessageHashes.push('trade:' + symbol);
|
|
1021
1021
|
}
|
|
1022
|
-
return await this.unWatchTopics(url, '
|
|
1022
|
+
return await this.unWatchTopics(url, 'trades', symbols, messageHashes, subMessageHashes, topics, params);
|
|
1023
1023
|
}
|
|
1024
1024
|
async unWatchTrades(symbol, params = {}) {
|
|
1025
1025
|
/**
|
|
@@ -2486,63 +2486,11 @@ export default class bybit extends bybitRest {
|
|
|
2486
2486
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
2487
2487
|
const unsubHash = messageHashes[j];
|
|
2488
2488
|
const subHash = subMessageHashes[j];
|
|
2489
|
-
|
|
2490
|
-
delete client.subscriptions[unsubHash];
|
|
2491
|
-
}
|
|
2492
|
-
if (subHash in client.subscriptions) {
|
|
2493
|
-
delete client.subscriptions[subHash];
|
|
2494
|
-
}
|
|
2495
|
-
const error = new UnsubscribeError(this.id + ' ' + messageHash);
|
|
2496
|
-
client.reject(error, subHash);
|
|
2497
|
-
client.resolve(true, unsubHash);
|
|
2489
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
2498
2490
|
}
|
|
2499
2491
|
this.cleanCache(subscription);
|
|
2500
2492
|
}
|
|
2501
2493
|
}
|
|
2502
2494
|
return message;
|
|
2503
2495
|
}
|
|
2504
|
-
cleanCache(subscription) {
|
|
2505
|
-
const topic = this.safeString(subscription, 'topic');
|
|
2506
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
2507
|
-
const symbolsLength = symbols.length;
|
|
2508
|
-
if (topic === 'ohlcv') {
|
|
2509
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
2510
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
2511
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
2512
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
2513
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
2514
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
else if (symbolsLength > 0) {
|
|
2518
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
2519
|
-
const symbol = symbols[i];
|
|
2520
|
-
if (topic === 'trade') {
|
|
2521
|
-
delete this.trades[symbol];
|
|
2522
|
-
}
|
|
2523
|
-
else if (topic === 'orderbook') {
|
|
2524
|
-
delete this.orderbooks[symbol];
|
|
2525
|
-
}
|
|
2526
|
-
else if (topic === 'ticker') {
|
|
2527
|
-
delete this.tickers[symbol];
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
else {
|
|
2532
|
-
if (topic === 'myTrades') {
|
|
2533
|
-
// don't reset this.myTrades directly here
|
|
2534
|
-
// because in c# we need to use a different object
|
|
2535
|
-
const keys = Object.keys(this.myTrades);
|
|
2536
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2537
|
-
delete this.myTrades[keys[i]];
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
else if (topic === 'orders') {
|
|
2541
|
-
const orderSymbols = Object.keys(this.orders);
|
|
2542
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
2543
|
-
delete this.orders[orderSymbols[i]];
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
2496
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cryptocomRest from '../cryptocom.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Str, Strings, OrderBook, Order, Trade, Ticker, OHLCV, Position, Balances, Num
|
|
2
|
+
import type { Int, OrderSide, OrderType, Str, Strings, OrderBook, Order, Trade, Ticker, OHLCV, Position, Balances, Num } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class cryptocom extends cryptocomRest {
|
|
5
5
|
describe(): any;
|
|
@@ -48,5 +48,4 @@ export default class cryptocom extends cryptocomRest {
|
|
|
48
48
|
handlePing(client: Client, message: any): void;
|
|
49
49
|
handleAuthenticate(client: Client, message: any): void;
|
|
50
50
|
handleUnsubscribe(client: Client, message: any): void;
|
|
51
|
-
cleanCache(subscription: Dict): void;
|
|
52
51
|
}
|
package/js/src/pro/cryptocom.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import cryptocomRest from '../cryptocom.js';
|
|
9
|
-
import { AuthenticationError, ChecksumError, ExchangeError, NetworkError
|
|
9
|
+
import { AuthenticationError, ChecksumError, ExchangeError, NetworkError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -374,7 +374,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
374
374
|
messageHashes.push('unsubscribe:trades:' + market['symbol']);
|
|
375
375
|
topics.push(currentTopic);
|
|
376
376
|
}
|
|
377
|
-
return await this.unWatchPublicMultiple('
|
|
377
|
+
return await this.unWatchPublicMultiple('trades', symbols, messageHashes, topics, topics, params);
|
|
378
378
|
}
|
|
379
379
|
handleTrades(client, message) {
|
|
380
380
|
//
|
|
@@ -1208,48 +1208,10 @@ export default class cryptocom extends cryptocomRest {
|
|
|
1208
1208
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1209
1209
|
const unsubHash = messageHashes[j];
|
|
1210
1210
|
const subHash = subMessageHashes[j];
|
|
1211
|
-
|
|
1212
|
-
delete client.subscriptions[unsubHash];
|
|
1213
|
-
}
|
|
1214
|
-
if (subHash in client.subscriptions) {
|
|
1215
|
-
delete client.subscriptions[subHash];
|
|
1216
|
-
}
|
|
1217
|
-
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
1218
|
-
client.reject(error, subHash);
|
|
1219
|
-
client.resolve(true, unsubHash);
|
|
1211
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1220
1212
|
}
|
|
1221
1213
|
this.cleanCache(subscription);
|
|
1222
1214
|
}
|
|
1223
1215
|
}
|
|
1224
1216
|
}
|
|
1225
|
-
cleanCache(subscription) {
|
|
1226
|
-
const topic = this.safeString(subscription, 'topic');
|
|
1227
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1228
|
-
const symbolsLength = symbols.length;
|
|
1229
|
-
if (topic === 'ohlcv') {
|
|
1230
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1231
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1232
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1233
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1234
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1235
|
-
if (timeframe in this.ohlcvs[symbol]) {
|
|
1236
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
else if (symbolsLength > 0) {
|
|
1241
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
1242
|
-
const symbol = symbols[i];
|
|
1243
|
-
if (topic === 'trade') {
|
|
1244
|
-
delete this.trades[symbol];
|
|
1245
|
-
}
|
|
1246
|
-
else if (topic === 'orderbook') {
|
|
1247
|
-
delete this.orderbooks[symbol];
|
|
1248
|
-
}
|
|
1249
|
-
else if (topic === 'ticker') {
|
|
1250
|
-
delete this.tickers[symbol];
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
1217
|
}
|
package/js/src/pro/gate.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import gateRest from '../gate.js';
|
|
9
|
-
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported
|
|
9
|
+
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha512 } from '../static_dependencies/noble-hashes/sha512.js';
|
|
12
12
|
import Precise from '../base/Precise.js';
|
|
@@ -1663,15 +1663,7 @@ export default class gate extends gateRest {
|
|
|
1663
1663
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1664
1664
|
const unsubHash = messageHashes[j];
|
|
1665
1665
|
const subHash = subMessageHashes[j];
|
|
1666
|
-
|
|
1667
|
-
delete client.subscriptions[unsubHash];
|
|
1668
|
-
}
|
|
1669
|
-
if (subHash in client.subscriptions) {
|
|
1670
|
-
delete client.subscriptions[subHash];
|
|
1671
|
-
}
|
|
1672
|
-
const error = new UnsubscribeError(this.id + ' ' + messageHash);
|
|
1673
|
-
client.reject(error, subHash);
|
|
1674
|
-
client.resolve(true, unsubHash);
|
|
1666
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1675
1667
|
}
|
|
1676
1668
|
this.cleanCache(subscription);
|
|
1677
1669
|
}
|
|
@@ -7,21 +7,30 @@ export default class hyperliquid extends hyperliquidRest {
|
|
|
7
7
|
createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
|
|
8
8
|
editOrderWs(id: string, symbol: string, type: string, side: string, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
9
9
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
10
|
+
unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
|
|
10
11
|
handleOrderBook(client: any, message: any): void;
|
|
11
12
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
|
+
unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
|
|
12
14
|
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
13
15
|
handleWsTickers(client: Client, message: any): void;
|
|
14
16
|
parseWsTicker(rawTicker: any, market?: Market): Ticker;
|
|
15
17
|
handleMyTrades(client: Client, message: any): void;
|
|
16
18
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
19
|
+
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
|
17
20
|
handleTrades(client: Client, message: any): void;
|
|
18
21
|
parseWsTrade(trade: Dict, market?: Market): Trade;
|
|
19
22
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
23
|
+
unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
|
|
20
24
|
handleOHLCV(client: Client, message: any): void;
|
|
21
|
-
handleWsPost(client: Client, message:
|
|
25
|
+
handleWsPost(client: Client, message: Dict): void;
|
|
22
26
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
23
27
|
handleOrder(client: Client, message: any): void;
|
|
24
28
|
handleErrorMessage(client: Client, message: any): boolean;
|
|
29
|
+
handleOrderBookUnsubscription(client: Client, subscription: Dict): void;
|
|
30
|
+
handleTradesUnsubscription(client: Client, subscription: Dict): void;
|
|
31
|
+
handleTickersUnsubscription(client: Client, subscription: Dict): void;
|
|
32
|
+
handleOHLCVUnsubscription(client: Client, subscription: Dict): void;
|
|
33
|
+
handleSubscriptionResponse(client: Client, message: any): void;
|
|
25
34
|
handleMessage(client: Client, message: any): void;
|
|
26
35
|
ping(client: Client): {
|
|
27
36
|
method: string;
|