ccxt 4.4.1 → 4.4.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 +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 +88 -18
- package/dist/cjs/src/bitmart.js +3 -1
- package/dist/cjs/src/bitstamp.js +24 -36
- package/dist/cjs/src/bybit.js +1 -0
- package/dist/cjs/src/cryptocom.js +3 -2
- package/dist/cjs/src/currencycom.js +1 -2
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/mexc.js +88 -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 +193 -61
- package/dist/cjs/src/pro/gate.js +1 -9
- package/dist/cjs/src/pro/hyperliquid.js +4 -36
- package/dist/cjs/src/pro/kucoin.js +2 -59
- package/dist/cjs/src/pro/kucoinfutures.js +139 -1
- package/dist/cjs/src/pro/mexc.js +82 -3
- package/dist/cjs/src/pro/okx.js +14 -39
- package/dist/cjs/src/pro/oxfun.js +75 -0
- package/dist/cjs/src/pro/phemex.js +45 -1
- package/dist/cjs/src/pro/woofipro.js +67 -0
- package/dist/cjs/src/xt.js +7 -2
- package/examples/js/cli.js +8 -4
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmart.d.ts +1 -0
- 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 +88 -18
- package/js/src/bitmart.js +3 -1
- package/js/src/bitstamp.js +24 -36
- package/js/src/bybit.js +2 -1
- package/js/src/cryptocom.js +3 -2
- package/js/src/currencycom.js +1 -2
- package/js/src/htx.js +1 -1
- package/js/src/mexc.js +88 -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 +7 -2
- package/js/src/pro/cryptocom.js +194 -62
- package/js/src/pro/gate.js +2 -10
- package/js/src/pro/hyperliquid.js +5 -37
- 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/mexc.d.ts +3 -1
- package/js/src/pro/mexc.js +82 -3
- package/js/src/pro/okx.js +15 -40
- package/js/src/pro/oxfun.d.ts +3 -0
- package/js/src/pro/oxfun.js +75 -0
- package/js/src/pro/phemex.d.ts +2 -1
- package/js/src/pro/phemex.js +45 -1
- package/js/src/pro/woofipro.d.ts +3 -0
- package/js/src/pro/woofipro.js +67 -0
- package/js/src/xt.js +7 -2
- package/package.json +1 -1
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,
|
|
@@ -5128,6 +5196,16 @@ export default class mexc extends Exchange {
|
|
|
5128
5196
|
return this.parseTransaction(response, currency);
|
|
5129
5197
|
}
|
|
5130
5198
|
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
5199
|
+
/**
|
|
5200
|
+
* @method
|
|
5201
|
+
* @name mexc#setPositionMode
|
|
5202
|
+
* @description set hedged to true or false for a market
|
|
5203
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#change-position-mode
|
|
5204
|
+
* @param {bool} hedged set to true to use dualSidePosition
|
|
5205
|
+
* @param {string} symbol not used by mexc setPositionMode ()
|
|
5206
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5207
|
+
* @returns {object} response from the exchange
|
|
5208
|
+
*/
|
|
5131
5209
|
const request = {
|
|
5132
5210
|
'positionMode': hedged ? 1 : 2, // 1 Hedge, 2 One-way, before changing position mode make sure that there are no active orders, planned orders, or open positions, the risk limit level will be reset to 1
|
|
5133
5211
|
};
|
|
@@ -5141,6 +5219,15 @@ export default class mexc extends Exchange {
|
|
|
5141
5219
|
return response;
|
|
5142
5220
|
}
|
|
5143
5221
|
async fetchPositionMode(symbol = undefined, params = {}) {
|
|
5222
|
+
/**
|
|
5223
|
+
* @method
|
|
5224
|
+
* @name mexc#fetchPositionMode
|
|
5225
|
+
* @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
|
|
5226
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode
|
|
5227
|
+
* @param {string} symbol not used by mexc fetchPositionMode
|
|
5228
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5229
|
+
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
|
5230
|
+
*/
|
|
5144
5231
|
const response = await this.contractPrivateGetPositionPositionMode(params);
|
|
5145
5232
|
//
|
|
5146
5233
|
// {
|
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, Dict } from '../base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Str, Strings, OrderBook, Order, Trade, Ticker, OHLCV, Position, Balances, Num, Dict, Tickers, Market } 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;
|
|
@@ -19,7 +19,13 @@ export default class cryptocom extends cryptocomRest {
|
|
|
19
19
|
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
20
20
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
21
21
|
unWatchTicker(symbol: string, params?: {}): Promise<any>;
|
|
22
|
+
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
23
|
+
unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
|
|
22
24
|
handleTicker(client: Client, message: any): void;
|
|
25
|
+
parseWsTicker(ticker: Dict, market?: Market): Ticker;
|
|
26
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
27
|
+
handleBidAsk(client: Client, message: any): void;
|
|
28
|
+
parseWsBidAsk(ticker: any, market?: any): Ticker;
|
|
23
29
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
24
30
|
unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
|
|
25
31
|
handleOHLCV(client: Client, message: any): void;
|
|
@@ -48,5 +54,4 @@ export default class cryptocom extends cryptocomRest {
|
|
|
48
54
|
handlePing(client: Client, message: any): void;
|
|
49
55
|
handleAuthenticate(client: Client, message: any): void;
|
|
50
56
|
handleUnsubscribe(client: Client, message: any): void;
|
|
51
|
-
cleanCache(subscription: Dict): void;
|
|
52
57
|
}
|