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/dist/cjs/src/mexc.js
CHANGED
|
@@ -1019,6 +1019,15 @@ class mexc extends mexc$1 {
|
|
|
1019
1019
|
return this.arrayConcat(spotMarket, swapMarket);
|
|
1020
1020
|
}
|
|
1021
1021
|
async fetchSpotMarkets(params = {}) {
|
|
1022
|
+
/**
|
|
1023
|
+
* @ignore
|
|
1024
|
+
* @method
|
|
1025
|
+
* @name mexc#fetchMarkets
|
|
1026
|
+
* @description retrieves data on all spot markets for mexc
|
|
1027
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
|
|
1028
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1029
|
+
* @returns {object[]} an array of objects representing market data
|
|
1030
|
+
*/
|
|
1022
1031
|
const response = await this.spotPublicGetExchangeInfo(params);
|
|
1023
1032
|
//
|
|
1024
1033
|
// {
|
|
@@ -1136,6 +1145,15 @@ class mexc extends mexc$1 {
|
|
|
1136
1145
|
return result;
|
|
1137
1146
|
}
|
|
1138
1147
|
async fetchSwapMarkets(params = {}) {
|
|
1148
|
+
/**
|
|
1149
|
+
* @ignore
|
|
1150
|
+
* @method
|
|
1151
|
+
* @name mexc#fetchMarkets
|
|
1152
|
+
* @description retrieves data on all swap markets for mexc
|
|
1153
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
|
|
1154
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1155
|
+
* @returns {object[]} an array of objects representing market data
|
|
1156
|
+
*/
|
|
1139
1157
|
const response = await this.contractPublicGetDetail(params);
|
|
1140
1158
|
//
|
|
1141
1159
|
// {
|
|
@@ -1727,6 +1745,8 @@ class mexc extends mexc$1 {
|
|
|
1727
1745
|
* @method
|
|
1728
1746
|
* @name mexc#fetchTickers
|
|
1729
1747
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1748
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
1749
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
|
1730
1750
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1731
1751
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1732
1752
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -1815,6 +1835,8 @@ class mexc extends mexc$1 {
|
|
|
1815
1835
|
* @method
|
|
1816
1836
|
* @name mexc#fetchTicker
|
|
1817
1837
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1838
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
1839
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
|
1818
1840
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1819
1841
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1820
1842
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2005,6 +2027,7 @@ class mexc extends mexc$1 {
|
|
|
2005
2027
|
* @method
|
|
2006
2028
|
* @name mexc#fetchBidsAsks
|
|
2007
2029
|
* @description fetches the bid and ask price and volume for multiple markets
|
|
2030
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
|
|
2008
2031
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
2009
2032
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2010
2033
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2150,6 +2173,23 @@ class mexc extends mexc$1 {
|
|
|
2150
2173
|
return this.extend(request, params);
|
|
2151
2174
|
}
|
|
2152
2175
|
async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2176
|
+
/**
|
|
2177
|
+
* @ignore
|
|
2178
|
+
* @method
|
|
2179
|
+
* @name mexc#createSpotOrder
|
|
2180
|
+
* @description create a trade order
|
|
2181
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
2182
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2183
|
+
* @param {string} type 'market' or 'limit'
|
|
2184
|
+
* @param {string} side 'buy' or 'sell'
|
|
2185
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2186
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
2187
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2188
|
+
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2189
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2190
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2191
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2192
|
+
*/
|
|
2153
2193
|
await this.loadMarkets();
|
|
2154
2194
|
const request = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, params);
|
|
2155
2195
|
const response = await this.spotPrivatePostOrder(this.extend(request, params));
|
|
@@ -2180,6 +2220,32 @@ class mexc extends mexc$1 {
|
|
|
2180
2220
|
return order;
|
|
2181
2221
|
}
|
|
2182
2222
|
async createSwapOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2223
|
+
/**
|
|
2224
|
+
* @ignore
|
|
2225
|
+
* @method
|
|
2226
|
+
* @name mexc#createOrder
|
|
2227
|
+
* @description create a trade order
|
|
2228
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
2229
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
|
|
2230
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
|
|
2231
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2232
|
+
* @param {string} type 'market' or 'limit'
|
|
2233
|
+
* @param {string} side 'buy' or 'sell'
|
|
2234
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2235
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
2236
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2237
|
+
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2238
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2239
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2240
|
+
* @param {bool} [params.reduceOnly] indicates if this order is to reduce the size of a position
|
|
2241
|
+
*
|
|
2242
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
2243
|
+
* @param {int} [params.leverage] leverage is necessary on isolated margin
|
|
2244
|
+
* @param {long} [params.positionId] it is recommended to fill in this parameter when closing a position
|
|
2245
|
+
* @param {string} [params.externalOid] external order ID
|
|
2246
|
+
* @param {int} [params.positionMode] 1:hedge, 2:one-way, default: the user's current config
|
|
2247
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2248
|
+
*/
|
|
2183
2249
|
await this.loadMarkets();
|
|
2184
2250
|
const symbol = market['symbol'];
|
|
2185
2251
|
const unavailableContracts = this.safeValue(this.options, 'unavailableContracts', {});
|
|
@@ -2355,6 +2421,8 @@ class mexc extends mexc$1 {
|
|
|
2355
2421
|
* @method
|
|
2356
2422
|
* @name mexc#fetchOrder
|
|
2357
2423
|
* @description fetches information on an order made by the user
|
|
2424
|
+
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
|
|
2425
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
|
|
2358
2426
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2359
2427
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2360
2428
|
* @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
|
|
@@ -4812,7 +4880,7 @@ class mexc extends mexc$1 {
|
|
|
4812
4880
|
'entryPrice': entryPrice,
|
|
4813
4881
|
'collateral': undefined,
|
|
4814
4882
|
'side': side,
|
|
4815
|
-
'
|
|
4883
|
+
'unrealizedPnl': undefined,
|
|
4816
4884
|
'leverage': this.parseNumber(leverage),
|
|
4817
4885
|
'percentage': undefined,
|
|
4818
4886
|
'marginMode': marginType,
|
|
@@ -5124,6 +5192,16 @@ class mexc extends mexc$1 {
|
|
|
5124
5192
|
return this.parseTransaction(response, currency);
|
|
5125
5193
|
}
|
|
5126
5194
|
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
5195
|
+
/**
|
|
5196
|
+
* @method
|
|
5197
|
+
* @name mexc#setPositionMode
|
|
5198
|
+
* @description set hedged to true or false for a market
|
|
5199
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#change-position-mode
|
|
5200
|
+
* @param {bool} hedged set to true to use dualSidePosition
|
|
5201
|
+
* @param {string} symbol not used by mexc setPositionMode ()
|
|
5202
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5203
|
+
* @returns {object} response from the exchange
|
|
5204
|
+
*/
|
|
5127
5205
|
const request = {
|
|
5128
5206
|
'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
|
|
5129
5207
|
};
|
|
@@ -5137,6 +5215,15 @@ class mexc extends mexc$1 {
|
|
|
5137
5215
|
return response;
|
|
5138
5216
|
}
|
|
5139
5217
|
async fetchPositionMode(symbol = undefined, params = {}) {
|
|
5218
|
+
/**
|
|
5219
|
+
* @method
|
|
5220
|
+
* @name mexc#fetchPositionMode
|
|
5221
|
+
* @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
|
|
5222
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode
|
|
5223
|
+
* @param {string} symbol not used by mexc fetchPositionMode
|
|
5224
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5225
|
+
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
|
5226
|
+
*/
|
|
5140
5227
|
const response = await this.contractPrivateGetPositionPositionMode(params);
|
|
5141
5228
|
//
|
|
5142
5229
|
// {
|
|
@@ -1023,70 +1023,10 @@ class binance extends binance$1 {
|
|
|
1023
1023
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1024
1024
|
const unsubHash = messageHashes[j];
|
|
1025
1025
|
const subHash = subMessageHashes[j];
|
|
1026
|
-
|
|
1027
|
-
delete client.subscriptions[unsubHash];
|
|
1028
|
-
}
|
|
1029
|
-
if (subHash in client.subscriptions) {
|
|
1030
|
-
delete client.subscriptions[subHash];
|
|
1031
|
-
}
|
|
1032
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
1033
|
-
client.reject(error, subHash);
|
|
1034
|
-
client.resolve(true, unsubHash);
|
|
1026
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1035
1027
|
}
|
|
1036
1028
|
this.cleanCache(subscription);
|
|
1037
1029
|
}
|
|
1038
|
-
cleanCache(subscription) {
|
|
1039
|
-
const topic = this.safeString(subscription, 'topic');
|
|
1040
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1041
|
-
const symbolsLength = symbols.length;
|
|
1042
|
-
if (topic === 'ohlcv') {
|
|
1043
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1044
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1045
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1046
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1047
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1048
|
-
if (timeframe in this.ohlcvs[symbol]) {
|
|
1049
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
else if (symbolsLength > 0) {
|
|
1054
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
1055
|
-
const symbol = symbols[i];
|
|
1056
|
-
if (topic === 'trade') {
|
|
1057
|
-
delete this.trades[symbol];
|
|
1058
|
-
}
|
|
1059
|
-
else if (topic === 'orderbook') {
|
|
1060
|
-
delete this.orderbooks[symbol];
|
|
1061
|
-
}
|
|
1062
|
-
else if (topic === 'ticker') {
|
|
1063
|
-
delete this.tickers[symbol];
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
else {
|
|
1068
|
-
if (topic === 'myTrades') {
|
|
1069
|
-
// don't reset this.myTrades directly here
|
|
1070
|
-
// because in c# we need to use a different object
|
|
1071
|
-
const keys = Object.keys(this.myTrades);
|
|
1072
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1073
|
-
delete this.myTrades[keys[i]];
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
else if (topic === 'orders') {
|
|
1077
|
-
const orderSymbols = Object.keys(this.orders);
|
|
1078
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
1079
|
-
delete this.orders[orderSymbols[i]];
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
else if (topic === 'ticker') {
|
|
1083
|
-
const tickerSymbols = Object.keys(this.tickers);
|
|
1084
|
-
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
1085
|
-
delete this.tickers[tickerSymbols[i]];
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
1030
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
1091
1031
|
/**
|
|
1092
1032
|
* @method
|
|
@@ -1208,7 +1148,7 @@ class binance extends binance$1 {
|
|
|
1208
1148
|
'subMessageHashes': subMessageHashes,
|
|
1209
1149
|
'messageHashes': messageHashes,
|
|
1210
1150
|
'symbols': symbols,
|
|
1211
|
-
'topic': '
|
|
1151
|
+
'topic': 'trades',
|
|
1212
1152
|
};
|
|
1213
1153
|
return await this.watchMultiple(url, messageHashes, this.extend(request, query), messageHashes, subscription);
|
|
1214
1154
|
}
|
|
@@ -1973,7 +1913,7 @@ class binance extends binance$1 {
|
|
|
1973
1913
|
if (this.newUpdates) {
|
|
1974
1914
|
return result;
|
|
1975
1915
|
}
|
|
1976
|
-
return this.filterByArray(this.
|
|
1916
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
1977
1917
|
}
|
|
1978
1918
|
async watchMultiTickerHelper(methodName, channelName, symbols = undefined, params = {}) {
|
|
1979
1919
|
await this.loadMarkets();
|
|
@@ -2010,15 +2010,7 @@ class bitget extends bitget$1 {
|
|
|
2010
2010
|
delete this.ohlcvs[symbol][timeframe];
|
|
2011
2011
|
}
|
|
2012
2012
|
}
|
|
2013
|
-
|
|
2014
|
-
delete client.subscriptions[subMessageHash];
|
|
2015
|
-
}
|
|
2016
|
-
if (messageHash in client.subscriptions) {
|
|
2017
|
-
delete client.subscriptions[messageHash];
|
|
2018
|
-
}
|
|
2019
|
-
const error = new errors.UnsubscribeError(this.id + ' ohlcv ' + timeframe + ' ' + symbol);
|
|
2020
|
-
client.reject(error, subMessageHash);
|
|
2021
|
-
client.resolve(true, messageHash);
|
|
2013
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2022
2014
|
}
|
|
2023
2015
|
handleUnSubscriptionStatus(client, message) {
|
|
2024
2016
|
//
|
|
@@ -59,6 +59,7 @@ class bitmex extends bitmex$1 {
|
|
|
59
59
|
* @method
|
|
60
60
|
* @name bitmex#watchTicker
|
|
61
61
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
62
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
62
63
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
63
64
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
64
65
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -73,6 +74,7 @@ class bitmex extends bitmex$1 {
|
|
|
73
74
|
* @method
|
|
74
75
|
* @name bitmex#watchTickers
|
|
75
76
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
77
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
76
78
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
77
79
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
78
80
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -461,6 +463,7 @@ class bitmex extends bitmex$1 {
|
|
|
461
463
|
* @method
|
|
462
464
|
* @name bitmex#watchBalance
|
|
463
465
|
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
466
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
464
467
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
465
468
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
466
469
|
*/
|
|
@@ -668,6 +671,7 @@ class bitmex extends bitmex$1 {
|
|
|
668
671
|
* @method
|
|
669
672
|
* @name bitmex#watchTrades
|
|
670
673
|
* @description get the list of most recent trades for a particular symbol
|
|
674
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
671
675
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
672
676
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
673
677
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -720,8 +724,8 @@ class bitmex extends bitmex$1 {
|
|
|
720
724
|
/**
|
|
721
725
|
* @method
|
|
722
726
|
* @name bitmex#watchPositions
|
|
723
|
-
* @see https://www.bitmex.com/app/wsAPI
|
|
724
727
|
* @description watch all open positions
|
|
728
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
725
729
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
726
730
|
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
727
731
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
@@ -925,6 +929,7 @@ class bitmex extends bitmex$1 {
|
|
|
925
929
|
* @method
|
|
926
930
|
* @name bitmex#watchOrders
|
|
927
931
|
* @description watches information on multiple orders made by the user
|
|
932
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
928
933
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
929
934
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
930
935
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -1140,6 +1145,7 @@ class bitmex extends bitmex$1 {
|
|
|
1140
1145
|
* @method
|
|
1141
1146
|
* @name bitmex#watchMyTrades
|
|
1142
1147
|
* @description watches information on multiple trades made by the user
|
|
1148
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
1143
1149
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
1144
1150
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1145
1151
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -1257,6 +1263,7 @@ class bitmex extends bitmex$1 {
|
|
|
1257
1263
|
* @method
|
|
1258
1264
|
* @name bitmex#watchOrderBook
|
|
1259
1265
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1266
|
+
* @see https://www.bitmex.com/app/wsAPI#OrderBookL2
|
|
1260
1267
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1261
1268
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1262
1269
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1269,6 +1276,7 @@ class bitmex extends bitmex$1 {
|
|
|
1269
1276
|
* @method
|
|
1270
1277
|
* @name bitmex#watchOrderBookForSymbols
|
|
1271
1278
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1279
|
+
* @see https://www.bitmex.com/app/wsAPI#OrderBookL2
|
|
1272
1280
|
* @param {string[]} symbols unified array of symbols
|
|
1273
1281
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1274
1282
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1312,6 +1320,7 @@ class bitmex extends bitmex$1 {
|
|
|
1312
1320
|
* @method
|
|
1313
1321
|
* @name bitmex#watchTradesForSymbols
|
|
1314
1322
|
* @description get the list of most recent trades for a list of symbols
|
|
1323
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
1315
1324
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
1316
1325
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1317
1326
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -1349,6 +1358,7 @@ class bitmex extends bitmex$1 {
|
|
|
1349
1358
|
* @method
|
|
1350
1359
|
* @name bitmex#watchOHLCV
|
|
1351
1360
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1361
|
+
* @see https://www.bitmex.com/app/wsAPI#Subscriptions
|
|
1352
1362
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1353
1363
|
* @param {string} timeframe the length of time each candle represents
|
|
1354
1364
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -1016,7 +1016,7 @@ class bybit extends bybit$1 {
|
|
|
1016
1016
|
messageHashes.push(messageHash);
|
|
1017
1017
|
subMessageHashes.push('trade:' + symbol);
|
|
1018
1018
|
}
|
|
1019
|
-
return await this.unWatchTopics(url, '
|
|
1019
|
+
return await this.unWatchTopics(url, 'trades', symbols, messageHashes, subMessageHashes, topics, params);
|
|
1020
1020
|
}
|
|
1021
1021
|
async unWatchTrades(symbol, params = {}) {
|
|
1022
1022
|
/**
|
|
@@ -2483,65 +2483,13 @@ class bybit extends bybit$1 {
|
|
|
2483
2483
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
2484
2484
|
const unsubHash = messageHashes[j];
|
|
2485
2485
|
const subHash = subMessageHashes[j];
|
|
2486
|
-
|
|
2487
|
-
delete client.subscriptions[unsubHash];
|
|
2488
|
-
}
|
|
2489
|
-
if (subHash in client.subscriptions) {
|
|
2490
|
-
delete client.subscriptions[subHash];
|
|
2491
|
-
}
|
|
2492
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + messageHash);
|
|
2493
|
-
client.reject(error, subHash);
|
|
2494
|
-
client.resolve(true, unsubHash);
|
|
2486
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
2495
2487
|
}
|
|
2496
2488
|
this.cleanCache(subscription);
|
|
2497
2489
|
}
|
|
2498
2490
|
}
|
|
2499
2491
|
return message;
|
|
2500
2492
|
}
|
|
2501
|
-
cleanCache(subscription) {
|
|
2502
|
-
const topic = this.safeString(subscription, 'topic');
|
|
2503
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
2504
|
-
const symbolsLength = symbols.length;
|
|
2505
|
-
if (topic === 'ohlcv') {
|
|
2506
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
2507
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
2508
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
2509
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
2510
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
2511
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
else if (symbolsLength > 0) {
|
|
2515
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
2516
|
-
const symbol = symbols[i];
|
|
2517
|
-
if (topic === 'trade') {
|
|
2518
|
-
delete this.trades[symbol];
|
|
2519
|
-
}
|
|
2520
|
-
else if (topic === 'orderbook') {
|
|
2521
|
-
delete this.orderbooks[symbol];
|
|
2522
|
-
}
|
|
2523
|
-
else if (topic === 'ticker') {
|
|
2524
|
-
delete this.tickers[symbol];
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
else {
|
|
2529
|
-
if (topic === 'myTrades') {
|
|
2530
|
-
// don't reset this.myTrades directly here
|
|
2531
|
-
// because in c# we need to use a different object
|
|
2532
|
-
const keys = Object.keys(this.myTrades);
|
|
2533
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2534
|
-
delete this.myTrades[keys[i]];
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
else if (topic === 'orders') {
|
|
2538
|
-
const orderSymbols = Object.keys(this.orders);
|
|
2539
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
2540
|
-
delete this.orders[orderSymbols[i]];
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
2493
|
}
|
|
2546
2494
|
|
|
2547
2495
|
module.exports = bybit;
|