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/js/src/base/Exchange.js
CHANGED
|
@@ -3270,6 +3270,12 @@ export default class Exchange {
|
|
|
3270
3270
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3271
3271
|
throw new NotSupported(this.id + ' fetchMyTrades() is not supported yet');
|
|
3272
3272
|
}
|
|
3273
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3274
|
+
throw new NotSupported(this.id + ' fetchMyLiquidations() is not supported yet');
|
|
3275
|
+
}
|
|
3276
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
3277
|
+
throw new NotSupported(this.id + ' fetchLiquidations() is not supported yet');
|
|
3278
|
+
}
|
|
3273
3279
|
async fetchMyTradesWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3274
3280
|
throw new NotSupported(this.id + ' fetchMyTradesWs() is not supported yet');
|
|
3275
3281
|
}
|
|
@@ -4394,5 +4400,29 @@ export default class Exchange {
|
|
|
4394
4400
|
'info': this.safeValue(interest, 'info'),
|
|
4395
4401
|
});
|
|
4396
4402
|
}
|
|
4403
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
4404
|
+
throw new NotSupported(this.id + ' parseLiquidation () is not supported yet');
|
|
4405
|
+
}
|
|
4406
|
+
parseLiquidations(liquidations, market = undefined, since = undefined, limit = undefined) {
|
|
4407
|
+
/**
|
|
4408
|
+
* @ignore
|
|
4409
|
+
* @method
|
|
4410
|
+
* @description parses liquidation info from the exchange response
|
|
4411
|
+
* @param {object[]} liquidations each item describes an instance of a liquidation event
|
|
4412
|
+
* @param {object} market ccxt market
|
|
4413
|
+
* @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
|
|
4414
|
+
* @param {int} [limit] limits the number of items in the response
|
|
4415
|
+
* @returns {object[]} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
4416
|
+
*/
|
|
4417
|
+
const result = [];
|
|
4418
|
+
for (let i = 0; i < liquidations.length; i++) {
|
|
4419
|
+
const entry = liquidations[i];
|
|
4420
|
+
const parsed = this.parseLiquidation(entry, market);
|
|
4421
|
+
result.push(parsed);
|
|
4422
|
+
}
|
|
4423
|
+
const sorted = this.sortBy(result, 'timestamp');
|
|
4424
|
+
const symbol = this.safeString(market, 'symbol');
|
|
4425
|
+
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
4426
|
+
}
|
|
4397
4427
|
}
|
|
4398
4428
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -218,6 +218,15 @@ export interface OpenInterest {
|
|
|
218
218
|
datetime?: string;
|
|
219
219
|
info: any;
|
|
220
220
|
}
|
|
221
|
+
export interface Liquidation {
|
|
222
|
+
info: any;
|
|
223
|
+
symbol: string;
|
|
224
|
+
timestamp?: number;
|
|
225
|
+
datetime?: string;
|
|
226
|
+
price: number;
|
|
227
|
+
baseValue?: number;
|
|
228
|
+
quoteValue?: number;
|
|
229
|
+
}
|
|
221
230
|
/** [ timestamp, open, high, low, close, volume ] */
|
|
222
231
|
export declare type OHLCV = [number, number, number, number, number, number];
|
|
223
232
|
/** [ timestamp, open, high, low, close, volume, count ] */
|
package/js/src/bigone.js
CHANGED
package/js/src/binance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/binance.js';
|
|
2
|
-
import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest } from './base/types.js';
|
|
2
|
+
import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @extends Exchange
|
|
@@ -497,4 +497,16 @@ export default class binance extends Exchange {
|
|
|
497
497
|
fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
|
|
498
498
|
fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
|
|
499
499
|
parseOpenInterest(interest: any, market?: any): OpenInterest;
|
|
500
|
+
fetchMyLiquidations(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
|
|
501
|
+
parseLiquidation(liquidation: any, market?: any): {
|
|
502
|
+
info: any;
|
|
503
|
+
symbol: any;
|
|
504
|
+
contracts: number;
|
|
505
|
+
contractSize: number;
|
|
506
|
+
price: number;
|
|
507
|
+
baseValue: number;
|
|
508
|
+
quoteValue: number;
|
|
509
|
+
timestamp: number;
|
|
510
|
+
datetime: string;
|
|
511
|
+
};
|
|
500
512
|
}
|
package/js/src/binance.js
CHANGED
|
@@ -77,9 +77,11 @@ export default class binance extends Exchange {
|
|
|
77
77
|
'fetchLedger': true,
|
|
78
78
|
'fetchLeverage': false,
|
|
79
79
|
'fetchLeverageTiers': true,
|
|
80
|
+
'fetchLiquidations': false,
|
|
80
81
|
'fetchMarketLeverageTiers': 'emulated',
|
|
81
82
|
'fetchMarkets': true,
|
|
82
83
|
'fetchMarkOHLCV': true,
|
|
84
|
+
'fetchMyLiquidations': true,
|
|
83
85
|
'fetchMySettlementHistory': true,
|
|
84
86
|
'fetchMyTrades': true,
|
|
85
87
|
'fetchOHLCV': true,
|
|
@@ -1810,14 +1812,16 @@ export default class binance extends Exchange {
|
|
|
1810
1812
|
const query = this.omit(params, 'type');
|
|
1811
1813
|
let subType = undefined;
|
|
1812
1814
|
[subType, params] = this.handleSubTypeAndParams('fetchTime', undefined, params);
|
|
1813
|
-
let
|
|
1815
|
+
let response = undefined;
|
|
1814
1816
|
if (this.isLinear(type, subType)) {
|
|
1815
|
-
|
|
1817
|
+
response = await this.fapiPublicGetTime(query);
|
|
1816
1818
|
}
|
|
1817
1819
|
else if (this.isInverse(type, subType)) {
|
|
1818
|
-
|
|
1820
|
+
response = await this.dapiPublicGetTime(query);
|
|
1821
|
+
}
|
|
1822
|
+
else {
|
|
1823
|
+
response = await this.publicGetTime(query);
|
|
1819
1824
|
}
|
|
1820
|
-
const response = await this[method](query);
|
|
1821
1825
|
return this.safeInteger(response, 'serverTime');
|
|
1822
1826
|
}
|
|
1823
1827
|
async fetchCurrencies(params = {}) {
|
|
@@ -2803,17 +2807,19 @@ export default class binance extends Exchange {
|
|
|
2803
2807
|
if (limit !== undefined) {
|
|
2804
2808
|
request['limit'] = limit; // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
|
|
2805
2809
|
}
|
|
2806
|
-
let
|
|
2810
|
+
let response = undefined;
|
|
2807
2811
|
if (market['option']) {
|
|
2808
|
-
|
|
2812
|
+
response = await this.eapiPublicGetDepth(this.extend(request, params));
|
|
2809
2813
|
}
|
|
2810
2814
|
else if (market['linear']) {
|
|
2811
|
-
|
|
2815
|
+
response = await this.fapiPublicGetDepth(this.extend(request, params));
|
|
2812
2816
|
}
|
|
2813
2817
|
else if (market['inverse']) {
|
|
2814
|
-
|
|
2818
|
+
response = await this.dapiPublicGetDepth(this.extend(request, params));
|
|
2819
|
+
}
|
|
2820
|
+
else {
|
|
2821
|
+
response = await this.publicGetDepth(this.extend(request, params));
|
|
2815
2822
|
}
|
|
2816
|
-
const response = await this[method](this.extend(request, params));
|
|
2817
2823
|
//
|
|
2818
2824
|
// future
|
|
2819
2825
|
//
|
|
@@ -3047,17 +3053,19 @@ export default class binance extends Exchange {
|
|
|
3047
3053
|
const request = {
|
|
3048
3054
|
'symbol': market['id'],
|
|
3049
3055
|
};
|
|
3050
|
-
let
|
|
3056
|
+
let response = undefined;
|
|
3051
3057
|
if (market['option']) {
|
|
3052
|
-
|
|
3058
|
+
response = await this.eapiPublicGetTicker(this.extend(request, params));
|
|
3053
3059
|
}
|
|
3054
3060
|
else if (market['linear']) {
|
|
3055
|
-
|
|
3061
|
+
response = await this.fapiPublicGetTicker24hr(this.extend(request, params));
|
|
3056
3062
|
}
|
|
3057
3063
|
else if (market['inverse']) {
|
|
3058
|
-
|
|
3064
|
+
response = await this.dapiPublicGetTicker24hr(this.extend(request, params));
|
|
3065
|
+
}
|
|
3066
|
+
else {
|
|
3067
|
+
response = await this.publicGetTicker24hr(this.extend(request, params));
|
|
3059
3068
|
}
|
|
3060
|
-
const response = await this[method](this.extend(request, params));
|
|
3061
3069
|
if (Array.isArray(response)) {
|
|
3062
3070
|
const firstTicker = this.safeValue(response, 0, {});
|
|
3063
3071
|
return this.parseTicker(firstTicker, market);
|
|
@@ -3087,17 +3095,16 @@ export default class binance extends Exchange {
|
|
|
3087
3095
|
let subType = undefined;
|
|
3088
3096
|
[subType, params] = this.handleSubTypeAndParams('fetchBidsAsks', market, params);
|
|
3089
3097
|
[type, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
|
|
3090
|
-
let
|
|
3098
|
+
let response = undefined;
|
|
3091
3099
|
if (this.isLinear(type, subType)) {
|
|
3092
|
-
|
|
3100
|
+
response = await this.fapiPublicGetTickerBookTicker(params);
|
|
3093
3101
|
}
|
|
3094
3102
|
else if (this.isInverse(type, subType)) {
|
|
3095
|
-
|
|
3103
|
+
response = await this.dapiPublicGetTickerBookTicker(params);
|
|
3096
3104
|
}
|
|
3097
3105
|
else {
|
|
3098
|
-
|
|
3106
|
+
response = await this.publicGetTickerBookTicker(params);
|
|
3099
3107
|
}
|
|
3100
|
-
const response = await this[method](params);
|
|
3101
3108
|
return this.parseTickers(response, symbols);
|
|
3102
3109
|
}
|
|
3103
3110
|
async fetchLastPrices(symbols = undefined, params = {}) {
|
|
@@ -3119,9 +3126,9 @@ export default class binance extends Exchange {
|
|
|
3119
3126
|
let subType = undefined;
|
|
3120
3127
|
[subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
|
|
3121
3128
|
[type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
|
|
3122
|
-
let
|
|
3129
|
+
let response = undefined;
|
|
3123
3130
|
if (this.isLinear(type, subType)) {
|
|
3124
|
-
|
|
3131
|
+
response = await this.fapiPublicGetTickerPrice(params);
|
|
3125
3132
|
//
|
|
3126
3133
|
// [
|
|
3127
3134
|
// {
|
|
@@ -3134,7 +3141,7 @@ export default class binance extends Exchange {
|
|
|
3134
3141
|
//
|
|
3135
3142
|
}
|
|
3136
3143
|
else if (this.isInverse(type, subType)) {
|
|
3137
|
-
|
|
3144
|
+
response = await this.dapiPublicGetTickerPrice(params);
|
|
3138
3145
|
//
|
|
3139
3146
|
// [
|
|
3140
3147
|
// {
|
|
@@ -3147,7 +3154,7 @@ export default class binance extends Exchange {
|
|
|
3147
3154
|
//
|
|
3148
3155
|
}
|
|
3149
3156
|
else if (type === 'spot') {
|
|
3150
|
-
|
|
3157
|
+
response = await this.publicGetTickerPrice(params);
|
|
3151
3158
|
//
|
|
3152
3159
|
// [
|
|
3153
3160
|
// {
|
|
@@ -3161,7 +3168,6 @@ export default class binance extends Exchange {
|
|
|
3161
3168
|
else {
|
|
3162
3169
|
throw new NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
|
|
3163
3170
|
}
|
|
3164
|
-
const response = await this[method](params);
|
|
3165
3171
|
return this.parseLastPrices(response, symbols);
|
|
3166
3172
|
}
|
|
3167
3173
|
parseLastPrice(info, market = undefined) {
|
|
@@ -6481,10 +6487,20 @@ export default class binance extends Exchange {
|
|
|
6481
6487
|
}
|
|
6482
6488
|
parseTradingFee(fee, market = undefined) {
|
|
6483
6489
|
//
|
|
6490
|
+
// spot
|
|
6491
|
+
// [
|
|
6492
|
+
// {
|
|
6493
|
+
// "symbol": "BTCUSDT",
|
|
6494
|
+
// "makerCommission": "0.001",
|
|
6495
|
+
// "takerCommission": "0.001"
|
|
6496
|
+
// }
|
|
6497
|
+
// ]
|
|
6498
|
+
//
|
|
6499
|
+
// swap
|
|
6484
6500
|
// {
|
|
6485
|
-
// "symbol": "
|
|
6486
|
-
// "
|
|
6487
|
-
// "
|
|
6501
|
+
// "symbol": "BTCUSD_PERP",
|
|
6502
|
+
// "makerCommissionRate": "0.00015", // 0.015%
|
|
6503
|
+
// "takerCommissionRate": "0.00040" // 0.040%
|
|
6488
6504
|
// }
|
|
6489
6505
|
//
|
|
6490
6506
|
const marketId = this.safeString(fee, 'symbol');
|
|
@@ -6492,8 +6508,8 @@ export default class binance extends Exchange {
|
|
|
6492
6508
|
return {
|
|
6493
6509
|
'info': fee,
|
|
6494
6510
|
'symbol': symbol,
|
|
6495
|
-
'maker': this.
|
|
6496
|
-
'taker': this.
|
|
6511
|
+
'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
|
|
6512
|
+
'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
|
|
6497
6513
|
};
|
|
6498
6514
|
}
|
|
6499
6515
|
async fetchTradingFee(symbol, params = {}) {
|
|
@@ -6502,17 +6518,37 @@ export default class binance extends Exchange {
|
|
|
6502
6518
|
* @name binance#fetchTradingFee
|
|
6503
6519
|
* @description fetch the trading fees for a market
|
|
6504
6520
|
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
|
|
6521
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
|
|
6522
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
|
|
6505
6523
|
* @param {string} symbol unified market symbol
|
|
6506
6524
|
* @param {object} [params] extra parameters specific to the binance api endpoint
|
|
6507
6525
|
* @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
|
|
6508
6526
|
*/
|
|
6509
6527
|
await this.loadMarkets();
|
|
6510
6528
|
const market = this.market(symbol);
|
|
6529
|
+
const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
|
|
6530
|
+
const type = this.safeString(params, 'type', defaultType);
|
|
6531
|
+
params = this.omit(params, 'type');
|
|
6532
|
+
let subType = undefined;
|
|
6533
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
|
|
6534
|
+
const isSpotOrMargin = (type === 'spot') || (type === 'margin');
|
|
6535
|
+
const isLinear = this.isLinear(type, subType);
|
|
6536
|
+
const isInverse = this.isInverse(type, subType);
|
|
6511
6537
|
const request = {
|
|
6512
6538
|
'symbol': market['id'],
|
|
6513
6539
|
};
|
|
6514
|
-
|
|
6540
|
+
let response = undefined;
|
|
6541
|
+
if (isSpotOrMargin) {
|
|
6542
|
+
response = await this.sapiGetAssetTradeFee(this.extend(request, params));
|
|
6543
|
+
}
|
|
6544
|
+
else if (isLinear) {
|
|
6545
|
+
response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
|
|
6546
|
+
}
|
|
6547
|
+
else if (isInverse) {
|
|
6548
|
+
response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
|
|
6549
|
+
}
|
|
6515
6550
|
//
|
|
6551
|
+
// spot
|
|
6516
6552
|
// [
|
|
6517
6553
|
// {
|
|
6518
6554
|
// "symbol": "BTCUSDT",
|
|
@@ -6521,8 +6557,18 @@ export default class binance extends Exchange {
|
|
|
6521
6557
|
// }
|
|
6522
6558
|
// ]
|
|
6523
6559
|
//
|
|
6524
|
-
|
|
6525
|
-
|
|
6560
|
+
// swap
|
|
6561
|
+
// {
|
|
6562
|
+
// "symbol": "BTCUSD_PERP",
|
|
6563
|
+
// "makerCommissionRate": "0.00015", // 0.015%
|
|
6564
|
+
// "takerCommissionRate": "0.00040" // 0.040%
|
|
6565
|
+
// }
|
|
6566
|
+
//
|
|
6567
|
+
let data = response;
|
|
6568
|
+
if (Array.isArray(data)) {
|
|
6569
|
+
data = this.safeValue(data, 0, {});
|
|
6570
|
+
}
|
|
6571
|
+
return this.parseTradingFee(data);
|
|
6526
6572
|
}
|
|
6527
6573
|
async fetchTradingFees(params = {}) {
|
|
6528
6574
|
/**
|
|
@@ -6537,11 +6583,10 @@ export default class binance extends Exchange {
|
|
|
6537
6583
|
*/
|
|
6538
6584
|
await this.loadMarkets();
|
|
6539
6585
|
let method = undefined;
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
params = this.omit(params, 'type');
|
|
6586
|
+
let type = undefined;
|
|
6587
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
|
|
6543
6588
|
let subType = undefined;
|
|
6544
|
-
[subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params);
|
|
6589
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params, 'linear');
|
|
6545
6590
|
const isSpotOrMargin = (type === 'spot') || (type === 'margin');
|
|
6546
6591
|
const isLinear = this.isLinear(type, subType);
|
|
6547
6592
|
const isInverse = this.isInverse(type, subType);
|
|
@@ -8218,13 +8263,15 @@ export default class binance extends Exchange {
|
|
|
8218
8263
|
let type = undefined;
|
|
8219
8264
|
let subType = undefined;
|
|
8220
8265
|
let currency = undefined;
|
|
8266
|
+
if (code !== undefined) {
|
|
8267
|
+
currency = this.currency(code);
|
|
8268
|
+
}
|
|
8221
8269
|
let method = undefined;
|
|
8222
8270
|
const request = {};
|
|
8223
8271
|
[type, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
|
|
8224
8272
|
[subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
|
|
8225
8273
|
if (type === 'option') {
|
|
8226
8274
|
this.checkRequiredArgument('fetchLedger', code, 'code');
|
|
8227
|
-
currency = this.currency(code);
|
|
8228
8275
|
request['currency'] = currency['id'];
|
|
8229
8276
|
method = 'eapiPrivateGetBill';
|
|
8230
8277
|
}
|
|
@@ -9179,4 +9226,230 @@ export default class binance extends Exchange {
|
|
|
9179
9226
|
'info': interest,
|
|
9180
9227
|
}, market);
|
|
9181
9228
|
}
|
|
9229
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
9230
|
+
/**
|
|
9231
|
+
* @method
|
|
9232
|
+
* @name binance#fetchMyLiquidations
|
|
9233
|
+
* @description retrieves the users liquidated positions
|
|
9234
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
|
|
9235
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
|
|
9236
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
|
|
9237
|
+
* @param {string} [symbol] unified CCXT market symbol
|
|
9238
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
9239
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
9240
|
+
* @param {object} [params] exchange specific parameters for the binance api endpoint
|
|
9241
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
9242
|
+
* @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)
|
|
9243
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
9244
|
+
*/
|
|
9245
|
+
await this.loadMarkets();
|
|
9246
|
+
let paginate = false;
|
|
9247
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchMyLiquidations', 'paginate');
|
|
9248
|
+
if (paginate) {
|
|
9249
|
+
return await this.fetchPaginatedCallIncremental('fetchMyLiquidations', symbol, since, limit, params, 'current', 100);
|
|
9250
|
+
}
|
|
9251
|
+
let market = undefined;
|
|
9252
|
+
if (symbol !== undefined) {
|
|
9253
|
+
market = this.market(symbol);
|
|
9254
|
+
}
|
|
9255
|
+
let type = undefined;
|
|
9256
|
+
[type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
|
|
9257
|
+
let subType = undefined;
|
|
9258
|
+
[subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
|
|
9259
|
+
let request = {};
|
|
9260
|
+
if (type !== 'spot') {
|
|
9261
|
+
request['autoCloseType'] = 'LIQUIDATION';
|
|
9262
|
+
}
|
|
9263
|
+
if (market !== undefined) {
|
|
9264
|
+
const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
|
|
9265
|
+
request[symbolKey] = market['id'];
|
|
9266
|
+
}
|
|
9267
|
+
if (since !== undefined) {
|
|
9268
|
+
request['startTime'] = since;
|
|
9269
|
+
}
|
|
9270
|
+
if (limit !== undefined) {
|
|
9271
|
+
if (type === 'spot') {
|
|
9272
|
+
request['size'] = limit;
|
|
9273
|
+
}
|
|
9274
|
+
else {
|
|
9275
|
+
request['limit'] = limit;
|
|
9276
|
+
}
|
|
9277
|
+
}
|
|
9278
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
9279
|
+
let response = undefined;
|
|
9280
|
+
if (type === 'spot') {
|
|
9281
|
+
response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
|
|
9282
|
+
}
|
|
9283
|
+
else if (subType === 'linear') {
|
|
9284
|
+
response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
|
|
9285
|
+
}
|
|
9286
|
+
else if (subType === 'inverse') {
|
|
9287
|
+
response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
|
|
9288
|
+
}
|
|
9289
|
+
else {
|
|
9290
|
+
throw new NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
|
|
9291
|
+
}
|
|
9292
|
+
//
|
|
9293
|
+
// margin
|
|
9294
|
+
//
|
|
9295
|
+
// {
|
|
9296
|
+
// "rows": [
|
|
9297
|
+
// {
|
|
9298
|
+
// "avgPrice": "0.00388359",
|
|
9299
|
+
// "executedQty": "31.39000000",
|
|
9300
|
+
// "orderId": 180015097,
|
|
9301
|
+
// "price": "0.00388110",
|
|
9302
|
+
// "qty": "31.39000000",
|
|
9303
|
+
// "side": "SELL",
|
|
9304
|
+
// "symbol": "BNBBTC",
|
|
9305
|
+
// "timeInForce": "GTC",
|
|
9306
|
+
// "isIsolated": true,
|
|
9307
|
+
// "updatedTime": 1558941374745
|
|
9308
|
+
// }
|
|
9309
|
+
// ],
|
|
9310
|
+
// "total": 1
|
|
9311
|
+
// }
|
|
9312
|
+
//
|
|
9313
|
+
// linear
|
|
9314
|
+
//
|
|
9315
|
+
// [
|
|
9316
|
+
// {
|
|
9317
|
+
// "orderId": 6071832819,
|
|
9318
|
+
// "symbol": "BTCUSDT",
|
|
9319
|
+
// "status": "FILLED",
|
|
9320
|
+
// "clientOrderId": "autoclose-1596107620040000020",
|
|
9321
|
+
// "price": "10871.09",
|
|
9322
|
+
// "avgPrice": "10913.21000",
|
|
9323
|
+
// "origQty": "0.001",
|
|
9324
|
+
// "executedQty": "0.001",
|
|
9325
|
+
// "cumQuote": "10.91321",
|
|
9326
|
+
// "timeInForce": "IOC",
|
|
9327
|
+
// "type": "LIMIT",
|
|
9328
|
+
// "reduceOnly": false,
|
|
9329
|
+
// "closePosition": false,
|
|
9330
|
+
// "side": "SELL",
|
|
9331
|
+
// "positionSide": "BOTH",
|
|
9332
|
+
// "stopPrice": "0",
|
|
9333
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9334
|
+
// "origType": "LIMIT",
|
|
9335
|
+
// "time": 1596107620044,
|
|
9336
|
+
// "updateTime": 1596107620087
|
|
9337
|
+
// },
|
|
9338
|
+
// ]
|
|
9339
|
+
//
|
|
9340
|
+
// inverse
|
|
9341
|
+
//
|
|
9342
|
+
// [
|
|
9343
|
+
// {
|
|
9344
|
+
// "orderId": 165123080,
|
|
9345
|
+
// "symbol": "BTCUSD_200925",
|
|
9346
|
+
// "pair": "BTCUSD",
|
|
9347
|
+
// "status": "FILLED",
|
|
9348
|
+
// "clientOrderId": "autoclose-1596542005017000006",
|
|
9349
|
+
// "price": "11326.9",
|
|
9350
|
+
// "avgPrice": "11326.9",
|
|
9351
|
+
// "origQty": "1",
|
|
9352
|
+
// "executedQty": "1",
|
|
9353
|
+
// "cumBase": "0.00882854",
|
|
9354
|
+
// "timeInForce": "IOC",
|
|
9355
|
+
// "type": "LIMIT",
|
|
9356
|
+
// "reduceOnly": false,
|
|
9357
|
+
// "closePosition": false,
|
|
9358
|
+
// "side": "SELL",
|
|
9359
|
+
// "positionSide": "BOTH",
|
|
9360
|
+
// "stopPrice": "0",
|
|
9361
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9362
|
+
// "priceProtect": false,
|
|
9363
|
+
// "origType": "LIMIT",
|
|
9364
|
+
// "time": 1596542005019,
|
|
9365
|
+
// "updateTime": 1596542005050
|
|
9366
|
+
// },
|
|
9367
|
+
// ]
|
|
9368
|
+
//
|
|
9369
|
+
const liquidations = this.safeValue(response, 'rows', response);
|
|
9370
|
+
return this.parseLiquidations(liquidations, market, since, limit);
|
|
9371
|
+
}
|
|
9372
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
9373
|
+
//
|
|
9374
|
+
// margin
|
|
9375
|
+
//
|
|
9376
|
+
// {
|
|
9377
|
+
// "avgPrice": "0.00388359",
|
|
9378
|
+
// "executedQty": "31.39000000",
|
|
9379
|
+
// "orderId": 180015097,
|
|
9380
|
+
// "price": "0.00388110",
|
|
9381
|
+
// "qty": "31.39000000",
|
|
9382
|
+
// "side": "SELL",
|
|
9383
|
+
// "symbol": "BNBBTC",
|
|
9384
|
+
// "timeInForce": "GTC",
|
|
9385
|
+
// "isIsolated": true,
|
|
9386
|
+
// "updatedTime": 1558941374745
|
|
9387
|
+
// }
|
|
9388
|
+
//
|
|
9389
|
+
// linear
|
|
9390
|
+
//
|
|
9391
|
+
// {
|
|
9392
|
+
// "orderId": 6071832819,
|
|
9393
|
+
// "symbol": "BTCUSDT",
|
|
9394
|
+
// "status": "FILLED",
|
|
9395
|
+
// "clientOrderId": "autoclose-1596107620040000020",
|
|
9396
|
+
// "price": "10871.09",
|
|
9397
|
+
// "avgPrice": "10913.21000",
|
|
9398
|
+
// "origQty": "0.001",
|
|
9399
|
+
// "executedQty": "0.001",
|
|
9400
|
+
// "cumQuote": "10.91321",
|
|
9401
|
+
// "timeInForce": "IOC",
|
|
9402
|
+
// "type": "LIMIT",
|
|
9403
|
+
// "reduceOnly": false,
|
|
9404
|
+
// "closePosition": false,
|
|
9405
|
+
// "side": "SELL",
|
|
9406
|
+
// "positionSide": "BOTH",
|
|
9407
|
+
// "stopPrice": "0",
|
|
9408
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9409
|
+
// "origType": "LIMIT",
|
|
9410
|
+
// "time": 1596107620044,
|
|
9411
|
+
// "updateTime": 1596107620087
|
|
9412
|
+
// }
|
|
9413
|
+
//
|
|
9414
|
+
// inverse
|
|
9415
|
+
//
|
|
9416
|
+
// {
|
|
9417
|
+
// "orderId": 165123080,
|
|
9418
|
+
// "symbol": "BTCUSD_200925",
|
|
9419
|
+
// "pair": "BTCUSD",
|
|
9420
|
+
// "status": "FILLED",
|
|
9421
|
+
// "clientOrderId": "autoclose-1596542005017000006",
|
|
9422
|
+
// "price": "11326.9",
|
|
9423
|
+
// "avgPrice": "11326.9",
|
|
9424
|
+
// "origQty": "1",
|
|
9425
|
+
// "executedQty": "1",
|
|
9426
|
+
// "cumBase": "0.00882854",
|
|
9427
|
+
// "timeInForce": "IOC",
|
|
9428
|
+
// "type": "LIMIT",
|
|
9429
|
+
// "reduceOnly": false,
|
|
9430
|
+
// "closePosition": false,
|
|
9431
|
+
// "side": "SELL",
|
|
9432
|
+
// "positionSide": "BOTH",
|
|
9433
|
+
// "stopPrice": "0",
|
|
9434
|
+
// "workingType": "CONTRACT_PRICE",
|
|
9435
|
+
// "priceProtect": false,
|
|
9436
|
+
// "origType": "LIMIT",
|
|
9437
|
+
// "time": 1596542005019,
|
|
9438
|
+
// "updateTime": 1596542005050
|
|
9439
|
+
// }
|
|
9440
|
+
//
|
|
9441
|
+
const marketId = this.safeString(liquidation, 'symbol');
|
|
9442
|
+
const timestamp = this.safeInteger2(liquidation, 'updatedTime', 'updateTime');
|
|
9443
|
+
return {
|
|
9444
|
+
'info': liquidation,
|
|
9445
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
9446
|
+
'contracts': this.safeNumber(liquidation, 'executedQty'),
|
|
9447
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
9448
|
+
'price': this.safeNumber(liquidation, 'avgPrice'),
|
|
9449
|
+
'baseValue': this.safeNumber(liquidation, 'cumBase'),
|
|
9450
|
+
'quoteValue': this.safeNumber(liquidation, 'cumQuote'),
|
|
9451
|
+
'timestamp': timestamp,
|
|
9452
|
+
'datetime': this.iso8601(timestamp),
|
|
9453
|
+
};
|
|
9454
|
+
}
|
|
9182
9455
|
}
|
package/js/src/bingx.d.ts
CHANGED
package/js/src/bingx.js
CHANGED
package/js/src/bitbank.js
CHANGED
package/js/src/bitbns.js
CHANGED
package/js/src/bitfinex.js
CHANGED
package/js/src/bitfinex2.js
CHANGED
package/js/src/bitflyer.js
CHANGED