ccxt 4.1.100 → 4.2.1
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.js +150 -92
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bitget.js +11 -6
- package/dist/cjs/src/cex.js +6 -5
- package/dist/cjs/src/deribit.js +38 -26
- package/dist/cjs/src/kucoinfutures.js +9 -4
- package/dist/cjs/src/pro/bitmart.js +85 -50
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/bitget.js +11 -6
- package/js/src/cex.js +6 -5
- package/js/src/deribit.js +38 -26
- package/js/src/kucoinfutures.js +9 -4
- package/js/src/pro/bitmart.js +85 -50
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +1 -1
- package/skip-tests.json +2 -1
package/js/src/deribit.js
CHANGED
|
@@ -1320,14 +1320,19 @@ export default class deribit extends Exchange {
|
|
|
1320
1320
|
'instrument_name': market['id'],
|
|
1321
1321
|
'include_old': true,
|
|
1322
1322
|
};
|
|
1323
|
-
const method = (since === undefined) ? 'publicGetGetLastTradesByInstrument' : 'publicGetGetLastTradesByInstrumentAndTime';
|
|
1324
1323
|
if (since !== undefined) {
|
|
1325
1324
|
request['start_timestamp'] = since;
|
|
1326
1325
|
}
|
|
1327
1326
|
if (limit !== undefined) {
|
|
1328
1327
|
request['count'] = Math.min(limit, 1000); // default 10
|
|
1329
1328
|
}
|
|
1330
|
-
|
|
1329
|
+
let response = undefined;
|
|
1330
|
+
if (since === undefined) {
|
|
1331
|
+
response = await this.publicGetGetLastTradesByInstrument(this.extend(request, params));
|
|
1332
|
+
}
|
|
1333
|
+
else {
|
|
1334
|
+
response = await this.publicGetGetLastTradesByInstrumentAndTime(this.extend(request, params));
|
|
1335
|
+
}
|
|
1331
1336
|
//
|
|
1332
1337
|
// {
|
|
1333
1338
|
// "jsonrpc":"2.0",
|
|
@@ -1824,9 +1829,14 @@ export default class deribit extends Exchange {
|
|
|
1824
1829
|
request['time_in_force'] = 'fill_or_kill';
|
|
1825
1830
|
}
|
|
1826
1831
|
}
|
|
1827
|
-
const method = 'privateGet' + this.capitalize(side);
|
|
1828
1832
|
params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly']);
|
|
1829
|
-
|
|
1833
|
+
let response = undefined;
|
|
1834
|
+
if (this.capitalize(side) === 'Buy') {
|
|
1835
|
+
response = await this.privateGetBuy(this.extend(request, params));
|
|
1836
|
+
}
|
|
1837
|
+
else {
|
|
1838
|
+
response = await this.privateGetSell(this.extend(request, params));
|
|
1839
|
+
}
|
|
1830
1840
|
//
|
|
1831
1841
|
// {
|
|
1832
1842
|
// "jsonrpc": "2.0",
|
|
@@ -1941,16 +1951,15 @@ export default class deribit extends Exchange {
|
|
|
1941
1951
|
*/
|
|
1942
1952
|
await this.loadMarkets();
|
|
1943
1953
|
const request = {};
|
|
1944
|
-
let
|
|
1954
|
+
let response = undefined;
|
|
1945
1955
|
if (symbol === undefined) {
|
|
1946
|
-
|
|
1956
|
+
response = await this.privateGetCancelAll(this.extend(request, params));
|
|
1947
1957
|
}
|
|
1948
1958
|
else {
|
|
1949
|
-
method = 'privateGetCancelAllByInstrument';
|
|
1950
1959
|
const market = this.market(symbol);
|
|
1951
1960
|
request['instrument_name'] = market['id'];
|
|
1961
|
+
response = await this.privateGetCancelAllByInstrument(this.extend(request, params));
|
|
1952
1962
|
}
|
|
1953
|
-
const response = await this[method](this.extend(request, params));
|
|
1954
1963
|
return response;
|
|
1955
1964
|
}
|
|
1956
1965
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -1967,19 +1976,18 @@ export default class deribit extends Exchange {
|
|
|
1967
1976
|
await this.loadMarkets();
|
|
1968
1977
|
const request = {};
|
|
1969
1978
|
let market = undefined;
|
|
1970
|
-
let
|
|
1979
|
+
let response = undefined;
|
|
1971
1980
|
if (symbol === undefined) {
|
|
1972
1981
|
const code = this.codeFromOptions('fetchOpenOrders', params);
|
|
1973
1982
|
const currency = this.currency(code);
|
|
1974
1983
|
request['currency'] = currency['id'];
|
|
1975
|
-
|
|
1984
|
+
response = await this.privateGetGetOpenOrdersByCurrency(this.extend(request, params));
|
|
1976
1985
|
}
|
|
1977
1986
|
else {
|
|
1978
1987
|
market = this.market(symbol);
|
|
1979
1988
|
request['instrument_name'] = market['id'];
|
|
1980
|
-
|
|
1989
|
+
response = await this.privateGetGetOpenOrdersByInstrument(this.extend(request, params));
|
|
1981
1990
|
}
|
|
1982
|
-
const response = await this[method](this.extend(request, params));
|
|
1983
1991
|
const result = this.safeValue(response, 'result', []);
|
|
1984
1992
|
return this.parseOrders(result, market, since, limit);
|
|
1985
1993
|
}
|
|
@@ -1997,19 +2005,18 @@ export default class deribit extends Exchange {
|
|
|
1997
2005
|
await this.loadMarkets();
|
|
1998
2006
|
const request = {};
|
|
1999
2007
|
let market = undefined;
|
|
2000
|
-
let
|
|
2008
|
+
let response = undefined;
|
|
2001
2009
|
if (symbol === undefined) {
|
|
2002
2010
|
const code = this.codeFromOptions('fetchClosedOrders', params);
|
|
2003
2011
|
const currency = this.currency(code);
|
|
2004
2012
|
request['currency'] = currency['id'];
|
|
2005
|
-
|
|
2013
|
+
response = await this.privateGetGetOrderHistoryByCurrency(this.extend(request, params));
|
|
2006
2014
|
}
|
|
2007
2015
|
else {
|
|
2008
2016
|
market = this.market(symbol);
|
|
2009
2017
|
request['instrument_name'] = market['id'];
|
|
2010
|
-
|
|
2018
|
+
response = await this.privateGetGetOrderHistoryByInstrument(this.extend(request, params));
|
|
2011
2019
|
}
|
|
2012
|
-
const response = await this[method](this.extend(request, params));
|
|
2013
2020
|
const result = this.safeValue(response, 'result', []);
|
|
2014
2021
|
return this.parseOrders(result, market, since, limit);
|
|
2015
2022
|
}
|
|
@@ -2082,34 +2089,33 @@ export default class deribit extends Exchange {
|
|
|
2082
2089
|
'include_old': true,
|
|
2083
2090
|
};
|
|
2084
2091
|
let market = undefined;
|
|
2085
|
-
|
|
2092
|
+
if (limit !== undefined) {
|
|
2093
|
+
request['count'] = limit; // default 10
|
|
2094
|
+
}
|
|
2095
|
+
let response = undefined;
|
|
2086
2096
|
if (symbol === undefined) {
|
|
2087
2097
|
const code = this.codeFromOptions('fetchMyTrades', params);
|
|
2088
2098
|
const currency = this.currency(code);
|
|
2089
2099
|
request['currency'] = currency['id'];
|
|
2090
2100
|
if (since === undefined) {
|
|
2091
|
-
|
|
2101
|
+
response = await this.privateGetGetUserTradesByCurrency(this.extend(request, params));
|
|
2092
2102
|
}
|
|
2093
2103
|
else {
|
|
2094
|
-
method = 'privateGetGetUserTradesByCurrencyAndTime';
|
|
2095
2104
|
request['start_timestamp'] = since;
|
|
2105
|
+
response = await this.privateGetGetUserTradesByCurrencyAndTime(this.extend(request, params));
|
|
2096
2106
|
}
|
|
2097
2107
|
}
|
|
2098
2108
|
else {
|
|
2099
2109
|
market = this.market(symbol);
|
|
2100
2110
|
request['instrument_name'] = market['id'];
|
|
2101
2111
|
if (since === undefined) {
|
|
2102
|
-
|
|
2112
|
+
response = await this.privateGetGetUserTradesByInstrument(this.extend(request, params));
|
|
2103
2113
|
}
|
|
2104
2114
|
else {
|
|
2105
|
-
method = 'privateGetGetUserTradesByInstrumentAndTime';
|
|
2106
2115
|
request['start_timestamp'] = since;
|
|
2116
|
+
response = await this.privateGetGetUserTradesByInstrumentAndTime(this.extend(request, params));
|
|
2107
2117
|
}
|
|
2108
2118
|
}
|
|
2109
|
-
if (limit !== undefined) {
|
|
2110
|
-
request['count'] = limit; // default 10
|
|
2111
|
-
}
|
|
2112
|
-
const response = await this[method](this.extend(request, params));
|
|
2113
2119
|
//
|
|
2114
2120
|
// {
|
|
2115
2121
|
// "jsonrpc": "2.0",
|
|
@@ -2643,7 +2649,13 @@ export default class deribit extends Exchange {
|
|
|
2643
2649
|
const transferOptions = this.safeValue(this.options, 'transfer', {});
|
|
2644
2650
|
method = this.safeString(transferOptions, 'method', 'privateGetSubmitTransferToSubaccount');
|
|
2645
2651
|
}
|
|
2646
|
-
|
|
2652
|
+
let response = undefined;
|
|
2653
|
+
if (method === 'privateGetSubmitTransferToUser') {
|
|
2654
|
+
response = await this.privateGetSubmitTransferToUser(this.extend(request, params));
|
|
2655
|
+
}
|
|
2656
|
+
else {
|
|
2657
|
+
response = await this.privateGetSubmitTransferToSubaccount(this.extend(request, params));
|
|
2658
|
+
}
|
|
2647
2659
|
//
|
|
2648
2660
|
// {
|
|
2649
2661
|
// "jsonrpc": "2.0",
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -1735,14 +1735,18 @@ export default class kucoinfutures extends kucoin {
|
|
|
1735
1735
|
const cancelExist = this.safeValue(order, 'cancelExist', false);
|
|
1736
1736
|
let status = isActive ? 'open' : 'closed';
|
|
1737
1737
|
status = cancelExist ? 'canceled' : status;
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1738
|
+
let fee = undefined;
|
|
1739
|
+
if (feeCost !== undefined) {
|
|
1740
|
+
fee = {
|
|
1741
|
+
'currency': feeCurrency,
|
|
1742
|
+
'cost': feeCost,
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1742
1745
|
const clientOrderId = this.safeString(order, 'clientOid');
|
|
1743
1746
|
const timeInForce = this.safeString(order, 'timeInForce');
|
|
1744
1747
|
const stopPrice = this.safeNumber(order, 'stopPrice');
|
|
1745
1748
|
const postOnly = this.safeValue(order, 'postOnly');
|
|
1749
|
+
const reduceOnly = this.safeValue(order, 'reduceOnly');
|
|
1746
1750
|
const lastUpdateTimestamp = this.safeInteger(order, 'updatedAt');
|
|
1747
1751
|
return this.safeOrder({
|
|
1748
1752
|
'id': orderId,
|
|
@@ -1751,6 +1755,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
1751
1755
|
'type': type,
|
|
1752
1756
|
'timeInForce': timeInForce,
|
|
1753
1757
|
'postOnly': postOnly,
|
|
1758
|
+
'reduceOnly': reduceOnly,
|
|
1754
1759
|
'side': side,
|
|
1755
1760
|
'amount': amount,
|
|
1756
1761
|
'price': price,
|
package/js/src/pro/bitmart.js
CHANGED
|
@@ -54,7 +54,7 @@ export default class bitmart extends bitmartRest {
|
|
|
54
54
|
'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
|
|
55
55
|
},
|
|
56
56
|
'watchOrderBook': {
|
|
57
|
-
'depth': '
|
|
57
|
+
'depth': 'depth/increase100', // depth/increase100, depth5, depth20, depth50
|
|
58
58
|
},
|
|
59
59
|
'ws': {
|
|
60
60
|
'inflate': true,
|
|
@@ -1072,6 +1072,7 @@ export default class bitmart extends bitmartRest {
|
|
|
1072
1072
|
* @method
|
|
1073
1073
|
* @name bitmart#watchOrderBook
|
|
1074
1074
|
* @see https://developer-pro.bitmart.com/en/spot/#public-depth-all-channel
|
|
1075
|
+
* @see https://developer-pro.bitmart.com/en/spot/#public-depth-increase-channel
|
|
1075
1076
|
* @see https://developer-pro.bitmart.com/en/futures/#public-depth-channel
|
|
1076
1077
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1077
1078
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
@@ -1081,11 +1082,14 @@ export default class bitmart extends bitmartRest {
|
|
|
1081
1082
|
*/
|
|
1082
1083
|
await this.loadMarkets();
|
|
1083
1084
|
const options = this.safeValue(this.options, 'watchOrderBook', {});
|
|
1084
|
-
|
|
1085
|
+
let depth = this.safeString(options, 'depth', 'depth/increase100');
|
|
1085
1086
|
symbol = this.symbol(symbol);
|
|
1086
1087
|
const market = this.market(symbol);
|
|
1087
1088
|
let type = 'spot';
|
|
1088
1089
|
[type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
|
|
1090
|
+
if (type === 'swap' && depth === 'depth/increase100') {
|
|
1091
|
+
depth = 'depth50';
|
|
1092
|
+
}
|
|
1089
1093
|
const orderbook = await this.subscribe(depth, symbol, type, params);
|
|
1090
1094
|
return orderbook.limit();
|
|
1091
1095
|
}
|
|
@@ -1134,46 +1138,72 @@ export default class bitmart extends bitmartRest {
|
|
|
1134
1138
|
}
|
|
1135
1139
|
handleOrderBook(client, message) {
|
|
1136
1140
|
//
|
|
1137
|
-
// spot
|
|
1138
|
-
//
|
|
1139
|
-
//
|
|
1140
|
-
//
|
|
1141
|
-
//
|
|
1142
|
-
//
|
|
1143
|
-
//
|
|
1144
|
-
//
|
|
1145
|
-
//
|
|
1146
|
-
//
|
|
1147
|
-
//
|
|
1148
|
-
//
|
|
1149
|
-
//
|
|
1141
|
+
// spot depth-all
|
|
1142
|
+
// {
|
|
1143
|
+
// "data": [
|
|
1144
|
+
// {
|
|
1145
|
+
// "asks": [
|
|
1146
|
+
// [ '46828.38', "0.21847" ],
|
|
1147
|
+
// [ '46830.68', "0.08232" ],
|
|
1148
|
+
// ...
|
|
1149
|
+
// ],
|
|
1150
|
+
// "bids": [
|
|
1151
|
+
// [ '46820.78', "0.00444" ],
|
|
1152
|
+
// [ '46814.33', "0.00234" ],
|
|
1153
|
+
// ...
|
|
1154
|
+
// ],
|
|
1155
|
+
// "ms_t": 1631044962431,
|
|
1156
|
+
// "symbol": "BTC_USDT"
|
|
1157
|
+
// }
|
|
1158
|
+
// ],
|
|
1159
|
+
// "table": "spot/depth5"
|
|
1160
|
+
// }
|
|
1161
|
+
// spot increse depth snapshot
|
|
1162
|
+
// {
|
|
1163
|
+
// "data":[
|
|
1164
|
+
// {
|
|
1165
|
+
// "asks":[
|
|
1166
|
+
// [
|
|
1167
|
+
// "43652.52",
|
|
1168
|
+
// "0.02039"
|
|
1150
1169
|
// ],
|
|
1151
|
-
//
|
|
1152
|
-
//
|
|
1153
|
-
//
|
|
1154
|
-
//
|
|
1155
|
-
//
|
|
1156
|
-
//
|
|
1170
|
+
// ...
|
|
1171
|
+
// ],
|
|
1172
|
+
// "bids":[
|
|
1173
|
+
// [
|
|
1174
|
+
// "43652.51",
|
|
1175
|
+
// "0.00500"
|
|
1176
|
+
// ],
|
|
1177
|
+
// ...
|
|
1178
|
+
// ],
|
|
1179
|
+
// "ms_t":1703376836487,
|
|
1180
|
+
// "symbol":"BTC_USDT",
|
|
1181
|
+
// "type":"snapshot", // or update
|
|
1182
|
+
// "version":2141731
|
|
1183
|
+
// }
|
|
1184
|
+
// ],
|
|
1185
|
+
// "table":"spot/depth/increase100"
|
|
1186
|
+
// }
|
|
1157
1187
|
// swap
|
|
1158
|
-
//
|
|
1159
|
-
//
|
|
1160
|
-
//
|
|
1161
|
-
//
|
|
1162
|
-
//
|
|
1163
|
-
//
|
|
1164
|
-
//
|
|
1165
|
-
//
|
|
1166
|
-
//
|
|
1167
|
-
//
|
|
1168
|
-
//
|
|
1169
|
-
//
|
|
1170
|
-
//
|
|
1171
|
-
//
|
|
1172
|
-
//
|
|
1173
|
-
//
|
|
1174
|
-
//
|
|
1175
|
-
//
|
|
1176
|
-
//
|
|
1188
|
+
// {
|
|
1189
|
+
// "group":"futures/depth50:BTCUSDT",
|
|
1190
|
+
// "data":{
|
|
1191
|
+
// "symbol":"BTCUSDT",
|
|
1192
|
+
// "way":1,
|
|
1193
|
+
// "depths":[
|
|
1194
|
+
// {
|
|
1195
|
+
// "price":"39509.8",
|
|
1196
|
+
// "vol":"2379"
|
|
1197
|
+
// },
|
|
1198
|
+
// {
|
|
1199
|
+
// "price":"39509.6",
|
|
1200
|
+
// "vol":"6815"
|
|
1201
|
+
// },
|
|
1202
|
+
// ...
|
|
1203
|
+
// ],
|
|
1204
|
+
// "ms_t":1701566021194
|
|
1205
|
+
// }
|
|
1206
|
+
// }
|
|
1177
1207
|
//
|
|
1178
1208
|
const data = this.safeValue(message, 'data');
|
|
1179
1209
|
if (data === undefined) {
|
|
@@ -1182,12 +1212,16 @@ export default class bitmart extends bitmartRest {
|
|
|
1182
1212
|
const depths = this.safeValue(data, 'depths');
|
|
1183
1213
|
const isSpot = (depths === undefined);
|
|
1184
1214
|
const table = this.safeString2(message, 'table', 'group');
|
|
1185
|
-
|
|
1186
|
-
const
|
|
1187
|
-
let
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1215
|
+
// find limit subscribed to
|
|
1216
|
+
const limitsToCheck = ['100', '50', '20', '10', '5'];
|
|
1217
|
+
let limit = 0;
|
|
1218
|
+
for (let i = 0; i < limitsToCheck.length; i++) {
|
|
1219
|
+
const limitString = limitsToCheck[i];
|
|
1220
|
+
if (table.indexOf(limitString) >= 0) {
|
|
1221
|
+
limit = this.parseToInt(limitString);
|
|
1222
|
+
break;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1191
1225
|
if (isSpot) {
|
|
1192
1226
|
for (let i = 0; i < data.length; i++) {
|
|
1193
1227
|
const update = data[i];
|
|
@@ -1199,7 +1233,10 @@ export default class bitmart extends bitmartRest {
|
|
|
1199
1233
|
orderbook['symbol'] = symbol;
|
|
1200
1234
|
this.orderbooks[symbol] = orderbook;
|
|
1201
1235
|
}
|
|
1202
|
-
|
|
1236
|
+
const type = this.safeValue(update, 'type');
|
|
1237
|
+
if ((type === 'snapshot') || (!(table.indexOf('increase') >= 0))) {
|
|
1238
|
+
orderbook.reset({});
|
|
1239
|
+
}
|
|
1203
1240
|
this.handleOrderBookMessage(client, update, orderbook);
|
|
1204
1241
|
const timestamp = this.safeInteger(update, 'ms_t');
|
|
1205
1242
|
orderbook['timestamp'] = timestamp;
|
|
@@ -1391,9 +1428,7 @@ export default class bitmart extends bitmartRest {
|
|
|
1391
1428
|
}
|
|
1392
1429
|
else {
|
|
1393
1430
|
const methods = {
|
|
1394
|
-
'
|
|
1395
|
-
'depth20': this.handleOrderBook,
|
|
1396
|
-
'depth50': this.handleOrderBook,
|
|
1431
|
+
'depth': this.handleOrderBook,
|
|
1397
1432
|
'ticker': this.handleTicker,
|
|
1398
1433
|
'trade': this.handleTrade,
|
|
1399
1434
|
'kline': this.handleOHLCV,
|
|
@@ -15,7 +15,7 @@ export declare class BigInteger {
|
|
|
15
15
|
protected intValue(): number;
|
|
16
16
|
protected byteValue(): number;
|
|
17
17
|
protected shortValue(): number;
|
|
18
|
-
protected signum():
|
|
18
|
+
protected signum(): 0 | 1 | -1;
|
|
19
19
|
toByteArray(): number[];
|
|
20
20
|
protected equals(a: BigInteger): boolean;
|
|
21
21
|
protected min(a: BigInteger): BigInteger;
|
package/package.json
CHANGED
package/skip-tests.json
CHANGED
|
@@ -712,7 +712,8 @@
|
|
|
712
712
|
"skipMethods": {
|
|
713
713
|
"proxies": "probably they do not permit our proxy location",
|
|
714
714
|
"loadMarkets": {
|
|
715
|
-
"active":"is undefined"
|
|
715
|
+
"active":"is undefined",
|
|
716
|
+
"currencyIdAndCode": "messes codes"
|
|
716
717
|
},
|
|
717
718
|
"fetchOHLCV": "unexpected issue",
|
|
718
719
|
"fetchCurrencies": {
|