ccxt 4.1.97 → 4.1.99
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 +524 -230
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +29 -0
- package/dist/cjs/src/binance.js +113 -91
- package/dist/cjs/src/bingx.js +58 -9
- package/dist/cjs/src/bitget.js +108 -51
- package/dist/cjs/src/bitmart.js +71 -17
- package/dist/cjs/src/bitvavo.js +52 -14
- package/dist/cjs/src/coinex.js +58 -21
- package/dist/cjs/src/kraken.js +21 -16
- package/dist/cjs/src/phemex.js +3 -3
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bingx.js +6 -3
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +16 -0
- package/js/src/abstract/binancecoinm.d.ts +16 -0
- package/js/src/abstract/binanceus.d.ts +16 -0
- package/js/src/abstract/binanceusdm.d.ts +16 -0
- package/js/src/abstract/coinex.d.ts +14 -1
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +29 -0
- package/js/src/binance.js +113 -91
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +58 -9
- package/js/src/bitget.js +108 -51
- package/js/src/bitmart.js +71 -17
- package/js/src/bitvavo.js +52 -14
- package/js/src/coinex.js +58 -21
- package/js/src/kraken.js +21 -16
- package/js/src/phemex.js +3 -3
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bingx.js +6 -3
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +13 -13
- package/skip-tests.json +119 -71
- package/run-tests-ws.js +0 -290
package/dist/cjs/ccxt.js
CHANGED
|
@@ -168,7 +168,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
168
168
|
|
|
169
169
|
//-----------------------------------------------------------------------------
|
|
170
170
|
// this is updated by vss.js when building
|
|
171
|
-
const version = '4.1.
|
|
171
|
+
const version = '4.1.99';
|
|
172
172
|
Exchange["default"].ccxtVersion = version;
|
|
173
173
|
const exchanges = {
|
|
174
174
|
'ace': ace,
|
|
@@ -373,7 +373,9 @@ class Exchange {
|
|
|
373
373
|
'createOrderWs': undefined,
|
|
374
374
|
'editOrderWs': undefined,
|
|
375
375
|
'fetchOpenOrdersWs': undefined,
|
|
376
|
+
'fetchClosedOrdersWs': undefined,
|
|
376
377
|
'fetchOrderWs': undefined,
|
|
378
|
+
'fetchOrdersWs': undefined,
|
|
377
379
|
'cancelOrderWs': undefined,
|
|
378
380
|
'cancelOrdersWs': undefined,
|
|
379
381
|
'cancelAllOrdersWs': undefined,
|
|
@@ -2287,6 +2289,11 @@ class Exchange {
|
|
|
2287
2289
|
if ('rate' in tradeFee) {
|
|
2288
2290
|
tradeFee['rate'] = this.safeNumber(tradeFee, 'rate');
|
|
2289
2291
|
}
|
|
2292
|
+
const entryFees = this.safeValue(entry, 'fees', []);
|
|
2293
|
+
for (let j = 0; j < entryFees.length; j++) {
|
|
2294
|
+
entryFees[j]['cost'] = this.safeNumber(entryFees[j], 'cost');
|
|
2295
|
+
}
|
|
2296
|
+
entry['fees'] = entryFees;
|
|
2290
2297
|
entry['fee'] = tradeFee;
|
|
2291
2298
|
}
|
|
2292
2299
|
let timeInForce = this.safeString(order, 'timeInForce');
|
|
@@ -3760,6 +3767,9 @@ class Exchange {
|
|
|
3760
3767
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3761
3768
|
throw new errors.NotSupported(this.id + ' fetchOrders() is not supported yet');
|
|
3762
3769
|
}
|
|
3770
|
+
async fetchOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3771
|
+
throw new errors.NotSupported(this.id + ' fetchOrdersWs() is not supported yet');
|
|
3772
|
+
}
|
|
3763
3773
|
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3764
3774
|
throw new errors.NotSupported(this.id + ' fetchOrderTrades() is not supported yet');
|
|
3765
3775
|
}
|
|
@@ -3767,14 +3777,33 @@ class Exchange {
|
|
|
3767
3777
|
throw new errors.NotSupported(this.id + ' watchOrders() is not supported yet');
|
|
3768
3778
|
}
|
|
3769
3779
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3780
|
+
if (this.has['fetchOrders']) {
|
|
3781
|
+
const orders = await this.fetchOrders(symbol, since, limit, params);
|
|
3782
|
+
return this.filterBy(orders, 'status', 'open');
|
|
3783
|
+
}
|
|
3770
3784
|
throw new errors.NotSupported(this.id + ' fetchOpenOrders() is not supported yet');
|
|
3771
3785
|
}
|
|
3772
3786
|
async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3787
|
+
if (this.has['fetchOrdersWs']) {
|
|
3788
|
+
const orders = await this.fetchOrdersWs(symbol, since, limit, params);
|
|
3789
|
+
return this.filterBy(orders, 'status', 'open');
|
|
3790
|
+
}
|
|
3773
3791
|
throw new errors.NotSupported(this.id + ' fetchOpenOrdersWs() is not supported yet');
|
|
3774
3792
|
}
|
|
3775
3793
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3794
|
+
if (this.has['fetchOrders']) {
|
|
3795
|
+
const orders = await this.fetchOrders(symbol, since, limit, params);
|
|
3796
|
+
return this.filterBy(orders, 'status', 'closed');
|
|
3797
|
+
}
|
|
3776
3798
|
throw new errors.NotSupported(this.id + ' fetchClosedOrders() is not supported yet');
|
|
3777
3799
|
}
|
|
3800
|
+
async fetchClosedOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3801
|
+
if (this.has['fetchOrdersWs']) {
|
|
3802
|
+
const orders = await this.fetchOrdersWs(symbol, since, limit, params);
|
|
3803
|
+
return this.filterBy(orders, 'status', 'closed');
|
|
3804
|
+
}
|
|
3805
|
+
throw new errors.NotSupported(this.id + ' fetchClosedOrdersWs() is not supported yet');
|
|
3806
|
+
}
|
|
3778
3807
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3779
3808
|
throw new errors.NotSupported(this.id + ' fetchMyTrades() is not supported yet');
|
|
3780
3809
|
}
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -340,6 +340,16 @@ class binance extends binance$1 {
|
|
|
340
340
|
'lending/union/interestHistory': 0.1,
|
|
341
341
|
'lending/project/list': 0.1,
|
|
342
342
|
'lending/project/position/list': 0.1,
|
|
343
|
+
// eth-staking
|
|
344
|
+
'eth-staking/eth/history/stakingHistory': 15,
|
|
345
|
+
'eth-staking/eth/history/redemptionHistory': 15,
|
|
346
|
+
'eth-staking/eth/history/rewardsHistory': 15,
|
|
347
|
+
'eth-staking/eth/quota': 15,
|
|
348
|
+
'eth-staking/eth/history/rateHistory': 15,
|
|
349
|
+
'eth-staking/account': 15,
|
|
350
|
+
'eth-staking/wbeth/history/wrapHistory': 15,
|
|
351
|
+
'eth-staking/wbeth/history/unwrapHistory': 15,
|
|
352
|
+
'eth-staking/eth/history/wbethRewardsHistory': 15,
|
|
343
353
|
// mining endpoints
|
|
344
354
|
'mining/pub/algoList': 0.1,
|
|
345
355
|
'mining/pub/coinList': 0.1,
|
|
@@ -541,6 +551,13 @@ class binance extends binance$1 {
|
|
|
541
551
|
'staking/purchase': 0.1,
|
|
542
552
|
'staking/redeem': 0.1,
|
|
543
553
|
'staking/setAutoStaking': 0.1,
|
|
554
|
+
// eth-staking
|
|
555
|
+
'eth-staking/eth/stake': 15,
|
|
556
|
+
'eth-staking/eth/redeem': 15,
|
|
557
|
+
'eth-staking/wbeth/wrap': 15,
|
|
558
|
+
// mining endpoints
|
|
559
|
+
'mining/hash-transfer/config': 0.5,
|
|
560
|
+
'mining/hash-transfer/config/cancel': 0.5,
|
|
544
561
|
'portfolio/repay': 20.001,
|
|
545
562
|
'loan/vip/renew': 40.002,
|
|
546
563
|
'loan/vip/borrow': 40.002,
|
|
@@ -594,11 +611,13 @@ class binance extends binance$1 {
|
|
|
594
611
|
},
|
|
595
612
|
'sapiV2': {
|
|
596
613
|
'get': {
|
|
614
|
+
'eth-staking/account': 15,
|
|
597
615
|
'sub-account/futures/account': 0.1,
|
|
598
616
|
'sub-account/futures/accountSummary': 1,
|
|
599
617
|
'sub-account/futures/positionRisk': 0.1,
|
|
600
618
|
},
|
|
601
619
|
'post': {
|
|
620
|
+
'eth-staking/eth/stake': 15,
|
|
602
621
|
'sub-account/subAccountApi/ipRestriction': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
|
|
603
622
|
},
|
|
604
623
|
},
|
|
@@ -3620,22 +3639,6 @@ class binance extends binance$1 {
|
|
|
3620
3639
|
// 'endTime': 789, // Timestamp in ms to get aggregate trades until INCLUSIVE.
|
|
3621
3640
|
// 'limit': 500, // default = 500, maximum = 1000
|
|
3622
3641
|
};
|
|
3623
|
-
let method = this.safeString(this.options, 'fetchTradesMethod');
|
|
3624
|
-
method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
|
|
3625
|
-
if (method === undefined) {
|
|
3626
|
-
if (market['option']) {
|
|
3627
|
-
method = 'eapiPublicGetTrades';
|
|
3628
|
-
}
|
|
3629
|
-
else if (market['linear']) {
|
|
3630
|
-
method = 'fapiPublicGetAggTrades';
|
|
3631
|
-
}
|
|
3632
|
-
else if (market['inverse']) {
|
|
3633
|
-
method = 'dapiPublicGetAggTrades';
|
|
3634
|
-
}
|
|
3635
|
-
else {
|
|
3636
|
-
method = 'publicGetAggTrades';
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
3639
3642
|
if (!market['option']) {
|
|
3640
3643
|
if (since !== undefined) {
|
|
3641
3644
|
request['startTime'] = since;
|
|
@@ -3652,7 +3655,22 @@ class binance extends binance$1 {
|
|
|
3652
3655
|
const isFutureOrSwap = (market['swap'] || market['future']);
|
|
3653
3656
|
request['limit'] = isFutureOrSwap ? Math.min(limit, 1000) : limit; // default = 500, maximum = 1000
|
|
3654
3657
|
}
|
|
3658
|
+
let method = this.safeString(this.options, 'fetchTradesMethod');
|
|
3659
|
+
method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
|
|
3655
3660
|
params = this.omit(params, ['until', 'fetchTradesMethod']);
|
|
3661
|
+
let response = undefined;
|
|
3662
|
+
if (market['option'] || method === 'eapiPublicGetTrades') {
|
|
3663
|
+
response = await this.eapiPublicGetTrades(this.extend(request, params));
|
|
3664
|
+
}
|
|
3665
|
+
else if (market['linear'] || method === 'fapiPublicGetAggTrades') {
|
|
3666
|
+
response = await this.fapiPublicGetAggTrades(this.extend(request, params));
|
|
3667
|
+
}
|
|
3668
|
+
else if (market['inverse'] || method === 'dapiPublicGetAggTrades') {
|
|
3669
|
+
response = await this.dapiPublicGetAggTrades(this.extend(request, params));
|
|
3670
|
+
}
|
|
3671
|
+
else {
|
|
3672
|
+
response = await this.publicGetAggTrades(this.extend(request, params));
|
|
3673
|
+
}
|
|
3656
3674
|
//
|
|
3657
3675
|
// Caveats:
|
|
3658
3676
|
// - default limit (500) applies only if no other parameters set, trades up
|
|
@@ -3662,7 +3680,6 @@ class binance extends binance$1 {
|
|
|
3662
3680
|
// - "tradeId" accepted and returned by this method is "aggregate" trade id
|
|
3663
3681
|
// which is different from actual trade id
|
|
3664
3682
|
// - setting both fromId and time window results in error
|
|
3665
|
-
const response = await this[method](this.extend(request, params));
|
|
3666
3683
|
//
|
|
3667
3684
|
// aggregate trades
|
|
3668
3685
|
//
|
|
@@ -4261,6 +4278,15 @@ class binance extends binance$1 {
|
|
|
4261
4278
|
}
|
|
4262
4279
|
const stopPriceString = this.safeString(order, 'stopPrice');
|
|
4263
4280
|
const stopPrice = this.parseNumber(this.omitZero(stopPriceString));
|
|
4281
|
+
const feeCost = this.safeNumber(order, 'fee');
|
|
4282
|
+
let fee = undefined;
|
|
4283
|
+
if (feeCost !== undefined) {
|
|
4284
|
+
fee = {
|
|
4285
|
+
'currency': this.safeString(order, 'quoteAsset'),
|
|
4286
|
+
'cost': feeCost,
|
|
4287
|
+
'rate': undefined,
|
|
4288
|
+
};
|
|
4289
|
+
}
|
|
4264
4290
|
return this.safeOrder({
|
|
4265
4291
|
'info': order,
|
|
4266
4292
|
'id': id,
|
|
@@ -4283,11 +4309,7 @@ class binance extends binance$1 {
|
|
|
4283
4309
|
'filled': filled,
|
|
4284
4310
|
'remaining': undefined,
|
|
4285
4311
|
'status': status,
|
|
4286
|
-
'fee':
|
|
4287
|
-
'currency': this.safeString(order, 'quoteAsset'),
|
|
4288
|
-
'cost': this.safeNumber(order, 'fee'),
|
|
4289
|
-
'rate': undefined,
|
|
4290
|
-
},
|
|
4312
|
+
'fee': fee,
|
|
4291
4313
|
'trades': fills,
|
|
4292
4314
|
}, market);
|
|
4293
4315
|
}
|
|
@@ -6076,7 +6098,8 @@ class binance extends binance$1 {
|
|
|
6076
6098
|
'amount': this.currencyToPrecision(code, amount),
|
|
6077
6099
|
};
|
|
6078
6100
|
request['type'] = this.safeString(params, 'type');
|
|
6079
|
-
|
|
6101
|
+
params = this.omit(params, 'type');
|
|
6102
|
+
let response = undefined;
|
|
6080
6103
|
if (request['type'] === undefined) {
|
|
6081
6104
|
const symbol = this.safeString(params, 'symbol');
|
|
6082
6105
|
if (symbol !== undefined) {
|
|
@@ -6116,16 +6139,16 @@ class binance extends binance$1 {
|
|
|
6116
6139
|
throw new errors.BadRequest(this.id + ' transfer () does not allow transfers between ' + fromAccount + ' and ' + toAccount);
|
|
6117
6140
|
}
|
|
6118
6141
|
else if (toSpot && fromIsolated) {
|
|
6119
|
-
method = 'sapiPostMarginIsolatedTransfer';
|
|
6120
6142
|
request['transFrom'] = 'ISOLATED_MARGIN';
|
|
6121
6143
|
request['transTo'] = 'SPOT';
|
|
6122
6144
|
request['symbol'] = fromId;
|
|
6145
|
+
response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
|
|
6123
6146
|
}
|
|
6124
6147
|
else if (fromSpot && toIsolated) {
|
|
6125
|
-
method = 'sapiPostMarginIsolatedTransfer';
|
|
6126
6148
|
request['transFrom'] = 'SPOT';
|
|
6127
6149
|
request['transTo'] = 'ISOLATED_MARGIN';
|
|
6128
6150
|
request['symbol'] = toId;
|
|
6151
|
+
response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
|
|
6129
6152
|
}
|
|
6130
6153
|
else {
|
|
6131
6154
|
if (fromIsolated) {
|
|
@@ -6143,8 +6166,9 @@ class binance extends binance$1 {
|
|
|
6143
6166
|
request['type'] = fromId + '_' + toId;
|
|
6144
6167
|
}
|
|
6145
6168
|
}
|
|
6146
|
-
|
|
6147
|
-
|
|
6169
|
+
if (response === undefined) {
|
|
6170
|
+
response = await this.sapiPostAssetTransfer(this.extend(request, params));
|
|
6171
|
+
}
|
|
6148
6172
|
//
|
|
6149
6173
|
// {
|
|
6150
6174
|
// "tranId":13526853623
|
|
@@ -6937,7 +6961,6 @@ class binance extends binance$1 {
|
|
|
6937
6961
|
*/
|
|
6938
6962
|
await this.loadMarkets();
|
|
6939
6963
|
const request = {};
|
|
6940
|
-
let method = undefined;
|
|
6941
6964
|
let paginate = false;
|
|
6942
6965
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
|
|
6943
6966
|
if (paginate) {
|
|
@@ -6954,15 +6977,6 @@ class binance extends binance$1 {
|
|
|
6954
6977
|
let subType = undefined;
|
|
6955
6978
|
[subType, params] = this.handleSubTypeAndParams('fetchFundingRateHistory', market, params, 'linear');
|
|
6956
6979
|
params = this.omit(params, 'type');
|
|
6957
|
-
if (this.isLinear(type, subType)) {
|
|
6958
|
-
method = 'fapiPublicGetFundingRate';
|
|
6959
|
-
}
|
|
6960
|
-
else if (this.isInverse(type, subType)) {
|
|
6961
|
-
method = 'dapiPublicGetFundingRate';
|
|
6962
|
-
}
|
|
6963
|
-
if (method === undefined) {
|
|
6964
|
-
throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
|
|
6965
|
-
}
|
|
6966
6980
|
if (since !== undefined) {
|
|
6967
6981
|
request['startTime'] = since;
|
|
6968
6982
|
}
|
|
@@ -6975,7 +6989,16 @@ class binance extends binance$1 {
|
|
|
6975
6989
|
if (limit !== undefined) {
|
|
6976
6990
|
request['limit'] = limit;
|
|
6977
6991
|
}
|
|
6978
|
-
|
|
6992
|
+
let response = undefined;
|
|
6993
|
+
if (this.isLinear(type, subType)) {
|
|
6994
|
+
response = await this.fapiPublicGetFundingRate(this.extend(request, params));
|
|
6995
|
+
}
|
|
6996
|
+
else if (this.isInverse(type, subType)) {
|
|
6997
|
+
response = await this.dapiPublicGetFundingRate(this.extend(request, params));
|
|
6998
|
+
}
|
|
6999
|
+
else {
|
|
7000
|
+
throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
|
|
7001
|
+
}
|
|
6979
7002
|
//
|
|
6980
7003
|
// {
|
|
6981
7004
|
// "symbol": "BTCUSDT",
|
|
@@ -7011,22 +7034,21 @@ class binance extends binance$1 {
|
|
|
7011
7034
|
*/
|
|
7012
7035
|
await this.loadMarkets();
|
|
7013
7036
|
symbols = this.marketSymbols(symbols);
|
|
7014
|
-
let method = undefined;
|
|
7015
7037
|
const defaultType = this.safeString2(this.options, 'fetchFundingRates', 'defaultType', 'future');
|
|
7016
7038
|
const type = this.safeString(params, 'type', defaultType);
|
|
7017
7039
|
let subType = undefined;
|
|
7018
7040
|
[subType, params] = this.handleSubTypeAndParams('fetchFundingRates', undefined, params, 'linear');
|
|
7019
7041
|
const query = this.omit(params, 'type');
|
|
7042
|
+
let response = undefined;
|
|
7020
7043
|
if (this.isLinear(type, subType)) {
|
|
7021
|
-
|
|
7044
|
+
response = await this.fapiPublicGetPremiumIndex(query);
|
|
7022
7045
|
}
|
|
7023
7046
|
else if (this.isInverse(type, subType)) {
|
|
7024
|
-
|
|
7047
|
+
response = await this.dapiPublicGetPremiumIndex(query);
|
|
7025
7048
|
}
|
|
7026
7049
|
else {
|
|
7027
7050
|
throw new errors.NotSupported(this.id + ' fetchFundingRates() supports linear and inverse contracts only');
|
|
7028
7051
|
}
|
|
7029
|
-
const response = await this[method](query);
|
|
7030
7052
|
const result = [];
|
|
7031
7053
|
for (let i = 0; i < response.length; i++) {
|
|
7032
7054
|
const entry = response[i];
|
|
@@ -7494,22 +7516,21 @@ class binance extends binance$1 {
|
|
|
7494
7516
|
// it contains useful stuff like the maintenance margin and initial margin for positions
|
|
7495
7517
|
const leverageBrackets = this.safeValue(this.options, 'leverageBrackets');
|
|
7496
7518
|
if ((leverageBrackets === undefined) || (reload)) {
|
|
7497
|
-
let method = undefined;
|
|
7498
7519
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
7499
7520
|
const type = this.safeString(params, 'type', defaultType);
|
|
7500
7521
|
const query = this.omit(params, 'type');
|
|
7501
7522
|
let subType = undefined;
|
|
7502
7523
|
[subType, params] = this.handleSubTypeAndParams('loadLeverageBrackets', undefined, params, 'linear');
|
|
7524
|
+
let response = undefined;
|
|
7503
7525
|
if (this.isLinear(type, subType)) {
|
|
7504
|
-
|
|
7526
|
+
response = await this.fapiPrivateGetLeverageBracket(query);
|
|
7505
7527
|
}
|
|
7506
7528
|
else if (this.isInverse(type, subType)) {
|
|
7507
|
-
|
|
7529
|
+
response = await this.dapiPrivateV2GetLeverageBracket(query);
|
|
7508
7530
|
}
|
|
7509
7531
|
else {
|
|
7510
7532
|
throw new errors.NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
|
|
7511
7533
|
}
|
|
7512
|
-
const response = await this[method](query);
|
|
7513
7534
|
this.options['leverageBrackets'] = {};
|
|
7514
7535
|
for (let i = 0; i < response.length; i++) {
|
|
7515
7536
|
const entry = response[i];
|
|
@@ -7837,23 +7858,22 @@ class binance extends binance$1 {
|
|
|
7837
7858
|
}
|
|
7838
7859
|
await this.loadMarkets();
|
|
7839
7860
|
await this.loadLeverageBrackets(false, params);
|
|
7840
|
-
let method = undefined;
|
|
7841
7861
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
7842
7862
|
const type = this.safeString(params, 'type', defaultType);
|
|
7843
7863
|
let query = this.omit(params, 'type');
|
|
7844
7864
|
let subType = undefined;
|
|
7845
7865
|
[subType, query] = this.handleSubTypeAndParams('fetchAccountPositions', undefined, params, 'linear');
|
|
7866
|
+
let response = undefined;
|
|
7846
7867
|
if (this.isLinear(type, subType)) {
|
|
7847
|
-
|
|
7868
|
+
response = await this.fapiPrivateV2GetAccount(query);
|
|
7848
7869
|
}
|
|
7849
7870
|
else if (this.isInverse(type, subType)) {
|
|
7850
|
-
|
|
7871
|
+
response = await this.dapiPrivateGetAccount(query);
|
|
7851
7872
|
}
|
|
7852
7873
|
else {
|
|
7853
7874
|
throw new errors.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
|
|
7854
7875
|
}
|
|
7855
|
-
const
|
|
7856
|
-
const result = this.parseAccountPositions(account);
|
|
7876
|
+
const result = this.parseAccountPositions(response);
|
|
7857
7877
|
symbols = this.marketSymbols(symbols);
|
|
7858
7878
|
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
7859
7879
|
}
|
|
@@ -7877,15 +7897,15 @@ class binance extends binance$1 {
|
|
|
7877
7897
|
await this.loadMarkets();
|
|
7878
7898
|
await this.loadLeverageBrackets(false, params);
|
|
7879
7899
|
const request = {};
|
|
7880
|
-
let method = undefined;
|
|
7881
7900
|
let defaultType = 'future';
|
|
7882
7901
|
defaultType = this.safeString(this.options, 'defaultType', defaultType);
|
|
7883
7902
|
const type = this.safeString(params, 'type', defaultType);
|
|
7884
7903
|
let subType = undefined;
|
|
7885
7904
|
[subType, params] = this.handleSubTypeAndParams('fetchPositionsRisk', undefined, params, 'linear');
|
|
7886
7905
|
params = this.omit(params, 'type');
|
|
7906
|
+
let response = undefined;
|
|
7887
7907
|
if (this.isLinear(type, subType)) {
|
|
7888
|
-
|
|
7908
|
+
response = await this.fapiPrivateV2GetPositionRisk(this.extend(request, params));
|
|
7889
7909
|
// ### Response examples ###
|
|
7890
7910
|
//
|
|
7891
7911
|
// For One-way position mode:
|
|
@@ -7942,12 +7962,11 @@ class binance extends binance$1 {
|
|
|
7942
7962
|
// ]
|
|
7943
7963
|
}
|
|
7944
7964
|
else if (this.isInverse(type, subType)) {
|
|
7945
|
-
|
|
7965
|
+
response = await this.dapiPrivateGetPositionRisk(this.extend(request, params));
|
|
7946
7966
|
}
|
|
7947
7967
|
else {
|
|
7948
7968
|
throw new errors.NotSupported(this.id + ' fetchPositionsRisk() supports linear and inverse contracts only');
|
|
7949
7969
|
}
|
|
7950
|
-
const response = await this[method](this.extend(request, params));
|
|
7951
7970
|
const result = [];
|
|
7952
7971
|
for (let i = 0; i < response.length; i++) {
|
|
7953
7972
|
const parsed = this.parsePositionRisk(response[i]);
|
|
@@ -7971,7 +7990,6 @@ class binance extends binance$1 {
|
|
|
7971
7990
|
*/
|
|
7972
7991
|
await this.loadMarkets();
|
|
7973
7992
|
let market = undefined;
|
|
7974
|
-
let method = undefined;
|
|
7975
7993
|
const request = {
|
|
7976
7994
|
'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION" and "INSURANCE_CLEAR"
|
|
7977
7995
|
};
|
|
@@ -7993,16 +8011,16 @@ class binance extends binance$1 {
|
|
|
7993
8011
|
const defaultType = this.safeString2(this.options, 'fetchFundingHistory', 'defaultType', 'future');
|
|
7994
8012
|
const type = this.safeString(params, 'type', defaultType);
|
|
7995
8013
|
params = this.omit(params, 'type');
|
|
8014
|
+
let response = undefined;
|
|
7996
8015
|
if (this.isLinear(type, subType)) {
|
|
7997
|
-
|
|
8016
|
+
response = await this.fapiPrivateGetIncome(this.extend(request, params));
|
|
7998
8017
|
}
|
|
7999
8018
|
else if (this.isInverse(type, subType)) {
|
|
8000
|
-
|
|
8019
|
+
response = await this.dapiPrivateGetIncome(this.extend(request, params));
|
|
8001
8020
|
}
|
|
8002
8021
|
else {
|
|
8003
8022
|
throw new errors.NotSupported(this.id + ' fetchFundingHistory() supports linear and inverse contracts only');
|
|
8004
8023
|
}
|
|
8005
|
-
const response = await this[method](this.extend(request, params));
|
|
8006
8024
|
return this.parseIncomes(response, market, since, limit);
|
|
8007
8025
|
}
|
|
8008
8026
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
@@ -8126,6 +8144,8 @@ class binance extends binance$1 {
|
|
|
8126
8144
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
8127
8145
|
const type = this.safeString(params, 'type', defaultType);
|
|
8128
8146
|
params = this.omit(params, ['type']);
|
|
8147
|
+
let subType = undefined;
|
|
8148
|
+
[subType, params] = this.handleSubTypeAndParams('setPositionMode', undefined, params);
|
|
8129
8149
|
let dualSidePosition = undefined;
|
|
8130
8150
|
if (hedged) {
|
|
8131
8151
|
dualSidePosition = 'true';
|
|
@@ -8136,13 +8156,13 @@ class binance extends binance$1 {
|
|
|
8136
8156
|
const request = {
|
|
8137
8157
|
'dualSidePosition': dualSidePosition,
|
|
8138
8158
|
};
|
|
8139
|
-
let
|
|
8140
|
-
if (this.isInverse(type)) {
|
|
8141
|
-
|
|
8159
|
+
let response = undefined;
|
|
8160
|
+
if (this.isInverse(type, subType)) {
|
|
8161
|
+
response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
|
|
8142
8162
|
}
|
|
8143
8163
|
else {
|
|
8144
8164
|
// default to future
|
|
8145
|
-
|
|
8165
|
+
response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
|
|
8146
8166
|
}
|
|
8147
8167
|
//
|
|
8148
8168
|
// {
|
|
@@ -8150,7 +8170,7 @@ class binance extends binance$1 {
|
|
|
8150
8170
|
// "msg": "success"
|
|
8151
8171
|
// }
|
|
8152
8172
|
//
|
|
8153
|
-
return
|
|
8173
|
+
return response;
|
|
8154
8174
|
}
|
|
8155
8175
|
async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
8156
8176
|
/**
|
|
@@ -8362,24 +8382,9 @@ class binance extends binance$1 {
|
|
|
8362
8382
|
if (code !== undefined) {
|
|
8363
8383
|
currency = this.currency(code);
|
|
8364
8384
|
}
|
|
8365
|
-
let method = undefined;
|
|
8366
8385
|
const request = {};
|
|
8367
8386
|
[type, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
|
|
8368
8387
|
[subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
|
|
8369
|
-
if (type === 'option') {
|
|
8370
|
-
this.checkRequiredArgument('fetchLedger', code, 'code');
|
|
8371
|
-
request['currency'] = currency['id'];
|
|
8372
|
-
method = 'eapiPrivateGetBill';
|
|
8373
|
-
}
|
|
8374
|
-
else if (this.isLinear(type, subType)) {
|
|
8375
|
-
method = 'fapiPrivateGetIncome';
|
|
8376
|
-
}
|
|
8377
|
-
else if (this.isInverse(type, subType)) {
|
|
8378
|
-
method = 'dapiPrivateGetIncome';
|
|
8379
|
-
}
|
|
8380
|
-
else {
|
|
8381
|
-
throw new errors.NotSupported(this.id + ' fetchLedger() supports contract wallets only');
|
|
8382
|
-
}
|
|
8383
8388
|
if (since !== undefined) {
|
|
8384
8389
|
request['startTime'] = since;
|
|
8385
8390
|
}
|
|
@@ -8391,7 +8396,21 @@ class binance extends binance$1 {
|
|
|
8391
8396
|
params = this.omit(params, 'until');
|
|
8392
8397
|
request['endTime'] = until;
|
|
8393
8398
|
}
|
|
8394
|
-
|
|
8399
|
+
let response = undefined;
|
|
8400
|
+
if (type === 'option') {
|
|
8401
|
+
this.checkRequiredArgument('fetchLedger', code, 'code');
|
|
8402
|
+
request['currency'] = currency['id'];
|
|
8403
|
+
response = await this.eapiPrivateGetBill(this.extend(request, params));
|
|
8404
|
+
}
|
|
8405
|
+
else if (this.isLinear(type, subType)) {
|
|
8406
|
+
response = await this.fapiPrivateGetIncome(this.extend(request, params));
|
|
8407
|
+
}
|
|
8408
|
+
else if (this.isInverse(type, subType)) {
|
|
8409
|
+
response = await this.dapiPrivateGetIncome(this.extend(request, params));
|
|
8410
|
+
}
|
|
8411
|
+
else {
|
|
8412
|
+
throw new errors.NotSupported(this.id + ' fetchLedger() supports contract wallets only');
|
|
8413
|
+
}
|
|
8395
8414
|
//
|
|
8396
8415
|
// options (eapi)
|
|
8397
8416
|
//
|
|
@@ -8756,17 +8775,16 @@ class binance extends binance$1 {
|
|
|
8756
8775
|
'symbol': market['id'],
|
|
8757
8776
|
'amount': amount,
|
|
8758
8777
|
};
|
|
8759
|
-
let
|
|
8778
|
+
let response = undefined;
|
|
8760
8779
|
let code = undefined;
|
|
8761
8780
|
if (market['linear']) {
|
|
8762
|
-
method = 'fapiPrivatePostPositionMargin';
|
|
8763
8781
|
code = market['quote'];
|
|
8782
|
+
response = await this.fapiPrivatePostPositionMargin(this.extend(request, params));
|
|
8764
8783
|
}
|
|
8765
8784
|
else {
|
|
8766
|
-
method = 'dapiPrivatePostPositionMargin';
|
|
8767
8785
|
code = market['base'];
|
|
8786
|
+
response = await this.dapiPrivatePostPositionMargin(this.extend(request, params));
|
|
8768
8787
|
}
|
|
8769
|
-
const response = await this[method](this.extend(request, params));
|
|
8770
8788
|
//
|
|
8771
8789
|
// {
|
|
8772
8790
|
// "code": 200,
|
|
@@ -9266,11 +9284,13 @@ class binance extends binance$1 {
|
|
|
9266
9284
|
const duration = this.parseTimeframe(timeframe);
|
|
9267
9285
|
request['endTime'] = this.sum(since, duration * limit * 1000);
|
|
9268
9286
|
}
|
|
9269
|
-
let
|
|
9287
|
+
let response = undefined;
|
|
9270
9288
|
if (market['inverse']) {
|
|
9271
|
-
|
|
9289
|
+
response = await this.dapiDataGetOpenInterestHist(this.extend(request, params));
|
|
9290
|
+
}
|
|
9291
|
+
else {
|
|
9292
|
+
response = await this.fapiDataGetOpenInterestHist(this.extend(request, params));
|
|
9272
9293
|
}
|
|
9273
|
-
const response = await this[method](this.extend(request, params));
|
|
9274
9294
|
//
|
|
9275
9295
|
// [
|
|
9276
9296
|
// {
|
|
@@ -9306,14 +9326,16 @@ class binance extends binance$1 {
|
|
|
9306
9326
|
else {
|
|
9307
9327
|
request['symbol'] = market['id'];
|
|
9308
9328
|
}
|
|
9309
|
-
let
|
|
9329
|
+
let response = undefined;
|
|
9310
9330
|
if (market['option']) {
|
|
9311
|
-
|
|
9331
|
+
response = await this.eapiPublicGetOpenInterest(this.extend(request, params));
|
|
9312
9332
|
}
|
|
9313
9333
|
else if (market['inverse']) {
|
|
9314
|
-
|
|
9334
|
+
response = await this.dapiPublicGetOpenInterest(this.extend(request, params));
|
|
9335
|
+
}
|
|
9336
|
+
else {
|
|
9337
|
+
response = await this.fapiPublicGetOpenInterest(this.extend(request, params));
|
|
9315
9338
|
}
|
|
9316
|
-
const response = await this[method](this.extend(request, params));
|
|
9317
9339
|
//
|
|
9318
9340
|
// futures (fapi)
|
|
9319
9341
|
//
|