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/src/bitget.js
CHANGED
|
@@ -1474,6 +1474,7 @@ class bitget extends bitget$1 {
|
|
|
1474
1474
|
'max': undefined,
|
|
1475
1475
|
},
|
|
1476
1476
|
},
|
|
1477
|
+
'created': undefined,
|
|
1477
1478
|
};
|
|
1478
1479
|
}
|
|
1479
1480
|
return result;
|
|
@@ -1573,7 +1574,7 @@ class bitget extends bitget$1 {
|
|
|
1573
1574
|
}
|
|
1574
1575
|
const currency = this.currency(code);
|
|
1575
1576
|
if (since === undefined) {
|
|
1576
|
-
since = this.milliseconds() -
|
|
1577
|
+
since = this.milliseconds() - 7776000000; // 90 days
|
|
1577
1578
|
}
|
|
1578
1579
|
let request = {
|
|
1579
1580
|
'coin': currency['code'],
|
|
@@ -1729,7 +1730,7 @@ class bitget extends bitget$1 {
|
|
|
1729
1730
|
}
|
|
1730
1731
|
const currency = this.currency(code);
|
|
1731
1732
|
if (since === undefined) {
|
|
1732
|
-
since = this.milliseconds() -
|
|
1733
|
+
since = this.milliseconds() - 7776000000; // 90 days
|
|
1733
1734
|
}
|
|
1734
1735
|
let request = {
|
|
1735
1736
|
'coin': currency['code'],
|
|
@@ -3882,8 +3883,16 @@ class bitget extends bitget$1 {
|
|
|
3882
3883
|
//
|
|
3883
3884
|
const data = this.safeValue(response, 'data');
|
|
3884
3885
|
if (data !== undefined) {
|
|
3885
|
-
|
|
3886
|
-
|
|
3886
|
+
if ('orderList' in data) {
|
|
3887
|
+
const orderList = this.safeValue(data, 'orderList');
|
|
3888
|
+
if (!orderList) {
|
|
3889
|
+
return [];
|
|
3890
|
+
}
|
|
3891
|
+
return this.addPaginationCursorToResult(data, orderList);
|
|
3892
|
+
}
|
|
3893
|
+
else {
|
|
3894
|
+
return this.addPaginationCursorToResult(response, data);
|
|
3895
|
+
}
|
|
3887
3896
|
}
|
|
3888
3897
|
const parsedData = JSON.parse(response);
|
|
3889
3898
|
return this.safeValue(parsedData, 'data', []);
|
|
@@ -4042,10 +4051,17 @@ class bitget extends bitget$1 {
|
|
|
4042
4051
|
response = await this.privateSpotPostTradeFills(this.extend(request, params));
|
|
4043
4052
|
}
|
|
4044
4053
|
else {
|
|
4054
|
+
const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
|
|
4045
4055
|
if (since !== undefined) {
|
|
4046
4056
|
request['startTime'] = since;
|
|
4047
4057
|
}
|
|
4058
|
+
else if (orderId === undefined) {
|
|
4059
|
+
request['startTime'] = 0;
|
|
4060
|
+
}
|
|
4048
4061
|
[request, params] = this.handleUntilOption('endTime', params, request);
|
|
4062
|
+
if (!('endTime' in request) && (orderId === undefined)) {
|
|
4063
|
+
request['endTime'] = this.milliseconds();
|
|
4064
|
+
}
|
|
4049
4065
|
response = await this.privateMixGetOrderFills(this.extend(request, params));
|
|
4050
4066
|
}
|
|
4051
4067
|
//
|
package/dist/cjs/src/bithumb.js
CHANGED
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -60,8 +60,10 @@ class bitmart extends bitmart$1 {
|
|
|
60
60
|
'fetchFundingRate': true,
|
|
61
61
|
'fetchFundingRateHistory': false,
|
|
62
62
|
'fetchFundingRates': false,
|
|
63
|
+
'fetchLiquidations': false,
|
|
63
64
|
'fetchMarginMode': false,
|
|
64
65
|
'fetchMarkets': true,
|
|
66
|
+
'fetchMyLiquidations': true,
|
|
65
67
|
'fetchMyTrades': true,
|
|
66
68
|
'fetchOHLCV': true,
|
|
67
69
|
'fetchOpenInterest': true,
|
|
@@ -3934,6 +3936,107 @@ class bitmart extends bitmart$1 {
|
|
|
3934
3936
|
'takeProfitPrice': undefined,
|
|
3935
3937
|
});
|
|
3936
3938
|
}
|
|
3939
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3940
|
+
/**
|
|
3941
|
+
* @method
|
|
3942
|
+
* @name bitmart#fetchMyLiquidations
|
|
3943
|
+
* @description retrieves the users liquidated positions
|
|
3944
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-order-history-keyed
|
|
3945
|
+
* @param {string} symbol unified CCXT market symbol
|
|
3946
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
3947
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
3948
|
+
* @param {object} [params] exchange specific parameters for the bitmart api endpoint
|
|
3949
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
3950
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
3951
|
+
*/
|
|
3952
|
+
this.checkRequiredSymbol('fetchMyLiquidations', symbol);
|
|
3953
|
+
await this.loadMarkets();
|
|
3954
|
+
const market = this.market(symbol);
|
|
3955
|
+
if (!market['swap']) {
|
|
3956
|
+
throw new errors.NotSupported(this.id + ' fetchMyLiquidations() supports swap markets only');
|
|
3957
|
+
}
|
|
3958
|
+
let request = {
|
|
3959
|
+
'symbol': market['id'],
|
|
3960
|
+
};
|
|
3961
|
+
if (since !== undefined) {
|
|
3962
|
+
request['start_time'] = since;
|
|
3963
|
+
}
|
|
3964
|
+
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
3965
|
+
const response = await this.privateGetContractPrivateOrderHistory(this.extend(request, params));
|
|
3966
|
+
//
|
|
3967
|
+
// {
|
|
3968
|
+
// "code": 1000,
|
|
3969
|
+
// "message": "Ok",
|
|
3970
|
+
// "data": [
|
|
3971
|
+
// {
|
|
3972
|
+
// "order_id": "231007865458273",
|
|
3973
|
+
// "client_order_id": "",
|
|
3974
|
+
// "price": "27407.9",
|
|
3975
|
+
// "size": "1",
|
|
3976
|
+
// "symbol": "BTCUSDT",
|
|
3977
|
+
// "state": 4,
|
|
3978
|
+
// "side": 3,
|
|
3979
|
+
// "type": "liquidate",
|
|
3980
|
+
// "leverage": "10",
|
|
3981
|
+
// "open_type": "isolated",
|
|
3982
|
+
// "deal_avg_price": "27422.6",
|
|
3983
|
+
// "deal_size": "1",
|
|
3984
|
+
// "create_time": 1696405864011,
|
|
3985
|
+
// "update_time": 1696405864045
|
|
3986
|
+
// },
|
|
3987
|
+
// ],
|
|
3988
|
+
// "trace": "4cad855074664097ac6ba4257c47305d.71.16965658195443021"
|
|
3989
|
+
// }
|
|
3990
|
+
//
|
|
3991
|
+
const data = this.safeValue(response, 'data', []);
|
|
3992
|
+
const result = [];
|
|
3993
|
+
for (let i = 0; i < data.length; i++) {
|
|
3994
|
+
const entry = data[i];
|
|
3995
|
+
const checkLiquidation = this.safeString(entry, 'type');
|
|
3996
|
+
if (checkLiquidation === 'liquidate') {
|
|
3997
|
+
result.push(entry);
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
return this.parseLiquidations(result, market, since, limit);
|
|
4001
|
+
}
|
|
4002
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
4003
|
+
//
|
|
4004
|
+
// {
|
|
4005
|
+
// "order_id": "231007865458273",
|
|
4006
|
+
// "client_order_id": "",
|
|
4007
|
+
// "price": "27407.9",
|
|
4008
|
+
// "size": "1",
|
|
4009
|
+
// "symbol": "BTCUSDT",
|
|
4010
|
+
// "state": 4,
|
|
4011
|
+
// "side": 3,
|
|
4012
|
+
// "type": "market",
|
|
4013
|
+
// "leverage": "10",
|
|
4014
|
+
// "open_type": "isolated",
|
|
4015
|
+
// "deal_avg_price": "27422.6",
|
|
4016
|
+
// "deal_size": "1",
|
|
4017
|
+
// "create_time": 1696405864011,
|
|
4018
|
+
// "update_time": 1696405864045
|
|
4019
|
+
// }
|
|
4020
|
+
//
|
|
4021
|
+
const marketId = this.safeString(liquidation, 'symbol');
|
|
4022
|
+
const timestamp = this.safeInteger(liquidation, 'update_time');
|
|
4023
|
+
const contractsString = this.safeString(liquidation, 'deal_size');
|
|
4024
|
+
const contractSizeString = this.safeString(market, 'contractSize');
|
|
4025
|
+
const priceString = this.safeString(liquidation, 'deal_avg_price');
|
|
4026
|
+
const baseValueString = Precise["default"].stringMul(contractsString, contractSizeString);
|
|
4027
|
+
const quoteValueString = Precise["default"].stringMul(baseValueString, priceString);
|
|
4028
|
+
return {
|
|
4029
|
+
'info': liquidation,
|
|
4030
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
4031
|
+
'contracts': this.parseNumber(contractsString),
|
|
4032
|
+
'contractSize': this.parseNumber(contractSizeString),
|
|
4033
|
+
'price': this.parseNumber(priceString),
|
|
4034
|
+
'baseValue': this.parseNumber(baseValueString),
|
|
4035
|
+
'quoteValue': this.parseNumber(quoteValueString),
|
|
4036
|
+
'timestamp': timestamp,
|
|
4037
|
+
'datetime': this.iso8601(timestamp),
|
|
4038
|
+
};
|
|
4039
|
+
}
|
|
3937
4040
|
nonce() {
|
|
3938
4041
|
return this.milliseconds();
|
|
3939
4042
|
}
|
package/dist/cjs/src/bitmex.js
CHANGED
|
@@ -58,9 +58,11 @@ class bitmex extends bitmex$1 {
|
|
|
58
58
|
'fetchLedger': true,
|
|
59
59
|
'fetchLeverage': false,
|
|
60
60
|
'fetchLeverageTiers': false,
|
|
61
|
+
'fetchLiquidations': true,
|
|
61
62
|
'fetchMarketLeverageTiers': false,
|
|
62
63
|
'fetchMarkets': true,
|
|
63
64
|
'fetchMarkOHLCV': false,
|
|
65
|
+
'fetchMyLiquidations': false,
|
|
64
66
|
'fetchMyTrades': true,
|
|
65
67
|
'fetchOHLCV': true,
|
|
66
68
|
'fetchOpenOrders': true,
|
|
@@ -2648,6 +2650,74 @@ class bitmex extends bitmex$1 {
|
|
|
2648
2650
|
}
|
|
2649
2651
|
return cost;
|
|
2650
2652
|
}
|
|
2653
|
+
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
2654
|
+
/**
|
|
2655
|
+
* @method
|
|
2656
|
+
* @name bitmex#fetchLiquidations
|
|
2657
|
+
* @description retrieves the public liquidations of a trading pair
|
|
2658
|
+
* @see https://www.bitmex.com/api/explorer/#!/Liquidation/Liquidation_get
|
|
2659
|
+
* @param {string} symbol unified CCXT market symbol
|
|
2660
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
2661
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
2662
|
+
* @param {object} [params] exchange specific parameters for the bitmex api endpoint
|
|
2663
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
2664
|
+
* @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)
|
|
2665
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
2666
|
+
*/
|
|
2667
|
+
await this.loadMarkets();
|
|
2668
|
+
let paginate = false;
|
|
2669
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
|
|
2670
|
+
if (paginate) {
|
|
2671
|
+
return await this.fetchPaginatedCallDynamic('fetchLiquidations', symbol, since, limit, params);
|
|
2672
|
+
}
|
|
2673
|
+
const market = this.market(symbol);
|
|
2674
|
+
let request = {
|
|
2675
|
+
'symbol': market['id'],
|
|
2676
|
+
};
|
|
2677
|
+
if (since !== undefined) {
|
|
2678
|
+
request['startTime'] = since;
|
|
2679
|
+
}
|
|
2680
|
+
if (limit !== undefined) {
|
|
2681
|
+
request['count'] = limit;
|
|
2682
|
+
}
|
|
2683
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
2684
|
+
const response = await this.publicGetLiquidation(this.extend(request, params));
|
|
2685
|
+
//
|
|
2686
|
+
// [
|
|
2687
|
+
// {
|
|
2688
|
+
// "orderID": "string",
|
|
2689
|
+
// "symbol": "string",
|
|
2690
|
+
// "side": "string",
|
|
2691
|
+
// "price": 0,
|
|
2692
|
+
// "leavesQty": 0
|
|
2693
|
+
// }
|
|
2694
|
+
// ]
|
|
2695
|
+
//
|
|
2696
|
+
return this.parseLiquidations(response, market, since, limit);
|
|
2697
|
+
}
|
|
2698
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
2699
|
+
//
|
|
2700
|
+
// {
|
|
2701
|
+
// "orderID": "string",
|
|
2702
|
+
// "symbol": "string",
|
|
2703
|
+
// "side": "string",
|
|
2704
|
+
// "price": 0,
|
|
2705
|
+
// "leavesQty": 0
|
|
2706
|
+
// }
|
|
2707
|
+
//
|
|
2708
|
+
const marketId = this.safeString(liquidation, 'symbol');
|
|
2709
|
+
return {
|
|
2710
|
+
'info': liquidation,
|
|
2711
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
2712
|
+
'contracts': undefined,
|
|
2713
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
2714
|
+
'price': this.safeNumber(liquidation, 'price'),
|
|
2715
|
+
'baseValue': undefined,
|
|
2716
|
+
'quoteValue': undefined,
|
|
2717
|
+
'timestamp': undefined,
|
|
2718
|
+
'datetime': undefined,
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2651
2721
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2652
2722
|
if (response === undefined) {
|
|
2653
2723
|
return undefined;
|
package/dist/cjs/src/bitopro.js
CHANGED
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
|
@@ -1750,6 +1750,7 @@ class bybit extends bybit$1 {
|
|
|
1750
1750
|
'max': this.safeNumber(lotSizeFilter, 'maxOrderAmt'),
|
|
1751
1751
|
},
|
|
1752
1752
|
},
|
|
1753
|
+
'created': undefined,
|
|
1753
1754
|
'info': market,
|
|
1754
1755
|
});
|
|
1755
1756
|
}
|
|
@@ -1924,6 +1925,7 @@ class bybit extends bybit$1 {
|
|
|
1924
1925
|
'max': undefined,
|
|
1925
1926
|
},
|
|
1926
1927
|
},
|
|
1928
|
+
'created': this.safeInteger(market, 'launchTime'),
|
|
1927
1929
|
'info': market,
|
|
1928
1930
|
});
|
|
1929
1931
|
}
|
|
@@ -2056,6 +2058,7 @@ class bybit extends bybit$1 {
|
|
|
2056
2058
|
'max': undefined,
|
|
2057
2059
|
},
|
|
2058
2060
|
},
|
|
2061
|
+
'created': this.safeInteger(market, 'launchTime'),
|
|
2059
2062
|
'info': market,
|
|
2060
2063
|
});
|
|
2061
2064
|
}
|
|
@@ -2771,7 +2774,7 @@ class bybit extends bybit$1 {
|
|
|
2771
2774
|
const feeToken = this.safeString(trade, 'feeTokenId');
|
|
2772
2775
|
const feeCurrency = this.safeCurrencyCode(feeToken);
|
|
2773
2776
|
fee = {
|
|
2774
|
-
'cost': feeCost,
|
|
2777
|
+
'cost': Precise["default"].stringAbs(feeCost),
|
|
2775
2778
|
'currency': feeCurrency,
|
|
2776
2779
|
};
|
|
2777
2780
|
}
|
|
@@ -2937,7 +2940,7 @@ class bybit extends bybit$1 {
|
|
|
2937
2940
|
feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
|
|
2938
2941
|
}
|
|
2939
2942
|
fee = {
|
|
2940
|
-
'cost': feeCostString,
|
|
2943
|
+
'cost': Precise["default"].stringAbs(feeCostString),
|
|
2941
2944
|
'currency': feeCurrencyCode,
|
|
2942
2945
|
};
|
|
2943
2946
|
}
|
|
@@ -3510,10 +3513,14 @@ class bybit extends bybit$1 {
|
|
|
3510
3513
|
// }
|
|
3511
3514
|
//
|
|
3512
3515
|
const marketId = this.safeString(order, 'symbol');
|
|
3513
|
-
|
|
3516
|
+
const isContract = ('tpslMode' in order);
|
|
3517
|
+
let marketType = undefined;
|
|
3514
3518
|
if (market !== undefined) {
|
|
3515
3519
|
marketType = market['type'];
|
|
3516
3520
|
}
|
|
3521
|
+
else {
|
|
3522
|
+
marketType = isContract ? 'contract' : 'spot';
|
|
3523
|
+
}
|
|
3517
3524
|
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
3518
3525
|
const symbol = market['symbol'];
|
|
3519
3526
|
const timestamp = this.safeInteger2(order, 'createdTime', 'createdAt');
|
|
@@ -5533,7 +5540,7 @@ class bybit extends bybit$1 {
|
|
|
5533
5540
|
'referenceAccount': undefined,
|
|
5534
5541
|
'referenceId': referenceId,
|
|
5535
5542
|
'status': undefined,
|
|
5536
|
-
'amount': this.parseNumber(amount),
|
|
5543
|
+
'amount': this.parseNumber(Precise["default"].stringAbs(amount)),
|
|
5537
5544
|
'before': this.parseNumber(before),
|
|
5538
5545
|
'after': this.parseNumber(after),
|
|
5539
5546
|
'fee': this.parseNumber(this.safeString(item, 'fee')),
|
|
@@ -5690,10 +5697,9 @@ class bybit extends bybit$1 {
|
|
|
5690
5697
|
const timestamp = this.safeInteger(response, 'time');
|
|
5691
5698
|
const first = this.safeValue(positions, 0, {});
|
|
5692
5699
|
const position = this.parsePosition(first, market);
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
});
|
|
5700
|
+
position['timestamp'] = timestamp;
|
|
5701
|
+
position['datetime'] = this.iso8601(timestamp);
|
|
5702
|
+
return position;
|
|
5697
5703
|
}
|
|
5698
5704
|
async fetchUsdcPositions(symbols = undefined, params = {}) {
|
|
5699
5705
|
await this.loadMarkets();
|
|
@@ -5768,7 +5774,7 @@ class bybit extends bybit$1 {
|
|
|
5768
5774
|
}
|
|
5769
5775
|
results.push(this.parsePosition(rawPosition, market));
|
|
5770
5776
|
}
|
|
5771
|
-
return this.
|
|
5777
|
+
return this.filterByArrayPositions(results, 'symbol', symbols, false);
|
|
5772
5778
|
}
|
|
5773
5779
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
5774
5780
|
/**
|
|
@@ -2953,7 +2953,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
2953
2953
|
const marketInner = this.safeMarket(marketId, undefined, undefined, 'contract');
|
|
2954
2954
|
result.push(this.parsePosition(entry, marketInner));
|
|
2955
2955
|
}
|
|
2956
|
-
return this.
|
|
2956
|
+
return this.filterByArrayPositions(result, 'symbol', undefined, false);
|
|
2957
2957
|
}
|
|
2958
2958
|
parsePosition(position, market = undefined) {
|
|
2959
2959
|
//
|
package/dist/cjs/src/delta.js
CHANGED
|
@@ -1672,7 +1672,7 @@ class delta extends delta$1 {
|
|
|
1672
1672
|
side = 'sell';
|
|
1673
1673
|
}
|
|
1674
1674
|
}
|
|
1675
|
-
return {
|
|
1675
|
+
return this.safePosition({
|
|
1676
1676
|
'info': position,
|
|
1677
1677
|
'id': undefined,
|
|
1678
1678
|
'symbol': symbol,
|
|
@@ -1698,7 +1698,7 @@ class delta extends delta$1 {
|
|
|
1698
1698
|
'marginRatio': undefined,
|
|
1699
1699
|
'stopLossPrice': undefined,
|
|
1700
1700
|
'takeProfitPrice': undefined,
|
|
1701
|
-
};
|
|
1701
|
+
});
|
|
1702
1702
|
}
|
|
1703
1703
|
parseOrderStatus(status) {
|
|
1704
1704
|
const statuses = {
|
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
|
}
|