ccxt 4.2.22 → 4.2.23
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 +235 -52
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bitfinex2.js +89 -0
- package/dist/cjs/src/bitget.js +9 -9
- package/dist/cjs/src/coinbasepro.js +1 -1
- package/dist/cjs/src/coinex.js +23 -2
- package/dist/cjs/src/okx.js +81 -31
- package/dist/cjs/src/phemex.js +12 -3
- package/dist/cjs/src/poloniex.js +1 -1
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/hitbtc.js +6 -0
- package/dist/cjs/src/pro/okx.js +11 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/bitfinex2.d.ts +2 -0
- package/js/src/bitfinex2.js +89 -0
- package/js/src/bitget.js +9 -9
- package/js/src/coinbasepro.js +1 -1
- package/js/src/coinex.js +23 -2
- package/js/src/okx.js +81 -31
- package/js/src/phemex.js +12 -3
- package/js/src/poloniex.js +1 -1
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/hitbtc.js +6 -0
- package/js/src/pro/okx.js +11 -3
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -174,7 +174,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
174
174
|
|
|
175
175
|
//-----------------------------------------------------------------------------
|
|
176
176
|
// this is updated by vss.js when building
|
|
177
|
-
const version = '4.2.
|
|
177
|
+
const version = '4.2.23';
|
|
178
178
|
Exchange["default"].ccxtVersion = version;
|
|
179
179
|
const exchanges = {
|
|
180
180
|
'ace': ace,
|
|
@@ -54,6 +54,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
54
54
|
'fetchMarkOHLCV': false,
|
|
55
55
|
'fetchMyTrades': true,
|
|
56
56
|
'fetchOHLCV': true,
|
|
57
|
+
'fetchOpenInterest': true,
|
|
57
58
|
'fetchOpenOrder': true,
|
|
58
59
|
'fetchOpenOrders': true,
|
|
59
60
|
'fetchOrder': true,
|
|
@@ -2985,6 +2986,94 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2985
2986
|
'previousFundingDatetime': undefined,
|
|
2986
2987
|
};
|
|
2987
2988
|
}
|
|
2989
|
+
async fetchOpenInterest(symbol, params = {}) {
|
|
2990
|
+
/**
|
|
2991
|
+
* @method
|
|
2992
|
+
* @name bitfinex2#fetchOpenInterest
|
|
2993
|
+
* @description retrieves the open interest of a contract trading pair
|
|
2994
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2995
|
+
* @param {string} symbol unified CCXT market symbol
|
|
2996
|
+
* @param {object} [params] exchange specific parameters
|
|
2997
|
+
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
2998
|
+
*/
|
|
2999
|
+
await this.loadMarkets();
|
|
3000
|
+
const market = this.market(symbol);
|
|
3001
|
+
const request = {
|
|
3002
|
+
'keys': market['id'],
|
|
3003
|
+
};
|
|
3004
|
+
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3005
|
+
//
|
|
3006
|
+
// [
|
|
3007
|
+
// [
|
|
3008
|
+
// "tXRPF0:USTF0", // market id
|
|
3009
|
+
// 1706256986000, // millisecond timestamp
|
|
3010
|
+
// null,
|
|
3011
|
+
// 0.512705, // derivative mid price
|
|
3012
|
+
// 0.512395, // underlying spot mid price
|
|
3013
|
+
// null,
|
|
3014
|
+
// 37671483.04, // insurance fund balance
|
|
3015
|
+
// null,
|
|
3016
|
+
// 1706284800000, // timestamp of next funding
|
|
3017
|
+
// 0.00002353, // accrued funding for next period
|
|
3018
|
+
// 317, // next funding step
|
|
3019
|
+
// null,
|
|
3020
|
+
// 0, // current funding
|
|
3021
|
+
// null,
|
|
3022
|
+
// null,
|
|
3023
|
+
// 0.5123016, // mark price
|
|
3024
|
+
// null,
|
|
3025
|
+
// null,
|
|
3026
|
+
// 2233562.03115, // open interest in contracts
|
|
3027
|
+
// null,
|
|
3028
|
+
// null,
|
|
3029
|
+
// null,
|
|
3030
|
+
// 0.0005, // average spread without funding payment
|
|
3031
|
+
// 0.0025 // funding payment cap
|
|
3032
|
+
// ]
|
|
3033
|
+
// ]
|
|
3034
|
+
//
|
|
3035
|
+
return this.parseOpenInterest(response[0], market);
|
|
3036
|
+
}
|
|
3037
|
+
parseOpenInterest(interest, market = undefined) {
|
|
3038
|
+
//
|
|
3039
|
+
// [
|
|
3040
|
+
// "tXRPF0:USTF0", // market id
|
|
3041
|
+
// 1706256986000, // millisecond timestamp
|
|
3042
|
+
// null,
|
|
3043
|
+
// 0.512705, // derivative mid price
|
|
3044
|
+
// 0.512395, // underlying spot mid price
|
|
3045
|
+
// null,
|
|
3046
|
+
// 37671483.04, // insurance fund balance
|
|
3047
|
+
// null,
|
|
3048
|
+
// 1706284800000, // timestamp of next funding
|
|
3049
|
+
// 0.00002353, // accrued funding for next period
|
|
3050
|
+
// 317, // next funding step
|
|
3051
|
+
// null,
|
|
3052
|
+
// 0, // current funding
|
|
3053
|
+
// null,
|
|
3054
|
+
// null,
|
|
3055
|
+
// 0.5123016, // mark price
|
|
3056
|
+
// null,
|
|
3057
|
+
// null,
|
|
3058
|
+
// 2233562.03115, // open interest in contracts
|
|
3059
|
+
// null,
|
|
3060
|
+
// null,
|
|
3061
|
+
// null,
|
|
3062
|
+
// 0.0005, // average spread without funding payment
|
|
3063
|
+
// 0.0025 // funding payment cap
|
|
3064
|
+
// ]
|
|
3065
|
+
//
|
|
3066
|
+
const timestamp = this.safeInteger(interest, 1);
|
|
3067
|
+
const marketId = this.safeString(interest, 0);
|
|
3068
|
+
return this.safeOpenInterest({
|
|
3069
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3070
|
+
'openInterestAmount': this.safeNumber(interest, 18),
|
|
3071
|
+
'openInterestValue': undefined,
|
|
3072
|
+
'timestamp': timestamp,
|
|
3073
|
+
'datetime': this.iso8601(timestamp),
|
|
3074
|
+
'info': interest,
|
|
3075
|
+
}, market);
|
|
3076
|
+
}
|
|
2988
3077
|
}
|
|
2989
3078
|
|
|
2990
3079
|
module.exports = bitfinex2;
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -44,16 +44,16 @@ class bitget extends bitget$1 {
|
|
|
44
44
|
'createOrder': true,
|
|
45
45
|
'createOrders': true,
|
|
46
46
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
47
|
-
'createReduceOnlyOrder': false,
|
|
48
|
-
'createStopLossOrder': true,
|
|
49
|
-
'createTakeProfitOrder': true,
|
|
50
47
|
'createPostOnlyOrder': true,
|
|
51
|
-
'
|
|
48
|
+
'createReduceOnlyOrder': false,
|
|
52
49
|
'createStopLimitOrder': true,
|
|
50
|
+
'createStopLossOrder': true,
|
|
53
51
|
'createStopMarketOrder': true,
|
|
52
|
+
'createStopOrder': true,
|
|
53
|
+
'createTakeProfitOrder': true,
|
|
54
|
+
'createTrailingAmountOrder': false,
|
|
54
55
|
'createTrailingPercentOrder': true,
|
|
55
56
|
'createTriggerOrder': true,
|
|
56
|
-
'signIn': false,
|
|
57
57
|
'editOrder': true,
|
|
58
58
|
'fetchAccounts': false,
|
|
59
59
|
'fetchBalance': true,
|
|
@@ -69,12 +69,10 @@ class bitget extends bitget$1 {
|
|
|
69
69
|
'fetchDepositAddress': true,
|
|
70
70
|
'fetchDepositAddresses': false,
|
|
71
71
|
'fetchDeposits': true,
|
|
72
|
+
'fetchDepositsWithdrawals': false,
|
|
72
73
|
'fetchDepositWithdrawFee': 'emulated',
|
|
73
74
|
'fetchDepositWithdrawFees': true,
|
|
74
|
-
'fetchDepositsWithdrawals': false,
|
|
75
75
|
'fetchFundingHistory': true,
|
|
76
|
-
'fetchWithdrawAddresses': false,
|
|
77
|
-
'fetchTransactions': false,
|
|
78
76
|
'fetchFundingRate': true,
|
|
79
77
|
'fetchFundingRateHistory': true,
|
|
80
78
|
'fetchFundingRates': false,
|
|
@@ -98,7 +96,6 @@ class bitget extends bitget$1 {
|
|
|
98
96
|
'fetchOrder': true,
|
|
99
97
|
'fetchOrderBook': true,
|
|
100
98
|
'fetchOrders': false,
|
|
101
|
-
'createTrailingAmountOrder': false,
|
|
102
99
|
'fetchOrderTrades': false,
|
|
103
100
|
'fetchPosition': true,
|
|
104
101
|
'fetchPositionMode': false,
|
|
@@ -111,8 +108,10 @@ class bitget extends bitget$1 {
|
|
|
111
108
|
'fetchTrades': true,
|
|
112
109
|
'fetchTradingFee': true,
|
|
113
110
|
'fetchTradingFees': true,
|
|
111
|
+
'fetchTransactions': false,
|
|
114
112
|
'fetchTransfer': false,
|
|
115
113
|
'fetchTransfers': true,
|
|
114
|
+
'fetchWithdrawAddresses': false,
|
|
116
115
|
'fetchWithdrawal': false,
|
|
117
116
|
'fetchWithdrawals': true,
|
|
118
117
|
'reduceMargin': true,
|
|
@@ -121,6 +120,7 @@ class bitget extends bitget$1 {
|
|
|
121
120
|
'setLeverage': true,
|
|
122
121
|
'setMarginMode': true,
|
|
123
122
|
'setPositionMode': true,
|
|
123
|
+
'signIn': false,
|
|
124
124
|
'transfer': true,
|
|
125
125
|
'withdraw': true,
|
|
126
126
|
},
|
|
@@ -42,8 +42,8 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
42
42
|
'fetchDepositAddress': false,
|
|
43
43
|
'fetchDeposits': true,
|
|
44
44
|
'fetchDepositsWithdrawals': true,
|
|
45
|
-
'fetchLedger': true,
|
|
46
45
|
'fetchFundingRate': false,
|
|
46
|
+
'fetchLedger': true,
|
|
47
47
|
'fetchMarginMode': false,
|
|
48
48
|
'fetchMarkets': true,
|
|
49
49
|
'fetchMyTrades': true,
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -3514,11 +3514,17 @@ class coinex extends coinex$1 {
|
|
|
3514
3514
|
* @name coinex#fetchPositions
|
|
3515
3515
|
* @description fetch all open positions
|
|
3516
3516
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
|
|
3517
|
-
* @
|
|
3517
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
|
|
3518
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3518
3519
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3520
|
+
* @param {string} [params.method] the method to use 'perpetualPrivateGetPositionPending' or 'perpetualPrivateGetPositionFinished' default is 'perpetualPrivateGetPositionPending'
|
|
3521
|
+
* @param {int} [params.side] *history endpoint only* 0: All, 1: Sell, 2: Buy, default is 0
|
|
3519
3522
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3520
3523
|
*/
|
|
3521
3524
|
await this.loadMarkets();
|
|
3525
|
+
let defaultMethod = undefined;
|
|
3526
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'perpetualPrivateGetPositionPending');
|
|
3527
|
+
const isHistory = (defaultMethod === 'perpetualPrivateGetPositionFinished');
|
|
3522
3528
|
symbols = this.marketSymbols(symbols);
|
|
3523
3529
|
const request = {};
|
|
3524
3530
|
let market = undefined;
|
|
@@ -3537,7 +3543,22 @@ class coinex extends coinex$1 {
|
|
|
3537
3543
|
market = this.market(symbol);
|
|
3538
3544
|
request['market'] = market['id'];
|
|
3539
3545
|
}
|
|
3540
|
-
|
|
3546
|
+
else {
|
|
3547
|
+
if (isHistory) {
|
|
3548
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchPositions() requires a symbol argument for closed positions');
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
if (isHistory) {
|
|
3552
|
+
request['limit'] = 100;
|
|
3553
|
+
request['side'] = this.safeInteger(params, 'side', 0); // 0: All, 1: Sell, 2: Buy
|
|
3554
|
+
}
|
|
3555
|
+
let response = undefined;
|
|
3556
|
+
if (defaultMethod === 'perpetualPrivateGetPositionPending') {
|
|
3557
|
+
response = await this.perpetualPrivateGetPositionPending(this.extend(request, params));
|
|
3558
|
+
}
|
|
3559
|
+
else {
|
|
3560
|
+
response = await this.perpetualPrivateGetPositionFinished(this.extend(request, params));
|
|
3561
|
+
}
|
|
3541
3562
|
//
|
|
3542
3563
|
// {
|
|
3543
3564
|
// "code": 0,
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -2914,12 +2914,26 @@ class okx extends okx$1 {
|
|
|
2914
2914
|
const request = {
|
|
2915
2915
|
'instId': market['id'],
|
|
2916
2916
|
};
|
|
2917
|
+
let isAlgoOrder = undefined;
|
|
2918
|
+
if ((type === 'trigger') || (type === 'conditional') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
|
|
2919
|
+
isAlgoOrder = true;
|
|
2920
|
+
}
|
|
2917
2921
|
const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
|
|
2918
2922
|
if (clientOrderId !== undefined) {
|
|
2919
|
-
|
|
2923
|
+
if (isAlgoOrder) {
|
|
2924
|
+
request['algoClOrdId'] = clientOrderId;
|
|
2925
|
+
}
|
|
2926
|
+
else {
|
|
2927
|
+
request['clOrdId'] = clientOrderId;
|
|
2928
|
+
}
|
|
2920
2929
|
}
|
|
2921
2930
|
else {
|
|
2922
|
-
|
|
2931
|
+
if (isAlgoOrder) {
|
|
2932
|
+
request['algoId'] = id;
|
|
2933
|
+
}
|
|
2934
|
+
else {
|
|
2935
|
+
request['ordId'] = id;
|
|
2936
|
+
}
|
|
2923
2937
|
}
|
|
2924
2938
|
let stopLossTriggerPrice = this.safeValue2(params, 'stopLossPrice', 'newSlTriggerPx');
|
|
2925
2939
|
let stopLossPrice = this.safeValue(params, 'newSlOrdPx');
|
|
@@ -2931,37 +2945,62 @@ class okx extends okx$1 {
|
|
|
2931
2945
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
2932
2946
|
const stopLossDefined = (stopLoss !== undefined);
|
|
2933
2947
|
const takeProfitDefined = (takeProfit !== undefined);
|
|
2934
|
-
if (
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2948
|
+
if (isAlgoOrder) {
|
|
2949
|
+
if ((stopLossTriggerPrice === undefined) && (takeProfitTriggerPrice === undefined)) {
|
|
2950
|
+
throw new errors.BadRequest(this.id + ' editOrder() requires a stopLossPrice or takeProfitPrice parameter for editing an algo order');
|
|
2951
|
+
}
|
|
2952
|
+
if (stopLossTriggerPrice !== undefined) {
|
|
2953
|
+
if (stopLossPrice === undefined) {
|
|
2954
|
+
throw new errors.BadRequest(this.id + ' editOrder() requires a newSlOrdPx parameter for editing an algo order');
|
|
2955
|
+
}
|
|
2956
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2957
|
+
request['newSlOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2958
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2959
|
+
}
|
|
2960
|
+
if (takeProfitTriggerPrice !== undefined) {
|
|
2961
|
+
if (takeProfitPrice === undefined) {
|
|
2962
|
+
throw new errors.BadRequest(this.id + ' editOrder() requires a newTpOrdPx parameter for editing an algo order');
|
|
2963
|
+
}
|
|
2964
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2965
|
+
request['newTpOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2966
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
else {
|
|
2970
|
+
if (stopLossTriggerPrice !== undefined) {
|
|
2971
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2972
|
+
request['newSlOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2973
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2974
|
+
}
|
|
2975
|
+
if (takeProfitTriggerPrice !== undefined) {
|
|
2976
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2977
|
+
request['newTpOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2978
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2979
|
+
}
|
|
2980
|
+
if (stopLossDefined) {
|
|
2981
|
+
stopLossTriggerPrice = this.safeValue(stopLoss, 'triggerPrice');
|
|
2982
|
+
stopLossPrice = this.safeValue(stopLoss, 'price');
|
|
2983
|
+
const stopLossType = this.safeString(stopLoss, 'type');
|
|
2984
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2985
|
+
request['newSlOrdPx'] = (stopLossType === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2986
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2987
|
+
}
|
|
2988
|
+
if (takeProfitDefined) {
|
|
2989
|
+
takeProfitTriggerPrice = this.safeValue(takeProfit, 'triggerPrice');
|
|
2990
|
+
takeProfitPrice = this.safeValue(takeProfit, 'price');
|
|
2991
|
+
const takeProfitType = this.safeString(takeProfit, 'type');
|
|
2992
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2993
|
+
request['newTpOrdPx'] = (takeProfitType === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2994
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2995
|
+
}
|
|
2959
2996
|
}
|
|
2960
2997
|
if (amount !== undefined) {
|
|
2961
2998
|
request['newSz'] = this.amountToPrecision(symbol, amount);
|
|
2962
2999
|
}
|
|
2963
|
-
if (
|
|
2964
|
-
|
|
3000
|
+
if (!isAlgoOrder) {
|
|
3001
|
+
if (price !== undefined) {
|
|
3002
|
+
request['newPx'] = this.priceToPrecision(symbol, price);
|
|
3003
|
+
}
|
|
2965
3004
|
}
|
|
2966
3005
|
params = this.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit']);
|
|
2967
3006
|
return this.extend(request, params);
|
|
@@ -2971,7 +3010,8 @@ class okx extends okx$1 {
|
|
|
2971
3010
|
* @method
|
|
2972
3011
|
* @name okx#editOrder
|
|
2973
3012
|
* @description edit a trade order
|
|
2974
|
-
* @see https://www.okx.com/docs-v5/en/#
|
|
3013
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-amend-order
|
|
3014
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-amend-algo-order
|
|
2975
3015
|
* @param {string} id order id
|
|
2976
3016
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2977
3017
|
* @param {string} type 'market' or 'limit'
|
|
@@ -2999,7 +3039,17 @@ class okx extends okx$1 {
|
|
|
2999
3039
|
await this.loadMarkets();
|
|
3000
3040
|
const market = this.market(symbol);
|
|
3001
3041
|
const request = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
3002
|
-
|
|
3042
|
+
let isAlgoOrder = undefined;
|
|
3043
|
+
if ((type === 'trigger') || (type === 'conditional') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
|
|
3044
|
+
isAlgoOrder = true;
|
|
3045
|
+
}
|
|
3046
|
+
let response = undefined;
|
|
3047
|
+
if (isAlgoOrder) {
|
|
3048
|
+
response = await this.privatePostTradeAmendAlgos(this.extend(request, params));
|
|
3049
|
+
}
|
|
3050
|
+
else {
|
|
3051
|
+
response = await this.privatePostTradeAmendOrder(this.extend(request, params));
|
|
3052
|
+
}
|
|
3003
3053
|
//
|
|
3004
3054
|
// {
|
|
3005
3055
|
// "code": "0",
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -3545,8 +3545,10 @@ class phemex extends phemex$1 {
|
|
|
3545
3545
|
* @description fetch all open positions
|
|
3546
3546
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-trading-account-and-positions
|
|
3547
3547
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
|
|
3548
|
-
* @
|
|
3548
|
+
* @see https://phemex-docs.github.io/#query-account-positions-with-unrealized-pnl
|
|
3549
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3549
3550
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3551
|
+
* @param {string} [param.method] *USDT contracts only* 'privateGetGAccountsAccountPositions' or 'privateGetAccountsPositions' default is 'privateGetGAccountsAccountPositions'
|
|
3550
3552
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3551
3553
|
*/
|
|
3552
3554
|
await this.loadMarkets();
|
|
@@ -3581,7 +3583,14 @@ class phemex extends phemex$1 {
|
|
|
3581
3583
|
};
|
|
3582
3584
|
let response = undefined;
|
|
3583
3585
|
if (isUSDTSettled) {
|
|
3584
|
-
|
|
3586
|
+
let method = undefined;
|
|
3587
|
+
[method, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'privateGetGAccountsAccountPositions');
|
|
3588
|
+
if (method === 'privateGetGAccountsAccountPositions') {
|
|
3589
|
+
response = await this.privateGetGAccountsAccountPositions(this.extend(request, params));
|
|
3590
|
+
}
|
|
3591
|
+
else {
|
|
3592
|
+
response = await this.privateGetAccountsPositions(this.extend(request, params));
|
|
3593
|
+
}
|
|
3585
3594
|
}
|
|
3586
3595
|
else {
|
|
3587
3596
|
response = await this.privateGetAccountsAccountPositions(this.extend(request, params));
|
|
@@ -3757,7 +3766,7 @@ class phemex extends phemex$1 {
|
|
|
3757
3766
|
const contracts = this.safeString(position, 'size');
|
|
3758
3767
|
const contractSize = this.safeValue(market, 'contractSize');
|
|
3759
3768
|
const contractSizeString = this.numberToString(contractSize);
|
|
3760
|
-
const leverage = this.
|
|
3769
|
+
const leverage = this.parseNumber(Precise["default"].stringAbs((this.safeString(position, 'leverage', 'leverageRr'))));
|
|
3761
3770
|
const entryPriceString = this.safeString2(position, 'avgEntryPrice', 'avgEntryPriceRp');
|
|
3762
3771
|
const rawSide = this.safeString(position, 'side');
|
|
3763
3772
|
let side = undefined;
|
package/dist/cjs/src/poloniex.js
CHANGED
|
@@ -45,6 +45,7 @@ class poloniex extends poloniex$1 {
|
|
|
45
45
|
'fetchDepositsWithdrawals': true,
|
|
46
46
|
'fetchDepositWithdrawFee': 'emulated',
|
|
47
47
|
'fetchDepositWithdrawFees': true,
|
|
48
|
+
'fetchFundingRate': false,
|
|
48
49
|
'fetchMarginMode': false,
|
|
49
50
|
'fetchMarkets': true,
|
|
50
51
|
'fetchMyTrades': true,
|
|
@@ -55,7 +56,6 @@ class poloniex extends poloniex$1 {
|
|
|
55
56
|
'fetchOrder': true,
|
|
56
57
|
'fetchOrderBook': true,
|
|
57
58
|
'fetchOrderBooks': false,
|
|
58
|
-
'fetchFundingRate': false,
|
|
59
59
|
'fetchOrderTrades': true,
|
|
60
60
|
'fetchPosition': false,
|
|
61
61
|
'fetchPositionMode': false,
|
|
@@ -986,7 +986,7 @@ class binance extends binance$1 {
|
|
|
986
986
|
}
|
|
987
987
|
else {
|
|
988
988
|
// take the timestamp of the closing price for candlestick streams
|
|
989
|
-
timestamp = this.
|
|
989
|
+
timestamp = this.safeInteger2(message, 'C', 'E');
|
|
990
990
|
}
|
|
991
991
|
const marketId = this.safeString(message, 's');
|
|
992
992
|
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
|
@@ -32,6 +32,12 @@ class hitbtc extends hitbtc$1 {
|
|
|
32
32
|
'private': 'wss://api.hitbtc.com/api/3/ws/trading',
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
+
'test': {
|
|
36
|
+
'ws': {
|
|
37
|
+
'public': 'wss://api.demo.hitbtc.com/api/3/ws/public',
|
|
38
|
+
'private': 'wss://api.demo.hitbtc.com/api/3/ws/trading',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
35
41
|
},
|
|
36
42
|
'options': {
|
|
37
43
|
'tradesLimit': 1000,
|
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -850,13 +850,15 @@ class okx extends okx$1 {
|
|
|
850
850
|
/**
|
|
851
851
|
* @method
|
|
852
852
|
* @name okx#watchMyTrades
|
|
853
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel
|
|
854
853
|
* @description watches information on multiple trades made by the user
|
|
854
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel
|
|
855
855
|
* @param {string} [symbol] unified market symbol of the market trades were made in
|
|
856
856
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
857
857
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
858
858
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
859
859
|
* @param {bool} [params.stop] true if fetching trigger or conditional trades
|
|
860
|
+
* @param {string} [params.type] 'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
|
|
861
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated', for automatically setting the type to spot margin
|
|
860
862
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
|
|
861
863
|
*/
|
|
862
864
|
// By default, receive order updates from any instrument type
|
|
@@ -878,7 +880,14 @@ class okx extends okx$1 {
|
|
|
878
880
|
if (type === 'future') {
|
|
879
881
|
type = 'futures';
|
|
880
882
|
}
|
|
881
|
-
|
|
883
|
+
let uppercaseType = type.toUpperCase();
|
|
884
|
+
let marginMode = undefined;
|
|
885
|
+
[marginMode, params] = this.handleMarginModeAndParams('watchMyTrades', params);
|
|
886
|
+
if (uppercaseType === 'SPOT') {
|
|
887
|
+
if (marginMode !== undefined) {
|
|
888
|
+
uppercaseType = 'MARGIN';
|
|
889
|
+
}
|
|
890
|
+
}
|
|
882
891
|
const request = {
|
|
883
892
|
'instType': uppercaseType,
|
|
884
893
|
};
|
|
@@ -1024,7 +1033,6 @@ class okx extends okx$1 {
|
|
|
1024
1033
|
*/
|
|
1025
1034
|
let type = undefined;
|
|
1026
1035
|
// By default, receive order updates from any instrument type
|
|
1027
|
-
[type, params] = this.handleOptionAndParams(params, 'watchOrders', 'defaultType');
|
|
1028
1036
|
[type, params] = this.handleOptionAndParams(params, 'watchOrders', 'type', 'ANY');
|
|
1029
1037
|
const isStop = this.safeValue2(params, 'stop', 'trigger', false);
|
|
1030
1038
|
params = this.omit(params, ['stop', 'trigger']);
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.22";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.23';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/bitfinex2.d.ts
CHANGED
|
@@ -156,4 +156,6 @@ export default class bitfinex2 extends Exchange {
|
|
|
156
156
|
previousFundingTimestamp: any;
|
|
157
157
|
previousFundingDatetime: any;
|
|
158
158
|
};
|
|
159
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
160
|
+
parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
|
|
159
161
|
}
|
package/js/src/bitfinex2.js
CHANGED
|
@@ -57,6 +57,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
57
57
|
'fetchMarkOHLCV': false,
|
|
58
58
|
'fetchMyTrades': true,
|
|
59
59
|
'fetchOHLCV': true,
|
|
60
|
+
'fetchOpenInterest': true,
|
|
60
61
|
'fetchOpenOrder': true,
|
|
61
62
|
'fetchOpenOrders': true,
|
|
62
63
|
'fetchOrder': true,
|
|
@@ -2988,4 +2989,92 @@ export default class bitfinex2 extends Exchange {
|
|
|
2988
2989
|
'previousFundingDatetime': undefined,
|
|
2989
2990
|
};
|
|
2990
2991
|
}
|
|
2992
|
+
async fetchOpenInterest(symbol, params = {}) {
|
|
2993
|
+
/**
|
|
2994
|
+
* @method
|
|
2995
|
+
* @name bitfinex2#fetchOpenInterest
|
|
2996
|
+
* @description retrieves the open interest of a contract trading pair
|
|
2997
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2998
|
+
* @param {string} symbol unified CCXT market symbol
|
|
2999
|
+
* @param {object} [params] exchange specific parameters
|
|
3000
|
+
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3001
|
+
*/
|
|
3002
|
+
await this.loadMarkets();
|
|
3003
|
+
const market = this.market(symbol);
|
|
3004
|
+
const request = {
|
|
3005
|
+
'keys': market['id'],
|
|
3006
|
+
};
|
|
3007
|
+
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3008
|
+
//
|
|
3009
|
+
// [
|
|
3010
|
+
// [
|
|
3011
|
+
// "tXRPF0:USTF0", // market id
|
|
3012
|
+
// 1706256986000, // millisecond timestamp
|
|
3013
|
+
// null,
|
|
3014
|
+
// 0.512705, // derivative mid price
|
|
3015
|
+
// 0.512395, // underlying spot mid price
|
|
3016
|
+
// null,
|
|
3017
|
+
// 37671483.04, // insurance fund balance
|
|
3018
|
+
// null,
|
|
3019
|
+
// 1706284800000, // timestamp of next funding
|
|
3020
|
+
// 0.00002353, // accrued funding for next period
|
|
3021
|
+
// 317, // next funding step
|
|
3022
|
+
// null,
|
|
3023
|
+
// 0, // current funding
|
|
3024
|
+
// null,
|
|
3025
|
+
// null,
|
|
3026
|
+
// 0.5123016, // mark price
|
|
3027
|
+
// null,
|
|
3028
|
+
// null,
|
|
3029
|
+
// 2233562.03115, // open interest in contracts
|
|
3030
|
+
// null,
|
|
3031
|
+
// null,
|
|
3032
|
+
// null,
|
|
3033
|
+
// 0.0005, // average spread without funding payment
|
|
3034
|
+
// 0.0025 // funding payment cap
|
|
3035
|
+
// ]
|
|
3036
|
+
// ]
|
|
3037
|
+
//
|
|
3038
|
+
return this.parseOpenInterest(response[0], market);
|
|
3039
|
+
}
|
|
3040
|
+
parseOpenInterest(interest, market = undefined) {
|
|
3041
|
+
//
|
|
3042
|
+
// [
|
|
3043
|
+
// "tXRPF0:USTF0", // market id
|
|
3044
|
+
// 1706256986000, // millisecond timestamp
|
|
3045
|
+
// null,
|
|
3046
|
+
// 0.512705, // derivative mid price
|
|
3047
|
+
// 0.512395, // underlying spot mid price
|
|
3048
|
+
// null,
|
|
3049
|
+
// 37671483.04, // insurance fund balance
|
|
3050
|
+
// null,
|
|
3051
|
+
// 1706284800000, // timestamp of next funding
|
|
3052
|
+
// 0.00002353, // accrued funding for next period
|
|
3053
|
+
// 317, // next funding step
|
|
3054
|
+
// null,
|
|
3055
|
+
// 0, // current funding
|
|
3056
|
+
// null,
|
|
3057
|
+
// null,
|
|
3058
|
+
// 0.5123016, // mark price
|
|
3059
|
+
// null,
|
|
3060
|
+
// null,
|
|
3061
|
+
// 2233562.03115, // open interest in contracts
|
|
3062
|
+
// null,
|
|
3063
|
+
// null,
|
|
3064
|
+
// null,
|
|
3065
|
+
// 0.0005, // average spread without funding payment
|
|
3066
|
+
// 0.0025 // funding payment cap
|
|
3067
|
+
// ]
|
|
3068
|
+
//
|
|
3069
|
+
const timestamp = this.safeInteger(interest, 1);
|
|
3070
|
+
const marketId = this.safeString(interest, 0);
|
|
3071
|
+
return this.safeOpenInterest({
|
|
3072
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3073
|
+
'openInterestAmount': this.safeNumber(interest, 18),
|
|
3074
|
+
'openInterestValue': undefined,
|
|
3075
|
+
'timestamp': timestamp,
|
|
3076
|
+
'datetime': this.iso8601(timestamp),
|
|
3077
|
+
'info': interest,
|
|
3078
|
+
}, market);
|
|
3079
|
+
}
|
|
2991
3080
|
}
|