ccxt 4.5.2 → 4.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +11 -0
- package/dist/cjs/src/binance.js +5 -11
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/coincatch.js +2 -2
- package/dist/cjs/src/gate.js +27 -12
- package/dist/cjs/src/gemini.js +3 -3
- package/dist/cjs/src/htx.js +4 -4
- package/dist/cjs/src/kucoinfutures.js +8 -8
- package/dist/cjs/src/mexc.js +30 -1
- package/dist/cjs/src/okx.js +17 -3
- package/dist/cjs/src/pro/binance.js +3 -3
- package/dist/cjs/src/pro/bitfinex.js +140 -0
- package/dist/cjs/src/pro/bitget.js +61 -16
- package/dist/cjs/src/pro/bybit.js +3 -3
- package/dist/cjs/src/pro/kucoin.js +64 -0
- package/dist/cjs/src/pro/mexc.js +7 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +11 -0
- package/js/src/binance.js +5 -11
- package/js/src/bitget.js +1 -1
- package/js/src/coincatch.js +2 -2
- package/js/src/gate.js +27 -12
- package/js/src/gemini.js +3 -3
- package/js/src/htx.js +4 -4
- package/js/src/kucoinfutures.js +8 -8
- package/js/src/mexc.d.ts +3 -0
- package/js/src/mexc.js +30 -1
- package/js/src/okx.d.ts +4 -2
- package/js/src/okx.js +17 -3
- package/js/src/pro/binance.js +3 -3
- package/js/src/pro/bitfinex.d.ts +30 -0
- package/js/src/pro/bitfinex.js +140 -0
- package/js/src/pro/bitget.d.ts +6 -0
- package/js/src/pro/bitget.js +61 -16
- package/js/src/pro/bybit.d.ts +2 -2
- package/js/src/pro/bybit.js +3 -3
- package/js/src/pro/kucoin.d.ts +22 -0
- package/js/src/pro/kucoin.js +64 -0
- package/js/src/pro/mexc.js +7 -3
- package/package.json +1 -1
|
@@ -922,10 +922,12 @@ class bitget extends bitget$1["default"] {
|
|
|
922
922
|
* @description get the list of most recent trades for a particular symbol
|
|
923
923
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
924
924
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
925
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
925
926
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
926
927
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
927
928
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
928
929
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
930
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
929
931
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
930
932
|
*/
|
|
931
933
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -937,10 +939,12 @@ class bitget extends bitget$1["default"] {
|
|
|
937
939
|
* @description get the list of most recent trades for a particular symbol
|
|
938
940
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
939
941
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
942
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
940
943
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
941
944
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
942
945
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
943
946
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
947
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
944
948
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
945
949
|
*/
|
|
946
950
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
@@ -950,21 +954,28 @@ class bitget extends bitget$1["default"] {
|
|
|
950
954
|
}
|
|
951
955
|
await this.loadMarkets();
|
|
952
956
|
symbols = this.marketSymbols(symbols);
|
|
957
|
+
let uta = undefined;
|
|
958
|
+
[uta, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'uta', false);
|
|
953
959
|
const topics = [];
|
|
954
960
|
const messageHashes = [];
|
|
955
961
|
for (let i = 0; i < symbols.length; i++) {
|
|
956
962
|
const symbol = symbols[i];
|
|
957
963
|
const market = this.market(symbol);
|
|
958
964
|
let instType = undefined;
|
|
959
|
-
[instType, params] = this.getInstType(market,
|
|
965
|
+
[instType, params] = this.getInstType(market, uta, params);
|
|
960
966
|
const args = {
|
|
961
967
|
'instType': instType,
|
|
962
|
-
'channel': 'trade',
|
|
963
|
-
'instId': market['id'],
|
|
964
968
|
};
|
|
969
|
+
const topicOrChannel = uta ? 'topic' : 'channel';
|
|
970
|
+
const symbolOrInstId = uta ? 'symbol' : 'instId';
|
|
971
|
+
args[topicOrChannel] = uta ? 'publicTrade' : 'trade';
|
|
972
|
+
args[symbolOrInstId] = market['id'];
|
|
965
973
|
topics.push(args);
|
|
966
974
|
messageHashes.push('trade:' + symbol);
|
|
967
975
|
}
|
|
976
|
+
if (uta) {
|
|
977
|
+
params['uta'] = true;
|
|
978
|
+
}
|
|
968
979
|
const trades = await this.watchPublicMultiple(messageHashes, topics, params);
|
|
969
980
|
if (this.newUpdates) {
|
|
970
981
|
const first = this.safeValue(trades, 0);
|
|
@@ -985,13 +996,17 @@ class bitget extends bitget$1["default"] {
|
|
|
985
996
|
* @description unsubscribe from the trades channel
|
|
986
997
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
987
998
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
999
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
988
1000
|
* @param {string} symbol unified symbol of the market to unwatch the trades for
|
|
989
1001
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1002
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
990
1003
|
* @returns {any} status of the unwatch request
|
|
991
1004
|
*/
|
|
992
1005
|
async unWatchTrades(symbol, params = {}) {
|
|
993
|
-
|
|
994
|
-
|
|
1006
|
+
let uta = undefined;
|
|
1007
|
+
[uta, params] = this.handleOptionAndParams(params, 'unWatchTrades', 'uta', false);
|
|
1008
|
+
const channelTopic = uta ? 'publicTrade' : 'trade';
|
|
1009
|
+
return await this.unWatchChannel(symbol, channelTopic, 'trade', params);
|
|
995
1010
|
}
|
|
996
1011
|
handleTrades(client, message) {
|
|
997
1012
|
//
|
|
@@ -1010,10 +1025,28 @@ class bitget extends bitget$1["default"] {
|
|
|
1010
1025
|
// "ts": 1701910980730
|
|
1011
1026
|
// }
|
|
1012
1027
|
//
|
|
1028
|
+
// uta
|
|
1029
|
+
//
|
|
1030
|
+
// {
|
|
1031
|
+
// "action": "snapshot",
|
|
1032
|
+
// "arg": { "instType": "spot", "topic": "publicTrade", "symbol": "BTCUSDT" },
|
|
1033
|
+
// "data": [
|
|
1034
|
+
// {
|
|
1035
|
+
// "T": "1756287827920",
|
|
1036
|
+
// "P": "110878.5",
|
|
1037
|
+
// "v": "0.07",
|
|
1038
|
+
// "S": "buy",
|
|
1039
|
+
// "L": "1344534089797185550"
|
|
1040
|
+
// "i": "1344534089797185549"
|
|
1041
|
+
// },
|
|
1042
|
+
// ],
|
|
1043
|
+
// "ts": 1701910980730
|
|
1044
|
+
// }
|
|
1045
|
+
//
|
|
1013
1046
|
const arg = this.safeValue(message, 'arg', {});
|
|
1014
|
-
const instType = this.
|
|
1015
|
-
const marketType = (instType === '
|
|
1016
|
-
const marketId = this.
|
|
1047
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
1048
|
+
const marketType = (instType === 'spot') ? 'spot' : 'contract';
|
|
1049
|
+
const marketId = this.safeString2(arg, 'instId', 'symbol');
|
|
1017
1050
|
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
1018
1051
|
const symbol = market['symbol'];
|
|
1019
1052
|
let stored = this.safeValue(this.trades, symbol);
|
|
@@ -1092,13 +1125,24 @@ class bitget extends bitget$1["default"] {
|
|
|
1092
1125
|
// "uTime": "1714471204194"
|
|
1093
1126
|
// }
|
|
1094
1127
|
//
|
|
1128
|
+
// uta
|
|
1129
|
+
//
|
|
1130
|
+
// {
|
|
1131
|
+
// "i": "1344534089797185549", // Fill execution ID
|
|
1132
|
+
// "L": "1344534089797185550", // Execution correlation ID
|
|
1133
|
+
// "p": "110878.5", // Fill price
|
|
1134
|
+
// "v": "0.07", // Fill size
|
|
1135
|
+
// "S": "buy", // Fill side
|
|
1136
|
+
// "T": "1756287827920" // Fill timestamp
|
|
1137
|
+
// }
|
|
1138
|
+
//
|
|
1095
1139
|
const instId = this.safeString2(trade, 'symbol', 'instId');
|
|
1096
1140
|
const posMode = this.safeString(trade, 'posMode');
|
|
1097
1141
|
const defaultType = (posMode !== undefined) ? 'contract' : 'spot';
|
|
1098
1142
|
if (market === undefined) {
|
|
1099
1143
|
market = this.safeMarket(instId, undefined, undefined, defaultType);
|
|
1100
1144
|
}
|
|
1101
|
-
const timestamp = this.safeIntegerN(trade, ['uTime', 'cTime', 'ts']);
|
|
1145
|
+
const timestamp = this.safeIntegerN(trade, ['uTime', 'cTime', 'ts', 'T']);
|
|
1102
1146
|
const feeDetail = this.safeList(trade, 'feeDetail', []);
|
|
1103
1147
|
const first = this.safeDict(feeDetail, 0);
|
|
1104
1148
|
let fee = undefined;
|
|
@@ -1112,16 +1156,16 @@ class bitget extends bitget$1["default"] {
|
|
|
1112
1156
|
}
|
|
1113
1157
|
return this.safeTrade({
|
|
1114
1158
|
'info': trade,
|
|
1115
|
-
'id': this.
|
|
1116
|
-
'order': this.
|
|
1159
|
+
'id': this.safeString2(trade, 'tradeId', 'i'),
|
|
1160
|
+
'order': this.safeString2(trade, 'orderId', 'L'),
|
|
1117
1161
|
'timestamp': timestamp,
|
|
1118
1162
|
'datetime': this.iso8601(timestamp),
|
|
1119
1163
|
'symbol': market['symbol'],
|
|
1120
1164
|
'type': this.safeString(trade, 'orderType'),
|
|
1121
|
-
'side': this.
|
|
1165
|
+
'side': this.safeString2(trade, 'side', 'S'),
|
|
1122
1166
|
'takerOrMaker': this.safeString(trade, 'tradeScope'),
|
|
1123
|
-
'price': this.
|
|
1124
|
-
'amount': this.
|
|
1167
|
+
'price': this.safeStringN(trade, ['priceAvg', 'price', 'P']),
|
|
1168
|
+
'amount': this.safeStringN(trade, ['size', 'baseVolume', 'v']),
|
|
1125
1169
|
'cost': this.safeString2(trade, 'amount', 'quoteVolume'),
|
|
1126
1170
|
'fee': fee,
|
|
1127
1171
|
}, market);
|
|
@@ -2253,6 +2297,7 @@ class bitget extends bitget$1["default"] {
|
|
|
2253
2297
|
const methods = {
|
|
2254
2298
|
'ticker': this.handleTicker,
|
|
2255
2299
|
'trade': this.handleTrades,
|
|
2300
|
+
'publicTrade': this.handleTrades,
|
|
2256
2301
|
'fill': this.handleMyTrades,
|
|
2257
2302
|
'orders': this.handleOrder,
|
|
2258
2303
|
'ordersAlgo': this.handleOrder,
|
|
@@ -2326,7 +2371,7 @@ class bitget extends bitget$1["default"] {
|
|
|
2326
2371
|
const arg = this.safeDict(message, 'arg', {});
|
|
2327
2372
|
const instType = this.safeStringLower(arg, 'instType');
|
|
2328
2373
|
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
2329
|
-
const instId = this.
|
|
2374
|
+
const instId = this.safeString2(arg, 'instId', 'symbol');
|
|
2330
2375
|
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
2331
2376
|
const symbol = market['symbol'];
|
|
2332
2377
|
const messageHash = 'unsubscribe:trade:' + market['symbol'];
|
|
@@ -2443,7 +2488,7 @@ class bitget extends bitget$1["default"] {
|
|
|
2443
2488
|
// for now only unWatchOrderBook is supporteod
|
|
2444
2489
|
this.handleOrderBookUnSubscription(client, message);
|
|
2445
2490
|
}
|
|
2446
|
-
else if (channel === 'trade') {
|
|
2491
|
+
else if ((channel === 'trade') || (channel === 'publicTrade')) {
|
|
2447
2492
|
this.handleTradesUnSubscription(client, message);
|
|
2448
2493
|
}
|
|
2449
2494
|
else if (channel === 'ticker') {
|
|
@@ -445,13 +445,13 @@ class bybit extends bybit$1["default"] {
|
|
|
445
445
|
* @description unWatches a price ticker
|
|
446
446
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
|
|
447
447
|
* @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
|
|
448
|
-
* @param {string[]}
|
|
448
|
+
* @param {string[]} symbol unified symbol of the market to fetch the ticker for
|
|
449
449
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
450
450
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
451
451
|
*/
|
|
452
|
-
async unWatchTicker(
|
|
452
|
+
async unWatchTicker(symbol, params = {}) {
|
|
453
453
|
await this.loadMarkets();
|
|
454
|
-
return await this.unWatchTickers([
|
|
454
|
+
return await this.unWatchTickers([symbol], params);
|
|
455
455
|
}
|
|
456
456
|
handleTicker(client, message) {
|
|
457
457
|
//
|
|
@@ -31,6 +31,11 @@ class kucoin extends kucoin$1["default"] {
|
|
|
31
31
|
'watchOrderBookForSymbols': true,
|
|
32
32
|
'watchBalance': true,
|
|
33
33
|
'watchOHLCV': true,
|
|
34
|
+
'unWatchTicker': true,
|
|
35
|
+
'unWatchOHLCV': true,
|
|
36
|
+
'unWatchOrderBook': true,
|
|
37
|
+
'unWatchTrades': true,
|
|
38
|
+
'unWatchhTradesForSymbols': true,
|
|
34
39
|
},
|
|
35
40
|
'options': {
|
|
36
41
|
'tradesLimit': 1000,
|
|
@@ -138,6 +143,9 @@ class kucoin extends kucoin$1["default"] {
|
|
|
138
143
|
}
|
|
139
144
|
return await this.watch(url, messageHash, message, subscriptionHash, subscription);
|
|
140
145
|
}
|
|
146
|
+
async unSubscribe(url, messageHash, topic, subscriptionHash, params = {}, subscription = undefined) {
|
|
147
|
+
return await this.unSubscribeMultiple(url, [messageHash], topic, [subscriptionHash], params, subscription);
|
|
148
|
+
}
|
|
141
149
|
async subscribeMultiple(url, messageHashes, topic, subscriptionHashes, params = {}, subscription = undefined) {
|
|
142
150
|
const requestId = this.requestId().toString();
|
|
143
151
|
const request = {
|
|
@@ -196,6 +204,34 @@ class kucoin extends kucoin$1["default"] {
|
|
|
196
204
|
const messageHash = 'ticker:' + symbol;
|
|
197
205
|
return await this.subscribe(url, messageHash, topic, query);
|
|
198
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* @method
|
|
209
|
+
* @name kucoin#unWatchTicker
|
|
210
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
211
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/market-snapshot
|
|
212
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
213
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
214
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
215
|
+
*/
|
|
216
|
+
async unWatchTicker(symbol, params = {}) {
|
|
217
|
+
await this.loadMarkets();
|
|
218
|
+
const market = this.market(symbol);
|
|
219
|
+
symbol = market['symbol'];
|
|
220
|
+
const url = await this.negotiate(false);
|
|
221
|
+
let method = undefined;
|
|
222
|
+
[method, params] = this.handleOptionAndParams(params, 'watchTicker', 'method', '/market/snapshot');
|
|
223
|
+
const topic = method + ':' + market['id'];
|
|
224
|
+
const messageHash = 'unsubscribe:ticker:' + symbol;
|
|
225
|
+
const subMessageHash = 'ticker:' + symbol;
|
|
226
|
+
const subscription = {
|
|
227
|
+
'messageHashes': [messageHash],
|
|
228
|
+
'subMessageHashes': [subMessageHash],
|
|
229
|
+
'topic': 'trades',
|
|
230
|
+
'unsubscribe': true,
|
|
231
|
+
'symbols': [symbol],
|
|
232
|
+
};
|
|
233
|
+
return await this.unSubscribe(url, messageHash, topic, subMessageHash, params, subscription);
|
|
234
|
+
}
|
|
199
235
|
/**
|
|
200
236
|
* @method
|
|
201
237
|
* @name kucoin#watchTickers
|
|
@@ -436,6 +472,34 @@ class kucoin extends kucoin$1["default"] {
|
|
|
436
472
|
}
|
|
437
473
|
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
438
474
|
}
|
|
475
|
+
/**
|
|
476
|
+
* @method
|
|
477
|
+
* @name kucoin#unWatchOHLCV
|
|
478
|
+
* @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
479
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/klines
|
|
480
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
481
|
+
* @param {string} timeframe the length of time each candle represents
|
|
482
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
483
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
484
|
+
*/
|
|
485
|
+
async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
|
|
486
|
+
await this.loadMarkets();
|
|
487
|
+
const url = await this.negotiate(false);
|
|
488
|
+
const market = this.market(symbol);
|
|
489
|
+
symbol = market['symbol'];
|
|
490
|
+
const period = this.safeString(this.timeframes, timeframe, timeframe);
|
|
491
|
+
const topic = '/market/candles:' + market['id'] + '_' + period;
|
|
492
|
+
const messageHash = 'unsubscribe:candles:' + symbol + ':' + timeframe;
|
|
493
|
+
const subMessageHash = 'candles:' + symbol + ':' + timeframe;
|
|
494
|
+
const subscription = {
|
|
495
|
+
'messageHashes': [messageHash],
|
|
496
|
+
'subMessageHashes': [subMessageHash],
|
|
497
|
+
'topic': 'ohlcv',
|
|
498
|
+
'unsubscribe': true,
|
|
499
|
+
'symbols': [symbol],
|
|
500
|
+
};
|
|
501
|
+
return await this.unSubscribe(url, messageHash, topic, messageHash, params, subscription);
|
|
502
|
+
}
|
|
439
503
|
handleOHLCV(client, message) {
|
|
440
504
|
//
|
|
441
505
|
// {
|
package/dist/cjs/src/pro/mexc.js
CHANGED
|
@@ -176,7 +176,7 @@ class mexc extends mexc$1["default"] {
|
|
|
176
176
|
this.handleBidAsk(client, message);
|
|
177
177
|
const rawTicker = this.safeDictN(message, ['d', 'data', 'publicAggreBookTicker']);
|
|
178
178
|
const marketId = this.safeString2(message, 's', 'symbol');
|
|
179
|
-
const timestamp = this.safeInteger2(message, 't', '
|
|
179
|
+
const timestamp = this.safeInteger2(message, 't', 'sendTime');
|
|
180
180
|
const market = this.safeMarket(marketId);
|
|
181
181
|
const symbol = market['symbol'];
|
|
182
182
|
let ticker = undefined;
|
|
@@ -1532,7 +1532,7 @@ class mexc extends mexc$1["default"] {
|
|
|
1532
1532
|
// "ts": 1680059188190
|
|
1533
1533
|
// }
|
|
1534
1534
|
//
|
|
1535
|
-
const c = this.
|
|
1535
|
+
const c = this.safeString(message, 'c'); // do not add 'channel' here, this is especially for spot
|
|
1536
1536
|
const type = (c === undefined) ? 'swap' : 'spot';
|
|
1537
1537
|
const messageHash = 'balance:' + type;
|
|
1538
1538
|
const data = this.safeDictN(message, ['d', 'data', 'privateAccount']);
|
|
@@ -1547,7 +1547,11 @@ class mexc extends mexc$1["default"] {
|
|
|
1547
1547
|
const currencyId = this.safeStringN(data, ['a', 'currency', 'vcoinName']);
|
|
1548
1548
|
const code = this.safeCurrencyCode(currencyId);
|
|
1549
1549
|
const account = this.account();
|
|
1550
|
-
|
|
1550
|
+
const balanceAmount = this.safeString(data, 'balanceAmount');
|
|
1551
|
+
if (balanceAmount !== undefined) {
|
|
1552
|
+
account['free'] = balanceAmount;
|
|
1553
|
+
}
|
|
1554
|
+
account['total'] = this.safeStringN(data, ['f', 'availableBalance']);
|
|
1551
1555
|
account['used'] = this.safeStringN(data, ['l', 'frozenBalance', 'frozenAmount']);
|
|
1552
1556
|
this.balance[type][code] = account;
|
|
1553
1557
|
this.balance[type] = this.safeBalance(this.balance[type]);
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, RestrictedLocation, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.5.
|
|
7
|
+
declare const version = "4.5.2";
|
|
8
8
|
import alpaca from './src/alpaca.js';
|
|
9
9
|
import apex from './src/apex.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, RestrictedLocation, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.5.
|
|
41
|
+
const version = '4.5.2';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import alpaca from './src/alpaca.js';
|
|
@@ -461,6 +461,7 @@ export default class Exchange {
|
|
|
461
461
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
462
462
|
unWatchOrderBookForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
463
463
|
unWatchPositions(symbols?: Strings, params?: {}): Promise<any>;
|
|
464
|
+
unWatchTicker(symbol: string, params?: {}): Promise<any>;
|
|
464
465
|
fetchDepositAddresses(codes?: Strings, params?: {}): Promise<DepositAddress[]>;
|
|
465
466
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
466
467
|
fetchOrderBookWs(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
@@ -684,6 +685,7 @@ export default class Exchange {
|
|
|
684
685
|
parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
|
|
685
686
|
safeCurrency(currencyId: Str, currency?: Currency): CurrencyInterface;
|
|
686
687
|
safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
|
|
688
|
+
marketOrNull(symbol: string): MarketInterface;
|
|
687
689
|
checkRequiredCredentials(error?: boolean): boolean;
|
|
688
690
|
oath(): string;
|
|
689
691
|
fetchBalance(params?: {}): Promise<Balances>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -1145,6 +1145,7 @@ export default class Exchange {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
async close() {
|
|
1147
1147
|
// test by running ts/src/pro/test/base/test.close.ts
|
|
1148
|
+
await this.sleep(0); // allow other futures to run
|
|
1148
1149
|
const clients = Object.values(this.clients || {});
|
|
1149
1150
|
const closedClients = [];
|
|
1150
1151
|
for (let i = 0; i < clients.length; i++) {
|
|
@@ -1183,6 +1184,7 @@ export default class Exchange {
|
|
|
1183
1184
|
}
|
|
1184
1185
|
client.reject(new ExchangeError(this.id + ' nonce is behind the cache after ' + maxRetries.toString() + ' tries.'), messageHash);
|
|
1185
1186
|
delete this.clients[client.url];
|
|
1187
|
+
this.orderbooks[symbol] = this.orderBook(); // clear the orderbook and its cache - issue https://github.com/ccxt/ccxt/issues/26753
|
|
1186
1188
|
}
|
|
1187
1189
|
catch (e) {
|
|
1188
1190
|
client.reject(e, messageHash);
|
|
@@ -2194,6 +2196,9 @@ export default class Exchange {
|
|
|
2194
2196
|
async unWatchPositions(symbols = undefined, params = {}) {
|
|
2195
2197
|
throw new NotSupported(this.id + ' unWatchPositions() is not supported yet');
|
|
2196
2198
|
}
|
|
2199
|
+
async unWatchTicker(symbol, params = {}) {
|
|
2200
|
+
throw new NotSupported(this.id + ' unWatchTicker() is not supported yet');
|
|
2201
|
+
}
|
|
2197
2202
|
async fetchDepositAddresses(codes = undefined, params = {}) {
|
|
2198
2203
|
throw new NotSupported(this.id + ' fetchDepositAddresses() is not supported yet');
|
|
2199
2204
|
}
|
|
@@ -4683,6 +4688,12 @@ export default class Exchange {
|
|
|
4683
4688
|
}
|
|
4684
4689
|
return result;
|
|
4685
4690
|
}
|
|
4691
|
+
marketOrNull(symbol) {
|
|
4692
|
+
if (symbol === undefined) {
|
|
4693
|
+
return undefined;
|
|
4694
|
+
}
|
|
4695
|
+
return this.market(symbol);
|
|
4696
|
+
}
|
|
4686
4697
|
checkRequiredCredentials(error = true) {
|
|
4687
4698
|
/**
|
|
4688
4699
|
* @ignore
|
package/js/src/binance.js
CHANGED
|
@@ -6612,19 +6612,13 @@ export default class binance extends Exchange {
|
|
|
6612
6612
|
}
|
|
6613
6613
|
}
|
|
6614
6614
|
if (quantityIsRequired) {
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6615
|
+
const marketAmountPrecision = this.safeString(market['precision'], 'amount');
|
|
6616
|
+
const isPrecisionAvailable = (marketAmountPrecision !== undefined);
|
|
6617
|
+
if (isPrecisionAvailable) {
|
|
6618
|
+
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
6618
6619
|
}
|
|
6619
6620
|
else {
|
|
6620
|
-
|
|
6621
|
-
const isPrecisionAvailable = (marketAmountPrecision !== undefined);
|
|
6622
|
-
if (isPrecisionAvailable) {
|
|
6623
|
-
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
6624
|
-
}
|
|
6625
|
-
else {
|
|
6626
|
-
request['quantity'] = this.parseToNumeric(amount); // some options don't have the precision available
|
|
6627
|
-
}
|
|
6621
|
+
request['quantity'] = this.parseToNumeric(amount); // some options don't have the precision available
|
|
6628
6622
|
}
|
|
6629
6623
|
}
|
|
6630
6624
|
if (priceIsRequired && !isPriceMatch) {
|
package/js/src/bitget.js
CHANGED
|
@@ -7709,7 +7709,7 @@ export default class bitget extends Exchange {
|
|
|
7709
7709
|
// "requestTime": 1700802995406,
|
|
7710
7710
|
// "data": [
|
|
7711
7711
|
// {
|
|
7712
|
-
// "userId": "
|
|
7712
|
+
// "userId": "7264631751",
|
|
7713
7713
|
// "symbol": "BTCUSDT",
|
|
7714
7714
|
// "orderId": "1098394344925597696",
|
|
7715
7715
|
// "tradeId": "1098394344974925824",
|
package/js/src/coincatch.js
CHANGED
|
@@ -611,8 +611,8 @@ export default class coincatch extends Exchange {
|
|
|
611
611
|
for (let j = 0; j < networks.length; j++) {
|
|
612
612
|
const network = networks[j];
|
|
613
613
|
const networkId = this.safeString(network, 'chain');
|
|
614
|
-
const networkCode = this.
|
|
615
|
-
parsedNetworks[
|
|
614
|
+
const networkCode = this.networkIdToCode(networkId);
|
|
615
|
+
parsedNetworks[networkCode] = {
|
|
616
616
|
'id': networkId,
|
|
617
617
|
'network': networkCode,
|
|
618
618
|
'limits': {
|
package/js/src/gate.js
CHANGED
|
@@ -57,14 +57,24 @@ export default class gate extends Exchange {
|
|
|
57
57
|
},
|
|
58
58
|
'test': {
|
|
59
59
|
'public': {
|
|
60
|
-
'futures': 'https://
|
|
61
|
-
'delivery': 'https://
|
|
62
|
-
'options': 'https://
|
|
60
|
+
'futures': 'https://api-testnet.gateapi.io/api/v4',
|
|
61
|
+
'delivery': 'https://api-testnet.gateapi.io/api/v4',
|
|
62
|
+
'options': 'https://api-testnet.gateapi.io/api/v4',
|
|
63
|
+
'spot': 'https://api-testnet.gateapi.io/api/v4',
|
|
64
|
+
'wallet': 'https://api-testnet.gateapi.io/api/v4',
|
|
65
|
+
'margin': 'https://api-testnet.gateapi.io/api/v4',
|
|
66
|
+
'sub_accounts': 'https://api-testnet.gateapi.io/api/v4',
|
|
67
|
+
'account': 'https://api-testnet.gateapi.io/api/v4',
|
|
63
68
|
},
|
|
64
69
|
'private': {
|
|
65
|
-
'futures': 'https://
|
|
66
|
-
'delivery': 'https://
|
|
67
|
-
'options': 'https://
|
|
70
|
+
'futures': 'https://api-testnet.gateapi.io/api/v4',
|
|
71
|
+
'delivery': 'https://api-testnet.gateapi.io/api/v4',
|
|
72
|
+
'options': 'https://api-testnet.gateapi.io/api/v4',
|
|
73
|
+
'spot': 'https://api-testnet.gateapi.io/api/v4',
|
|
74
|
+
'wallet': 'https://api-testnet.gateapi.io/api/v4',
|
|
75
|
+
'margin': 'https://api-testnet.gateapi.io/api/v4',
|
|
76
|
+
'sub_accounts': 'https://api-testnet.gateapi.io/api/v4',
|
|
77
|
+
'account': 'https://api-testnet.gateapi.io/api/v4',
|
|
68
78
|
},
|
|
69
79
|
},
|
|
70
80
|
'referral': {
|
|
@@ -1231,16 +1241,15 @@ export default class gate extends Exchange {
|
|
|
1231
1241
|
await this.loadUnifiedStatus();
|
|
1232
1242
|
}
|
|
1233
1243
|
const rawPromises = [];
|
|
1234
|
-
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
1235
1244
|
const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets');
|
|
1236
1245
|
const types = this.safeList(fetchMarketsOptions, 'types', ['spot', 'swap', 'future', 'option']);
|
|
1237
1246
|
for (let i = 0; i < types.length; i++) {
|
|
1238
1247
|
const marketType = types[i];
|
|
1239
1248
|
if (marketType === 'spot') {
|
|
1240
|
-
if (!sandboxMode) {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1249
|
+
// if (!sandboxMode) {
|
|
1250
|
+
// gate doesn't have a sandbox for spot markets
|
|
1251
|
+
rawPromises.push(this.fetchSpotMarkets(params));
|
|
1252
|
+
// }
|
|
1244
1253
|
}
|
|
1245
1254
|
else if (marketType === 'swap') {
|
|
1246
1255
|
rawPromises.push(this.fetchSwapMarkets(params));
|
|
@@ -1371,7 +1380,10 @@ export default class gate extends Exchange {
|
|
|
1371
1380
|
}
|
|
1372
1381
|
async fetchSwapMarkets(params = {}) {
|
|
1373
1382
|
const result = [];
|
|
1374
|
-
|
|
1383
|
+
let swapSettlementCurrencies = this.getSettlementCurrencies('swap', 'fetchMarkets');
|
|
1384
|
+
if (this.options['sandboxMode']) {
|
|
1385
|
+
swapSettlementCurrencies = ['usdt']; // gate sandbox only has usdt-margined swaps
|
|
1386
|
+
}
|
|
1375
1387
|
for (let c = 0; c < swapSettlementCurrencies.length; c++) {
|
|
1376
1388
|
const settleId = swapSettlementCurrencies[c];
|
|
1377
1389
|
const request = {
|
|
@@ -1386,6 +1398,9 @@ export default class gate extends Exchange {
|
|
|
1386
1398
|
return result;
|
|
1387
1399
|
}
|
|
1388
1400
|
async fetchFutureMarkets(params = {}) {
|
|
1401
|
+
if (this.options['sandboxMode']) {
|
|
1402
|
+
return []; // right now sandbox does not have inverse swaps
|
|
1403
|
+
}
|
|
1389
1404
|
const result = [];
|
|
1390
1405
|
const futureSettlementCurrencies = this.getSettlementCurrencies('future', 'fetchMarkets');
|
|
1391
1406
|
for (let c = 0; c < futureSettlementCurrencies.length; c++) {
|
package/js/src/gemini.js
CHANGED
|
@@ -694,8 +694,8 @@ export default class gemini extends Exchange {
|
|
|
694
694
|
//
|
|
695
695
|
// [
|
|
696
696
|
// 'BTCUSD', // symbol
|
|
697
|
-
// 2, // priceTickDecimalPlaces
|
|
698
|
-
// 8, // quantityTickDecimalPlaces
|
|
697
|
+
// 2, // tick precision (priceTickDecimalPlaces)
|
|
698
|
+
// 8, // amount precision (quantityTickDecimalPlaces)
|
|
699
699
|
// '0.00001', // quantityMinimum
|
|
700
700
|
// 10, // quantityRoundDecimalPlaces
|
|
701
701
|
// true // minimumsAreInclusive
|
|
@@ -714,7 +714,7 @@ export default class gemini extends Exchange {
|
|
|
714
714
|
// "wrap_enabled": false
|
|
715
715
|
// "product_type": "swap", // only in perps
|
|
716
716
|
// "contract_type": "linear", // only in perps
|
|
717
|
-
// "contract_price_currency": "GUSD"
|
|
717
|
+
// "contract_price_currency": "GUSD"
|
|
718
718
|
// }
|
|
719
719
|
//
|
|
720
720
|
let marketId = undefined;
|
package/js/src/htx.js
CHANGED
|
@@ -664,7 +664,7 @@ export default class htx extends Exchange {
|
|
|
664
664
|
'api/v1/contract_batchorder': 1,
|
|
665
665
|
'api/v1/contract_cancel': 1,
|
|
666
666
|
'api/v1/contract_cancelall': 1,
|
|
667
|
-
'api/v1/contract_switch_lever_rate':
|
|
667
|
+
'api/v1/contract_switch_lever_rate': 30,
|
|
668
668
|
'api/v1/lightning_close_position': 1,
|
|
669
669
|
'api/v1/contract_order_info': 1,
|
|
670
670
|
'api/v1/contract_order_detail': 1,
|
|
@@ -723,7 +723,7 @@ export default class htx extends Exchange {
|
|
|
723
723
|
'swap-api/v1/swap_cancel': 1,
|
|
724
724
|
'swap-api/v1/swap_cancelall': 1,
|
|
725
725
|
'swap-api/v1/swap_lightning_close_position': 1,
|
|
726
|
-
'swap-api/v1/swap_switch_lever_rate':
|
|
726
|
+
'swap-api/v1/swap_switch_lever_rate': 30,
|
|
727
727
|
'swap-api/v1/swap_order_info': 1,
|
|
728
728
|
'swap-api/v1/swap_order_detail': 1,
|
|
729
729
|
'swap-api/v1/swap_openorders': 1,
|
|
@@ -797,8 +797,8 @@ export default class htx extends Exchange {
|
|
|
797
797
|
'linear-swap-api/v1/swap_cross_cancel': 1,
|
|
798
798
|
'linear-swap-api/v1/swap_cancelall': 1,
|
|
799
799
|
'linear-swap-api/v1/swap_cross_cancelall': 1,
|
|
800
|
-
'linear-swap-api/v1/swap_switch_lever_rate':
|
|
801
|
-
'linear-swap-api/v1/swap_cross_switch_lever_rate':
|
|
800
|
+
'linear-swap-api/v1/swap_switch_lever_rate': 30,
|
|
801
|
+
'linear-swap-api/v1/swap_cross_switch_lever_rate': 30,
|
|
802
802
|
'linear-swap-api/v1/swap_lightning_close_position': 1,
|
|
803
803
|
'linear-swap-api/v1/swap_cross_lightning_close_position': 1,
|
|
804
804
|
'linear-swap-api/v1/swap_order_info': 1,
|