ccxt 4.1.45 → 4.1.47
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 +1692 -194
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +14 -3
- package/dist/cjs/src/base/ws/Cache.js +50 -0
- package/dist/cjs/src/binance.js +4 -0
- package/dist/cjs/src/bitmart.js +2 -2
- package/dist/cjs/src/bitvavo.js +6 -5
- package/dist/cjs/src/bybit.js +84 -132
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/gate.js +3 -1
- package/dist/cjs/src/hitbtc.js +79 -1
- package/dist/cjs/src/huobi.js +1 -2
- package/dist/cjs/src/krakenfutures.js +13 -3
- package/dist/cjs/src/okx.js +19 -2
- package/dist/cjs/src/pro/binance.js +203 -1
- package/dist/cjs/src/pro/bitget.js +181 -0
- package/dist/cjs/src/pro/bybit.js +154 -10
- package/dist/cjs/src/pro/cryptocom.js +131 -1
- package/dist/cjs/src/pro/gate.js +161 -0
- package/dist/cjs/src/pro/huobi.js +128 -4
- package/dist/cjs/src/pro/krakenfutures.js +129 -0
- package/dist/cjs/src/pro/kucoinfutures.js +182 -0
- package/dist/cjs/src/pro/okx.js +121 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +4 -0
- package/js/src/abstract/binancecoinm.d.ts +4 -0
- package/js/src/abstract/binanceus.d.ts +4 -0
- package/js/src/abstract/binanceusdm.d.ts +4 -0
- package/js/src/ascendex.d.ts +3 -3
- package/js/src/base/Exchange.d.ts +6 -2
- package/js/src/base/Exchange.js +14 -3
- package/js/src/base/types.d.ts +5 -0
- package/js/src/base/ws/Cache.d.ts +5 -1
- package/js/src/base/ws/Cache.js +50 -1
- package/js/src/bigone.d.ts +2 -2
- package/js/src/binance.d.ts +2 -2
- package/js/src/binance.js +4 -0
- package/js/src/bingx.d.ts +2 -2
- package/js/src/bitbns.d.ts +2 -2
- package/js/src/bitfinex.d.ts +3 -3
- package/js/src/bitfinex2.d.ts +3 -3
- package/js/src/bitflyer.d.ts +2 -2
- package/js/src/bitget.d.ts +2 -2
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +2 -2
- package/js/src/bitmex.d.ts +1 -1
- package/js/src/bitopro.d.ts +2 -2
- package/js/src/bitpanda.d.ts +2 -2
- package/js/src/bitrue.d.ts +2 -2
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitstamp.d.ts +2 -2
- package/js/src/bittrex.d.ts +4 -4
- package/js/src/bitvavo.d.ts +2 -2
- package/js/src/bitvavo.js +6 -5
- package/js/src/blockchaincom.d.ts +4 -4
- package/js/src/btcalpha.d.ts +2 -2
- package/js/src/btcmarkets.d.ts +3 -3
- package/js/src/bybit.d.ts +2 -4
- package/js/src/bybit.js +84 -132
- package/js/src/coinbase.d.ts +5 -5
- package/js/src/coinbasepro.d.ts +3 -3
- package/js/src/coincheck.d.ts +2 -2
- package/js/src/coinex.d.ts +8 -8
- package/js/src/coinfalcon.d.ts +2 -2
- package/js/src/coinlist.d.ts +1 -1
- package/js/src/coinmate.d.ts +1 -1
- package/js/src/coinsph.d.ts +2 -2
- package/js/src/cryptocom.d.ts +2 -2
- package/js/src/cryptocom.js +1 -1
- package/js/src/currencycom.d.ts +6 -6
- package/js/src/deribit.d.ts +2 -2
- package/js/src/digifinex.d.ts +2 -2
- package/js/src/exmo.d.ts +3 -3
- package/js/src/gate.d.ts +2 -2
- package/js/src/gate.js +3 -1
- package/js/src/gemini.d.ts +1 -1
- package/js/src/hitbtc.d.ts +5 -4
- package/js/src/hitbtc.js +79 -1
- package/js/src/hollaex.d.ts +2 -2
- package/js/src/huobi.d.ts +2 -2
- package/js/src/huobi.js +1 -2
- package/js/src/huobijp.d.ts +2 -2
- package/js/src/idex.d.ts +2 -2
- package/js/src/indodax.d.ts +1 -1
- package/js/src/kraken.d.ts +2 -2
- package/js/src/krakenfutures.js +14 -4
- package/js/src/kucoin.d.ts +2 -2
- package/js/src/kucoinfutures.d.ts +3 -3
- package/js/src/kuna.d.ts +2 -2
- package/js/src/latoken.d.ts +2 -2
- package/js/src/lbank2.d.ts +2 -2
- package/js/src/lykke.d.ts +1 -1
- package/js/src/mexc.d.ts +2 -2
- package/js/src/ndax.d.ts +2 -2
- package/js/src/novadax.d.ts +3 -3
- package/js/src/okcoin.d.ts +8 -8
- package/js/src/okx.d.ts +7 -7
- package/js/src/okx.js +19 -2
- package/js/src/phemex.d.ts +6 -6
- package/js/src/poloniex.d.ts +3 -3
- package/js/src/pro/binance.d.ts +6 -0
- package/js/src/pro/binance.js +204 -2
- package/js/src/pro/bitget.d.ts +3 -0
- package/js/src/pro/bitget.js +182 -1
- package/js/src/pro/bybit.d.ts +5 -1
- package/js/src/pro/bybit.js +156 -12
- package/js/src/pro/cryptocom.d.ts +4 -0
- package/js/src/pro/cryptocom.js +132 -2
- package/js/src/pro/gate.d.ts +5 -0
- package/js/src/pro/gate.js +162 -1
- package/js/src/pro/huobi.d.ts +2 -0
- package/js/src/pro/huobi.js +129 -5
- package/js/src/pro/krakenfutures.d.ts +3 -0
- package/js/src/pro/krakenfutures.js +129 -0
- package/js/src/pro/kucoinfutures.d.ts +5 -0
- package/js/src/pro/kucoinfutures.js +182 -0
- package/js/src/pro/okx.d.ts +2 -0
- package/js/src/pro/okx.js +123 -2
- package/js/src/probit.d.ts +2 -2
- package/js/src/timex.d.ts +2 -2
- package/js/src/tokocrypto.d.ts +5 -5
- package/js/src/upbit.d.ts +2 -2
- package/js/src/wavesexchange.d.ts +2 -2
- package/js/src/whitebit.d.ts +1 -1
- package/js/src/woo.d.ts +3 -3
- package/package.json +1 -1
- package/skip-tests.json +8 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -181,7 +181,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
181
181
|
|
|
182
182
|
//-----------------------------------------------------------------------------
|
|
183
183
|
// this is updated by vss.js when building
|
|
184
|
-
const version = '4.1.
|
|
184
|
+
const version = '4.1.47';
|
|
185
185
|
Exchange["default"].ccxtVersion = version;
|
|
186
186
|
const exchanges = {
|
|
187
187
|
'ace': ace,
|
|
@@ -70,7 +70,6 @@ class Exchange {
|
|
|
70
70
|
this.orders = undefined;
|
|
71
71
|
this.triggerOrders = undefined;
|
|
72
72
|
this.transactions = {};
|
|
73
|
-
this.positions = {};
|
|
74
73
|
this.requiresWeb3 = false;
|
|
75
74
|
this.requiresEddsa = false;
|
|
76
75
|
this.enableLastJsonResponse = true;
|
|
@@ -264,7 +263,7 @@ class Exchange {
|
|
|
264
263
|
this.transactions = {};
|
|
265
264
|
this.ohlcvs = {};
|
|
266
265
|
this.myTrades = undefined;
|
|
267
|
-
this.positions =
|
|
266
|
+
this.positions = undefined;
|
|
268
267
|
// web3 and cryptography flags
|
|
269
268
|
this.requiresWeb3 = false;
|
|
270
269
|
this.requiresEddsa = false;
|
|
@@ -1350,6 +1349,9 @@ class Exchange {
|
|
|
1350
1349
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
1351
1350
|
throw new errors.NotSupported(this.id + ' fetchOrderBook() is not supported yet');
|
|
1352
1351
|
}
|
|
1352
|
+
async fetchMarginMode(symbol = undefined, params = {}) {
|
|
1353
|
+
throw new errors.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
|
|
1354
|
+
}
|
|
1353
1355
|
async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
|
|
1354
1356
|
const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
|
|
1355
1357
|
for (let i = 0; i < fetchSnapshotMaxRetries; i++) {
|
|
@@ -2749,7 +2751,7 @@ class Exchange {
|
|
|
2749
2751
|
const symbol = this.safeString(position, 'symbol');
|
|
2750
2752
|
let market = undefined;
|
|
2751
2753
|
if (symbol !== undefined) {
|
|
2752
|
-
market = this.
|
|
2754
|
+
market = this.safeValue(this.markets, symbol);
|
|
2753
2755
|
}
|
|
2754
2756
|
if (contractSize === undefined && market !== undefined) {
|
|
2755
2757
|
contractSize = this.safeNumber(market, 'contractSize');
|
|
@@ -2970,6 +2972,15 @@ class Exchange {
|
|
|
2970
2972
|
async fetchPosition(symbol, params = {}) {
|
|
2971
2973
|
throw new errors.NotSupported(this.id + ' fetchPosition() is not supported yet');
|
|
2972
2974
|
}
|
|
2975
|
+
async watchPosition(symbol = undefined, params = {}) {
|
|
2976
|
+
throw new errors.NotSupported(this.id + ' watchPosition() is not supported yet');
|
|
2977
|
+
}
|
|
2978
|
+
async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2979
|
+
throw new errors.NotSupported(this.id + ' watchPositions() is not supported yet');
|
|
2980
|
+
}
|
|
2981
|
+
async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2982
|
+
return this.watchPositions(symbols, since, limit, params);
|
|
2983
|
+
}
|
|
2973
2984
|
async fetchPositionsBySymbol(symbol, params = {}) {
|
|
2974
2985
|
/**
|
|
2975
2986
|
* @method
|
|
@@ -198,7 +198,57 @@ class ArrayCacheBySymbolById extends ArrayCache {
|
|
|
198
198
|
this.allNewUpdates = (this.allNewUpdates || 0) + (afterLength - beforeLength);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
+
class ArrayCacheBySymbolBySide extends ArrayCache {
|
|
202
|
+
constructor() {
|
|
203
|
+
super();
|
|
204
|
+
this.nestedNewUpdatesBySymbol = true;
|
|
205
|
+
Object.defineProperty(this, 'hashmap', {
|
|
206
|
+
__proto__: null,
|
|
207
|
+
value: {},
|
|
208
|
+
writable: true,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
append(item) {
|
|
212
|
+
const bySide = this.hashmap[item.symbol] = this.hashmap[item.symbol] || {};
|
|
213
|
+
if (item.side in bySide) {
|
|
214
|
+
const reference = bySide[item.side];
|
|
215
|
+
if (reference !== item) {
|
|
216
|
+
for (const prop in item) {
|
|
217
|
+
reference[prop] = item[prop];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
item = reference;
|
|
221
|
+
const index = this.findIndex((x) => x.symbol === item.symbol && x.side === item.side);
|
|
222
|
+
// move the order to the end of the array
|
|
223
|
+
this.splice(index, 1);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
bySide[item.side] = item;
|
|
227
|
+
}
|
|
228
|
+
this.push(item);
|
|
229
|
+
if (this.clearAllUpdates) {
|
|
230
|
+
this.clearAllUpdates = false;
|
|
231
|
+
this.clearUpdatesBySymbol = {};
|
|
232
|
+
this.allNewUpdates = 0;
|
|
233
|
+
this.newUpdatesBySymbol = {};
|
|
234
|
+
}
|
|
235
|
+
if (this.newUpdatesBySymbol[item.symbol] === undefined) {
|
|
236
|
+
this.newUpdatesBySymbol[item.symbol] = new Set();
|
|
237
|
+
}
|
|
238
|
+
if (this.clearUpdatesBySymbol[item.symbol]) {
|
|
239
|
+
this.clearUpdatesBySymbol[item.symbol] = false;
|
|
240
|
+
this.newUpdatesBySymbol[item.symbol].clear();
|
|
241
|
+
}
|
|
242
|
+
// in case an exchange updates the same order id twice
|
|
243
|
+
const sideSet = this.newUpdatesBySymbol[item.symbol];
|
|
244
|
+
const beforeLength = sideSet.size;
|
|
245
|
+
sideSet.add(item.side);
|
|
246
|
+
const afterLength = sideSet.size;
|
|
247
|
+
this.allNewUpdates = (this.allNewUpdates || 0) + (afterLength - beforeLength);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
201
250
|
|
|
202
251
|
exports.ArrayCache = ArrayCache;
|
|
203
252
|
exports.ArrayCacheBySymbolById = ArrayCacheBySymbolById;
|
|
253
|
+
exports.ArrayCacheBySymbolBySide = ArrayCacheBySymbolBySide;
|
|
204
254
|
exports.ArrayCacheByTimestamp = ArrayCacheByTimestamp;
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -960,7 +960,9 @@ class binance extends binance$1 {
|
|
|
960
960
|
},
|
|
961
961
|
'post': {
|
|
962
962
|
'um/order': 1,
|
|
963
|
+
'um/conditional/order': 1,
|
|
963
964
|
'cm/order': 1,
|
|
965
|
+
'cm/conditional/order': 1,
|
|
964
966
|
'margin/order': 0.0133,
|
|
965
967
|
'marginLoan': 0.1333,
|
|
966
968
|
'repayLoan': 0.1333,
|
|
@@ -981,8 +983,10 @@ class binance extends binance$1 {
|
|
|
981
983
|
},
|
|
982
984
|
'delete': {
|
|
983
985
|
'um/order': 1,
|
|
986
|
+
'um/conditional/order': 1,
|
|
984
987
|
'um/allOpenOrders': 1,
|
|
985
988
|
'cm/order': 1,
|
|
989
|
+
'cm/conditional/order': 1,
|
|
986
990
|
'cm/allOpenOrders': 1,
|
|
987
991
|
'margin/order': 1,
|
|
988
992
|
'margin/allOpenOrders': 5,
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -1509,7 +1509,7 @@ class bitmart extends bitmart$1 {
|
|
|
1509
1509
|
* @method
|
|
1510
1510
|
* @name bitmart#fetchOHLCV
|
|
1511
1511
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1512
|
-
* @see https://developer-pro.bitmart.com/en/spot/#get-
|
|
1512
|
+
* @see https://developer-pro.bitmart.com/en/spot/#get-history-k-line-v3
|
|
1513
1513
|
* @see https://developer-pro.bitmart.com/en/futures/#get-k-line
|
|
1514
1514
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1515
1515
|
* @param {string} timeframe the length of time each candle represents
|
|
@@ -1572,7 +1572,7 @@ class bitmart extends bitmart$1 {
|
|
|
1572
1572
|
response = await this.publicGetContractPublicKline(this.extend(request, params));
|
|
1573
1573
|
}
|
|
1574
1574
|
else {
|
|
1575
|
-
response = await this.
|
|
1575
|
+
response = await this.publicGetSpotQuotationV3Klines(this.extend(request, params));
|
|
1576
1576
|
}
|
|
1577
1577
|
//
|
|
1578
1578
|
// spot
|
package/dist/cjs/src/bitvavo.js
CHANGED
|
@@ -312,8 +312,8 @@ class bitvavo extends bitvavo$1 {
|
|
|
312
312
|
* @returns {object[]} an array of objects representing market data
|
|
313
313
|
*/
|
|
314
314
|
const response = await this.publicGetMarkets(params);
|
|
315
|
-
const currencies = this.
|
|
316
|
-
const currenciesById = this.indexBy(currencies, '
|
|
315
|
+
const currencies = await this.fetchCurrencies();
|
|
316
|
+
const currenciesById = this.indexBy(currencies, 'id');
|
|
317
317
|
//
|
|
318
318
|
// [
|
|
319
319
|
// {
|
|
@@ -338,7 +338,8 @@ class bitvavo extends bitvavo$1 {
|
|
|
338
338
|
const quote = this.safeCurrencyCode(quoteId);
|
|
339
339
|
const status = this.safeString(market, 'status');
|
|
340
340
|
const baseCurrency = this.safeValue(currenciesById, baseId);
|
|
341
|
-
|
|
341
|
+
const basePrecision = this.safeInteger(baseCurrency, 'precision');
|
|
342
|
+
result.push(this.safeMarketStructure({
|
|
342
343
|
'id': id,
|
|
343
344
|
'symbol': base + '/' + quote,
|
|
344
345
|
'base': base,
|
|
@@ -363,7 +364,7 @@ class bitvavo extends bitvavo$1 {
|
|
|
363
364
|
'strike': undefined,
|
|
364
365
|
'optionType': undefined,
|
|
365
366
|
'precision': {
|
|
366
|
-
'amount': this.safeInteger(baseCurrency, 'decimals',
|
|
367
|
+
'amount': this.safeInteger(baseCurrency, 'decimals', basePrecision),
|
|
367
368
|
'price': this.safeInteger(market, 'pricePrecision'),
|
|
368
369
|
},
|
|
369
370
|
'limits': {
|
|
@@ -386,7 +387,7 @@ class bitvavo extends bitvavo$1 {
|
|
|
386
387
|
},
|
|
387
388
|
'created': undefined,
|
|
388
389
|
'info': market,
|
|
389
|
-
});
|
|
390
|
+
}));
|
|
390
391
|
}
|
|
391
392
|
return result;
|
|
392
393
|
}
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -2523,88 +2523,8 @@ class bybit extends bybit$1 {
|
|
|
2523
2523
|
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
2524
2524
|
}
|
|
2525
2525
|
parseTrade(trade, market = undefined) {
|
|
2526
|
-
const isSpotTrade = ('isBuyerMaker' in trade) || ('feeTokenId' in trade);
|
|
2527
|
-
if (isSpotTrade) {
|
|
2528
|
-
return this.parseSpotTrade(trade, market);
|
|
2529
|
-
}
|
|
2530
|
-
else {
|
|
2531
|
-
return this.parseContractTrade(trade, market);
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
parseSpotTrade(trade, market = undefined) {
|
|
2535
|
-
//
|
|
2536
|
-
// public:
|
|
2537
|
-
// {
|
|
2538
|
-
// "price": "39548.68",
|
|
2539
|
-
// "time": "1651748717850",
|
|
2540
|
-
// "qty": "0.166872",
|
|
2541
|
-
// "isBuyerMaker": 0
|
|
2542
|
-
// }
|
|
2543
|
-
//
|
|
2544
|
-
// private:
|
|
2545
|
-
// {
|
|
2546
|
-
// "orderPrice": "82.5",
|
|
2547
|
-
// "creatTime": "1666702226326",
|
|
2548
|
-
// "orderQty": "0.016",
|
|
2549
|
-
// "isBuyer": "0",
|
|
2550
|
-
// "isMaker": "0",
|
|
2551
|
-
// "symbol": "AAVEUSDT",
|
|
2552
|
-
// "id": "1274785101965716992",
|
|
2553
|
-
// "orderId": "1274784252359089664",
|
|
2554
|
-
// "tradeId": "2270000000031365639",
|
|
2555
|
-
// "execFee": "0",
|
|
2556
|
-
// "feeTokenId": "AAVE",
|
|
2557
|
-
// "matchOrderId": "1274785101865076224",
|
|
2558
|
-
// "makerRebate": "0",
|
|
2559
|
-
// "executionTime": "1666702226335"
|
|
2560
|
-
// }
|
|
2561
|
-
//
|
|
2562
|
-
const timestamp = this.safeIntegerN(trade, ['time', 'creatTime']);
|
|
2563
|
-
let takerOrMaker = undefined;
|
|
2564
|
-
let side = undefined;
|
|
2565
|
-
const isBuyerMaker = this.safeInteger(trade, 'isBuyerMaker');
|
|
2566
|
-
if (isBuyerMaker !== undefined) {
|
|
2567
|
-
// if public response
|
|
2568
|
-
side = (isBuyerMaker === 1) ? 'buy' : 'sell';
|
|
2569
|
-
}
|
|
2570
|
-
else {
|
|
2571
|
-
// if private response
|
|
2572
|
-
const isBuyer = this.safeInteger(trade, 'isBuyer');
|
|
2573
|
-
const isMaker = this.safeInteger(trade, 'isMaker');
|
|
2574
|
-
takerOrMaker = (isMaker === 0) ? 'maker' : 'taker';
|
|
2575
|
-
side = (isBuyer === 0) ? 'buy' : 'sell';
|
|
2576
|
-
}
|
|
2577
|
-
const marketId = this.safeString(trade, 'symbol');
|
|
2578
|
-
market = this.safeMarket(marketId, market, undefined, 'spot');
|
|
2579
|
-
let fee = undefined;
|
|
2580
|
-
const feeCost = this.safeString(trade, 'execFee');
|
|
2581
|
-
if (feeCost !== undefined) {
|
|
2582
|
-
const feeToken = this.safeString(trade, 'feeTokenId');
|
|
2583
|
-
const feeCurrency = this.safeCurrencyCode(feeToken);
|
|
2584
|
-
fee = {
|
|
2585
|
-
'cost': feeCost,
|
|
2586
|
-
'currency': feeCurrency,
|
|
2587
|
-
};
|
|
2588
|
-
}
|
|
2589
|
-
return this.safeTrade({
|
|
2590
|
-
'id': this.safeString(trade, 'tradeId'),
|
|
2591
|
-
'info': trade,
|
|
2592
|
-
'timestamp': timestamp,
|
|
2593
|
-
'datetime': this.iso8601(timestamp),
|
|
2594
|
-
'symbol': market['symbol'],
|
|
2595
|
-
'order': this.safeString(trade, 'orderId'),
|
|
2596
|
-
'type': undefined,
|
|
2597
|
-
'side': side,
|
|
2598
|
-
'takerOrMaker': takerOrMaker,
|
|
2599
|
-
'price': this.safeString2(trade, 'price', 'orderPrice'),
|
|
2600
|
-
'amount': this.safeString2(trade, 'qty', 'orderQty'),
|
|
2601
|
-
'cost': undefined,
|
|
2602
|
-
'fee': fee,
|
|
2603
|
-
}, market);
|
|
2604
|
-
}
|
|
2605
|
-
parseContractTrade(trade, market = undefined) {
|
|
2606
2526
|
//
|
|
2607
|
-
// public
|
|
2527
|
+
// public https://bybit-exchange.github.io/docs/v5/market/recent-trade
|
|
2608
2528
|
//
|
|
2609
2529
|
// {
|
|
2610
2530
|
// "execId": "666042b4-50c6-58f3-bd9c-89b2088663ff",
|
|
@@ -2616,59 +2536,66 @@ class bybit extends bybit$1 {
|
|
|
2616
2536
|
// "isBlockTrade": false
|
|
2617
2537
|
// }
|
|
2618
2538
|
//
|
|
2619
|
-
//
|
|
2539
|
+
// private trades classic spot https://bybit-exchange.github.io/docs/v5/position/execution
|
|
2620
2540
|
//
|
|
2621
2541
|
// {
|
|
2622
|
-
// "
|
|
2623
|
-
// "
|
|
2624
|
-
// "price": "20802.50",
|
|
2625
|
-
// "size": "0.200",
|
|
2626
|
-
// "side": "Sell",
|
|
2627
|
-
// "time": "1657870316630"
|
|
2628
|
-
// }
|
|
2629
|
-
//
|
|
2630
|
-
// private contract trades
|
|
2631
|
-
//
|
|
2632
|
-
// {
|
|
2633
|
-
// "symbol": "ETHUSD",
|
|
2634
|
-
// "execFee": "0.00005484",
|
|
2635
|
-
// "execId": "acf78206-d464-589b-b888-51bd130821c1",
|
|
2636
|
-
// "execPrice": "1367.80",
|
|
2637
|
-
// "execQty": "100",
|
|
2638
|
-
// "execType": "Trade",
|
|
2639
|
-
// "execValue": "0.0731101",
|
|
2640
|
-
// "feeRate": "0.00075",
|
|
2641
|
-
// "lastLiquidityInd": "RemovedLiquidity",
|
|
2642
|
-
// "leavesQty": "0",
|
|
2643
|
-
// "orderId": "fdc584c3-be5d-41ff-8f54-5be7649b1d1c",
|
|
2542
|
+
// "symbol": "QNTUSDT",
|
|
2543
|
+
// "orderId": "1538686353240339712",
|
|
2644
2544
|
// "orderLinkId": "",
|
|
2645
|
-
// "orderPrice": "1299.50",
|
|
2646
|
-
// "orderQty": "100",
|
|
2647
|
-
// "orderType": "Market",
|
|
2648
|
-
// "stopOrderType": "UNKNOWN",
|
|
2649
2545
|
// "side": "Sell",
|
|
2650
|
-
// "
|
|
2651
|
-
// "
|
|
2546
|
+
// "orderPrice": "",
|
|
2547
|
+
// "orderQty": "",
|
|
2548
|
+
// "leavesQty": "",
|
|
2549
|
+
// "orderType": "Limit",
|
|
2550
|
+
// "stopOrderType": "",
|
|
2551
|
+
// "execFee": "0.040919",
|
|
2552
|
+
// "execId": "2210000000097330907",
|
|
2553
|
+
// "execPrice": "98.6",
|
|
2554
|
+
// "execQty": "0.415",
|
|
2555
|
+
// "execType": "",
|
|
2556
|
+
// "execValue": "",
|
|
2557
|
+
// "execTime": "1698161716634",
|
|
2558
|
+
// "isMaker": true,
|
|
2559
|
+
// "feeRate": "",
|
|
2560
|
+
// "tradeIv": "",
|
|
2561
|
+
// "markIv": "",
|
|
2562
|
+
// "markPrice": "",
|
|
2563
|
+
// "indexPrice": "",
|
|
2564
|
+
// "underlyingPrice": "",
|
|
2565
|
+
// "blockTradeId": ""
|
|
2652
2566
|
// }
|
|
2653
2567
|
//
|
|
2654
|
-
// private unified
|
|
2568
|
+
// private trades unified https://bybit-exchange.github.io/docs/v5/position/execution
|
|
2655
2569
|
//
|
|
2656
2570
|
// {
|
|
2657
|
-
// "symbol": "
|
|
2658
|
-
// "
|
|
2659
|
-
// "
|
|
2660
|
-
// "
|
|
2661
|
-
// "
|
|
2662
|
-
// "
|
|
2663
|
-
// "
|
|
2664
|
-
// "
|
|
2665
|
-
// "
|
|
2666
|
-
// "
|
|
2667
|
-
// "
|
|
2668
|
-
// "
|
|
2669
|
-
// "
|
|
2670
|
-
// "
|
|
2671
|
-
//
|
|
2571
|
+
// "symbol": "QNTUSDT",
|
|
2572
|
+
// "orderType": "Limit",
|
|
2573
|
+
// "underlyingPrice": "",
|
|
2574
|
+
// "orderLinkId": "1549452573428424449",
|
|
2575
|
+
// "orderId": "1549452573428424448",
|
|
2576
|
+
// "stopOrderType": "",
|
|
2577
|
+
// "execTime": "1699445151998",
|
|
2578
|
+
// "feeRate": "0.00025",
|
|
2579
|
+
// "tradeIv": "",
|
|
2580
|
+
// "blockTradeId": "",
|
|
2581
|
+
// "markPrice": "",
|
|
2582
|
+
// "execPrice": "102.8",
|
|
2583
|
+
// "markIv": "",
|
|
2584
|
+
// "orderQty": "3.652",
|
|
2585
|
+
// "orderPrice": "102.8",
|
|
2586
|
+
// "execValue": "1.028",
|
|
2587
|
+
// "closedSize": "",
|
|
2588
|
+
// "execType": "Trade",
|
|
2589
|
+
// "seq": "19157444346",
|
|
2590
|
+
// "side": "Buy",
|
|
2591
|
+
// "indexPrice": "",
|
|
2592
|
+
// "leavesQty": "3.642",
|
|
2593
|
+
// "isMaker": true,
|
|
2594
|
+
// "execFee": "0.0000025",
|
|
2595
|
+
// "execId": "2210000000101610464",
|
|
2596
|
+
// "execQty": "0.01",
|
|
2597
|
+
// "nextPageCursor": "267951%3A0%2C38567%3A0"
|
|
2598
|
+
// },
|
|
2672
2599
|
//
|
|
2673
2600
|
// private USDC settled trades
|
|
2674
2601
|
//
|
|
@@ -2740,9 +2667,25 @@ class bybit extends bybit$1 {
|
|
|
2740
2667
|
const feeCostString = this.safeString(trade, 'execFee');
|
|
2741
2668
|
let fee = undefined;
|
|
2742
2669
|
if (feeCostString !== undefined) {
|
|
2670
|
+
const feeRateString = this.safeString(trade, 'feeRate');
|
|
2743
2671
|
let feeCurrencyCode = undefined;
|
|
2744
2672
|
if (market['spot']) {
|
|
2745
|
-
|
|
2673
|
+
if (Precise["default"].stringGt(feeCostString, '0')) {
|
|
2674
|
+
if (side === 'buy') {
|
|
2675
|
+
feeCurrencyCode = market['base'];
|
|
2676
|
+
}
|
|
2677
|
+
else {
|
|
2678
|
+
feeCurrencyCode = market['quote'];
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
else {
|
|
2682
|
+
if (side === 'buy') {
|
|
2683
|
+
feeCurrencyCode = market['quote'];
|
|
2684
|
+
}
|
|
2685
|
+
else {
|
|
2686
|
+
feeCurrencyCode = market['base'];
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2746
2689
|
}
|
|
2747
2690
|
else {
|
|
2748
2691
|
feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
|
|
@@ -2750,6 +2693,7 @@ class bybit extends bybit$1 {
|
|
|
2750
2693
|
fee = {
|
|
2751
2694
|
'cost': feeCostString,
|
|
2752
2695
|
'currency': feeCurrencyCode,
|
|
2696
|
+
'rate': feeRateString,
|
|
2753
2697
|
};
|
|
2754
2698
|
}
|
|
2755
2699
|
return this.safeTrade({
|
|
@@ -5755,11 +5699,19 @@ class bybit extends bybit$1 {
|
|
|
5755
5699
|
}
|
|
5756
5700
|
if (type === 'linear' || type === 'inverse') {
|
|
5757
5701
|
const baseCoin = this.safeString(params, 'baseCoin');
|
|
5758
|
-
if (
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5702
|
+
if (type === 'linear') {
|
|
5703
|
+
if (symbol === undefined && baseCoin === undefined) {
|
|
5704
|
+
const defaultSettle = this.safeString(this.options, 'defaultSettle', 'USDT');
|
|
5705
|
+
const settleCoin = this.safeString(params, 'settleCoin', defaultSettle);
|
|
5706
|
+
request['settleCoin'] = settleCoin;
|
|
5707
|
+
isUsdcSettled = (settleCoin === 'USDC');
|
|
5708
|
+
}
|
|
5709
|
+
}
|
|
5710
|
+
else {
|
|
5711
|
+
// inverse
|
|
5712
|
+
if (symbol === undefined && baseCoin === undefined) {
|
|
5713
|
+
request['category'] = 'inverse';
|
|
5714
|
+
}
|
|
5763
5715
|
}
|
|
5764
5716
|
}
|
|
5765
5717
|
if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
|
|
@@ -3167,7 +3167,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
3167
3167
|
'datetime': this.iso8601(timestamp),
|
|
3168
3168
|
'hedged': undefined,
|
|
3169
3169
|
'side': undefined,
|
|
3170
|
-
'contracts':
|
|
3170
|
+
'contracts': this.safeNumber(position, 'quantity'),
|
|
3171
3171
|
'contractSize': market['contractSize'],
|
|
3172
3172
|
'entryPrice': undefined,
|
|
3173
3173
|
'markPrice': undefined,
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -5092,13 +5092,14 @@ class gate extends gate$1 {
|
|
|
5092
5092
|
const takerFee = '0.00075';
|
|
5093
5093
|
const feePaid = Precise["default"].stringMul(takerFee, notional);
|
|
5094
5094
|
const initialMarginString = Precise["default"].stringAdd(Precise["default"].stringDiv(notional, leverage), feePaid);
|
|
5095
|
+
const timestamp = this.safeInteger(position, 'time_ms');
|
|
5095
5096
|
return this.safePosition({
|
|
5096
5097
|
'info': position,
|
|
5097
5098
|
'id': undefined,
|
|
5098
5099
|
'symbol': this.safeString(market, 'symbol'),
|
|
5099
5100
|
'timestamp': undefined,
|
|
5100
5101
|
'datetime': undefined,
|
|
5101
|
-
'lastUpdateTimestamp':
|
|
5102
|
+
'lastUpdateTimestamp': timestamp,
|
|
5102
5103
|
'initialMargin': this.parseNumber(initialMarginString),
|
|
5103
5104
|
'initialMarginPercentage': this.parseNumber(Precise["default"].stringDiv(initialMarginString, notional)),
|
|
5104
5105
|
'maintenanceMargin': this.parseNumber(Precise["default"].stringMul(maintenanceRate, notional)),
|
|
@@ -5107,6 +5108,7 @@ class gate extends gate$1 {
|
|
|
5107
5108
|
'notional': this.parseNumber(notional),
|
|
5108
5109
|
'leverage': this.safeNumber(position, 'leverage'),
|
|
5109
5110
|
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
5111
|
+
'realizedPnl': this.safeNumber(position, 'realised_pnl'),
|
|
5110
5112
|
'contracts': this.parseNumber(Precise["default"].stringAbs(size)),
|
|
5111
5113
|
'contractSize': this.safeValue(market, 'contractSize'),
|
|
5112
5114
|
// 'realisedPnl': position['realised_pnl'],
|
package/dist/cjs/src/hitbtc.js
CHANGED
|
@@ -60,7 +60,7 @@ class hitbtc extends hitbtc$1 {
|
|
|
60
60
|
'fetchLeverage': true,
|
|
61
61
|
'fetchLeverageTiers': undefined,
|
|
62
62
|
'fetchLiquidations': false,
|
|
63
|
-
'fetchMarginMode':
|
|
63
|
+
'fetchMarginMode': true,
|
|
64
64
|
'fetchMarketLeverageTiers': false,
|
|
65
65
|
'fetchMarkets': true,
|
|
66
66
|
'fetchMarkOHLCV': true,
|
|
@@ -2346,6 +2346,84 @@ class hitbtc extends hitbtc$1 {
|
|
|
2346
2346
|
'stopLossPrice': undefined,
|
|
2347
2347
|
}, market);
|
|
2348
2348
|
}
|
|
2349
|
+
async fetchMarginMode(symbol = undefined, params = {}) {
|
|
2350
|
+
/**
|
|
2351
|
+
* @method
|
|
2352
|
+
* @name hitbtc#fetchMarginMode
|
|
2353
|
+
* @description fetches margin mode of the user
|
|
2354
|
+
* @see https://api.hitbtc.com/#get-margin-position-parameters
|
|
2355
|
+
* @see https://api.hitbtc.com/#get-futures-position-parameters
|
|
2356
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
2357
|
+
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
2358
|
+
* @returns {object} Struct of MarginMode
|
|
2359
|
+
*/
|
|
2360
|
+
await this.loadMarkets();
|
|
2361
|
+
let market = undefined;
|
|
2362
|
+
if (symbol !== undefined) {
|
|
2363
|
+
market = this.market(symbol);
|
|
2364
|
+
}
|
|
2365
|
+
let marketType = undefined;
|
|
2366
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchMarginMode', market, params);
|
|
2367
|
+
let response = undefined;
|
|
2368
|
+
if (marketType === 'margin') {
|
|
2369
|
+
response = await this.privateGetMarginConfig(params);
|
|
2370
|
+
}
|
|
2371
|
+
else if (marketType === 'swap') {
|
|
2372
|
+
response = await this.privateGetFuturesConfig(params);
|
|
2373
|
+
}
|
|
2374
|
+
else {
|
|
2375
|
+
throw new errors.BadSymbol(this.id + ' fetchMarginMode() supports swap contracts and margin only');
|
|
2376
|
+
}
|
|
2377
|
+
//
|
|
2378
|
+
// margin
|
|
2379
|
+
// {
|
|
2380
|
+
// "config": [{
|
|
2381
|
+
// "symbol": "BTCUSD",
|
|
2382
|
+
// "margin_call_leverage_mul": "1.50",
|
|
2383
|
+
// "liquidation_leverage_mul": "2.00",
|
|
2384
|
+
// "max_initial_leverage": "10.00",
|
|
2385
|
+
// "margin_mode": "Isolated",
|
|
2386
|
+
// "force_close_fee": "0.05",
|
|
2387
|
+
// "enabled": true,
|
|
2388
|
+
// "active": true,
|
|
2389
|
+
// "limit_base": "50000.00",
|
|
2390
|
+
// "limit_power": "2.2",
|
|
2391
|
+
// "unlimited_threshold": "10.0"
|
|
2392
|
+
// }]
|
|
2393
|
+
// }
|
|
2394
|
+
//
|
|
2395
|
+
// swap
|
|
2396
|
+
// {
|
|
2397
|
+
// "config": [{
|
|
2398
|
+
// "symbol": "BTCUSD_PERP",
|
|
2399
|
+
// "margin_call_leverage_mul": "1.20",
|
|
2400
|
+
// "liquidation_leverage_mul": "2.00",
|
|
2401
|
+
// "max_initial_leverage": "100.00",
|
|
2402
|
+
// "margin_mode": "Isolated",
|
|
2403
|
+
// "force_close_fee": "0.001",
|
|
2404
|
+
// "enabled": true,
|
|
2405
|
+
// "active": false,
|
|
2406
|
+
// "limit_base": "5000000.000000000000",
|
|
2407
|
+
// "limit_power": "1.25",
|
|
2408
|
+
// "unlimited_threshold": "2.00"
|
|
2409
|
+
// }]
|
|
2410
|
+
// }
|
|
2411
|
+
//
|
|
2412
|
+
const config = this.safeValue(response, 'config', []);
|
|
2413
|
+
const marginModes = [];
|
|
2414
|
+
for (let i = 0; i < config.length; i++) {
|
|
2415
|
+
const data = this.safeValue(config, i);
|
|
2416
|
+
const marketId = this.safeString(data, 'symbol');
|
|
2417
|
+
const marketInner = this.safeMarket(marketId);
|
|
2418
|
+
marginModes.push({
|
|
2419
|
+
'info': data,
|
|
2420
|
+
'symbol': this.safeString(marketInner, 'symbol'),
|
|
2421
|
+
'marginMode': this.safeStringLower(data, 'margin_mode'),
|
|
2422
|
+
});
|
|
2423
|
+
}
|
|
2424
|
+
const filteredMargin = this.filterBySymbol(marginModes, symbol);
|
|
2425
|
+
return this.safeValue(filteredMargin, 0);
|
|
2426
|
+
}
|
|
2349
2427
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
2350
2428
|
/**
|
|
2351
2429
|
* @method
|
package/dist/cjs/src/huobi.js
CHANGED
|
@@ -7044,8 +7044,7 @@ class huobi extends huobi$1 {
|
|
|
7044
7044
|
market = this.market(first);
|
|
7045
7045
|
}
|
|
7046
7046
|
let marginMode = undefined;
|
|
7047
|
-
[marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params);
|
|
7048
|
-
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
7047
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params, 'cross');
|
|
7049
7048
|
let subType = undefined;
|
|
7050
7049
|
[subType, params] = this.handleSubTypeAndParams('fetchPositions', market, params, 'linear');
|
|
7051
7050
|
let marketType = undefined;
|
|
@@ -156,7 +156,7 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
156
156
|
'exceptions': {
|
|
157
157
|
'exact': {
|
|
158
158
|
'apiLimitExceeded': errors.RateLimitExceeded,
|
|
159
|
-
'marketUnavailable': errors.
|
|
159
|
+
'marketUnavailable': errors.ContractUnavailable,
|
|
160
160
|
'requiredArgumentMissing': errors.BadRequest,
|
|
161
161
|
'unavailable': errors.ExchangeNotAvailable,
|
|
162
162
|
'authenticationError': errors.AuthenticationError,
|
|
@@ -165,7 +165,14 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
165
165
|
'invalidAmount': errors.BadRequest,
|
|
166
166
|
'insufficientFunds': errors.InsufficientFunds,
|
|
167
167
|
'Bad Request': errors.BadRequest,
|
|
168
|
-
'Unavailable': errors.InsufficientFunds,
|
|
168
|
+
'Unavailable': errors.InsufficientFunds,
|
|
169
|
+
'invalidUnit': errors.BadRequest,
|
|
170
|
+
'Json Parse Error': errors.ExchangeError,
|
|
171
|
+
'nonceBelowThreshold': errors.InvalidNonce,
|
|
172
|
+
'nonceDuplicate': errors.InvalidNonce,
|
|
173
|
+
'notFound': errors.BadRequest,
|
|
174
|
+
'Server Error': errors.ExchangeError,
|
|
175
|
+
'unknownError': errors.ExchangeError,
|
|
169
176
|
},
|
|
170
177
|
'broad': {
|
|
171
178
|
'invalidArgument': errors.BadRequest,
|
|
@@ -2305,7 +2312,10 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
2305
2312
|
if (code === 429) {
|
|
2306
2313
|
throw new errors.DDoSProtection(this.id + ' ' + body);
|
|
2307
2314
|
}
|
|
2308
|
-
const
|
|
2315
|
+
const errors$1 = this.safeValue(response, 'errors');
|
|
2316
|
+
const firstError = this.safeValue(errors$1, 0);
|
|
2317
|
+
const firtErrorMessage = this.safeString(firstError, 'message');
|
|
2318
|
+
const message = this.safeString(response, 'error', firtErrorMessage);
|
|
2309
2319
|
if (message === undefined) {
|
|
2310
2320
|
return undefined;
|
|
2311
2321
|
}
|