ccxt 4.1.11 → 4.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.js +1056 -66
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +1 -0
- package/dist/cjs/src/alpaca.js +1 -0
- package/dist/cjs/src/base/Exchange.js +30 -0
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/binance.js +310 -37
- package/dist/cjs/src/bingx.js +1 -0
- package/dist/cjs/src/bitbank.js +1 -0
- package/dist/cjs/src/bitbns.js +1 -0
- package/dist/cjs/src/bitfinex.js +1 -0
- package/dist/cjs/src/bitfinex2.js +1 -0
- package/dist/cjs/src/bitflyer.js +1 -0
- package/dist/cjs/src/bitforex.js +1 -0
- package/dist/cjs/src/bitget.js +20 -4
- package/dist/cjs/src/bithumb.js +1 -0
- package/dist/cjs/src/bitmart.js +103 -0
- package/dist/cjs/src/bitmex.js +70 -0
- package/dist/cjs/src/bitopro.js +1 -0
- package/dist/cjs/src/bitpanda.js +1 -0
- package/dist/cjs/src/bitrue.js +1 -0
- package/dist/cjs/src/bitso.js +1 -0
- package/dist/cjs/src/bitstamp.js +1 -0
- package/dist/cjs/src/bitvavo.js +1 -0
- package/dist/cjs/src/blockchaincom.js +1 -0
- package/dist/cjs/src/btcalpha.js +1 -0
- package/dist/cjs/src/btcmarkets.js +1 -0
- package/dist/cjs/src/btcturk.js +1 -0
- package/dist/cjs/src/bybit.js +15 -9
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/delta.js +2 -2
- package/dist/cjs/src/deribit.js +163 -0
- package/dist/cjs/src/gate.js +189 -0
- package/dist/cjs/src/huobi.js +105 -4
- package/dist/cjs/src/kucoin.js +1 -0
- package/dist/cjs/src/kucoinfutures.js +1 -1
- package/dist/cjs/src/okx.js +2 -0
- package/dist/cjs/src/poloniex.js +21 -7
- package/dist/cjs/src/whitebit.js +1 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/poloniex.d.ts +18 -5
- package/js/src/ace.js +1 -0
- package/js/src/alpaca.js +1 -0
- package/js/src/base/Exchange.d.ts +6 -2
- package/js/src/base/Exchange.js +30 -0
- package/js/src/base/types.d.ts +9 -0
- package/js/src/bigone.js +1 -0
- package/js/src/binance.d.ts +13 -1
- package/js/src/binance.js +310 -37
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +1 -0
- package/js/src/bitbank.js +1 -0
- package/js/src/bitbns.js +1 -0
- package/js/src/bitfinex.js +1 -0
- package/js/src/bitfinex2.js +1 -0
- package/js/src/bitflyer.js +1 -0
- package/js/src/bitforex.js +1 -0
- package/js/src/bitget.js +20 -4
- package/js/src/bithumb.js +1 -0
- package/js/src/bitmart.d.ts +12 -0
- package/js/src/bitmart.js +103 -0
- package/js/src/bitmex.d.ts +13 -1
- package/js/src/bitmex.js +70 -0
- package/js/src/bitopro.js +1 -0
- package/js/src/bitpanda.js +1 -0
- package/js/src/bitrue.js +1 -0
- package/js/src/bitso.js +1 -0
- package/js/src/bitstamp.js +1 -0
- package/js/src/bitvavo.js +1 -0
- package/js/src/blockchaincom.js +1 -0
- package/js/src/btcalpha.js +1 -0
- package/js/src/btcmarkets.js +1 -0
- package/js/src/btcturk.js +1 -0
- package/js/src/bybit.d.ts +3 -3
- package/js/src/bybit.js +15 -9
- package/js/src/cryptocom.d.ts +1 -1
- package/js/src/cryptocom.js +1 -1
- package/js/src/delta.d.ts +2 -54
- package/js/src/delta.js +2 -2
- package/js/src/deribit.d.ts +14 -0
- package/js/src/deribit.js +163 -0
- package/js/src/gate.d.ts +13 -0
- package/js/src/gate.js +189 -0
- package/js/src/huobi.d.ts +13 -1
- package/js/src/huobi.js +105 -4
- package/js/src/kucoin.js +1 -0
- package/js/src/kucoinfutures.js +1 -1
- package/js/src/mexc.d.ts +4 -4
- package/js/src/okx.js +2 -0
- package/js/src/poloniex.js +21 -7
- package/js/src/whitebit.js +1 -0
- package/package.json +1 -1
- package/skip-tests.json +61 -5
package/dist/cjs/ccxt.js
CHANGED
|
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
180
180
|
|
|
181
181
|
//-----------------------------------------------------------------------------
|
|
182
182
|
// this is updated by vss.js when building
|
|
183
|
-
const version = '4.1.
|
|
183
|
+
const version = '4.1.13';
|
|
184
184
|
Exchange["default"].ccxtVersion = version;
|
|
185
185
|
const exchanges = {
|
|
186
186
|
'ace': ace,
|
package/dist/cjs/src/ace.js
CHANGED
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -3276,6 +3276,12 @@ class Exchange {
|
|
|
3276
3276
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3277
3277
|
throw new errors.NotSupported(this.id + ' fetchMyTrades() is not supported yet');
|
|
3278
3278
|
}
|
|
3279
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3280
|
+
throw new errors.NotSupported(this.id + ' fetchMyLiquidations() is not supported yet');
|
|
3281
|
+
}
|
|
3282
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
3283
|
+
throw new errors.NotSupported(this.id + ' fetchLiquidations() is not supported yet');
|
|
3284
|
+
}
|
|
3279
3285
|
async fetchMyTradesWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3280
3286
|
throw new errors.NotSupported(this.id + ' fetchMyTradesWs() is not supported yet');
|
|
3281
3287
|
}
|
|
@@ -4400,6 +4406,30 @@ class Exchange {
|
|
|
4400
4406
|
'info': this.safeValue(interest, 'info'),
|
|
4401
4407
|
});
|
|
4402
4408
|
}
|
|
4409
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
4410
|
+
throw new errors.NotSupported(this.id + ' parseLiquidation () is not supported yet');
|
|
4411
|
+
}
|
|
4412
|
+
parseLiquidations(liquidations, market = undefined, since = undefined, limit = undefined) {
|
|
4413
|
+
/**
|
|
4414
|
+
* @ignore
|
|
4415
|
+
* @method
|
|
4416
|
+
* @description parses liquidation info from the exchange response
|
|
4417
|
+
* @param {object[]} liquidations each item describes an instance of a liquidation event
|
|
4418
|
+
* @param {object} market ccxt market
|
|
4419
|
+
* @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
|
|
4420
|
+
* @param {int} [limit] limits the number of items in the response
|
|
4421
|
+
* @returns {object[]} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
4422
|
+
*/
|
|
4423
|
+
const result = [];
|
|
4424
|
+
for (let i = 0; i < liquidations.length; i++) {
|
|
4425
|
+
const entry = liquidations[i];
|
|
4426
|
+
const parsed = this.parseLiquidation(entry, market);
|
|
4427
|
+
result.push(parsed);
|
|
4428
|
+
}
|
|
4429
|
+
const sorted = this.sortBy(result, 'timestamp');
|
|
4430
|
+
const symbol = this.safeString(market, 'symbol');
|
|
4431
|
+
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
4432
|
+
}
|
|
4403
4433
|
}
|
|
4404
4434
|
|
|
4405
4435
|
exports.Exchange = Exchange;
|
package/dist/cjs/src/bigone.js
CHANGED
package/dist/cjs/src/binance.js
CHANGED
|
@@ -74,9 +74,11 @@ class binance extends binance$1 {
|
|
|
74
74
|
'fetchLedger': true,
|
|
75
75
|
'fetchLeverage': false,
|
|
76
76
|
'fetchLeverageTiers': true,
|
|
77
|
+
'fetchLiquidations': false,
|
|
77
78
|
'fetchMarketLeverageTiers': 'emulated',
|
|
78
79
|
'fetchMarkets': true,
|
|
79
80
|
'fetchMarkOHLCV': true,
|
|
81
|
+
'fetchMyLiquidations': true,
|
|
80
82
|
'fetchMySettlementHistory': true,
|
|
81
83
|
'fetchMyTrades': true,
|
|
82
84
|
'fetchOHLCV': true,
|
|
@@ -1807,14 +1809,16 @@ class binance extends binance$1 {
|
|
|
1807
1809
|
const query = this.omit(params, 'type');
|
|
1808
1810
|
let subType = undefined;
|
|
1809
1811
|
[subType, params] = this.handleSubTypeAndParams('fetchTime', undefined, params);
|
|
1810
|
-
let
|
|
1812
|
+
let response = undefined;
|
|
1811
1813
|
if (this.isLinear(type, subType)) {
|
|
1812
|
-
|
|
1814
|
+
response = await this.fapiPublicGetTime(query);
|
|
1813
1815
|
}
|
|
1814
1816
|
else if (this.isInverse(type, subType)) {
|
|
1815
|
-
|
|
1817
|
+
response = await this.dapiPublicGetTime(query);
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
response = await this.publicGetTime(query);
|
|
1816
1821
|
}
|
|
1817
|
-
const response = await this[method](query);
|
|
1818
1822
|
return this.safeInteger(response, 'serverTime');
|
|
1819
1823
|
}
|
|
1820
1824
|
async fetchCurrencies(params = {}) {
|
|
@@ -2800,17 +2804,19 @@ class binance extends binance$1 {
|
|
|
2800
2804
|
if (limit !== undefined) {
|
|
2801
2805
|
request['limit'] = limit; // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
|
|
2802
2806
|
}
|
|
2803
|
-
let
|
|
2807
|
+
let response = undefined;
|
|
2804
2808
|
if (market['option']) {
|
|
2805
|
-
|
|
2809
|
+
response = await this.eapiPublicGetDepth(this.extend(request, params));
|
|
2806
2810
|
}
|
|
2807
2811
|
else if (market['linear']) {
|
|
2808
|
-
|
|
2812
|
+
response = await this.fapiPublicGetDepth(this.extend(request, params));
|
|
2809
2813
|
}
|
|
2810
2814
|
else if (market['inverse']) {
|
|
2811
|
-
|
|
2815
|
+
response = await this.dapiPublicGetDepth(this.extend(request, params));
|
|
2816
|
+
}
|
|
2817
|
+
else {
|
|
2818
|
+
response = await this.publicGetDepth(this.extend(request, params));
|
|
2812
2819
|
}
|
|
2813
|
-
const response = await this[method](this.extend(request, params));
|
|
2814
2820
|
//
|
|
2815
2821
|
// future
|
|
2816
2822
|
//
|
|
@@ -3044,17 +3050,19 @@ class binance extends binance$1 {
|
|
|
3044
3050
|
const request = {
|
|
3045
3051
|
'symbol': market['id'],
|
|
3046
3052
|
};
|
|
3047
|
-
let
|
|
3053
|
+
let response = undefined;
|
|
3048
3054
|
if (market['option']) {
|
|
3049
|
-
|
|
3055
|
+
response = await this.eapiPublicGetTicker(this.extend(request, params));
|
|
3050
3056
|
}
|
|
3051
3057
|
else if (market['linear']) {
|
|
3052
|
-
|
|
3058
|
+
response = await this.fapiPublicGetTicker24hr(this.extend(request, params));
|
|
3053
3059
|
}
|
|
3054
3060
|
else if (market['inverse']) {
|
|
3055
|
-
|
|
3061
|
+
response = await this.dapiPublicGetTicker24hr(this.extend(request, params));
|
|
3062
|
+
}
|
|
3063
|
+
else {
|
|
3064
|
+
response = await this.publicGetTicker24hr(this.extend(request, params));
|
|
3056
3065
|
}
|
|
3057
|
-
const response = await this[method](this.extend(request, params));
|
|
3058
3066
|
if (Array.isArray(response)) {
|
|
3059
3067
|
const firstTicker = this.safeValue(response, 0, {});
|
|
3060
3068
|
return this.parseTicker(firstTicker, market);
|
|
@@ -3084,17 +3092,16 @@ class binance extends binance$1 {
|
|
|
3084
3092
|
let subType = undefined;
|
|
3085
3093
|
[subType, params] = this.handleSubTypeAndParams('fetchBidsAsks', market, params);
|
|
3086
3094
|
[type, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
|
|
3087
|
-
let
|
|
3095
|
+
let response = undefined;
|
|
3088
3096
|
if (this.isLinear(type, subType)) {
|
|
3089
|
-
|
|
3097
|
+
response = await this.fapiPublicGetTickerBookTicker(params);
|
|
3090
3098
|
}
|
|
3091
3099
|
else if (this.isInverse(type, subType)) {
|
|
3092
|
-
|
|
3100
|
+
response = await this.dapiPublicGetTickerBookTicker(params);
|
|
3093
3101
|
}
|
|
3094
3102
|
else {
|
|
3095
|
-
|
|
3103
|
+
response = await this.publicGetTickerBookTicker(params);
|
|
3096
3104
|
}
|
|
3097
|
-
const response = await this[method](params);
|
|
3098
3105
|
return this.parseTickers(response, symbols);
|
|
3099
3106
|
}
|
|
3100
3107
|
async fetchLastPrices(symbols = undefined, params = {}) {
|
|
@@ -3116,9 +3123,9 @@ class binance extends binance$1 {
|
|
|
3116
3123
|
let subType = undefined;
|
|
3117
3124
|
[subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
|
|
3118
3125
|
[type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
|
|
3119
|
-
let
|
|
3126
|
+
let response = undefined;
|
|
3120
3127
|
if (this.isLinear(type, subType)) {
|
|
3121
|
-
|
|
3128
|
+
response = await this.fapiPublicGetTickerPrice(params);
|
|
3122
3129
|
//
|
|
3123
3130
|
// [
|
|
3124
3131
|
// {
|
|
@@ -3131,7 +3138,7 @@ class binance extends binance$1 {
|
|
|
3131
3138
|
//
|
|
3132
3139
|
}
|
|
3133
3140
|
else if (this.isInverse(type, subType)) {
|
|
3134
|
-
|
|
3141
|
+
response = await this.dapiPublicGetTickerPrice(params);
|
|
3135
3142
|
//
|
|
3136
3143
|
// [
|
|
3137
3144
|
// {
|
|
@@ -3144,7 +3151,7 @@ class binance extends binance$1 {
|
|
|
3144
3151
|
//
|
|
3145
3152
|
}
|
|
3146
3153
|
else if (type === 'spot') {
|
|
3147
|
-
|
|
3154
|
+
response = await this.publicGetTickerPrice(params);
|
|
3148
3155
|
//
|
|
3149
3156
|
// [
|
|
3150
3157
|
// {
|
|
@@ -3158,7 +3165,6 @@ class binance extends binance$1 {
|
|
|
3158
3165
|
else {
|
|
3159
3166
|
throw new errors.NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
|
|
3160
3167
|
}
|
|
3161
|
-
const response = await this[method](params);
|
|
3162
3168
|
return this.parseLastPrices(response, symbols);
|
|
3163
3169
|
}
|
|
3164
3170
|
parseLastPrice(info, market = undefined) {
|
|
@@ -6478,10 +6484,20 @@ class binance extends binance$1 {
|
|
|
6478
6484
|
}
|
|
6479
6485
|
parseTradingFee(fee, market = undefined) {
|
|
6480
6486
|
//
|
|
6487
|
+
// spot
|
|
6488
|
+
// [
|
|
6489
|
+
// {
|
|
6490
|
+
// "symbol": "BTCUSDT",
|
|
6491
|
+
// "makerCommission": "0.001",
|
|
6492
|
+
// "takerCommission": "0.001"
|
|
6493
|
+
// }
|
|
6494
|
+
// ]
|
|
6495
|
+
//
|
|
6496
|
+
// swap
|
|
6481
6497
|
// {
|
|
6482
|
-
// "symbol": "
|
|
6483
|
-
// "
|
|
6484
|
-
// "
|
|
6498
|
+
// "symbol": "BTCUSD_PERP",
|
|
6499
|
+
// "makerCommissionRate": "0.00015", // 0.015%
|
|
6500
|
+
// "takerCommissionRate": "0.00040" // 0.040%
|
|
6485
6501
|
// }
|
|
6486
6502
|
//
|
|
6487
6503
|
const marketId = this.safeString(fee, 'symbol');
|
|
@@ -6489,8 +6505,8 @@ class binance extends binance$1 {
|
|
|
6489
6505
|
return {
|
|
6490
6506
|
'info': fee,
|
|
6491
6507
|
'symbol': symbol,
|
|
6492
|
-
'maker': this.
|
|
6493
|
-
'taker': this.
|
|
6508
|
+
'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
|
|
6509
|
+
'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
|
|
6494
6510
|
};
|
|
6495
6511
|
}
|
|
6496
6512
|
async fetchTradingFee(symbol, params = {}) {
|
|
@@ -6499,17 +6515,37 @@ class binance extends binance$1 {
|
|
|
6499
6515
|
* @name binance#fetchTradingFee
|
|
6500
6516
|
* @description fetch the trading fees for a market
|
|
6501
6517
|
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
|
|
6518
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
|
|
6519
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
|
|
6502
6520
|
* @param {string} symbol unified market symbol
|
|
6503
6521
|
* @param {object} [params] extra parameters specific to the binance api endpoint
|
|
6504
6522
|
* @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
|
|
6505
6523
|
*/
|
|
6506
6524
|
await this.loadMarkets();
|
|
6507
6525
|
const market = this.market(symbol);
|
|
6526
|
+
const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
|
|
6527
|
+
const type = this.safeString(params, 'type', defaultType);
|
|
6528
|
+
params = this.omit(params, 'type');
|
|
6529
|
+
let subType = undefined;
|
|
6530
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
|
|
6531
|
+
const isSpotOrMargin = (type === 'spot') || (type === 'margin');
|
|
6532
|
+
const isLinear = this.isLinear(type, subType);
|
|
6533
|
+
const isInverse = this.isInverse(type, subType);
|
|
6508
6534
|
const request = {
|
|
6509
6535
|
'symbol': market['id'],
|
|
6510
6536
|
};
|
|
6511
|
-
|
|
6537
|
+
let response = undefined;
|
|
6538
|
+
if (isSpotOrMargin) {
|
|
6539
|
+
response = await this.sapiGetAssetTradeFee(this.extend(request, params));
|
|
6540
|
+
}
|
|
6541
|
+
else if (isLinear) {
|
|
6542
|
+
response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
|
|
6543
|
+
}
|
|
6544
|
+
else if (isInverse) {
|
|
6545
|
+
response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
|
|
6546
|
+
}
|
|
6512
6547
|
//
|
|
6548
|
+
// spot
|
|
6513
6549
|
// [
|
|
6514
6550
|
// {
|
|
6515
6551
|
// "symbol": "BTCUSDT",
|
|
@@ -6518,8 +6554,18 @@ class binance extends binance$1 {
|
|
|
6518
6554
|
// }
|
|
6519
6555
|
// ]
|
|
6520
6556
|
//
|
|
6521
|
-
|
|
6522
|
-
|
|
6557
|
+
// swap
|
|
6558
|
+
// {
|
|
6559
|
+
// "symbol": "BTCUSD_PERP",
|
|
6560
|
+
// "makerCommissionRate": "0.00015", // 0.015%
|
|
6561
|
+
// "takerCommissionRate": "0.00040" // 0.040%
|
|
6562
|
+
// }
|
|
6563
|
+
//
|
|
6564
|
+
let data = response;
|
|
6565
|
+
if (Array.isArray(data)) {
|
|
6566
|
+
data = this.safeValue(data, 0, {});
|
|
6567
|
+
}
|
|
6568
|
+
return this.parseTradingFee(data);
|
|
6523
6569
|
}
|
|
6524
6570
|
async fetchTradingFees(params = {}) {
|
|
6525
6571
|
/**
|
|
@@ -6534,11 +6580,10 @@ class binance extends binance$1 {
|
|
|
6534
6580
|
*/
|
|
6535
6581
|
await this.loadMarkets();
|
|
6536
6582
|
let method = undefined;
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
params = this.omit(params, 'type');
|
|
6583
|
+
let type = undefined;
|
|
6584
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
|
|
6540
6585
|
let subType = undefined;
|
|
6541
|
-
[subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params);
|
|
6586
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params, 'linear');
|
|
6542
6587
|
const isSpotOrMargin = (type === 'spot') || (type === 'margin');
|
|
6543
6588
|
const isLinear = this.isLinear(type, subType);
|
|
6544
6589
|
const isInverse = this.isInverse(type, subType);
|
|
@@ -8215,13 +8260,15 @@ class binance extends binance$1 {
|
|
|
8215
8260
|
let type = undefined;
|
|
8216
8261
|
let subType = undefined;
|
|
8217
8262
|
let currency = undefined;
|
|
8263
|
+
if (code !== undefined) {
|
|
8264
|
+
currency = this.currency(code);
|
|
8265
|
+
}
|
|
8218
8266
|
let method = undefined;
|
|
8219
8267
|
const request = {};
|
|
8220
8268
|
[type, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
|
|
8221
8269
|
[subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
|
|
8222
8270
|
if (type === 'option') {
|
|
8223
8271
|
this.checkRequiredArgument('fetchLedger', code, 'code');
|
|
8224
|
-
currency = this.currency(code);
|
|
8225
8272
|
request['currency'] = currency['id'];
|
|
8226
8273
|
method = 'eapiPrivateGetBill';
|
|
8227
8274
|
}
|
|
@@ -9176,6 +9223,232 @@ class binance extends binance$1 {
|
|
|
9176
9223
|
'info': interest,
|
|
9177
9224
|
}, market);
|
|
9178
9225
|
}
|
|
9226
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
9227
|
+
/**
|
|
9228
|
+
* @method
|
|
9229
|
+
* @name binance#fetchMyLiquidations
|
|
9230
|
+
* @description retrieves the users liquidated positions
|
|
9231
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
|
|
9232
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
|
|
9233
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
|
|
9234
|
+
* @param {string} [symbol] unified CCXT market symbol
|
|
9235
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
9236
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
9237
|
+
* @param {object} [params] exchange specific parameters for the binance api endpoint
|
|
9238
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
9239
|
+
* @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
9240
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
9241
|
+
*/
|
|
9242
|
+
await this.loadMarkets();
|
|
9243
|
+
let paginate = false;
|
|
9244
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchMyLiquidations', 'paginate');
|
|
9245
|
+
if (paginate) {
|
|
9246
|
+
return await this.fetchPaginatedCallIncremental('fetchMyLiquidations', symbol, since, limit, params, 'current', 100);
|
|
9247
|
+
}
|
|
9248
|
+
let market = undefined;
|
|
9249
|
+
if (symbol !== undefined) {
|
|
9250
|
+
market = this.market(symbol);
|
|
9251
|
+
}
|
|
9252
|
+
let type = undefined;
|
|
9253
|
+
[type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
|
|
9254
|
+
let subType = undefined;
|
|
9255
|
+
[subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
|
|
9256
|
+
let request = {};
|
|
9257
|
+
if (type !== 'spot') {
|
|
9258
|
+
request['autoCloseType'] = 'LIQUIDATION';
|
|
9259
|
+
}
|
|
9260
|
+
if (market !== undefined) {
|
|
9261
|
+
const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
|
|
9262
|
+
request[symbolKey] = market['id'];
|
|
9263
|
+
}
|
|
9264
|
+
if (since !== undefined) {
|
|
9265
|
+
request['startTime'] = since;
|
|
9266
|
+
}
|
|
9267
|
+
if (limit !== undefined) {
|
|
9268
|
+
if (type === 'spot') {
|
|
9269
|
+
request['size'] = limit;
|
|
9270
|
+
}
|
|
9271
|
+
else {
|
|
9272
|
+
request['limit'] = limit;
|
|
9273
|
+
}
|
|
9274
|
+
}
|
|
9275
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
9276
|
+
let response = undefined;
|
|
9277
|
+
if (type === 'spot') {
|
|
9278
|
+
response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
|
|
9279
|
+
}
|
|
9280
|
+
else if (subType === 'linear') {
|
|
9281
|
+
response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
|
|
9282
|
+
}
|
|
9283
|
+
else if (subType === 'inverse') {
|
|
9284
|
+
response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
|
|
9285
|
+
}
|
|
9286
|
+
else {
|
|
9287
|
+
throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
|
|
9288
|
+
}
|
|
9289
|
+
//
|
|
9290
|
+
// margin
|
|
9291
|
+
//
|
|
9292
|
+
// {
|
|
9293
|
+
// "rows": [
|
|
9294
|
+
// {
|
|
9295
|
+
// "avgPrice": "0.00388359",
|
|
9296
|
+
// "executedQty": "31.39000000",
|
|
9297
|
+
// "orderId": 180015097,
|
|
9298
|
+
// "price": "0.00388110",
|
|
9299
|
+
// "qty": "31.39000000",
|
|
9300
|
+
// "side": "SELL",
|
|
9301
|
+
// "symbol": "BNBBTC",
|
|
9302
|
+
// "timeInForce": "GTC",
|
|
9303
|
+
// "isIsolated": true,
|
|
9304
|
+
// "updatedTime": 1558941374745
|
|
9305
|
+
// }
|
|
9306
|
+
// ],
|
|
9307
|
+
// "total": 1
|
|
9308
|
+
// }
|
|
9309
|
+
//
|
|
9310
|
+
// linear
|
|
9311
|
+
//
|
|
9312
|
+
// [
|
|
9313
|
+
// {
|
|
9314
|
+
// "orderId": 6071832819,
|
|
9315
|
+
// "symbol": "BTCUSDT",
|
|
9316
|
+
// "status": "FILLED",
|
|
9317
|
+
// "clientOrderId": "autoclose-1596107620040000020",
|
|
9318
|
+
// "price": "10871.09",
|
|
9319
|
+
// "avgPrice": "10913.21000",
|
|
9320
|
+
// "origQty": "0.001",
|
|
9321
|
+
// "executedQty": "0.001",
|
|
9322
|
+
// "cumQuote": "10.91321",
|
|
9323
|
+
// "timeInForce": "IOC",
|
|
9324
|
+
// "type": "LIMIT",
|
|
9325
|
+
// "reduceOnly": false,
|
|
9326
|
+
// "closePosition": false,
|
|
9327
|
+
// "side": "SELL",
|
|
9328
|
+
// "positionSide": "BOTH",
|
|
9329
|
+
// "stopPrice": "0",
|
|
9330
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9331
|
+
// "origType": "LIMIT",
|
|
9332
|
+
// "time": 1596107620044,
|
|
9333
|
+
// "updateTime": 1596107620087
|
|
9334
|
+
// },
|
|
9335
|
+
// ]
|
|
9336
|
+
//
|
|
9337
|
+
// inverse
|
|
9338
|
+
//
|
|
9339
|
+
// [
|
|
9340
|
+
// {
|
|
9341
|
+
// "orderId": 165123080,
|
|
9342
|
+
// "symbol": "BTCUSD_200925",
|
|
9343
|
+
// "pair": "BTCUSD",
|
|
9344
|
+
// "status": "FILLED",
|
|
9345
|
+
// "clientOrderId": "autoclose-1596542005017000006",
|
|
9346
|
+
// "price": "11326.9",
|
|
9347
|
+
// "avgPrice": "11326.9",
|
|
9348
|
+
// "origQty": "1",
|
|
9349
|
+
// "executedQty": "1",
|
|
9350
|
+
// "cumBase": "0.00882854",
|
|
9351
|
+
// "timeInForce": "IOC",
|
|
9352
|
+
// "type": "LIMIT",
|
|
9353
|
+
// "reduceOnly": false,
|
|
9354
|
+
// "closePosition": false,
|
|
9355
|
+
// "side": "SELL",
|
|
9356
|
+
// "positionSide": "BOTH",
|
|
9357
|
+
// "stopPrice": "0",
|
|
9358
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9359
|
+
// "priceProtect": false,
|
|
9360
|
+
// "origType": "LIMIT",
|
|
9361
|
+
// "time": 1596542005019,
|
|
9362
|
+
// "updateTime": 1596542005050
|
|
9363
|
+
// },
|
|
9364
|
+
// ]
|
|
9365
|
+
//
|
|
9366
|
+
const liquidations = this.safeValue(response, 'rows', response);
|
|
9367
|
+
return this.parseLiquidations(liquidations, market, since, limit);
|
|
9368
|
+
}
|
|
9369
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
9370
|
+
//
|
|
9371
|
+
// margin
|
|
9372
|
+
//
|
|
9373
|
+
// {
|
|
9374
|
+
// "avgPrice": "0.00388359",
|
|
9375
|
+
// "executedQty": "31.39000000",
|
|
9376
|
+
// "orderId": 180015097,
|
|
9377
|
+
// "price": "0.00388110",
|
|
9378
|
+
// "qty": "31.39000000",
|
|
9379
|
+
// "side": "SELL",
|
|
9380
|
+
// "symbol": "BNBBTC",
|
|
9381
|
+
// "timeInForce": "GTC",
|
|
9382
|
+
// "isIsolated": true,
|
|
9383
|
+
// "updatedTime": 1558941374745
|
|
9384
|
+
// }
|
|
9385
|
+
//
|
|
9386
|
+
// linear
|
|
9387
|
+
//
|
|
9388
|
+
// {
|
|
9389
|
+
// "orderId": 6071832819,
|
|
9390
|
+
// "symbol": "BTCUSDT",
|
|
9391
|
+
// "status": "FILLED",
|
|
9392
|
+
// "clientOrderId": "autoclose-1596107620040000020",
|
|
9393
|
+
// "price": "10871.09",
|
|
9394
|
+
// "avgPrice": "10913.21000",
|
|
9395
|
+
// "origQty": "0.001",
|
|
9396
|
+
// "executedQty": "0.001",
|
|
9397
|
+
// "cumQuote": "10.91321",
|
|
9398
|
+
// "timeInForce": "IOC",
|
|
9399
|
+
// "type": "LIMIT",
|
|
9400
|
+
// "reduceOnly": false,
|
|
9401
|
+
// "closePosition": false,
|
|
9402
|
+
// "side": "SELL",
|
|
9403
|
+
// "positionSide": "BOTH",
|
|
9404
|
+
// "stopPrice": "0",
|
|
9405
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9406
|
+
// "origType": "LIMIT",
|
|
9407
|
+
// "time": 1596107620044,
|
|
9408
|
+
// "updateTime": 1596107620087
|
|
9409
|
+
// }
|
|
9410
|
+
//
|
|
9411
|
+
// inverse
|
|
9412
|
+
//
|
|
9413
|
+
// {
|
|
9414
|
+
// "orderId": 165123080,
|
|
9415
|
+
// "symbol": "BTCUSD_200925",
|
|
9416
|
+
// "pair": "BTCUSD",
|
|
9417
|
+
// "status": "FILLED",
|
|
9418
|
+
// "clientOrderId": "autoclose-1596542005017000006",
|
|
9419
|
+
// "price": "11326.9",
|
|
9420
|
+
// "avgPrice": "11326.9",
|
|
9421
|
+
// "origQty": "1",
|
|
9422
|
+
// "executedQty": "1",
|
|
9423
|
+
// "cumBase": "0.00882854",
|
|
9424
|
+
// "timeInForce": "IOC",
|
|
9425
|
+
// "type": "LIMIT",
|
|
9426
|
+
// "reduceOnly": false,
|
|
9427
|
+
// "closePosition": false,
|
|
9428
|
+
// "side": "SELL",
|
|
9429
|
+
// "positionSide": "BOTH",
|
|
9430
|
+
// "stopPrice": "0",
|
|
9431
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9432
|
+
// "priceProtect": false,
|
|
9433
|
+
// "origType": "LIMIT",
|
|
9434
|
+
// "time": 1596542005019,
|
|
9435
|
+
// "updateTime": 1596542005050
|
|
9436
|
+
// }
|
|
9437
|
+
//
|
|
9438
|
+
const marketId = this.safeString(liquidation, 'symbol');
|
|
9439
|
+
const timestamp = this.safeInteger2(liquidation, 'updatedTime', 'updateTime');
|
|
9440
|
+
return {
|
|
9441
|
+
'info': liquidation,
|
|
9442
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
9443
|
+
'contracts': this.safeNumber(liquidation, 'executedQty'),
|
|
9444
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
9445
|
+
'price': this.safeNumber(liquidation, 'avgPrice'),
|
|
9446
|
+
'baseValue': this.safeNumber(liquidation, 'cumBase'),
|
|
9447
|
+
'quoteValue': this.safeNumber(liquidation, 'cumQuote'),
|
|
9448
|
+
'timestamp': timestamp,
|
|
9449
|
+
'datetime': this.iso8601(timestamp),
|
|
9450
|
+
};
|
|
9451
|
+
}
|
|
9179
9452
|
}
|
|
9180
9453
|
|
|
9181
9454
|
module.exports = binance;
|
package/dist/cjs/src/bingx.js
CHANGED
package/dist/cjs/src/bitbank.js
CHANGED
package/dist/cjs/src/bitbns.js
CHANGED
package/dist/cjs/src/bitfinex.js
CHANGED
package/dist/cjs/src/bitflyer.js
CHANGED