ccxt 4.2.62 → 4.2.64
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/build.sh +1 -1
- package/dist/ccxt.browser.js +271 -105
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +7 -9
- package/dist/cjs/src/bingx.js +45 -45
- package/dist/cjs/src/bitget.js +69 -1
- package/dist/cjs/src/blofin.js +11 -11
- package/dist/cjs/src/bybit.js +100 -7
- package/dist/cjs/src/gemini.js +9 -4
- package/dist/cjs/src/hitbtc.js +1 -1
- package/dist/cjs/src/krakenfutures.js +1 -0
- package/dist/cjs/src/kucoin.js +2 -1
- package/dist/cjs/src/pro/bitget.js +5 -5
- package/dist/cjs/src/pro/coinex.js +4 -4
- package/dist/cjs/src/pro/lbank.js +1 -1
- package/dist/cjs/src/yobit.js +15 -15
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/krakenfutures.d.ts +1 -0
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/binance.js +7 -9
- package/js/src/bingx.js +45 -45
- package/js/src/bitget.d.ts +3 -1
- package/js/src/bitget.js +69 -1
- package/js/src/blofin.js +11 -11
- package/js/src/bybit.d.ts +1 -0
- package/js/src/bybit.js +100 -7
- package/js/src/gemini.js +9 -4
- package/js/src/hitbtc.js +1 -1
- package/js/src/krakenfutures.js +1 -0
- package/js/src/kucoin.js +2 -1
- package/js/src/pro/bitget.js +5 -5
- package/js/src/pro/coinex.js +4 -4
- package/js/src/pro/lbank.js +1 -1
- package/js/src/yobit.js +15 -15
- package/package.json +1 -1
- package/skip-tests.json +14 -11
package/js/src/bingx.js
CHANGED
|
@@ -438,7 +438,7 @@ export default class bingx extends Exchange {
|
|
|
438
438
|
// }
|
|
439
439
|
// }
|
|
440
440
|
//
|
|
441
|
-
const data = this.
|
|
441
|
+
const data = this.safeDict(response, 'data');
|
|
442
442
|
return this.safeInteger(data, 'serverTime');
|
|
443
443
|
}
|
|
444
444
|
async fetchCurrencies(params = {}) {
|
|
@@ -493,14 +493,14 @@ export default class bingx extends Exchange {
|
|
|
493
493
|
// ],
|
|
494
494
|
// }
|
|
495
495
|
//
|
|
496
|
-
const data = this.
|
|
496
|
+
const data = this.safeList(response, 'data', []);
|
|
497
497
|
const result = {};
|
|
498
498
|
for (let i = 0; i < data.length; i++) {
|
|
499
499
|
const entry = data[i];
|
|
500
500
|
const currencyId = this.safeString(entry, 'coin');
|
|
501
501
|
const code = this.safeCurrencyCode(currencyId);
|
|
502
502
|
const name = this.safeString(entry, 'name');
|
|
503
|
-
const networkList = this.
|
|
503
|
+
const networkList = this.safeList(entry, 'networkList');
|
|
504
504
|
const networks = {};
|
|
505
505
|
let fee = undefined;
|
|
506
506
|
let active = undefined;
|
|
@@ -510,8 +510,8 @@ export default class bingx extends Exchange {
|
|
|
510
510
|
const rawNetwork = networkList[j];
|
|
511
511
|
const network = this.safeString(rawNetwork, 'network');
|
|
512
512
|
const networkCode = this.networkIdToCode(network);
|
|
513
|
-
const isDefault = this.
|
|
514
|
-
withdrawEnabled = this.
|
|
513
|
+
const isDefault = this.safeBool(rawNetwork, 'isDefault');
|
|
514
|
+
withdrawEnabled = this.safeBool(rawNetwork, 'withdrawEnable');
|
|
515
515
|
const limits = {
|
|
516
516
|
'amounts': { 'min': this.safeNumber(rawNetwork, 'withdrawMin'), 'max': this.safeNumber(rawNetwork, 'withdrawMax') },
|
|
517
517
|
};
|
|
@@ -572,8 +572,8 @@ export default class bingx extends Exchange {
|
|
|
572
572
|
// }
|
|
573
573
|
// }
|
|
574
574
|
//
|
|
575
|
-
const data = this.
|
|
576
|
-
const markets = this.
|
|
575
|
+
const data = this.safeDict(response, 'data');
|
|
576
|
+
const markets = this.safeList(data, 'symbols', []);
|
|
577
577
|
return this.parseMarkets(markets);
|
|
578
578
|
}
|
|
579
579
|
async fetchSwapMarkets(params) {
|
|
@@ -601,7 +601,7 @@ export default class bingx extends Exchange {
|
|
|
601
601
|
// ]
|
|
602
602
|
// }
|
|
603
603
|
//
|
|
604
|
-
const markets = this.
|
|
604
|
+
const markets = this.safeList(response, 'data', []);
|
|
605
605
|
return this.parseMarkets(markets);
|
|
606
606
|
}
|
|
607
607
|
parseMarket(market) {
|
|
@@ -628,7 +628,7 @@ export default class bingx extends Exchange {
|
|
|
628
628
|
if (settle !== undefined) {
|
|
629
629
|
symbol += ':' + settle;
|
|
630
630
|
}
|
|
631
|
-
const fees = this.
|
|
631
|
+
const fees = this.safeDict(this.fees, type, {});
|
|
632
632
|
const contractSize = this.safeNumber(market, 'size');
|
|
633
633
|
const isActive = this.safeString(market, 'status') === '1';
|
|
634
634
|
const isInverse = (spot) ? undefined : false;
|
|
@@ -702,8 +702,8 @@ export default class bingx extends Exchange {
|
|
|
702
702
|
requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
|
|
703
703
|
}
|
|
704
704
|
const promises = await Promise.all(requests);
|
|
705
|
-
const spotMarkets = this.
|
|
706
|
-
const swapMarkets = this.
|
|
705
|
+
const spotMarkets = this.safeList(promises, 0, []);
|
|
706
|
+
const swapMarkets = this.safeList(promises, 1, []);
|
|
707
707
|
return this.arrayConcat(spotMarkets, swapMarkets);
|
|
708
708
|
}
|
|
709
709
|
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
@@ -917,7 +917,7 @@ export default class bingx extends Exchange {
|
|
|
917
917
|
// ]
|
|
918
918
|
// }
|
|
919
919
|
//
|
|
920
|
-
const trades = this.
|
|
920
|
+
const trades = this.safeList(response, 'data', []);
|
|
921
921
|
return this.parseTrades(trades, market, since, limit);
|
|
922
922
|
}
|
|
923
923
|
parseTrade(trade, market = undefined) {
|
|
@@ -1013,9 +1013,9 @@ export default class bingx extends Exchange {
|
|
|
1013
1013
|
const type = (cost === undefined) ? 'spot' : 'swap';
|
|
1014
1014
|
const currencyId = this.safeStringN(trade, ['currency', 'N', 'commissionAsset']);
|
|
1015
1015
|
const currencyCode = this.safeCurrencyCode(currencyId);
|
|
1016
|
-
const m = this.
|
|
1016
|
+
const m = this.safeBool(trade, 'm');
|
|
1017
1017
|
const marketId = this.safeString(trade, 's');
|
|
1018
|
-
const isBuyerMaker = this.
|
|
1018
|
+
const isBuyerMaker = this.safeBool2(trade, 'buyerMaker', 'isBuyerMaker');
|
|
1019
1019
|
let takeOrMaker = undefined;
|
|
1020
1020
|
if ((isBuyerMaker !== undefined) || (m !== undefined)) {
|
|
1021
1021
|
takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
|
|
@@ -1027,11 +1027,11 @@ export default class bingx extends Exchange {
|
|
|
1027
1027
|
takeOrMaker = 'taker';
|
|
1028
1028
|
}
|
|
1029
1029
|
}
|
|
1030
|
-
const isBuyer = this.
|
|
1030
|
+
const isBuyer = this.safeBool(trade, 'isBuyer');
|
|
1031
1031
|
if (isBuyer !== undefined) {
|
|
1032
1032
|
side = isBuyer ? 'buy' : 'sell';
|
|
1033
1033
|
}
|
|
1034
|
-
const isMaker = this.
|
|
1034
|
+
const isMaker = this.safeBool(trade, 'isMaker');
|
|
1035
1035
|
if (isMaker !== undefined) {
|
|
1036
1036
|
takeOrMaker = isMaker ? 'maker' : 'taker';
|
|
1037
1037
|
}
|
|
@@ -1141,7 +1141,7 @@ export default class bingx extends Exchange {
|
|
|
1141
1141
|
// ]}
|
|
1142
1142
|
// }
|
|
1143
1143
|
//
|
|
1144
|
-
const orderbook = this.
|
|
1144
|
+
const orderbook = this.safeDict(response, 'data', {});
|
|
1145
1145
|
const timestamp = this.safeInteger2(orderbook, 'T', 'ts');
|
|
1146
1146
|
return this.parseOrderBook(orderbook, market['symbol'], timestamp, 'bids', 'asks', 0, 1);
|
|
1147
1147
|
}
|
|
@@ -1177,7 +1177,7 @@ export default class bingx extends Exchange {
|
|
|
1177
1177
|
// ]
|
|
1178
1178
|
// }
|
|
1179
1179
|
//
|
|
1180
|
-
const data = this.
|
|
1180
|
+
const data = this.safeList(response, 'data', []);
|
|
1181
1181
|
return this.parseFundingRate(data, market);
|
|
1182
1182
|
}
|
|
1183
1183
|
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
@@ -1193,7 +1193,7 @@ export default class bingx extends Exchange {
|
|
|
1193
1193
|
await this.loadMarkets();
|
|
1194
1194
|
symbols = this.marketSymbols(symbols, 'swap', true);
|
|
1195
1195
|
const response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(params));
|
|
1196
|
-
const data = this.
|
|
1196
|
+
const data = this.safeList(response, 'data', []);
|
|
1197
1197
|
const filteredResponse = [];
|
|
1198
1198
|
for (let i = 0; i < data.length; i++) {
|
|
1199
1199
|
const item = data[i];
|
|
@@ -1290,7 +1290,7 @@ export default class bingx extends Exchange {
|
|
|
1290
1290
|
// ]
|
|
1291
1291
|
// }
|
|
1292
1292
|
//
|
|
1293
|
-
const data = this.
|
|
1293
|
+
const data = this.safeList(response, 'data', []);
|
|
1294
1294
|
const rates = [];
|
|
1295
1295
|
for (let i = 0; i < data.length; i++) {
|
|
1296
1296
|
const entry = data[i];
|
|
@@ -1335,7 +1335,7 @@ export default class bingx extends Exchange {
|
|
|
1335
1335
|
// }
|
|
1336
1336
|
// }
|
|
1337
1337
|
//
|
|
1338
|
-
const data = this.
|
|
1338
|
+
const data = this.safeDict(response, 'data', {});
|
|
1339
1339
|
return this.parseOpenInterest(data, market);
|
|
1340
1340
|
}
|
|
1341
1341
|
parseOpenInterest(interest, market = undefined) {
|
|
@@ -1669,7 +1669,7 @@ export default class bingx extends Exchange {
|
|
|
1669
1669
|
// ]
|
|
1670
1670
|
// }
|
|
1671
1671
|
//
|
|
1672
|
-
const positions = this.
|
|
1672
|
+
const positions = this.safeList(response, 'data', []);
|
|
1673
1673
|
return this.parsePositions(positions, symbols);
|
|
1674
1674
|
}
|
|
1675
1675
|
parsePosition(position, market = undefined) {
|
|
@@ -1704,7 +1704,7 @@ export default class bingx extends Exchange {
|
|
|
1704
1704
|
//
|
|
1705
1705
|
let marketId = this.safeString(position, 'symbol', '');
|
|
1706
1706
|
marketId = marketId.replace('/', '-'); // standard return different format
|
|
1707
|
-
const isolated = this.
|
|
1707
|
+
const isolated = this.safeBool(position, 'isolated');
|
|
1708
1708
|
let marginMode = undefined;
|
|
1709
1709
|
if (isolated !== undefined) {
|
|
1710
1710
|
marginMode = isolated ? 'isolated' : 'cross';
|
|
@@ -2089,7 +2089,7 @@ export default class bingx extends Exchange {
|
|
|
2089
2089
|
const side = this.safeString(rawOrder, 'side');
|
|
2090
2090
|
const amount = this.safeNumber(rawOrder, 'amount');
|
|
2091
2091
|
const price = this.safeNumber(rawOrder, 'price');
|
|
2092
|
-
const orderParams = this.
|
|
2092
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
2093
2093
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
2094
2094
|
ordersRequests.push(orderRequest);
|
|
2095
2095
|
}
|
|
@@ -2149,8 +2149,8 @@ export default class bingx extends Exchange {
|
|
|
2149
2149
|
// }
|
|
2150
2150
|
// }
|
|
2151
2151
|
//
|
|
2152
|
-
const data = this.
|
|
2153
|
-
const result = this.
|
|
2152
|
+
const data = this.safeDict(response, 'data', {});
|
|
2153
|
+
const result = this.safeList(data, 'orders', []);
|
|
2154
2154
|
return this.parseOrders(result, market);
|
|
2155
2155
|
}
|
|
2156
2156
|
parseOrderSide(side) {
|
|
@@ -2883,8 +2883,8 @@ export default class bingx extends Exchange {
|
|
|
2883
2883
|
// }
|
|
2884
2884
|
// }
|
|
2885
2885
|
//
|
|
2886
|
-
const data = this.
|
|
2887
|
-
const orders = this.
|
|
2886
|
+
const data = this.safeDict(response, 'data', {});
|
|
2887
|
+
const orders = this.safeList(data, 'orders', []);
|
|
2888
2888
|
return this.parseOrders(orders, market, since, limit);
|
|
2889
2889
|
}
|
|
2890
2890
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2998,7 +2998,7 @@ export default class bingx extends Exchange {
|
|
|
2998
2998
|
*/
|
|
2999
2999
|
await this.loadMarkets();
|
|
3000
3000
|
const currency = this.currency(code);
|
|
3001
|
-
const accountsByType = this.
|
|
3001
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
3002
3002
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
3003
3003
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
3004
3004
|
const request = {
|
|
@@ -3041,7 +3041,7 @@ export default class bingx extends Exchange {
|
|
|
3041
3041
|
if (code !== undefined) {
|
|
3042
3042
|
currency = this.currency(code);
|
|
3043
3043
|
}
|
|
3044
|
-
const accountsByType = this.
|
|
3044
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
3045
3045
|
const fromAccount = this.safeString(params, 'fromAccount');
|
|
3046
3046
|
const toAccount = this.safeString(params, 'toAccount');
|
|
3047
3047
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
@@ -3074,7 +3074,7 @@ export default class bingx extends Exchange {
|
|
|
3074
3074
|
// ]
|
|
3075
3075
|
// }
|
|
3076
3076
|
//
|
|
3077
|
-
const rows = this.
|
|
3077
|
+
const rows = this.safeList(response, 'rows', []);
|
|
3078
3078
|
return this.parseTransfers(rows, currency, since, limit);
|
|
3079
3079
|
}
|
|
3080
3080
|
parseTransfer(transfer, currency = undefined) {
|
|
@@ -3082,7 +3082,7 @@ export default class bingx extends Exchange {
|
|
|
3082
3082
|
const timestamp = this.safeInteger(transfer, 'timestamp');
|
|
3083
3083
|
const currencyCode = this.safeCurrencyCode(undefined, currency);
|
|
3084
3084
|
const status = this.safeString(transfer, 'status');
|
|
3085
|
-
const accountsById = this.
|
|
3085
|
+
const accountsById = this.safeDict(this.options, 'accountsById', {});
|
|
3086
3086
|
const typeId = this.safeString(transfer, 'type');
|
|
3087
3087
|
const typeIdSplit = typeId.split('_');
|
|
3088
3088
|
const fromId = this.safeString(typeIdSplit, 0);
|
|
@@ -3140,7 +3140,7 @@ export default class bingx extends Exchange {
|
|
|
3140
3140
|
// }
|
|
3141
3141
|
// }
|
|
3142
3142
|
//
|
|
3143
|
-
const data = this.
|
|
3143
|
+
const data = this.safeList(this.safeDict(response, 'data'), 'data');
|
|
3144
3144
|
const parsed = this.parseDepositAddresses(data, [currency['code']], false);
|
|
3145
3145
|
return this.indexBy(parsed, 'network');
|
|
3146
3146
|
}
|
|
@@ -3593,8 +3593,8 @@ export default class bingx extends Exchange {
|
|
|
3593
3593
|
let fills = undefined;
|
|
3594
3594
|
if (market['spot']) {
|
|
3595
3595
|
response = await this.spotV1PrivateGetTradeMyTrades(this.extend(request, params));
|
|
3596
|
-
const data = this.
|
|
3597
|
-
fills = this.
|
|
3596
|
+
const data = this.safeDict(response, 'data', {});
|
|
3597
|
+
fills = this.safeList(data, 'fills', []);
|
|
3598
3598
|
//
|
|
3599
3599
|
// {
|
|
3600
3600
|
// "code": 0,
|
|
@@ -3625,8 +3625,8 @@ export default class bingx extends Exchange {
|
|
|
3625
3625
|
params = this.omit(params, 'tradingUnit');
|
|
3626
3626
|
request['tradingUnit'] = tradingUnit;
|
|
3627
3627
|
response = await this.swapV2PrivateGetTradeAllFillOrders(this.extend(request, params));
|
|
3628
|
-
const data = this.
|
|
3629
|
-
fills = this.
|
|
3628
|
+
const data = this.safeDict(response, 'data', {});
|
|
3629
|
+
fills = this.safeList(data, 'fill_orders', []);
|
|
3630
3630
|
//
|
|
3631
3631
|
// {
|
|
3632
3632
|
// "code": "0",
|
|
@@ -3679,7 +3679,7 @@ export default class bingx extends Exchange {
|
|
|
3679
3679
|
// ]
|
|
3680
3680
|
// }
|
|
3681
3681
|
//
|
|
3682
|
-
const networkList = this.
|
|
3682
|
+
const networkList = this.safeList(fee, 'networkList', []);
|
|
3683
3683
|
const networkListLength = networkList.length;
|
|
3684
3684
|
const result = {
|
|
3685
3685
|
'info': fee,
|
|
@@ -3697,7 +3697,7 @@ export default class bingx extends Exchange {
|
|
|
3697
3697
|
for (let i = 0; i < networkListLength; i++) {
|
|
3698
3698
|
const network = networkList[i];
|
|
3699
3699
|
const networkId = this.safeString(network, 'network');
|
|
3700
|
-
const isDefault = this.
|
|
3700
|
+
const isDefault = this.safeBool(network, 'isDefault');
|
|
3701
3701
|
const currencyCode = this.safeString(currency, 'code');
|
|
3702
3702
|
const networkCode = this.networkIdToCode(networkId, currencyCode);
|
|
3703
3703
|
result['networks'][networkCode] = {
|
|
@@ -3852,8 +3852,8 @@ export default class bingx extends Exchange {
|
|
|
3852
3852
|
// }
|
|
3853
3853
|
// }
|
|
3854
3854
|
//
|
|
3855
|
-
const data = this.
|
|
3856
|
-
const liquidations = this.
|
|
3855
|
+
const data = this.safeDict(response, 'data', {});
|
|
3856
|
+
const liquidations = this.safeList(data, 'orders', []);
|
|
3857
3857
|
return this.parseLiquidations(liquidations, market, since, limit);
|
|
3858
3858
|
}
|
|
3859
3859
|
parseLiquidation(liquidation, market = undefined) {
|
|
@@ -3926,7 +3926,7 @@ export default class bingx extends Exchange {
|
|
|
3926
3926
|
// }
|
|
3927
3927
|
// }
|
|
3928
3928
|
//
|
|
3929
|
-
const data = this.
|
|
3929
|
+
const data = this.safeDict(response, 'data');
|
|
3930
3930
|
return this.parseOrder(data);
|
|
3931
3931
|
}
|
|
3932
3932
|
async closeAllPositions(params = {}) {
|
|
@@ -3964,8 +3964,8 @@ export default class bingx extends Exchange {
|
|
|
3964
3964
|
// }
|
|
3965
3965
|
// }
|
|
3966
3966
|
//
|
|
3967
|
-
const data = this.
|
|
3968
|
-
const success = this.
|
|
3967
|
+
const data = this.safeDict(response, 'data', {});
|
|
3968
|
+
const success = this.safeList(data, 'success', []);
|
|
3969
3969
|
const positions = [];
|
|
3970
3970
|
for (let i = 0; i < success.length; i++) {
|
|
3971
3971
|
const position = this.parsePosition({ 'positionId': success[i] });
|
|
@@ -4178,7 +4178,7 @@ export default class bingx extends Exchange {
|
|
|
4178
4178
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Mode
|
|
4179
4179
|
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
4180
4180
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4181
|
-
* @returns {object}
|
|
4181
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
4182
4182
|
*/
|
|
4183
4183
|
await this.loadMarkets();
|
|
4184
4184
|
const market = this.market(symbol);
|
package/js/src/bitget.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bitget.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bitget
|
|
5
5
|
* @augments Exchange
|
|
@@ -290,6 +290,8 @@ export default class bitget extends Exchange {
|
|
|
290
290
|
};
|
|
291
291
|
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
292
292
|
closeAllPositions(params?: {}): Promise<Position[]>;
|
|
293
|
+
fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
|
|
294
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
293
295
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
294
296
|
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
295
297
|
url: string;
|
package/js/src/bitget.js
CHANGED
|
@@ -87,7 +87,7 @@ export default class bitget extends Exchange {
|
|
|
87
87
|
'fetchLeverage': true,
|
|
88
88
|
'fetchLeverageTiers': false,
|
|
89
89
|
'fetchLiquidations': false,
|
|
90
|
-
'fetchMarginMode':
|
|
90
|
+
'fetchMarginMode': true,
|
|
91
91
|
'fetchMarketLeverageTiers': true,
|
|
92
92
|
'fetchMarkets': true,
|
|
93
93
|
'fetchMarkOHLCV': true,
|
|
@@ -8307,6 +8307,74 @@ export default class bitget extends Exchange {
|
|
|
8307
8307
|
const orderInfo = this.safeValue(data, 'successList', []);
|
|
8308
8308
|
return this.parsePositions(orderInfo, undefined, params);
|
|
8309
8309
|
}
|
|
8310
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
8311
|
+
/**
|
|
8312
|
+
* @method
|
|
8313
|
+
* @name bitget#fetchMarginMode
|
|
8314
|
+
* @description fetches the margin mode of a trading pair
|
|
8315
|
+
* @see https://www.bitget.com/api-doc/contract/account/Get-Single-Account
|
|
8316
|
+
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
8317
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8318
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
8319
|
+
*/
|
|
8320
|
+
await this.loadMarkets();
|
|
8321
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
8322
|
+
let market = undefined;
|
|
8323
|
+
if (sandboxMode) {
|
|
8324
|
+
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
8325
|
+
market = this.market(sandboxSymbol);
|
|
8326
|
+
}
|
|
8327
|
+
else {
|
|
8328
|
+
market = this.market(symbol);
|
|
8329
|
+
}
|
|
8330
|
+
let productType = undefined;
|
|
8331
|
+
[productType, params] = this.handleProductTypeAndParams(market, params);
|
|
8332
|
+
const request = {
|
|
8333
|
+
'symbol': market['id'],
|
|
8334
|
+
'marginCoin': market['settleId'],
|
|
8335
|
+
'productType': productType,
|
|
8336
|
+
};
|
|
8337
|
+
const response = await this.privateMixGetV2MixAccountAccount(this.extend(request, params));
|
|
8338
|
+
//
|
|
8339
|
+
// {
|
|
8340
|
+
// "code": "00000",
|
|
8341
|
+
// "msg": "success",
|
|
8342
|
+
// "requestTime": 1709791216652,
|
|
8343
|
+
// "data": {
|
|
8344
|
+
// "marginCoin": "USDT",
|
|
8345
|
+
// "locked": "0",
|
|
8346
|
+
// "available": "19.88811074",
|
|
8347
|
+
// "crossedMaxAvailable": "19.88811074",
|
|
8348
|
+
// "isolatedMaxAvailable": "19.88811074",
|
|
8349
|
+
// "maxTransferOut": "19.88811074",
|
|
8350
|
+
// "accountEquity": "19.88811074",
|
|
8351
|
+
// "usdtEquity": "19.888110749166",
|
|
8352
|
+
// "btcEquity": "0.000302183391",
|
|
8353
|
+
// "crossedRiskRate": "0",
|
|
8354
|
+
// "crossedMarginLeverage": 20,
|
|
8355
|
+
// "isolatedLongLever": 20,
|
|
8356
|
+
// "isolatedShortLever": 20,
|
|
8357
|
+
// "marginMode": "crossed",
|
|
8358
|
+
// "posMode": "hedge_mode",
|
|
8359
|
+
// "unrealizedPL": "0",
|
|
8360
|
+
// "coupon": "0",
|
|
8361
|
+
// "crossedUnrealizedPL": "0",
|
|
8362
|
+
// "isolatedUnrealizedPL": ""
|
|
8363
|
+
// }
|
|
8364
|
+
// }
|
|
8365
|
+
//
|
|
8366
|
+
const data = this.safeDict(response, 'data', {});
|
|
8367
|
+
return this.parseMarginMode(data, market);
|
|
8368
|
+
}
|
|
8369
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
8370
|
+
let marginType = this.safeString(marginMode, 'marginMode');
|
|
8371
|
+
marginType = (marginType === 'crossed') ? 'cross' : marginType;
|
|
8372
|
+
return {
|
|
8373
|
+
'info': marginMode,
|
|
8374
|
+
'symbol': market['symbol'],
|
|
8375
|
+
'marginMode': marginType,
|
|
8376
|
+
};
|
|
8377
|
+
}
|
|
8310
8378
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
8311
8379
|
if (!response) {
|
|
8312
8380
|
return undefined; // fallback to default error handler
|
package/js/src/blofin.js
CHANGED
|
@@ -381,7 +381,7 @@ export default class blofin extends Exchange {
|
|
|
381
381
|
const strikePrice = undefined;
|
|
382
382
|
const optionType = undefined;
|
|
383
383
|
const tickSize = this.safeString(market, 'tickSize');
|
|
384
|
-
const fees = this.
|
|
384
|
+
const fees = this.safeDict2(this.fees, type, 'trading', {});
|
|
385
385
|
const taker = this.safeNumber(fees, 'taker');
|
|
386
386
|
const maker = this.safeNumber(fees, 'maker');
|
|
387
387
|
let maxLeverage = this.safeString(market, 'maxLeverage', '100');
|
|
@@ -482,7 +482,7 @@ export default class blofin extends Exchange {
|
|
|
482
482
|
// }
|
|
483
483
|
//
|
|
484
484
|
const data = this.safeList(response, 'data', []);
|
|
485
|
-
const first = this.
|
|
485
|
+
const first = this.safeDict(data, 0, {});
|
|
486
486
|
const timestamp = this.safeInteger(first, 'ts');
|
|
487
487
|
return this.parseOrderBook(first, symbol, timestamp);
|
|
488
488
|
}
|
|
@@ -538,7 +538,7 @@ export default class blofin extends Exchange {
|
|
|
538
538
|
};
|
|
539
539
|
const response = await this.publicGetMarketTickers(this.extend(request, params));
|
|
540
540
|
const data = this.safeList(response, 'data', []);
|
|
541
|
-
const first = this.
|
|
541
|
+
const first = this.safeDict(data, 0, {});
|
|
542
542
|
return this.parseTicker(first, market);
|
|
543
543
|
}
|
|
544
544
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -998,8 +998,8 @@ export default class blofin extends Exchange {
|
|
|
998
998
|
if (postOnly) {
|
|
999
999
|
request['type'] = 'post_only';
|
|
1000
1000
|
}
|
|
1001
|
-
const stopLoss = this.
|
|
1002
|
-
const takeProfit = this.
|
|
1001
|
+
const stopLoss = this.safeDict(params, 'stopLoss');
|
|
1002
|
+
const takeProfit = this.safeDict(params, 'takeProfit');
|
|
1003
1003
|
params = this.omit(params, ['stopLoss', 'takeProfit']);
|
|
1004
1004
|
const isStopLoss = stopLoss !== undefined;
|
|
1005
1005
|
const isTakeProfit = takeProfit !== undefined;
|
|
@@ -1292,7 +1292,7 @@ export default class blofin extends Exchange {
|
|
|
1292
1292
|
const side = this.safeString(rawOrder, 'side');
|
|
1293
1293
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
1294
1294
|
const price = this.safeValue(rawOrder, 'price');
|
|
1295
|
-
const orderParams = this.
|
|
1295
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
1296
1296
|
const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
|
|
1297
1297
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
|
|
1298
1298
|
ordersRequests.push(orderRequest);
|
|
@@ -1331,7 +1331,7 @@ export default class blofin extends Exchange {
|
|
|
1331
1331
|
if (limit !== undefined) {
|
|
1332
1332
|
request['limit'] = limit; // default 100, max 100
|
|
1333
1333
|
}
|
|
1334
|
-
const isStop = this.
|
|
1334
|
+
const isStop = this.safeBoolN(params, ['stop', 'trigger', 'tpsl', 'TPSL'], false);
|
|
1335
1335
|
let method = undefined;
|
|
1336
1336
|
[method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersPending');
|
|
1337
1337
|
const query = this.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL']);
|
|
@@ -1659,7 +1659,7 @@ export default class blofin extends Exchange {
|
|
|
1659
1659
|
await this.loadMarkets();
|
|
1660
1660
|
const market = this.market(symbol);
|
|
1661
1661
|
const request = [];
|
|
1662
|
-
const options = this.
|
|
1662
|
+
const options = this.safeDict(this.options, 'cancelOrders', {});
|
|
1663
1663
|
const defaultMethod = this.safeString(options, 'method', 'privatePostTradeCancelBatchOrders');
|
|
1664
1664
|
let method = this.safeString(params, 'method', defaultMethod);
|
|
1665
1665
|
const clientOrderIds = this.parseIds(this.safeValue(params, 'clientOrderId'));
|
|
@@ -1726,7 +1726,7 @@ export default class blofin extends Exchange {
|
|
|
1726
1726
|
*/
|
|
1727
1727
|
await this.loadMarkets();
|
|
1728
1728
|
const currency = this.currency(code);
|
|
1729
|
-
const accountsByType = this.
|
|
1729
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
1730
1730
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
1731
1731
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
1732
1732
|
const request = {
|
|
@@ -2059,7 +2059,7 @@ export default class blofin extends Exchange {
|
|
|
2059
2059
|
request['clientOrderId'] = clientOrderId;
|
|
2060
2060
|
}
|
|
2061
2061
|
const response = await this.privatePostTradeClosePosition(this.extend(request, params));
|
|
2062
|
-
return this.
|
|
2062
|
+
return this.safeDict(response, 'data');
|
|
2063
2063
|
}
|
|
2064
2064
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2065
2065
|
/**
|
|
@@ -2094,7 +2094,7 @@ export default class blofin extends Exchange {
|
|
|
2094
2094
|
if (since !== undefined) {
|
|
2095
2095
|
request['begin'] = since;
|
|
2096
2096
|
}
|
|
2097
|
-
const isStop = this.
|
|
2097
|
+
const isStop = this.safeBoolN(params, ['stop', 'trigger', 'tpsl', 'TPSL'], false);
|
|
2098
2098
|
let method = undefined;
|
|
2099
2099
|
[method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersHistory');
|
|
2100
2100
|
const query = this.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL']);
|
package/js/src/bybit.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export default class bybit extends Exchange {
|
|
|
66
66
|
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
|
|
67
67
|
cancelUsdcOrder(id: any, symbol?: Str, params?: {}): Promise<Order>;
|
|
68
68
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
69
|
+
cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
|
|
69
70
|
cancelAllUsdcOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
70
71
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
71
72
|
fetchUsdcOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|