ccxt 4.2.63 → 4.2.65
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 +2 -2
- package/dist/ccxt.browser.js +565 -178
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +12 -0
- package/dist/cjs/src/binance.js +33 -12
- package/dist/cjs/src/bingx.js +58 -49
- package/dist/cjs/src/bitget.js +69 -1
- package/dist/cjs/src/bitmex.js +3 -1
- package/dist/cjs/src/blofin.js +46 -11
- package/dist/cjs/src/btcmarkets.js +12 -0
- package/dist/cjs/src/bybit.js +100 -7
- package/dist/cjs/src/coinbase.js +12 -2
- package/dist/cjs/src/delta.js +95 -1
- 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 +87 -62
- package/dist/cjs/src/pro/bitget.js +5 -5
- package/dist/cjs/src/pro/coinex.js +4 -4
- package/dist/cjs/src/pro/currencycom.js +1 -1
- 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/blofin.d.ts +1 -0
- package/js/src/abstract/krakenfutures.d.ts +1 -0
- package/js/src/abstract/kucoin.d.ts +10 -0
- package/js/src/abstract/kucoinfutures.d.ts +10 -0
- package/js/src/base/Exchange.js +12 -0
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +33 -12
- package/js/src/bingx.js +58 -49
- package/js/src/bitget.d.ts +3 -1
- package/js/src/bitget.js +69 -1
- package/js/src/bitmex.js +3 -1
- package/js/src/blofin.d.ts +3 -1
- package/js/src/blofin.js +46 -11
- package/js/src/btcmarkets.js +12 -0
- package/js/src/bybit.d.ts +1 -0
- package/js/src/bybit.js +100 -7
- package/js/src/coinbase.js +12 -2
- package/js/src/delta.d.ts +3 -1
- package/js/src/delta.js +95 -1
- package/js/src/gate.d.ts +1 -1
- 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 +87 -62
- package/js/src/okx.d.ts +1 -1
- package/js/src/pro/bitget.js +5 -5
- package/js/src/pro/coinex.js +4 -4
- package/js/src/pro/currencycom.d.ts +1 -1
- package/js/src/pro/currencycom.js +1 -1
- package/js/src/pro/lbank.js +1 -1
- package/js/src/woo.d.ts +1 -1
- package/js/src/yobit.js +15 -15
- package/package.json +2 -2
- package/skip-tests.json +47 -22
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';
|
|
@@ -1867,6 +1867,7 @@ export default class bingx extends Exchange {
|
|
|
1867
1867
|
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
1868
1868
|
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
1869
1869
|
const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
|
|
1870
|
+
const trailingType = this.safeString(params, 'trailingType', 'TRAILING_STOP_MARKET');
|
|
1870
1871
|
const isTriggerOrder = triggerPrice !== undefined;
|
|
1871
1872
|
const isStopLossPriceOrder = stopLossPrice !== undefined;
|
|
1872
1873
|
const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
|
|
@@ -1913,7 +1914,7 @@ export default class bingx extends Exchange {
|
|
|
1913
1914
|
}
|
|
1914
1915
|
}
|
|
1915
1916
|
else if (isTrailing) {
|
|
1916
|
-
request['type'] =
|
|
1917
|
+
request['type'] = trailingType;
|
|
1917
1918
|
if (isTrailingAmountOrder) {
|
|
1918
1919
|
request['price'] = this.parseToNumeric(trailingAmount);
|
|
1919
1920
|
}
|
|
@@ -1968,7 +1969,7 @@ export default class bingx extends Exchange {
|
|
|
1968
1969
|
}
|
|
1969
1970
|
request['positionSide'] = positionSide;
|
|
1970
1971
|
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
1971
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
1972
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
1972
1973
|
}
|
|
1973
1974
|
return this.extend(request, params);
|
|
1974
1975
|
}
|
|
@@ -1999,14 +2000,22 @@ export default class bingx extends Exchange {
|
|
|
1999
2000
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
2000
2001
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
2001
2002
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
2003
|
+
* @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
|
|
2002
2004
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2003
2005
|
*/
|
|
2004
2006
|
await this.loadMarkets();
|
|
2005
2007
|
const market = this.market(symbol);
|
|
2008
|
+
const test = this.safeBool(params, 'test', false);
|
|
2009
|
+
params = this.omit(params, 'test');
|
|
2006
2010
|
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
2007
2011
|
let response = undefined;
|
|
2008
2012
|
if (market['swap']) {
|
|
2009
|
-
|
|
2013
|
+
if (test) {
|
|
2014
|
+
response = await this.swapV2PrivatePostTradeOrderTest(request);
|
|
2015
|
+
}
|
|
2016
|
+
else {
|
|
2017
|
+
response = await this.swapV2PrivatePostTradeOrder(request);
|
|
2018
|
+
}
|
|
2010
2019
|
}
|
|
2011
2020
|
else {
|
|
2012
2021
|
response = await this.spotV1PrivatePostTradeOrder(request);
|
|
@@ -2089,7 +2098,7 @@ export default class bingx extends Exchange {
|
|
|
2089
2098
|
const side = this.safeString(rawOrder, 'side');
|
|
2090
2099
|
const amount = this.safeNumber(rawOrder, 'amount');
|
|
2091
2100
|
const price = this.safeNumber(rawOrder, 'price');
|
|
2092
|
-
const orderParams = this.
|
|
2101
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
2093
2102
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
2094
2103
|
ordersRequests.push(orderRequest);
|
|
2095
2104
|
}
|
|
@@ -2149,8 +2158,8 @@ export default class bingx extends Exchange {
|
|
|
2149
2158
|
// }
|
|
2150
2159
|
// }
|
|
2151
2160
|
//
|
|
2152
|
-
const data = this.
|
|
2153
|
-
const result = this.
|
|
2161
|
+
const data = this.safeDict(response, 'data', {});
|
|
2162
|
+
const result = this.safeList(data, 'orders', []);
|
|
2154
2163
|
return this.parseOrders(result, market);
|
|
2155
2164
|
}
|
|
2156
2165
|
parseOrderSide(side) {
|
|
@@ -2883,8 +2892,8 @@ export default class bingx extends Exchange {
|
|
|
2883
2892
|
// }
|
|
2884
2893
|
// }
|
|
2885
2894
|
//
|
|
2886
|
-
const data = this.
|
|
2887
|
-
const orders = this.
|
|
2895
|
+
const data = this.safeDict(response, 'data', {});
|
|
2896
|
+
const orders = this.safeList(data, 'orders', []);
|
|
2888
2897
|
return this.parseOrders(orders, market, since, limit);
|
|
2889
2898
|
}
|
|
2890
2899
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2998,7 +3007,7 @@ export default class bingx extends Exchange {
|
|
|
2998
3007
|
*/
|
|
2999
3008
|
await this.loadMarkets();
|
|
3000
3009
|
const currency = this.currency(code);
|
|
3001
|
-
const accountsByType = this.
|
|
3010
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
3002
3011
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
3003
3012
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
3004
3013
|
const request = {
|
|
@@ -3041,7 +3050,7 @@ export default class bingx extends Exchange {
|
|
|
3041
3050
|
if (code !== undefined) {
|
|
3042
3051
|
currency = this.currency(code);
|
|
3043
3052
|
}
|
|
3044
|
-
const accountsByType = this.
|
|
3053
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
3045
3054
|
const fromAccount = this.safeString(params, 'fromAccount');
|
|
3046
3055
|
const toAccount = this.safeString(params, 'toAccount');
|
|
3047
3056
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
@@ -3074,7 +3083,7 @@ export default class bingx extends Exchange {
|
|
|
3074
3083
|
// ]
|
|
3075
3084
|
// }
|
|
3076
3085
|
//
|
|
3077
|
-
const rows = this.
|
|
3086
|
+
const rows = this.safeList(response, 'rows', []);
|
|
3078
3087
|
return this.parseTransfers(rows, currency, since, limit);
|
|
3079
3088
|
}
|
|
3080
3089
|
parseTransfer(transfer, currency = undefined) {
|
|
@@ -3082,7 +3091,7 @@ export default class bingx extends Exchange {
|
|
|
3082
3091
|
const timestamp = this.safeInteger(transfer, 'timestamp');
|
|
3083
3092
|
const currencyCode = this.safeCurrencyCode(undefined, currency);
|
|
3084
3093
|
const status = this.safeString(transfer, 'status');
|
|
3085
|
-
const accountsById = this.
|
|
3094
|
+
const accountsById = this.safeDict(this.options, 'accountsById', {});
|
|
3086
3095
|
const typeId = this.safeString(transfer, 'type');
|
|
3087
3096
|
const typeIdSplit = typeId.split('_');
|
|
3088
3097
|
const fromId = this.safeString(typeIdSplit, 0);
|
|
@@ -3140,7 +3149,7 @@ export default class bingx extends Exchange {
|
|
|
3140
3149
|
// }
|
|
3141
3150
|
// }
|
|
3142
3151
|
//
|
|
3143
|
-
const data = this.
|
|
3152
|
+
const data = this.safeList(this.safeDict(response, 'data'), 'data');
|
|
3144
3153
|
const parsed = this.parseDepositAddresses(data, [currency['code']], false);
|
|
3145
3154
|
return this.indexBy(parsed, 'network');
|
|
3146
3155
|
}
|
|
@@ -3593,8 +3602,8 @@ export default class bingx extends Exchange {
|
|
|
3593
3602
|
let fills = undefined;
|
|
3594
3603
|
if (market['spot']) {
|
|
3595
3604
|
response = await this.spotV1PrivateGetTradeMyTrades(this.extend(request, params));
|
|
3596
|
-
const data = this.
|
|
3597
|
-
fills = this.
|
|
3605
|
+
const data = this.safeDict(response, 'data', {});
|
|
3606
|
+
fills = this.safeList(data, 'fills', []);
|
|
3598
3607
|
//
|
|
3599
3608
|
// {
|
|
3600
3609
|
// "code": 0,
|
|
@@ -3625,8 +3634,8 @@ export default class bingx extends Exchange {
|
|
|
3625
3634
|
params = this.omit(params, 'tradingUnit');
|
|
3626
3635
|
request['tradingUnit'] = tradingUnit;
|
|
3627
3636
|
response = await this.swapV2PrivateGetTradeAllFillOrders(this.extend(request, params));
|
|
3628
|
-
const data = this.
|
|
3629
|
-
fills = this.
|
|
3637
|
+
const data = this.safeDict(response, 'data', {});
|
|
3638
|
+
fills = this.safeList(data, 'fill_orders', []);
|
|
3630
3639
|
//
|
|
3631
3640
|
// {
|
|
3632
3641
|
// "code": "0",
|
|
@@ -3679,7 +3688,7 @@ export default class bingx extends Exchange {
|
|
|
3679
3688
|
// ]
|
|
3680
3689
|
// }
|
|
3681
3690
|
//
|
|
3682
|
-
const networkList = this.
|
|
3691
|
+
const networkList = this.safeList(fee, 'networkList', []);
|
|
3683
3692
|
const networkListLength = networkList.length;
|
|
3684
3693
|
const result = {
|
|
3685
3694
|
'info': fee,
|
|
@@ -3697,7 +3706,7 @@ export default class bingx extends Exchange {
|
|
|
3697
3706
|
for (let i = 0; i < networkListLength; i++) {
|
|
3698
3707
|
const network = networkList[i];
|
|
3699
3708
|
const networkId = this.safeString(network, 'network');
|
|
3700
|
-
const isDefault = this.
|
|
3709
|
+
const isDefault = this.safeBool(network, 'isDefault');
|
|
3701
3710
|
const currencyCode = this.safeString(currency, 'code');
|
|
3702
3711
|
const networkCode = this.networkIdToCode(networkId, currencyCode);
|
|
3703
3712
|
result['networks'][networkCode] = {
|
|
@@ -3852,8 +3861,8 @@ export default class bingx extends Exchange {
|
|
|
3852
3861
|
// }
|
|
3853
3862
|
// }
|
|
3854
3863
|
//
|
|
3855
|
-
const data = this.
|
|
3856
|
-
const liquidations = this.
|
|
3864
|
+
const data = this.safeDict(response, 'data', {});
|
|
3865
|
+
const liquidations = this.safeList(data, 'orders', []);
|
|
3857
3866
|
return this.parseLiquidations(liquidations, market, since, limit);
|
|
3858
3867
|
}
|
|
3859
3868
|
parseLiquidation(liquidation, market = undefined) {
|
|
@@ -3926,7 +3935,7 @@ export default class bingx extends Exchange {
|
|
|
3926
3935
|
// }
|
|
3927
3936
|
// }
|
|
3928
3937
|
//
|
|
3929
|
-
const data = this.
|
|
3938
|
+
const data = this.safeDict(response, 'data');
|
|
3930
3939
|
return this.parseOrder(data);
|
|
3931
3940
|
}
|
|
3932
3941
|
async closeAllPositions(params = {}) {
|
|
@@ -3964,8 +3973,8 @@ export default class bingx extends Exchange {
|
|
|
3964
3973
|
// }
|
|
3965
3974
|
// }
|
|
3966
3975
|
//
|
|
3967
|
-
const data = this.
|
|
3968
|
-
const success = this.
|
|
3976
|
+
const data = this.safeDict(response, 'data', {});
|
|
3977
|
+
const success = this.safeList(data, 'success', []);
|
|
3969
3978
|
const positions = [];
|
|
3970
3979
|
for (let i = 0; i < success.length; i++) {
|
|
3971
3980
|
const position = this.parsePosition({ 'positionId': success[i] });
|
|
@@ -4060,7 +4069,7 @@ export default class bingx extends Exchange {
|
|
|
4060
4069
|
* @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
|
|
4061
4070
|
* @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
|
|
4062
4071
|
* @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
|
|
4063
|
-
* @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
|
|
4072
|
+
* @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
|
|
4064
4073
|
* @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
|
|
4065
4074
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4066
4075
|
*/
|
|
@@ -4178,7 +4187,7 @@ export default class bingx extends Exchange {
|
|
|
4178
4187
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Mode
|
|
4179
4188
|
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
4180
4189
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4181
|
-
* @returns {object}
|
|
4190
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
4182
4191
|
*/
|
|
4183
4192
|
await this.loadMarkets();
|
|
4184
4193
|
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/bitmex.js
CHANGED
|
@@ -2550,7 +2550,9 @@ export default class bitmex extends Exchange {
|
|
|
2550
2550
|
if (until !== undefined) {
|
|
2551
2551
|
request['endTime'] = this.iso8601(until);
|
|
2552
2552
|
}
|
|
2553
|
-
|
|
2553
|
+
if ((since === undefined) && (until === undefined)) {
|
|
2554
|
+
request['reverse'] = true;
|
|
2555
|
+
}
|
|
2554
2556
|
const response = await this.publicGetFunding(this.extend(request, params));
|
|
2555
2557
|
//
|
|
2556
2558
|
// [
|
package/js/src/blofin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/blofin.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages, MarginMode } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class blofin
|
|
5
5
|
* @augments Exchange
|
|
@@ -116,6 +116,8 @@ export default class blofin extends Exchange {
|
|
|
116
116
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
117
117
|
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
118
118
|
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
119
|
+
fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
|
|
120
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
119
121
|
handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
120
122
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
121
123
|
url: string;
|
package/js/src/blofin.js
CHANGED
|
@@ -85,6 +85,8 @@ export default class blofin extends Exchange {
|
|
|
85
85
|
'fetchLeverage': true,
|
|
86
86
|
'fetchLeverages': true,
|
|
87
87
|
'fetchLeverageTiers': false,
|
|
88
|
+
'fetchMarginMode': true,
|
|
89
|
+
'fetchMarginModes': false,
|
|
88
90
|
'fetchMarketLeverageTiers': false,
|
|
89
91
|
'fetchMarkets': true,
|
|
90
92
|
'fetchMarkOHLCV': false,
|
|
@@ -188,6 +190,7 @@ export default class blofin extends Exchange {
|
|
|
188
190
|
'account/balance': 1,
|
|
189
191
|
'account/positions': 1,
|
|
190
192
|
'account/leverage-info': 1,
|
|
193
|
+
'account/margin-mode': 1,
|
|
191
194
|
'account/batch-leverage-info': 1,
|
|
192
195
|
'trade/orders-tpsl-pending': 1,
|
|
193
196
|
'trade/orders-history': 1,
|
|
@@ -381,7 +384,7 @@ export default class blofin extends Exchange {
|
|
|
381
384
|
const strikePrice = undefined;
|
|
382
385
|
const optionType = undefined;
|
|
383
386
|
const tickSize = this.safeString(market, 'tickSize');
|
|
384
|
-
const fees = this.
|
|
387
|
+
const fees = this.safeDict2(this.fees, type, 'trading', {});
|
|
385
388
|
const taker = this.safeNumber(fees, 'taker');
|
|
386
389
|
const maker = this.safeNumber(fees, 'maker');
|
|
387
390
|
let maxLeverage = this.safeString(market, 'maxLeverage', '100');
|
|
@@ -482,7 +485,7 @@ export default class blofin extends Exchange {
|
|
|
482
485
|
// }
|
|
483
486
|
//
|
|
484
487
|
const data = this.safeList(response, 'data', []);
|
|
485
|
-
const first = this.
|
|
488
|
+
const first = this.safeDict(data, 0, {});
|
|
486
489
|
const timestamp = this.safeInteger(first, 'ts');
|
|
487
490
|
return this.parseOrderBook(first, symbol, timestamp);
|
|
488
491
|
}
|
|
@@ -538,7 +541,7 @@ export default class blofin extends Exchange {
|
|
|
538
541
|
};
|
|
539
542
|
const response = await this.publicGetMarketTickers(this.extend(request, params));
|
|
540
543
|
const data = this.safeList(response, 'data', []);
|
|
541
|
-
const first = this.
|
|
544
|
+
const first = this.safeDict(data, 0, {});
|
|
542
545
|
return this.parseTicker(first, market);
|
|
543
546
|
}
|
|
544
547
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -998,8 +1001,8 @@ export default class blofin extends Exchange {
|
|
|
998
1001
|
if (postOnly) {
|
|
999
1002
|
request['type'] = 'post_only';
|
|
1000
1003
|
}
|
|
1001
|
-
const stopLoss = this.
|
|
1002
|
-
const takeProfit = this.
|
|
1004
|
+
const stopLoss = this.safeDict(params, 'stopLoss');
|
|
1005
|
+
const takeProfit = this.safeDict(params, 'takeProfit');
|
|
1003
1006
|
params = this.omit(params, ['stopLoss', 'takeProfit']);
|
|
1004
1007
|
const isStopLoss = stopLoss !== undefined;
|
|
1005
1008
|
const isTakeProfit = takeProfit !== undefined;
|
|
@@ -1292,7 +1295,7 @@ export default class blofin extends Exchange {
|
|
|
1292
1295
|
const side = this.safeString(rawOrder, 'side');
|
|
1293
1296
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
1294
1297
|
const price = this.safeValue(rawOrder, 'price');
|
|
1295
|
-
const orderParams = this.
|
|
1298
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
1296
1299
|
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
1300
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
|
|
1298
1301
|
ordersRequests.push(orderRequest);
|
|
@@ -1331,7 +1334,7 @@ export default class blofin extends Exchange {
|
|
|
1331
1334
|
if (limit !== undefined) {
|
|
1332
1335
|
request['limit'] = limit; // default 100, max 100
|
|
1333
1336
|
}
|
|
1334
|
-
const isStop = this.
|
|
1337
|
+
const isStop = this.safeBoolN(params, ['stop', 'trigger', 'tpsl', 'TPSL'], false);
|
|
1335
1338
|
let method = undefined;
|
|
1336
1339
|
[method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersPending');
|
|
1337
1340
|
const query = this.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL']);
|
|
@@ -1659,7 +1662,7 @@ export default class blofin extends Exchange {
|
|
|
1659
1662
|
await this.loadMarkets();
|
|
1660
1663
|
const market = this.market(symbol);
|
|
1661
1664
|
const request = [];
|
|
1662
|
-
const options = this.
|
|
1665
|
+
const options = this.safeDict(this.options, 'cancelOrders', {});
|
|
1663
1666
|
const defaultMethod = this.safeString(options, 'method', 'privatePostTradeCancelBatchOrders');
|
|
1664
1667
|
let method = this.safeString(params, 'method', defaultMethod);
|
|
1665
1668
|
const clientOrderIds = this.parseIds(this.safeValue(params, 'clientOrderId'));
|
|
@@ -1726,7 +1729,7 @@ export default class blofin extends Exchange {
|
|
|
1726
1729
|
*/
|
|
1727
1730
|
await this.loadMarkets();
|
|
1728
1731
|
const currency = this.currency(code);
|
|
1729
|
-
const accountsByType = this.
|
|
1732
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
1730
1733
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
1731
1734
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
1732
1735
|
const request = {
|
|
@@ -2059,7 +2062,7 @@ export default class blofin extends Exchange {
|
|
|
2059
2062
|
request['clientOrderId'] = clientOrderId;
|
|
2060
2063
|
}
|
|
2061
2064
|
const response = await this.privatePostTradeClosePosition(this.extend(request, params));
|
|
2062
|
-
return this.
|
|
2065
|
+
return this.safeDict(response, 'data');
|
|
2063
2066
|
}
|
|
2064
2067
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2065
2068
|
/**
|
|
@@ -2094,7 +2097,7 @@ export default class blofin extends Exchange {
|
|
|
2094
2097
|
if (since !== undefined) {
|
|
2095
2098
|
request['begin'] = since;
|
|
2096
2099
|
}
|
|
2097
|
-
const isStop = this.
|
|
2100
|
+
const isStop = this.safeBoolN(params, ['stop', 'trigger', 'tpsl', 'TPSL'], false);
|
|
2098
2101
|
let method = undefined;
|
|
2099
2102
|
[method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersHistory');
|
|
2100
2103
|
const query = this.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL']);
|
|
@@ -2108,6 +2111,38 @@ export default class blofin extends Exchange {
|
|
|
2108
2111
|
const data = this.safeList(response, 'data', []);
|
|
2109
2112
|
return this.parseOrders(data, market, since, limit);
|
|
2110
2113
|
}
|
|
2114
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
2115
|
+
/**
|
|
2116
|
+
* @method
|
|
2117
|
+
* @name blofin#fetchMarginMode
|
|
2118
|
+
* @description fetches the margin mode of a trading pair
|
|
2119
|
+
* @see https://docs.blofin.com/index.html#get-margin-mode
|
|
2120
|
+
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
2121
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2122
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
2123
|
+
*/
|
|
2124
|
+
await this.loadMarkets();
|
|
2125
|
+
const market = this.market(symbol);
|
|
2126
|
+
const response = await this.privateGetAccountMarginMode(params);
|
|
2127
|
+
//
|
|
2128
|
+
// {
|
|
2129
|
+
// "code": "0",
|
|
2130
|
+
// "msg": "success",
|
|
2131
|
+
// "data": {
|
|
2132
|
+
// "marginMode": "cross"
|
|
2133
|
+
// }
|
|
2134
|
+
// }
|
|
2135
|
+
//
|
|
2136
|
+
const data = this.safeDict(response, 'data', {});
|
|
2137
|
+
return this.parseMarginMode(data, market);
|
|
2138
|
+
}
|
|
2139
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
2140
|
+
return {
|
|
2141
|
+
'info': marginMode,
|
|
2142
|
+
'symbol': market['symbol'],
|
|
2143
|
+
'marginMode': this.safeString(marginMode, 'marginMode'),
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2111
2146
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2112
2147
|
if (response === undefined) {
|
|
2113
2148
|
return undefined; // fallback to default error handler
|