ccxt 4.1.12 → 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 +947 -15
- package/dist/ccxt.browser.min.js +2 -2
- 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 +231 -1
- 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 +11 -2
- 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 +3 -3
- package/dist/cjs/src/deribit.js +163 -0
- package/dist/cjs/src/gate.js +189 -0
- package/dist/cjs/src/huobi.js +102 -0
- package/dist/cjs/src/kucoin.js +1 -0
- package/dist/cjs/src/kucoinfutures.js +1 -1
- package/dist/cjs/src/okx.js +1 -0
- package/dist/cjs/src/poloniex.js +20 -7
- 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 +231 -1
- 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 +11 -2
- 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.js +3 -3
- 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 +12 -0
- package/js/src/huobi.js +102 -0
- package/js/src/kucoin.js +1 -0
- package/js/src/kucoinfutures.js +1 -1
- package/js/src/okx.js +1 -0
- package/js/src/poloniex.js +20 -7
- package/package.json +1 -1
- package/skip-tests.json +61 -5
package/dist/cjs/src/bitpanda.js
CHANGED
package/dist/cjs/src/bitrue.js
CHANGED
package/dist/cjs/src/bitso.js
CHANGED
package/dist/cjs/src/bitstamp.js
CHANGED
package/dist/cjs/src/bitvavo.js
CHANGED
package/dist/cjs/src/btcalpha.js
CHANGED
package/dist/cjs/src/btcturk.js
CHANGED
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -2774,7 +2774,7 @@ class bybit extends bybit$1 {
|
|
|
2774
2774
|
const feeToken = this.safeString(trade, 'feeTokenId');
|
|
2775
2775
|
const feeCurrency = this.safeCurrencyCode(feeToken);
|
|
2776
2776
|
fee = {
|
|
2777
|
-
'cost': feeCost,
|
|
2777
|
+
'cost': Precise["default"].stringAbs(feeCost),
|
|
2778
2778
|
'currency': feeCurrency,
|
|
2779
2779
|
};
|
|
2780
2780
|
}
|
|
@@ -2940,7 +2940,7 @@ class bybit extends bybit$1 {
|
|
|
2940
2940
|
feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
|
|
2941
2941
|
}
|
|
2942
2942
|
fee = {
|
|
2943
|
-
'cost': feeCostString,
|
|
2943
|
+
'cost': Precise["default"].stringAbs(feeCostString),
|
|
2944
2944
|
'currency': feeCurrencyCode,
|
|
2945
2945
|
};
|
|
2946
2946
|
}
|
|
@@ -5540,7 +5540,7 @@ class bybit extends bybit$1 {
|
|
|
5540
5540
|
'referenceAccount': undefined,
|
|
5541
5541
|
'referenceId': referenceId,
|
|
5542
5542
|
'status': undefined,
|
|
5543
|
-
'amount': this.parseNumber(amount),
|
|
5543
|
+
'amount': this.parseNumber(Precise["default"].stringAbs(amount)),
|
|
5544
5544
|
'before': this.parseNumber(before),
|
|
5545
5545
|
'after': this.parseNumber(after),
|
|
5546
5546
|
'fee': this.parseNumber(this.safeString(item, 'fee')),
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -58,9 +58,11 @@ class deribit extends deribit$1 {
|
|
|
58
58
|
'fetchFundingRateHistory': true,
|
|
59
59
|
'fetchIndexOHLCV': false,
|
|
60
60
|
'fetchLeverageTiers': false,
|
|
61
|
+
'fetchLiquidations': true,
|
|
61
62
|
'fetchMarginMode': false,
|
|
62
63
|
'fetchMarkets': true,
|
|
63
64
|
'fetchMarkOHLCV': false,
|
|
65
|
+
'fetchMyLiquidations': true,
|
|
64
66
|
'fetchMySettlementHistory': false,
|
|
65
67
|
'fetchMyTrades': true,
|
|
66
68
|
'fetchOHLCV': true,
|
|
@@ -2914,6 +2916,167 @@ class deribit extends deribit$1 {
|
|
|
2914
2916
|
'previousFundingDatetime': undefined,
|
|
2915
2917
|
};
|
|
2916
2918
|
}
|
|
2919
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
2920
|
+
/**
|
|
2921
|
+
* @method
|
|
2922
|
+
* @name deribit#fetchLiquidations
|
|
2923
|
+
* @description retrieves the public liquidations of a trading pair
|
|
2924
|
+
* @see https://docs.deribit.com/#public-get_last_settlements_by_currency
|
|
2925
|
+
* @param {string} symbol unified CCXT market symbol
|
|
2926
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
2927
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
2928
|
+
* @param {object} [params] exchange specific parameters for the deribit api endpoint
|
|
2929
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2930
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
2931
|
+
*/
|
|
2932
|
+
await this.loadMarkets();
|
|
2933
|
+
let paginate = false;
|
|
2934
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
|
|
2935
|
+
if (paginate) {
|
|
2936
|
+
return await this.fetchPaginatedCallCursor('fetchLiquidations', symbol, since, limit, params, 'continuation', 'continuation', undefined);
|
|
2937
|
+
}
|
|
2938
|
+
const market = this.market(symbol);
|
|
2939
|
+
if (market['spot']) {
|
|
2940
|
+
throw new errors.NotSupported(this.id + ' fetchLiquidations() does not support ' + market['type'] + ' markets');
|
|
2941
|
+
}
|
|
2942
|
+
const request = {
|
|
2943
|
+
'instrument_name': market['id'],
|
|
2944
|
+
'type': 'bankruptcy',
|
|
2945
|
+
};
|
|
2946
|
+
if (since !== undefined) {
|
|
2947
|
+
request['search_start_timestamp'] = since;
|
|
2948
|
+
}
|
|
2949
|
+
if (limit !== undefined) {
|
|
2950
|
+
request['count'] = limit;
|
|
2951
|
+
}
|
|
2952
|
+
const response = await this.publicGetGetLastSettlementsByInstrument(this.extend(request, params));
|
|
2953
|
+
//
|
|
2954
|
+
// {
|
|
2955
|
+
// "jsonrpc": "2.0",
|
|
2956
|
+
// "result": {
|
|
2957
|
+
// "settlements": [
|
|
2958
|
+
// {
|
|
2959
|
+
// "type": "bankruptcy",
|
|
2960
|
+
// "timestamp": 1696579200041,
|
|
2961
|
+
// "funded": 10000.0,
|
|
2962
|
+
// "session_bankrupcy": 10000.0
|
|
2963
|
+
// "session_profit_loss": 112951.68715857354,
|
|
2964
|
+
// "session_tax": 0.15,
|
|
2965
|
+
// "session_tax_rate": 0.0015,
|
|
2966
|
+
// "socialized": 0.001,
|
|
2967
|
+
// },
|
|
2968
|
+
// ],
|
|
2969
|
+
// "continuation": "5dHzoGyD8Hs8KURoUhfgXgHpJTA5oyapoudSmNeAfEftqRbjNE6jNNUpo2oCu1khnZL9ao"
|
|
2970
|
+
// },
|
|
2971
|
+
// "usIn": 1696652052254890,
|
|
2972
|
+
// "usOut": 1696652052255733,
|
|
2973
|
+
// "usDiff": 843,
|
|
2974
|
+
// "testnet": false
|
|
2975
|
+
// }
|
|
2976
|
+
//
|
|
2977
|
+
const result = this.safeValue(response, 'result', {});
|
|
2978
|
+
const cursor = this.safeString(result, 'continuation');
|
|
2979
|
+
const settlements = this.safeValue(result, 'settlements', []);
|
|
2980
|
+
const settlementsWithCursor = this.addPaginationCursorToResult(cursor, settlements);
|
|
2981
|
+
return this.parseLiquidations(settlementsWithCursor, market, since, limit);
|
|
2982
|
+
}
|
|
2983
|
+
addPaginationCursorToResult(cursor, data) {
|
|
2984
|
+
if (cursor !== undefined) {
|
|
2985
|
+
const dataLength = data.length;
|
|
2986
|
+
if (dataLength > 0) {
|
|
2987
|
+
const first = data[0];
|
|
2988
|
+
const last = data[dataLength - 1];
|
|
2989
|
+
first['continuation'] = cursor;
|
|
2990
|
+
last['continuation'] = cursor;
|
|
2991
|
+
data[0] = first;
|
|
2992
|
+
data[dataLength - 1] = last;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
return data;
|
|
2996
|
+
}
|
|
2997
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2998
|
+
/**
|
|
2999
|
+
* @method
|
|
3000
|
+
* @name deribit#fetchMyLiquidations
|
|
3001
|
+
* @description retrieves the users liquidated positions
|
|
3002
|
+
* @see https://docs.deribit.com/#private-get_settlement_history_by_instrument
|
|
3003
|
+
* @param {string} symbol unified CCXT market symbol
|
|
3004
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
3005
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
3006
|
+
* @param {object} [params] exchange specific parameters for the deribit api endpoint
|
|
3007
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
3008
|
+
*/
|
|
3009
|
+
this.checkRequiredSymbol('fetchMyLiquidations', symbol);
|
|
3010
|
+
await this.loadMarkets();
|
|
3011
|
+
const market = this.market(symbol);
|
|
3012
|
+
if (market['spot']) {
|
|
3013
|
+
throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
|
|
3014
|
+
}
|
|
3015
|
+
const request = {
|
|
3016
|
+
'instrument_name': market['id'],
|
|
3017
|
+
'type': 'bankruptcy',
|
|
3018
|
+
};
|
|
3019
|
+
if (since !== undefined) {
|
|
3020
|
+
request['search_start_timestamp'] = since;
|
|
3021
|
+
}
|
|
3022
|
+
if (limit !== undefined) {
|
|
3023
|
+
request['count'] = limit;
|
|
3024
|
+
}
|
|
3025
|
+
const response = await this.privateGetGetSettlementHistoryByInstrument(this.extend(request, params));
|
|
3026
|
+
//
|
|
3027
|
+
// {
|
|
3028
|
+
// "jsonrpc": "2.0",
|
|
3029
|
+
// "result": {
|
|
3030
|
+
// "settlements": [
|
|
3031
|
+
// {
|
|
3032
|
+
// "type": "bankruptcy",
|
|
3033
|
+
// "timestamp": 1696579200041,
|
|
3034
|
+
// "funded": 10000.0,
|
|
3035
|
+
// "session_bankrupcy": 10000.0
|
|
3036
|
+
// "session_profit_loss": 112951.68715857354,
|
|
3037
|
+
// "session_tax": 0.15,
|
|
3038
|
+
// "session_tax_rate": 0.0015,
|
|
3039
|
+
// "socialized": 0.001,
|
|
3040
|
+
// },
|
|
3041
|
+
// ],
|
|
3042
|
+
// "continuation": "5dHzoGyD8Hs8KURoUhfgXgHpJTA5oyapoudSmNeAfEftqRbjNE6jNNUpo2oCu1khnZL9ao"
|
|
3043
|
+
// },
|
|
3044
|
+
// "usIn": 1696652052254890,
|
|
3045
|
+
// "usOut": 1696652052255733,
|
|
3046
|
+
// "usDiff": 843,
|
|
3047
|
+
// "testnet": false
|
|
3048
|
+
// }
|
|
3049
|
+
//
|
|
3050
|
+
const result = this.safeValue(response, 'result', {});
|
|
3051
|
+
const settlements = this.safeValue(result, 'settlements', []);
|
|
3052
|
+
return this.parseLiquidations(settlements, market, since, limit);
|
|
3053
|
+
}
|
|
3054
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
3055
|
+
//
|
|
3056
|
+
// {
|
|
3057
|
+
// "type": "bankruptcy",
|
|
3058
|
+
// "timestamp": 1696579200041,
|
|
3059
|
+
// "funded": 1,
|
|
3060
|
+
// "session_bankrupcy": 0.001,
|
|
3061
|
+
// "session_profit_loss": 0.001,
|
|
3062
|
+
// "session_tax": 0.0015,
|
|
3063
|
+
// "session_tax_rate": 0.0015,
|
|
3064
|
+
// "socialized": 0.001,
|
|
3065
|
+
// }
|
|
3066
|
+
//
|
|
3067
|
+
const timestamp = this.safeInteger(liquidation, 'timestamp');
|
|
3068
|
+
return {
|
|
3069
|
+
'info': liquidation,
|
|
3070
|
+
'symbol': this.safeSymbol(undefined, market),
|
|
3071
|
+
'contracts': undefined,
|
|
3072
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
3073
|
+
'price': undefined,
|
|
3074
|
+
'baseValue': this.safeNumber(liquidation, 'session_bankrupcy'),
|
|
3075
|
+
'quoteValue': undefined,
|
|
3076
|
+
'timestamp': timestamp,
|
|
3077
|
+
'datetime': this.iso8601(timestamp),
|
|
3078
|
+
};
|
|
3079
|
+
}
|
|
2917
3080
|
nonce() {
|
|
2918
3081
|
return this.milliseconds();
|
|
2919
3082
|
}
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -105,10 +105,12 @@ class gate extends gate$1 {
|
|
|
105
105
|
'fetchLedger': true,
|
|
106
106
|
'fetchLeverage': false,
|
|
107
107
|
'fetchLeverageTiers': true,
|
|
108
|
+
'fetchLiquidations': true,
|
|
108
109
|
'fetchMarginMode': false,
|
|
109
110
|
'fetchMarketLeverageTiers': 'emulated',
|
|
110
111
|
'fetchMarkets': true,
|
|
111
112
|
'fetchMarkOHLCV': true,
|
|
113
|
+
'fetchMyLiquidations': true,
|
|
112
114
|
'fetchMySettlementHistory': true,
|
|
113
115
|
'fetchMyTrades': true,
|
|
114
116
|
'fetchNetworkDepositAddress': true,
|
|
@@ -6326,6 +6328,193 @@ class gate extends gate$1 {
|
|
|
6326
6328
|
}
|
|
6327
6329
|
return underlyings;
|
|
6328
6330
|
}
|
|
6331
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
6332
|
+
/**
|
|
6333
|
+
* @method
|
|
6334
|
+
* @name gate#fetchLiquidations
|
|
6335
|
+
* @description retrieves the public liquidations of a trading pair
|
|
6336
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-liquidation-history
|
|
6337
|
+
* @param {string} symbol unified CCXT market symbol
|
|
6338
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
6339
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
6340
|
+
* @param {object} [params] exchange specific parameters for the gate api endpoint
|
|
6341
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
6342
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
6343
|
+
*/
|
|
6344
|
+
await this.loadMarkets();
|
|
6345
|
+
const market = this.market(symbol);
|
|
6346
|
+
if (!market['swap']) {
|
|
6347
|
+
throw new errors.NotSupported(this.id + ' fetchLiquidations() supports swap markets only');
|
|
6348
|
+
}
|
|
6349
|
+
let request = {
|
|
6350
|
+
'settle': market['settleId'],
|
|
6351
|
+
'contract': market['id'],
|
|
6352
|
+
};
|
|
6353
|
+
if (since !== undefined) {
|
|
6354
|
+
request['from'] = since;
|
|
6355
|
+
}
|
|
6356
|
+
if (limit !== undefined) {
|
|
6357
|
+
request['limit'] = limit;
|
|
6358
|
+
}
|
|
6359
|
+
[request, params] = this.handleUntilOption('to', request, params);
|
|
6360
|
+
const response = await this.publicFuturesGetSettleLiqOrders(this.extend(request, params));
|
|
6361
|
+
//
|
|
6362
|
+
// [
|
|
6363
|
+
// {
|
|
6364
|
+
// "contract": "BTC_USDT",
|
|
6365
|
+
// "left": 0,
|
|
6366
|
+
// "size": -165,
|
|
6367
|
+
// "fill_price": "28070",
|
|
6368
|
+
// "order_price": "28225",
|
|
6369
|
+
// "time": 1696736132
|
|
6370
|
+
// },
|
|
6371
|
+
// ]
|
|
6372
|
+
//
|
|
6373
|
+
return this.parseLiquidations(response, market, since, limit);
|
|
6374
|
+
}
|
|
6375
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
6376
|
+
/**
|
|
6377
|
+
* @method
|
|
6378
|
+
* @name gate#fetchMyLiquidations
|
|
6379
|
+
* @description retrieves the users liquidated positions
|
|
6380
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-liquidation-history
|
|
6381
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-liquidation-history-2
|
|
6382
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-user-s-liquidation-history-of-specified-underlying
|
|
6383
|
+
* @param {string} symbol unified CCXT market symbol
|
|
6384
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
6385
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
6386
|
+
* @param {object} [params] exchange specific parameters for the gate api endpoint
|
|
6387
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
6388
|
+
*/
|
|
6389
|
+
this.checkRequiredSymbol('fetchMyLiquidations', symbol);
|
|
6390
|
+
await this.loadMarkets();
|
|
6391
|
+
const market = this.market(symbol);
|
|
6392
|
+
const request = {
|
|
6393
|
+
'contract': market['id'],
|
|
6394
|
+
};
|
|
6395
|
+
let response = undefined;
|
|
6396
|
+
if ((market['swap']) || (market['future'])) {
|
|
6397
|
+
if (limit !== undefined) {
|
|
6398
|
+
request['limit'] = limit;
|
|
6399
|
+
}
|
|
6400
|
+
request['settle'] = market['settleId'];
|
|
6401
|
+
}
|
|
6402
|
+
else if (market['option']) {
|
|
6403
|
+
const marketId = market['id'];
|
|
6404
|
+
const optionParts = marketId.split('-');
|
|
6405
|
+
request['underlying'] = this.safeString(optionParts, 0);
|
|
6406
|
+
}
|
|
6407
|
+
if (market['swap']) {
|
|
6408
|
+
response = await this.privateFuturesGetSettleLiquidates(this.extend(request, params));
|
|
6409
|
+
}
|
|
6410
|
+
else if (market['future']) {
|
|
6411
|
+
response = await this.privateDeliveryGetSettleLiquidates(this.extend(request, params));
|
|
6412
|
+
}
|
|
6413
|
+
else if (market['option']) {
|
|
6414
|
+
response = await this.privateOptionsGetPositionClose(this.extend(request, params));
|
|
6415
|
+
}
|
|
6416
|
+
else {
|
|
6417
|
+
throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' orders');
|
|
6418
|
+
}
|
|
6419
|
+
//
|
|
6420
|
+
// swap and future
|
|
6421
|
+
//
|
|
6422
|
+
// [
|
|
6423
|
+
// {
|
|
6424
|
+
// "time": 1548654951,
|
|
6425
|
+
// "contract": "BTC_USDT",
|
|
6426
|
+
// "size": 600,
|
|
6427
|
+
// "leverage": "25",
|
|
6428
|
+
// "margin": "0.006705256878",
|
|
6429
|
+
// "entry_price": "3536.123",
|
|
6430
|
+
// "liq_price": "3421.54",
|
|
6431
|
+
// "mark_price": "3420.27",
|
|
6432
|
+
// "order_id": 317393847,
|
|
6433
|
+
// "order_price": "3405",
|
|
6434
|
+
// "fill_price": "3424",
|
|
6435
|
+
// "left": 0
|
|
6436
|
+
// }
|
|
6437
|
+
// ]
|
|
6438
|
+
//
|
|
6439
|
+
// option
|
|
6440
|
+
//
|
|
6441
|
+
// [
|
|
6442
|
+
// {
|
|
6443
|
+
// "time": 1631764800,
|
|
6444
|
+
// "pnl": "-42914.291",
|
|
6445
|
+
// "settle_size": "-10001",
|
|
6446
|
+
// "side": "short",
|
|
6447
|
+
// "contract": "BTC_USDT-20210916-5000-C",
|
|
6448
|
+
// "text": "settled"
|
|
6449
|
+
// }
|
|
6450
|
+
// ]
|
|
6451
|
+
//
|
|
6452
|
+
return this.parseLiquidations(response, market, since, limit);
|
|
6453
|
+
}
|
|
6454
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
6455
|
+
//
|
|
6456
|
+
// fetchLiquidations
|
|
6457
|
+
//
|
|
6458
|
+
// {
|
|
6459
|
+
// "contract": "BTC_USDT",
|
|
6460
|
+
// "left": 0,
|
|
6461
|
+
// "size": -165,
|
|
6462
|
+
// "fill_price": "28070",
|
|
6463
|
+
// "order_price": "28225",
|
|
6464
|
+
// "time": 1696736132
|
|
6465
|
+
// }
|
|
6466
|
+
//
|
|
6467
|
+
// swap and future: fetchMyLiquidations
|
|
6468
|
+
//
|
|
6469
|
+
// {
|
|
6470
|
+
// "time": 1548654951,
|
|
6471
|
+
// "contract": "BTC_USDT",
|
|
6472
|
+
// "size": 600,
|
|
6473
|
+
// "leverage": "25",
|
|
6474
|
+
// "margin": "0.006705256878",
|
|
6475
|
+
// "entry_price": "3536.123",
|
|
6476
|
+
// "liq_price": "3421.54",
|
|
6477
|
+
// "mark_price": "3420.27",
|
|
6478
|
+
// "order_id": 317393847,
|
|
6479
|
+
// "order_price": "3405",
|
|
6480
|
+
// "fill_price": "3424",
|
|
6481
|
+
// "left": 0
|
|
6482
|
+
// }
|
|
6483
|
+
//
|
|
6484
|
+
// option: fetchMyLiquidations
|
|
6485
|
+
//
|
|
6486
|
+
// {
|
|
6487
|
+
// "time": 1631764800,
|
|
6488
|
+
// "pnl": "-42914.291",
|
|
6489
|
+
// "settle_size": "-10001",
|
|
6490
|
+
// "side": "short",
|
|
6491
|
+
// "contract": "BTC_USDT-20210916-5000-C",
|
|
6492
|
+
// "text": "settled"
|
|
6493
|
+
// }
|
|
6494
|
+
//
|
|
6495
|
+
const marketId = this.safeString(liquidation, 'contract');
|
|
6496
|
+
const timestamp = this.safeTimestamp(liquidation, 'time');
|
|
6497
|
+
const contractsStringRaw = this.safeString2(liquidation, 'size', 'settle_size');
|
|
6498
|
+
const contractsString = Precise["default"].stringAbs(contractsStringRaw);
|
|
6499
|
+
const contractSizeString = this.safeString(market, 'contractSize');
|
|
6500
|
+
const priceString = this.safeString2(liquidation, 'liq_price', 'fill_price');
|
|
6501
|
+
const baseValueString = Precise["default"].stringMul(contractsString, contractSizeString);
|
|
6502
|
+
let quoteValueString = this.safeString(liquidation, 'pnl');
|
|
6503
|
+
if (quoteValueString === undefined) {
|
|
6504
|
+
quoteValueString = Precise["default"].stringMul(baseValueString, priceString);
|
|
6505
|
+
}
|
|
6506
|
+
return {
|
|
6507
|
+
'info': liquidation,
|
|
6508
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
6509
|
+
'contracts': this.parseNumber(contractsString),
|
|
6510
|
+
'contractSize': this.parseNumber(contractSizeString),
|
|
6511
|
+
'price': this.parseNumber(priceString),
|
|
6512
|
+
'baseValue': this.parseNumber(baseValueString),
|
|
6513
|
+
'quoteValue': this.parseNumber(Precise["default"].stringAbs(quoteValueString)),
|
|
6514
|
+
'timestamp': timestamp,
|
|
6515
|
+
'datetime': this.iso8601(timestamp),
|
|
6516
|
+
};
|
|
6517
|
+
}
|
|
6329
6518
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
6330
6519
|
if (response === undefined) {
|
|
6331
6520
|
return undefined;
|
package/dist/cjs/src/huobi.js
CHANGED
|
@@ -72,9 +72,11 @@ class huobi extends huobi$1 {
|
|
|
72
72
|
'fetchLedgerEntry': undefined,
|
|
73
73
|
'fetchLeverage': false,
|
|
74
74
|
'fetchLeverageTiers': true,
|
|
75
|
+
'fetchLiquidations': true,
|
|
75
76
|
'fetchMarketLeverageTiers': true,
|
|
76
77
|
'fetchMarkets': true,
|
|
77
78
|
'fetchMarkOHLCV': true,
|
|
79
|
+
'fetchMyLiquidations': false,
|
|
78
80
|
'fetchMyTrades': true,
|
|
79
81
|
'fetchOHLCV': true,
|
|
80
82
|
'fetchOpenInterest': true,
|
|
@@ -8227,6 +8229,106 @@ class huobi extends huobi$1 {
|
|
|
8227
8229
|
'datetime': this.iso8601(timestamp),
|
|
8228
8230
|
};
|
|
8229
8231
|
}
|
|
8232
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
8233
|
+
/**
|
|
8234
|
+
* @method
|
|
8235
|
+
* @name huobi#fetchLiquidations
|
|
8236
|
+
* @description retrieves the public liquidations of a trading pair
|
|
8237
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-liquidation-orders-new
|
|
8238
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-liquidation-orders-new
|
|
8239
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#query-liquidation-order-information-new
|
|
8240
|
+
* @param {string} symbol unified CCXT market symbol
|
|
8241
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
8242
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
8243
|
+
* @param {object} [params] exchange specific parameters for the huobi api endpoint
|
|
8244
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
8245
|
+
* @param {int} [params.tradeType] default 0, linear swap 0: all liquidated orders, 5: liquidated longs; 6: liquidated shorts, inverse swap and future 0: filled liquidated orders, 5: liquidated close orders, 6: liquidated open orders
|
|
8246
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
8247
|
+
*/
|
|
8248
|
+
await this.loadMarkets();
|
|
8249
|
+
const market = this.market(symbol);
|
|
8250
|
+
const tradeType = this.safeInteger(params, 'trade_type', 0);
|
|
8251
|
+
let request = {
|
|
8252
|
+
'trade_type': tradeType,
|
|
8253
|
+
};
|
|
8254
|
+
if (since !== undefined) {
|
|
8255
|
+
request['start_time'] = since;
|
|
8256
|
+
}
|
|
8257
|
+
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
8258
|
+
let response = undefined;
|
|
8259
|
+
if (market['swap']) {
|
|
8260
|
+
request['contract'] = market['id'];
|
|
8261
|
+
if (market['linear']) {
|
|
8262
|
+
response = await this.contractPublicGetLinearSwapApiV3SwapLiquidationOrders(this.extend(request, params));
|
|
8263
|
+
}
|
|
8264
|
+
else {
|
|
8265
|
+
response = await this.contractPublicGetSwapApiV3SwapLiquidationOrders(this.extend(request, params));
|
|
8266
|
+
}
|
|
8267
|
+
}
|
|
8268
|
+
else if (market['future']) {
|
|
8269
|
+
request['symbol'] = market['id'];
|
|
8270
|
+
response = await this.contractPublicGetApiV3ContractLiquidationOrders(this.extend(request, params));
|
|
8271
|
+
}
|
|
8272
|
+
else {
|
|
8273
|
+
throw new errors.NotSupported(this.id + ' fetchLiquidations() does not support ' + market['type'] + ' orders');
|
|
8274
|
+
}
|
|
8275
|
+
//
|
|
8276
|
+
// {
|
|
8277
|
+
// "code": 200,
|
|
8278
|
+
// "msg": "",
|
|
8279
|
+
// "data": [
|
|
8280
|
+
// {
|
|
8281
|
+
// "query_id": 452057,
|
|
8282
|
+
// "contract_code": "BTC-USDT-211210",
|
|
8283
|
+
// "symbol": "USDT",
|
|
8284
|
+
// "direction": "sell",
|
|
8285
|
+
// "offset": "close",
|
|
8286
|
+
// "volume": 479.000000000000000000,
|
|
8287
|
+
// "price": 51441.700000000000000000,
|
|
8288
|
+
// "created_at": 1638593647864,
|
|
8289
|
+
// "amount": 0.479000000000000000,
|
|
8290
|
+
// "trade_turnover": 24640.574300000000000000,
|
|
8291
|
+
// "business_type": "futures",
|
|
8292
|
+
// "pair": "BTC-USDT"
|
|
8293
|
+
// }
|
|
8294
|
+
// ],
|
|
8295
|
+
// "ts": 1604312615051
|
|
8296
|
+
// }
|
|
8297
|
+
//
|
|
8298
|
+
const data = this.safeValue(response, 'data', []);
|
|
8299
|
+
return this.parseLiquidations(data, market, since, limit);
|
|
8300
|
+
}
|
|
8301
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
8302
|
+
//
|
|
8303
|
+
// {
|
|
8304
|
+
// "query_id": 452057,
|
|
8305
|
+
// "contract_code": "BTC-USDT-211210",
|
|
8306
|
+
// "symbol": "USDT",
|
|
8307
|
+
// "direction": "sell",
|
|
8308
|
+
// "offset": "close",
|
|
8309
|
+
// "volume": 479.000000000000000000,
|
|
8310
|
+
// "price": 51441.700000000000000000,
|
|
8311
|
+
// "created_at": 1638593647864,
|
|
8312
|
+
// "amount": 0.479000000000000000,
|
|
8313
|
+
// "trade_turnover": 24640.574300000000000000,
|
|
8314
|
+
// "business_type": "futures",
|
|
8315
|
+
// "pair": "BTC-USDT"
|
|
8316
|
+
// }
|
|
8317
|
+
//
|
|
8318
|
+
const marketId = this.safeString(liquidation, 'contract_code');
|
|
8319
|
+
const timestamp = this.safeInteger(liquidation, 'created_at');
|
|
8320
|
+
return {
|
|
8321
|
+
'info': liquidation,
|
|
8322
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
8323
|
+
'contracts': this.safeNumber(liquidation, 'volume'),
|
|
8324
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
8325
|
+
'price': this.safeNumber(liquidation, 'price'),
|
|
8326
|
+
'baseValue': this.safeNumber(liquidation, 'amount'),
|
|
8327
|
+
'quoteValue': this.safeNumber(liquidation, 'trade_turnover'),
|
|
8328
|
+
'timestamp': timestamp,
|
|
8329
|
+
'datetime': this.iso8601(timestamp),
|
|
8330
|
+
};
|
|
8331
|
+
}
|
|
8230
8332
|
}
|
|
8231
8333
|
|
|
8232
8334
|
module.exports = huobi;
|
package/dist/cjs/src/kucoin.js
CHANGED
|
@@ -1033,7 +1033,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1033
1033
|
//
|
|
1034
1034
|
const symbol = this.safeString(position, 'symbol');
|
|
1035
1035
|
market = this.safeMarket(symbol, market);
|
|
1036
|
-
const timestamp = this.
|
|
1036
|
+
const timestamp = this.safeInteger(position, 'currentTimestamp');
|
|
1037
1037
|
const size = this.safeString(position, 'currentQty');
|
|
1038
1038
|
let side = undefined;
|
|
1039
1039
|
if (Precise["default"].stringGt(size, '0')) {
|