ccxt 4.1.45 → 4.1.46
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 +1591 -188
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +11 -3
- package/dist/cjs/src/base/ws/Cache.js +50 -0
- 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/huobi.js +1 -2
- 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 +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +4 -1
- package/js/src/base/Exchange.js +11 -3
- package/js/src/base/ws/Cache.d.ts +5 -1
- package/js/src/base/ws/Cache.js +50 -1
- package/js/src/bitvavo.js +6 -5
- package/js/src/bybit.d.ts +0 -2
- package/js/src/bybit.js +84 -132
- package/js/src/cryptocom.js +1 -1
- package/js/src/gate.js +3 -1
- package/js/src/huobi.js +1 -2
- package/js/src/okx.js +19 -2
- 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/package.json +1 -1
- package/skip-tests.json +3 -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.46';
|
|
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;
|
|
@@ -2749,7 +2748,7 @@ class Exchange {
|
|
|
2749
2748
|
const symbol = this.safeString(position, 'symbol');
|
|
2750
2749
|
let market = undefined;
|
|
2751
2750
|
if (symbol !== undefined) {
|
|
2752
|
-
market = this.
|
|
2751
|
+
market = this.safeValue(this.markets, symbol);
|
|
2753
2752
|
}
|
|
2754
2753
|
if (contractSize === undefined && market !== undefined) {
|
|
2755
2754
|
contractSize = this.safeNumber(market, 'contractSize');
|
|
@@ -2970,6 +2969,15 @@ class Exchange {
|
|
|
2970
2969
|
async fetchPosition(symbol, params = {}) {
|
|
2971
2970
|
throw new errors.NotSupported(this.id + ' fetchPosition() is not supported yet');
|
|
2972
2971
|
}
|
|
2972
|
+
async watchPosition(symbol = undefined, params = {}) {
|
|
2973
|
+
throw new errors.NotSupported(this.id + ' watchPosition() is not supported yet');
|
|
2974
|
+
}
|
|
2975
|
+
async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2976
|
+
throw new errors.NotSupported(this.id + ' watchPositions() is not supported yet');
|
|
2977
|
+
}
|
|
2978
|
+
async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2979
|
+
return this.watchPositions(symbols, since, limit, params);
|
|
2980
|
+
}
|
|
2973
2981
|
async fetchPositionsBySymbol(symbol, params = {}) {
|
|
2974
2982
|
/**
|
|
2975
2983
|
* @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/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/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;
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -2551,6 +2551,13 @@ class okx extends okx$1 {
|
|
|
2551
2551
|
request['tdMode'] = tradeMode;
|
|
2552
2552
|
}
|
|
2553
2553
|
else if (contract) {
|
|
2554
|
+
if (market['swap'] || market['future']) {
|
|
2555
|
+
let positionSide = undefined;
|
|
2556
|
+
[positionSide, params] = this.handleOptionAndParams(params, 'createOrder', 'positionSide');
|
|
2557
|
+
if (positionSide !== undefined) {
|
|
2558
|
+
request['posSide'] = positionSide;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2554
2561
|
request['tdMode'] = marginMode;
|
|
2555
2562
|
}
|
|
2556
2563
|
const isMarketOrder = type === 'market';
|
|
@@ -2747,7 +2754,7 @@ class okx extends okx$1 {
|
|
|
2747
2754
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2748
2755
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
2749
2756
|
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
2750
|
-
* @param {bool} [params.reduceOnly]
|
|
2757
|
+
* @param {bool} [params.reduceOnly] a mark to reduce the position size for margin, swap and future orders
|
|
2751
2758
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
2752
2759
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
|
|
2753
2760
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
@@ -2757,6 +2764,7 @@ class okx extends okx$1 {
|
|
|
2757
2764
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
2758
2765
|
* @param {float} [params.stopLoss.price] used for stop loss limit orders, not used for stop loss market price orders
|
|
2759
2766
|
* @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
|
|
2767
|
+
* @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
|
|
2760
2768
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2761
2769
|
*/
|
|
2762
2770
|
await this.loadMarkets();
|
|
@@ -2776,7 +2784,16 @@ class okx extends okx$1 {
|
|
|
2776
2784
|
// because it has a lower ratelimit
|
|
2777
2785
|
request = [request];
|
|
2778
2786
|
}
|
|
2779
|
-
|
|
2787
|
+
let response = undefined;
|
|
2788
|
+
if (method === 'privatePostTradeOrder') {
|
|
2789
|
+
response = await this.privatePostTradeOrder(request);
|
|
2790
|
+
}
|
|
2791
|
+
else if (method === 'privatePostTradeOrderAlgo') {
|
|
2792
|
+
response = await this.privatePostTradeOrderAlgo(request);
|
|
2793
|
+
}
|
|
2794
|
+
else {
|
|
2795
|
+
response = await this.privatePostTradeBatchOrders(request);
|
|
2796
|
+
}
|
|
2780
2797
|
const data = this.safeValue(response, 'data', []);
|
|
2781
2798
|
const first = this.safeValue(data, 0);
|
|
2782
2799
|
const order = this.parseOrder(first, market);
|