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/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.1.
|
|
41
|
+
const version = '4.1.46';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -72,7 +72,7 @@ export default class Exchange {
|
|
|
72
72
|
transactions: {};
|
|
73
73
|
ohlcvs: any;
|
|
74
74
|
myTrades: any;
|
|
75
|
-
positions:
|
|
75
|
+
positions: any;
|
|
76
76
|
urls: {
|
|
77
77
|
logo?: string;
|
|
78
78
|
api?: string | Dictionary<string>;
|
|
@@ -675,6 +675,9 @@ export default class Exchange {
|
|
|
675
675
|
editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
|
|
676
676
|
fetchPermissions(params?: {}): Promise<void>;
|
|
677
677
|
fetchPosition(symbol: string, params?: {}): Promise<Position>;
|
|
678
|
+
watchPosition(symbol?: string, params?: {}): Promise<Position>;
|
|
679
|
+
watchPositions(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
680
|
+
watchPositionForSymbols(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
678
681
|
fetchPositionsBySymbol(symbol: string, params?: {}): Promise<Position[]>;
|
|
679
682
|
fetchPositions(symbols?: string[], params?: {}): Promise<Position[]>;
|
|
680
683
|
fetchPositionsRisk(symbols?: string[], params?: {}): Promise<Position[]>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -58,7 +58,6 @@ export default class Exchange {
|
|
|
58
58
|
this.orders = undefined;
|
|
59
59
|
this.triggerOrders = undefined;
|
|
60
60
|
this.transactions = {};
|
|
61
|
-
this.positions = {};
|
|
62
61
|
this.requiresWeb3 = false;
|
|
63
62
|
this.requiresEddsa = false;
|
|
64
63
|
this.enableLastJsonResponse = true;
|
|
@@ -252,7 +251,7 @@ export default class Exchange {
|
|
|
252
251
|
this.transactions = {};
|
|
253
252
|
this.ohlcvs = {};
|
|
254
253
|
this.myTrades = undefined;
|
|
255
|
-
this.positions =
|
|
254
|
+
this.positions = undefined;
|
|
256
255
|
// web3 and cryptography flags
|
|
257
256
|
this.requiresWeb3 = false;
|
|
258
257
|
this.requiresEddsa = false;
|
|
@@ -2745,7 +2744,7 @@ export default class Exchange {
|
|
|
2745
2744
|
const symbol = this.safeString(position, 'symbol');
|
|
2746
2745
|
let market = undefined;
|
|
2747
2746
|
if (symbol !== undefined) {
|
|
2748
|
-
market = this.
|
|
2747
|
+
market = this.safeValue(this.markets, symbol);
|
|
2749
2748
|
}
|
|
2750
2749
|
if (contractSize === undefined && market !== undefined) {
|
|
2751
2750
|
contractSize = this.safeNumber(market, 'contractSize');
|
|
@@ -2966,6 +2965,15 @@ export default class Exchange {
|
|
|
2966
2965
|
async fetchPosition(symbol, params = {}) {
|
|
2967
2966
|
throw new NotSupported(this.id + ' fetchPosition() is not supported yet');
|
|
2968
2967
|
}
|
|
2968
|
+
async watchPosition(symbol = undefined, params = {}) {
|
|
2969
|
+
throw new NotSupported(this.id + ' watchPosition() is not supported yet');
|
|
2970
|
+
}
|
|
2971
|
+
async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2972
|
+
throw new NotSupported(this.id + ' watchPositions() is not supported yet');
|
|
2973
|
+
}
|
|
2974
|
+
async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2975
|
+
return this.watchPositions(symbols, since, limit, params);
|
|
2976
|
+
}
|
|
2969
2977
|
async fetchPositionsBySymbol(symbol, params = {}) {
|
|
2970
2978
|
/**
|
|
2971
2979
|
* @method
|
|
@@ -16,4 +16,8 @@ declare class ArrayCacheBySymbolById extends ArrayCache {
|
|
|
16
16
|
constructor(maxSize?: any);
|
|
17
17
|
append(item: any): void;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
declare class ArrayCacheBySymbolBySide extends ArrayCache {
|
|
20
|
+
constructor();
|
|
21
|
+
append(item: any): void;
|
|
22
|
+
}
|
|
23
|
+
export { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, };
|
package/js/src/base/ws/Cache.js
CHANGED
|
@@ -200,4 +200,53 @@ class ArrayCacheBySymbolById extends ArrayCache {
|
|
|
200
200
|
this.allNewUpdates = (this.allNewUpdates || 0) + (afterLength - beforeLength);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
class ArrayCacheBySymbolBySide extends ArrayCache {
|
|
204
|
+
constructor() {
|
|
205
|
+
super();
|
|
206
|
+
this.nestedNewUpdatesBySymbol = true;
|
|
207
|
+
Object.defineProperty(this, 'hashmap', {
|
|
208
|
+
__proto__: null,
|
|
209
|
+
value: {},
|
|
210
|
+
writable: true,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
append(item) {
|
|
214
|
+
const bySide = this.hashmap[item.symbol] = this.hashmap[item.symbol] || {};
|
|
215
|
+
if (item.side in bySide) {
|
|
216
|
+
const reference = bySide[item.side];
|
|
217
|
+
if (reference !== item) {
|
|
218
|
+
for (const prop in item) {
|
|
219
|
+
reference[prop] = item[prop];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
item = reference;
|
|
223
|
+
const index = this.findIndex((x) => x.symbol === item.symbol && x.side === item.side);
|
|
224
|
+
// move the order to the end of the array
|
|
225
|
+
this.splice(index, 1);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
bySide[item.side] = item;
|
|
229
|
+
}
|
|
230
|
+
this.push(item);
|
|
231
|
+
if (this.clearAllUpdates) {
|
|
232
|
+
this.clearAllUpdates = false;
|
|
233
|
+
this.clearUpdatesBySymbol = {};
|
|
234
|
+
this.allNewUpdates = 0;
|
|
235
|
+
this.newUpdatesBySymbol = {};
|
|
236
|
+
}
|
|
237
|
+
if (this.newUpdatesBySymbol[item.symbol] === undefined) {
|
|
238
|
+
this.newUpdatesBySymbol[item.symbol] = new Set();
|
|
239
|
+
}
|
|
240
|
+
if (this.clearUpdatesBySymbol[item.symbol]) {
|
|
241
|
+
this.clearUpdatesBySymbol[item.symbol] = false;
|
|
242
|
+
this.newUpdatesBySymbol[item.symbol].clear();
|
|
243
|
+
}
|
|
244
|
+
// in case an exchange updates the same order id twice
|
|
245
|
+
const sideSet = this.newUpdatesBySymbol[item.symbol];
|
|
246
|
+
const beforeLength = sideSet.size;
|
|
247
|
+
sideSet.add(item.side);
|
|
248
|
+
const afterLength = sideSet.size;
|
|
249
|
+
this.allNewUpdates = (this.allNewUpdates || 0) + (afterLength - beforeLength);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
export { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, };
|
package/js/src/bitvavo.js
CHANGED
|
@@ -315,8 +315,8 @@ export default class bitvavo extends Exchange {
|
|
|
315
315
|
* @returns {object[]} an array of objects representing market data
|
|
316
316
|
*/
|
|
317
317
|
const response = await this.publicGetMarkets(params);
|
|
318
|
-
const currencies = this.
|
|
319
|
-
const currenciesById = this.indexBy(currencies, '
|
|
318
|
+
const currencies = await this.fetchCurrencies();
|
|
319
|
+
const currenciesById = this.indexBy(currencies, 'id');
|
|
320
320
|
//
|
|
321
321
|
// [
|
|
322
322
|
// {
|
|
@@ -341,7 +341,8 @@ export default class bitvavo extends Exchange {
|
|
|
341
341
|
const quote = this.safeCurrencyCode(quoteId);
|
|
342
342
|
const status = this.safeString(market, 'status');
|
|
343
343
|
const baseCurrency = this.safeValue(currenciesById, baseId);
|
|
344
|
-
|
|
344
|
+
const basePrecision = this.safeInteger(baseCurrency, 'precision');
|
|
345
|
+
result.push(this.safeMarketStructure({
|
|
345
346
|
'id': id,
|
|
346
347
|
'symbol': base + '/' + quote,
|
|
347
348
|
'base': base,
|
|
@@ -366,7 +367,7 @@ export default class bitvavo extends Exchange {
|
|
|
366
367
|
'strike': undefined,
|
|
367
368
|
'optionType': undefined,
|
|
368
369
|
'precision': {
|
|
369
|
-
'amount': this.safeInteger(baseCurrency, 'decimals',
|
|
370
|
+
'amount': this.safeInteger(baseCurrency, 'decimals', basePrecision),
|
|
370
371
|
'price': this.safeInteger(market, 'pricePrecision'),
|
|
371
372
|
},
|
|
372
373
|
'limits': {
|
|
@@ -389,7 +390,7 @@ export default class bitvavo extends Exchange {
|
|
|
389
390
|
},
|
|
390
391
|
'created': undefined,
|
|
391
392
|
'info': market,
|
|
392
|
-
});
|
|
393
|
+
}));
|
|
393
394
|
}
|
|
394
395
|
return result;
|
|
395
396
|
}
|
package/js/src/bybit.d.ts
CHANGED
|
@@ -93,8 +93,6 @@ export default class bybit extends Exchange {
|
|
|
93
93
|
fetchFundingRates(symbols?: string[], params?: {}): Promise<any>;
|
|
94
94
|
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
95
95
|
parseTrade(trade: any, market?: any): Trade;
|
|
96
|
-
parseSpotTrade(trade: any, market?: any): Trade;
|
|
97
|
-
parseContractTrade(trade: any, market?: any): Trade;
|
|
98
96
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
99
97
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
100
98
|
parseBalance(response: any): Balances;
|
package/js/src/bybit.js
CHANGED
|
@@ -2526,88 +2526,8 @@ export default class bybit extends Exchange {
|
|
|
2526
2526
|
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
2527
2527
|
}
|
|
2528
2528
|
parseTrade(trade, market = undefined) {
|
|
2529
|
-
const isSpotTrade = ('isBuyerMaker' in trade) || ('feeTokenId' in trade);
|
|
2530
|
-
if (isSpotTrade) {
|
|
2531
|
-
return this.parseSpotTrade(trade, market);
|
|
2532
|
-
}
|
|
2533
|
-
else {
|
|
2534
|
-
return this.parseContractTrade(trade, market);
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
parseSpotTrade(trade, market = undefined) {
|
|
2538
|
-
//
|
|
2539
|
-
// public:
|
|
2540
|
-
// {
|
|
2541
|
-
// "price": "39548.68",
|
|
2542
|
-
// "time": "1651748717850",
|
|
2543
|
-
// "qty": "0.166872",
|
|
2544
|
-
// "isBuyerMaker": 0
|
|
2545
|
-
// }
|
|
2546
|
-
//
|
|
2547
|
-
// private:
|
|
2548
|
-
// {
|
|
2549
|
-
// "orderPrice": "82.5",
|
|
2550
|
-
// "creatTime": "1666702226326",
|
|
2551
|
-
// "orderQty": "0.016",
|
|
2552
|
-
// "isBuyer": "0",
|
|
2553
|
-
// "isMaker": "0",
|
|
2554
|
-
// "symbol": "AAVEUSDT",
|
|
2555
|
-
// "id": "1274785101965716992",
|
|
2556
|
-
// "orderId": "1274784252359089664",
|
|
2557
|
-
// "tradeId": "2270000000031365639",
|
|
2558
|
-
// "execFee": "0",
|
|
2559
|
-
// "feeTokenId": "AAVE",
|
|
2560
|
-
// "matchOrderId": "1274785101865076224",
|
|
2561
|
-
// "makerRebate": "0",
|
|
2562
|
-
// "executionTime": "1666702226335"
|
|
2563
|
-
// }
|
|
2564
|
-
//
|
|
2565
|
-
const timestamp = this.safeIntegerN(trade, ['time', 'creatTime']);
|
|
2566
|
-
let takerOrMaker = undefined;
|
|
2567
|
-
let side = undefined;
|
|
2568
|
-
const isBuyerMaker = this.safeInteger(trade, 'isBuyerMaker');
|
|
2569
|
-
if (isBuyerMaker !== undefined) {
|
|
2570
|
-
// if public response
|
|
2571
|
-
side = (isBuyerMaker === 1) ? 'buy' : 'sell';
|
|
2572
|
-
}
|
|
2573
|
-
else {
|
|
2574
|
-
// if private response
|
|
2575
|
-
const isBuyer = this.safeInteger(trade, 'isBuyer');
|
|
2576
|
-
const isMaker = this.safeInteger(trade, 'isMaker');
|
|
2577
|
-
takerOrMaker = (isMaker === 0) ? 'maker' : 'taker';
|
|
2578
|
-
side = (isBuyer === 0) ? 'buy' : 'sell';
|
|
2579
|
-
}
|
|
2580
|
-
const marketId = this.safeString(trade, 'symbol');
|
|
2581
|
-
market = this.safeMarket(marketId, market, undefined, 'spot');
|
|
2582
|
-
let fee = undefined;
|
|
2583
|
-
const feeCost = this.safeString(trade, 'execFee');
|
|
2584
|
-
if (feeCost !== undefined) {
|
|
2585
|
-
const feeToken = this.safeString(trade, 'feeTokenId');
|
|
2586
|
-
const feeCurrency = this.safeCurrencyCode(feeToken);
|
|
2587
|
-
fee = {
|
|
2588
|
-
'cost': feeCost,
|
|
2589
|
-
'currency': feeCurrency,
|
|
2590
|
-
};
|
|
2591
|
-
}
|
|
2592
|
-
return this.safeTrade({
|
|
2593
|
-
'id': this.safeString(trade, 'tradeId'),
|
|
2594
|
-
'info': trade,
|
|
2595
|
-
'timestamp': timestamp,
|
|
2596
|
-
'datetime': this.iso8601(timestamp),
|
|
2597
|
-
'symbol': market['symbol'],
|
|
2598
|
-
'order': this.safeString(trade, 'orderId'),
|
|
2599
|
-
'type': undefined,
|
|
2600
|
-
'side': side,
|
|
2601
|
-
'takerOrMaker': takerOrMaker,
|
|
2602
|
-
'price': this.safeString2(trade, 'price', 'orderPrice'),
|
|
2603
|
-
'amount': this.safeString2(trade, 'qty', 'orderQty'),
|
|
2604
|
-
'cost': undefined,
|
|
2605
|
-
'fee': fee,
|
|
2606
|
-
}, market);
|
|
2607
|
-
}
|
|
2608
|
-
parseContractTrade(trade, market = undefined) {
|
|
2609
2529
|
//
|
|
2610
|
-
// public
|
|
2530
|
+
// public https://bybit-exchange.github.io/docs/v5/market/recent-trade
|
|
2611
2531
|
//
|
|
2612
2532
|
// {
|
|
2613
2533
|
// "execId": "666042b4-50c6-58f3-bd9c-89b2088663ff",
|
|
@@ -2619,59 +2539,66 @@ export default class bybit extends Exchange {
|
|
|
2619
2539
|
// "isBlockTrade": false
|
|
2620
2540
|
// }
|
|
2621
2541
|
//
|
|
2622
|
-
//
|
|
2542
|
+
// private trades classic spot https://bybit-exchange.github.io/docs/v5/position/execution
|
|
2623
2543
|
//
|
|
2624
2544
|
// {
|
|
2625
|
-
// "
|
|
2626
|
-
// "
|
|
2627
|
-
// "price": "20802.50",
|
|
2628
|
-
// "size": "0.200",
|
|
2629
|
-
// "side": "Sell",
|
|
2630
|
-
// "time": "1657870316630"
|
|
2631
|
-
// }
|
|
2632
|
-
//
|
|
2633
|
-
// private contract trades
|
|
2634
|
-
//
|
|
2635
|
-
// {
|
|
2636
|
-
// "symbol": "ETHUSD",
|
|
2637
|
-
// "execFee": "0.00005484",
|
|
2638
|
-
// "execId": "acf78206-d464-589b-b888-51bd130821c1",
|
|
2639
|
-
// "execPrice": "1367.80",
|
|
2640
|
-
// "execQty": "100",
|
|
2641
|
-
// "execType": "Trade",
|
|
2642
|
-
// "execValue": "0.0731101",
|
|
2643
|
-
// "feeRate": "0.00075",
|
|
2644
|
-
// "lastLiquidityInd": "RemovedLiquidity",
|
|
2645
|
-
// "leavesQty": "0",
|
|
2646
|
-
// "orderId": "fdc584c3-be5d-41ff-8f54-5be7649b1d1c",
|
|
2545
|
+
// "symbol": "QNTUSDT",
|
|
2546
|
+
// "orderId": "1538686353240339712",
|
|
2647
2547
|
// "orderLinkId": "",
|
|
2648
|
-
// "orderPrice": "1299.50",
|
|
2649
|
-
// "orderQty": "100",
|
|
2650
|
-
// "orderType": "Market",
|
|
2651
|
-
// "stopOrderType": "UNKNOWN",
|
|
2652
2548
|
// "side": "Sell",
|
|
2653
|
-
// "
|
|
2654
|
-
// "
|
|
2549
|
+
// "orderPrice": "",
|
|
2550
|
+
// "orderQty": "",
|
|
2551
|
+
// "leavesQty": "",
|
|
2552
|
+
// "orderType": "Limit",
|
|
2553
|
+
// "stopOrderType": "",
|
|
2554
|
+
// "execFee": "0.040919",
|
|
2555
|
+
// "execId": "2210000000097330907",
|
|
2556
|
+
// "execPrice": "98.6",
|
|
2557
|
+
// "execQty": "0.415",
|
|
2558
|
+
// "execType": "",
|
|
2559
|
+
// "execValue": "",
|
|
2560
|
+
// "execTime": "1698161716634",
|
|
2561
|
+
// "isMaker": true,
|
|
2562
|
+
// "feeRate": "",
|
|
2563
|
+
// "tradeIv": "",
|
|
2564
|
+
// "markIv": "",
|
|
2565
|
+
// "markPrice": "",
|
|
2566
|
+
// "indexPrice": "",
|
|
2567
|
+
// "underlyingPrice": "",
|
|
2568
|
+
// "blockTradeId": ""
|
|
2655
2569
|
// }
|
|
2656
2570
|
//
|
|
2657
|
-
// private unified
|
|
2571
|
+
// private trades unified https://bybit-exchange.github.io/docs/v5/position/execution
|
|
2658
2572
|
//
|
|
2659
2573
|
// {
|
|
2660
|
-
// "symbol": "
|
|
2661
|
-
// "
|
|
2662
|
-
// "
|
|
2663
|
-
// "
|
|
2664
|
-
// "
|
|
2665
|
-
// "
|
|
2666
|
-
// "
|
|
2667
|
-
// "
|
|
2668
|
-
// "
|
|
2669
|
-
// "
|
|
2670
|
-
// "
|
|
2671
|
-
// "
|
|
2672
|
-
// "
|
|
2673
|
-
// "
|
|
2674
|
-
//
|
|
2574
|
+
// "symbol": "QNTUSDT",
|
|
2575
|
+
// "orderType": "Limit",
|
|
2576
|
+
// "underlyingPrice": "",
|
|
2577
|
+
// "orderLinkId": "1549452573428424449",
|
|
2578
|
+
// "orderId": "1549452573428424448",
|
|
2579
|
+
// "stopOrderType": "",
|
|
2580
|
+
// "execTime": "1699445151998",
|
|
2581
|
+
// "feeRate": "0.00025",
|
|
2582
|
+
// "tradeIv": "",
|
|
2583
|
+
// "blockTradeId": "",
|
|
2584
|
+
// "markPrice": "",
|
|
2585
|
+
// "execPrice": "102.8",
|
|
2586
|
+
// "markIv": "",
|
|
2587
|
+
// "orderQty": "3.652",
|
|
2588
|
+
// "orderPrice": "102.8",
|
|
2589
|
+
// "execValue": "1.028",
|
|
2590
|
+
// "closedSize": "",
|
|
2591
|
+
// "execType": "Trade",
|
|
2592
|
+
// "seq": "19157444346",
|
|
2593
|
+
// "side": "Buy",
|
|
2594
|
+
// "indexPrice": "",
|
|
2595
|
+
// "leavesQty": "3.642",
|
|
2596
|
+
// "isMaker": true,
|
|
2597
|
+
// "execFee": "0.0000025",
|
|
2598
|
+
// "execId": "2210000000101610464",
|
|
2599
|
+
// "execQty": "0.01",
|
|
2600
|
+
// "nextPageCursor": "267951%3A0%2C38567%3A0"
|
|
2601
|
+
// },
|
|
2675
2602
|
//
|
|
2676
2603
|
// private USDC settled trades
|
|
2677
2604
|
//
|
|
@@ -2743,9 +2670,25 @@ export default class bybit extends Exchange {
|
|
|
2743
2670
|
const feeCostString = this.safeString(trade, 'execFee');
|
|
2744
2671
|
let fee = undefined;
|
|
2745
2672
|
if (feeCostString !== undefined) {
|
|
2673
|
+
const feeRateString = this.safeString(trade, 'feeRate');
|
|
2746
2674
|
let feeCurrencyCode = undefined;
|
|
2747
2675
|
if (market['spot']) {
|
|
2748
|
-
|
|
2676
|
+
if (Precise.stringGt(feeCostString, '0')) {
|
|
2677
|
+
if (side === 'buy') {
|
|
2678
|
+
feeCurrencyCode = market['base'];
|
|
2679
|
+
}
|
|
2680
|
+
else {
|
|
2681
|
+
feeCurrencyCode = market['quote'];
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
else {
|
|
2685
|
+
if (side === 'buy') {
|
|
2686
|
+
feeCurrencyCode = market['quote'];
|
|
2687
|
+
}
|
|
2688
|
+
else {
|
|
2689
|
+
feeCurrencyCode = market['base'];
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2749
2692
|
}
|
|
2750
2693
|
else {
|
|
2751
2694
|
feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
|
|
@@ -2753,6 +2696,7 @@ export default class bybit extends Exchange {
|
|
|
2753
2696
|
fee = {
|
|
2754
2697
|
'cost': feeCostString,
|
|
2755
2698
|
'currency': feeCurrencyCode,
|
|
2699
|
+
'rate': feeRateString,
|
|
2756
2700
|
};
|
|
2757
2701
|
}
|
|
2758
2702
|
return this.safeTrade({
|
|
@@ -5758,11 +5702,19 @@ export default class bybit extends Exchange {
|
|
|
5758
5702
|
}
|
|
5759
5703
|
if (type === 'linear' || type === 'inverse') {
|
|
5760
5704
|
const baseCoin = this.safeString(params, 'baseCoin');
|
|
5761
|
-
if (
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5705
|
+
if (type === 'linear') {
|
|
5706
|
+
if (symbol === undefined && baseCoin === undefined) {
|
|
5707
|
+
const defaultSettle = this.safeString(this.options, 'defaultSettle', 'USDT');
|
|
5708
|
+
const settleCoin = this.safeString(params, 'settleCoin', defaultSettle);
|
|
5709
|
+
request['settleCoin'] = settleCoin;
|
|
5710
|
+
isUsdcSettled = (settleCoin === 'USDC');
|
|
5711
|
+
}
|
|
5712
|
+
}
|
|
5713
|
+
else {
|
|
5714
|
+
// inverse
|
|
5715
|
+
if (symbol === undefined && baseCoin === undefined) {
|
|
5716
|
+
request['category'] = 'inverse';
|
|
5717
|
+
}
|
|
5766
5718
|
}
|
|
5767
5719
|
}
|
|
5768
5720
|
if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
|
package/js/src/cryptocom.js
CHANGED
|
@@ -3170,7 +3170,7 @@ export default class cryptocom extends Exchange {
|
|
|
3170
3170
|
'datetime': this.iso8601(timestamp),
|
|
3171
3171
|
'hedged': undefined,
|
|
3172
3172
|
'side': undefined,
|
|
3173
|
-
'contracts':
|
|
3173
|
+
'contracts': this.safeNumber(position, 'quantity'),
|
|
3174
3174
|
'contractSize': market['contractSize'],
|
|
3175
3175
|
'entryPrice': undefined,
|
|
3176
3176
|
'markPrice': undefined,
|
package/js/src/gate.js
CHANGED
|
@@ -5095,13 +5095,14 @@ export default class gate extends Exchange {
|
|
|
5095
5095
|
const takerFee = '0.00075';
|
|
5096
5096
|
const feePaid = Precise.stringMul(takerFee, notional);
|
|
5097
5097
|
const initialMarginString = Precise.stringAdd(Precise.stringDiv(notional, leverage), feePaid);
|
|
5098
|
+
const timestamp = this.safeInteger(position, 'time_ms');
|
|
5098
5099
|
return this.safePosition({
|
|
5099
5100
|
'info': position,
|
|
5100
5101
|
'id': undefined,
|
|
5101
5102
|
'symbol': this.safeString(market, 'symbol'),
|
|
5102
5103
|
'timestamp': undefined,
|
|
5103
5104
|
'datetime': undefined,
|
|
5104
|
-
'lastUpdateTimestamp':
|
|
5105
|
+
'lastUpdateTimestamp': timestamp,
|
|
5105
5106
|
'initialMargin': this.parseNumber(initialMarginString),
|
|
5106
5107
|
'initialMarginPercentage': this.parseNumber(Precise.stringDiv(initialMarginString, notional)),
|
|
5107
5108
|
'maintenanceMargin': this.parseNumber(Precise.stringMul(maintenanceRate, notional)),
|
|
@@ -5110,6 +5111,7 @@ export default class gate extends Exchange {
|
|
|
5110
5111
|
'notional': this.parseNumber(notional),
|
|
5111
5112
|
'leverage': this.safeNumber(position, 'leverage'),
|
|
5112
5113
|
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
5114
|
+
'realizedPnl': this.safeNumber(position, 'realised_pnl'),
|
|
5113
5115
|
'contracts': this.parseNumber(Precise.stringAbs(size)),
|
|
5114
5116
|
'contractSize': this.safeValue(market, 'contractSize'),
|
|
5115
5117
|
// 'realisedPnl': position['realised_pnl'],
|
package/js/src/huobi.js
CHANGED
|
@@ -7047,8 +7047,7 @@ export default class huobi extends Exchange {
|
|
|
7047
7047
|
market = this.market(first);
|
|
7048
7048
|
}
|
|
7049
7049
|
let marginMode = undefined;
|
|
7050
|
-
[marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params);
|
|
7051
|
-
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
7050
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params, 'cross');
|
|
7052
7051
|
let subType = undefined;
|
|
7053
7052
|
[subType, params] = this.handleSubTypeAndParams('fetchPositions', market, params, 'linear');
|
|
7054
7053
|
let marketType = undefined;
|
package/js/src/okx.js
CHANGED
|
@@ -2554,6 +2554,13 @@ export default class okx extends Exchange {
|
|
|
2554
2554
|
request['tdMode'] = tradeMode;
|
|
2555
2555
|
}
|
|
2556
2556
|
else if (contract) {
|
|
2557
|
+
if (market['swap'] || market['future']) {
|
|
2558
|
+
let positionSide = undefined;
|
|
2559
|
+
[positionSide, params] = this.handleOptionAndParams(params, 'createOrder', 'positionSide');
|
|
2560
|
+
if (positionSide !== undefined) {
|
|
2561
|
+
request['posSide'] = positionSide;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2557
2564
|
request['tdMode'] = marginMode;
|
|
2558
2565
|
}
|
|
2559
2566
|
const isMarketOrder = type === 'market';
|
|
@@ -2750,7 +2757,7 @@ export default class okx extends Exchange {
|
|
|
2750
2757
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2751
2758
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
2752
2759
|
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
2753
|
-
* @param {bool} [params.reduceOnly]
|
|
2760
|
+
* @param {bool} [params.reduceOnly] a mark to reduce the position size for margin, swap and future orders
|
|
2754
2761
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
2755
2762
|
* @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)
|
|
2756
2763
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
@@ -2760,6 +2767,7 @@ export default class okx extends Exchange {
|
|
|
2760
2767
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
2761
2768
|
* @param {float} [params.stopLoss.price] used for stop loss limit orders, not used for stop loss market price orders
|
|
2762
2769
|
* @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
|
|
2770
|
+
* @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
|
|
2763
2771
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2764
2772
|
*/
|
|
2765
2773
|
await this.loadMarkets();
|
|
@@ -2779,7 +2787,16 @@ export default class okx extends Exchange {
|
|
|
2779
2787
|
// because it has a lower ratelimit
|
|
2780
2788
|
request = [request];
|
|
2781
2789
|
}
|
|
2782
|
-
|
|
2790
|
+
let response = undefined;
|
|
2791
|
+
if (method === 'privatePostTradeOrder') {
|
|
2792
|
+
response = await this.privatePostTradeOrder(request);
|
|
2793
|
+
}
|
|
2794
|
+
else if (method === 'privatePostTradeOrderAlgo') {
|
|
2795
|
+
response = await this.privatePostTradeOrderAlgo(request);
|
|
2796
|
+
}
|
|
2797
|
+
else {
|
|
2798
|
+
response = await this.privatePostTradeBatchOrders(request);
|
|
2799
|
+
}
|
|
2783
2800
|
const data = this.safeValue(response, 'data', []);
|
|
2784
2801
|
const first = this.safeValue(data, 0);
|
|
2785
2802
|
const order = this.parseOrder(first, market);
|
package/js/src/pro/binance.d.ts
CHANGED
|
@@ -70,11 +70,17 @@ export default class binance extends binanceRest {
|
|
|
70
70
|
watchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
71
71
|
parseWsOrder(order: any, market?: any): import("../base/types.js").Order;
|
|
72
72
|
handleOrderUpdate(client: Client, message: any): void;
|
|
73
|
+
watchPositions(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
74
|
+
setPositionsCache(client: Client, type: any, symbols?: string[]): void;
|
|
75
|
+
loadPositionsSnapshot(client: any, messageHash: any, type: any): Promise<void>;
|
|
76
|
+
handlePositions(client: any, message: any): void;
|
|
77
|
+
parseWsPosition(position: any, market?: any): import("../base/types.js").Position;
|
|
73
78
|
fetchMyTradesWs(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
74
79
|
handleTradesWs(client: Client, message: any): void;
|
|
75
80
|
watchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
76
81
|
handleMyTrade(client: Client, message: any): void;
|
|
77
82
|
handleOrder(client: Client, message: any): void;
|
|
83
|
+
handleAcountUpdate(client: any, message: any): void;
|
|
78
84
|
handleWsError(client: Client, message: any): void;
|
|
79
85
|
handleMessage(client: Client, message: any): any;
|
|
80
86
|
}
|