ccxt 4.2.22 → 4.2.24
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 +587 -60
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binanceus.js +108 -6
- package/dist/cjs/src/bingx.js +1 -1
- package/dist/cjs/src/bitfinex2.js +186 -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/bitopro.js +146 -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/abstract/binanceus.d.ts +52 -1
- package/js/src/binanceus.js +108 -6
- package/js/src/bingx.js +2 -2
- package/js/src/bitfinex2.d.ts +4 -1
- package/js/src/bitfinex2.js +186 -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/bitopro.d.ts +4 -1
- package/js/src/pro/bitopro.js +147 -2
- package/js/src/pro/hitbtc.js +6 -0
- package/js/src/pro/okx.js +11 -3
- package/package.json +1 -1
- package/skip-tests.json +1 -0
package/js/src/bitfinex2.js
CHANGED
|
@@ -57,6 +57,8 @@ export default class bitfinex2 extends Exchange {
|
|
|
57
57
|
'fetchMarkOHLCV': false,
|
|
58
58
|
'fetchMyTrades': true,
|
|
59
59
|
'fetchOHLCV': true,
|
|
60
|
+
'fetchOpenInterest': true,
|
|
61
|
+
'fetchOpenInterestHistory': true,
|
|
60
62
|
'fetchOpenOrder': true,
|
|
61
63
|
'fetchOpenOrders': true,
|
|
62
64
|
'fetchOrder': true,
|
|
@@ -2988,4 +2990,188 @@ export default class bitfinex2 extends Exchange {
|
|
|
2988
2990
|
'previousFundingDatetime': undefined,
|
|
2989
2991
|
};
|
|
2990
2992
|
}
|
|
2993
|
+
async fetchOpenInterest(symbol, params = {}) {
|
|
2994
|
+
/**
|
|
2995
|
+
* @method
|
|
2996
|
+
* @name bitfinex2#fetchOpenInterest
|
|
2997
|
+
* @description retrieves the open interest of a contract trading pair
|
|
2998
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2999
|
+
* @param {string} symbol unified CCXT market symbol
|
|
3000
|
+
* @param {object} [params] exchange specific parameters
|
|
3001
|
+
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3002
|
+
*/
|
|
3003
|
+
await this.loadMarkets();
|
|
3004
|
+
const market = this.market(symbol);
|
|
3005
|
+
const request = {
|
|
3006
|
+
'keys': market['id'],
|
|
3007
|
+
};
|
|
3008
|
+
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3009
|
+
//
|
|
3010
|
+
// [
|
|
3011
|
+
// [
|
|
3012
|
+
// "tXRPF0:USTF0", // market id
|
|
3013
|
+
// 1706256986000, // millisecond timestamp
|
|
3014
|
+
// null,
|
|
3015
|
+
// 0.512705, // derivative mid price
|
|
3016
|
+
// 0.512395, // underlying spot mid price
|
|
3017
|
+
// null,
|
|
3018
|
+
// 37671483.04, // insurance fund balance
|
|
3019
|
+
// null,
|
|
3020
|
+
// 1706284800000, // timestamp of next funding
|
|
3021
|
+
// 0.00002353, // accrued funding for next period
|
|
3022
|
+
// 317, // next funding step
|
|
3023
|
+
// null,
|
|
3024
|
+
// 0, // current funding
|
|
3025
|
+
// null,
|
|
3026
|
+
// null,
|
|
3027
|
+
// 0.5123016, // mark price
|
|
3028
|
+
// null,
|
|
3029
|
+
// null,
|
|
3030
|
+
// 2233562.03115, // open interest in contracts
|
|
3031
|
+
// null,
|
|
3032
|
+
// null,
|
|
3033
|
+
// null,
|
|
3034
|
+
// 0.0005, // average spread without funding payment
|
|
3035
|
+
// 0.0025 // funding payment cap
|
|
3036
|
+
// ]
|
|
3037
|
+
// ]
|
|
3038
|
+
//
|
|
3039
|
+
return this.parseOpenInterest(response[0], market);
|
|
3040
|
+
}
|
|
3041
|
+
async fetchOpenInterestHistory(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
3042
|
+
/**
|
|
3043
|
+
* @method
|
|
3044
|
+
* @name bitfinex2#fetchOpenInterestHistory
|
|
3045
|
+
* @description retrieves the open interest history of a currency
|
|
3046
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
|
|
3047
|
+
* @param {string} symbol unified CCXT market symbol
|
|
3048
|
+
* @param {string} timeframe the time period of each row of data, not used by bitfinex2
|
|
3049
|
+
* @param {int} [since] the time in ms of the earliest record to retrieve as a unix timestamp
|
|
3050
|
+
* @param {int} [limit] the number of records in the response
|
|
3051
|
+
* @param {object} [params] exchange specific parameters
|
|
3052
|
+
* @param {int} [params.until] the time in ms of the latest record to retrieve as a unix timestamp
|
|
3053
|
+
* @param {boolean} [params.paginate] 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)
|
|
3054
|
+
* @returns An array of [open interest structures]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3055
|
+
*/
|
|
3056
|
+
await this.loadMarkets();
|
|
3057
|
+
let paginate = false;
|
|
3058
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchOpenInterestHistory', 'paginate');
|
|
3059
|
+
if (paginate) {
|
|
3060
|
+
return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, '8h', params, 5000);
|
|
3061
|
+
}
|
|
3062
|
+
const market = this.market(symbol);
|
|
3063
|
+
let request = {
|
|
3064
|
+
'symbol': market['id'],
|
|
3065
|
+
};
|
|
3066
|
+
if (since !== undefined) {
|
|
3067
|
+
request['start'] = since;
|
|
3068
|
+
}
|
|
3069
|
+
if (limit !== undefined) {
|
|
3070
|
+
request['limit'] = limit;
|
|
3071
|
+
}
|
|
3072
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
3073
|
+
const response = await this.publicGetStatusDerivSymbolHist(this.extend(request, params));
|
|
3074
|
+
//
|
|
3075
|
+
// [
|
|
3076
|
+
// [
|
|
3077
|
+
// 1706295191000, // timestamp
|
|
3078
|
+
// null,
|
|
3079
|
+
// 42152.425382, // derivative mid price
|
|
3080
|
+
// 42133, // spot mid price
|
|
3081
|
+
// null,
|
|
3082
|
+
// 37671589.7853521, // insurance fund balance
|
|
3083
|
+
// null,
|
|
3084
|
+
// 1706313600000, // timestamp of next funding
|
|
3085
|
+
// 0.00018734, // accrued funding for next period
|
|
3086
|
+
// 3343, // next funding step
|
|
3087
|
+
// null,
|
|
3088
|
+
// 0.00007587, // current funding
|
|
3089
|
+
// null,
|
|
3090
|
+
// null,
|
|
3091
|
+
// 42134.1, // mark price
|
|
3092
|
+
// null,
|
|
3093
|
+
// null,
|
|
3094
|
+
// 5775.20348804, // open interest number of contracts
|
|
3095
|
+
// null,
|
|
3096
|
+
// null,
|
|
3097
|
+
// null,
|
|
3098
|
+
// 0.0005, // average spread without funding payment
|
|
3099
|
+
// 0.0025 // funding payment cap
|
|
3100
|
+
// ],
|
|
3101
|
+
// ]
|
|
3102
|
+
//
|
|
3103
|
+
return this.parseOpenInterests(response, market, since, limit);
|
|
3104
|
+
}
|
|
3105
|
+
parseOpenInterest(interest, market = undefined) {
|
|
3106
|
+
//
|
|
3107
|
+
// fetchOpenInterest:
|
|
3108
|
+
//
|
|
3109
|
+
// [
|
|
3110
|
+
// "tXRPF0:USTF0", // market id
|
|
3111
|
+
// 1706256986000, // millisecond timestamp
|
|
3112
|
+
// null,
|
|
3113
|
+
// 0.512705, // derivative mid price
|
|
3114
|
+
// 0.512395, // underlying spot mid price
|
|
3115
|
+
// null,
|
|
3116
|
+
// 37671483.04, // insurance fund balance
|
|
3117
|
+
// null,
|
|
3118
|
+
// 1706284800000, // timestamp of next funding
|
|
3119
|
+
// 0.00002353, // accrued funding for next period
|
|
3120
|
+
// 317, // next funding step
|
|
3121
|
+
// null,
|
|
3122
|
+
// 0, // current funding
|
|
3123
|
+
// null,
|
|
3124
|
+
// null,
|
|
3125
|
+
// 0.5123016, // mark price
|
|
3126
|
+
// null,
|
|
3127
|
+
// null,
|
|
3128
|
+
// 2233562.03115, // open interest in contracts
|
|
3129
|
+
// null,
|
|
3130
|
+
// null,
|
|
3131
|
+
// null,
|
|
3132
|
+
// 0.0005, // average spread without funding payment
|
|
3133
|
+
// 0.0025 // funding payment cap
|
|
3134
|
+
// ]
|
|
3135
|
+
//
|
|
3136
|
+
// fetchOpenInterestHistory:
|
|
3137
|
+
//
|
|
3138
|
+
// [
|
|
3139
|
+
// 1706295191000, // timestamp
|
|
3140
|
+
// null,
|
|
3141
|
+
// 42152.425382, // derivative mid price
|
|
3142
|
+
// 42133, // spot mid price
|
|
3143
|
+
// null,
|
|
3144
|
+
// 37671589.7853521, // insurance fund balance
|
|
3145
|
+
// null,
|
|
3146
|
+
// 1706313600000, // timestamp of next funding
|
|
3147
|
+
// 0.00018734, // accrued funding for next period
|
|
3148
|
+
// 3343, // next funding step
|
|
3149
|
+
// null,
|
|
3150
|
+
// 0.00007587, // current funding
|
|
3151
|
+
// null,
|
|
3152
|
+
// null,
|
|
3153
|
+
// 42134.1, // mark price
|
|
3154
|
+
// null,
|
|
3155
|
+
// null,
|
|
3156
|
+
// 5775.20348804, // open interest number of contracts
|
|
3157
|
+
// null,
|
|
3158
|
+
// null,
|
|
3159
|
+
// null,
|
|
3160
|
+
// 0.0005, // average spread without funding payment
|
|
3161
|
+
// 0.0025 // funding payment cap
|
|
3162
|
+
// ]
|
|
3163
|
+
//
|
|
3164
|
+
const interestLength = interest.length;
|
|
3165
|
+
const openInterestIndex = (interestLength === 23) ? 17 : 18;
|
|
3166
|
+
const timestamp = this.safeInteger(interest, 1);
|
|
3167
|
+
const marketId = this.safeString(interest, 0);
|
|
3168
|
+
return this.safeOpenInterest({
|
|
3169
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3170
|
+
'openInterestAmount': this.safeNumber(interest, openInterestIndex),
|
|
3171
|
+
'openInterestValue': undefined,
|
|
3172
|
+
'timestamp': timestamp,
|
|
3173
|
+
'datetime': this.iso8601(timestamp),
|
|
3174
|
+
'info': interest,
|
|
3175
|
+
}, market);
|
|
3176
|
+
}
|
|
2991
3177
|
}
|
package/js/src/bitget.js
CHANGED
|
@@ -47,16 +47,16 @@ export default class bitget extends Exchange {
|
|
|
47
47
|
'createOrder': true,
|
|
48
48
|
'createOrders': true,
|
|
49
49
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
50
|
-
'createReduceOnlyOrder': false,
|
|
51
|
-
'createStopLossOrder': true,
|
|
52
|
-
'createTakeProfitOrder': true,
|
|
53
50
|
'createPostOnlyOrder': true,
|
|
54
|
-
'
|
|
51
|
+
'createReduceOnlyOrder': false,
|
|
55
52
|
'createStopLimitOrder': true,
|
|
53
|
+
'createStopLossOrder': true,
|
|
56
54
|
'createStopMarketOrder': true,
|
|
55
|
+
'createStopOrder': true,
|
|
56
|
+
'createTakeProfitOrder': true,
|
|
57
|
+
'createTrailingAmountOrder': false,
|
|
57
58
|
'createTrailingPercentOrder': true,
|
|
58
59
|
'createTriggerOrder': true,
|
|
59
|
-
'signIn': false,
|
|
60
60
|
'editOrder': true,
|
|
61
61
|
'fetchAccounts': false,
|
|
62
62
|
'fetchBalance': true,
|
|
@@ -72,12 +72,10 @@ export default class bitget extends Exchange {
|
|
|
72
72
|
'fetchDepositAddress': true,
|
|
73
73
|
'fetchDepositAddresses': false,
|
|
74
74
|
'fetchDeposits': true,
|
|
75
|
+
'fetchDepositsWithdrawals': false,
|
|
75
76
|
'fetchDepositWithdrawFee': 'emulated',
|
|
76
77
|
'fetchDepositWithdrawFees': true,
|
|
77
|
-
'fetchDepositsWithdrawals': false,
|
|
78
78
|
'fetchFundingHistory': true,
|
|
79
|
-
'fetchWithdrawAddresses': false,
|
|
80
|
-
'fetchTransactions': false,
|
|
81
79
|
'fetchFundingRate': true,
|
|
82
80
|
'fetchFundingRateHistory': true,
|
|
83
81
|
'fetchFundingRates': false,
|
|
@@ -101,7 +99,6 @@ export default class bitget extends Exchange {
|
|
|
101
99
|
'fetchOrder': true,
|
|
102
100
|
'fetchOrderBook': true,
|
|
103
101
|
'fetchOrders': false,
|
|
104
|
-
'createTrailingAmountOrder': false,
|
|
105
102
|
'fetchOrderTrades': false,
|
|
106
103
|
'fetchPosition': true,
|
|
107
104
|
'fetchPositionMode': false,
|
|
@@ -114,8 +111,10 @@ export default class bitget extends Exchange {
|
|
|
114
111
|
'fetchTrades': true,
|
|
115
112
|
'fetchTradingFee': true,
|
|
116
113
|
'fetchTradingFees': true,
|
|
114
|
+
'fetchTransactions': false,
|
|
117
115
|
'fetchTransfer': false,
|
|
118
116
|
'fetchTransfers': true,
|
|
117
|
+
'fetchWithdrawAddresses': false,
|
|
119
118
|
'fetchWithdrawal': false,
|
|
120
119
|
'fetchWithdrawals': true,
|
|
121
120
|
'reduceMargin': true,
|
|
@@ -124,6 +123,7 @@ export default class bitget extends Exchange {
|
|
|
124
123
|
'setLeverage': true,
|
|
125
124
|
'setMarginMode': true,
|
|
126
125
|
'setPositionMode': true,
|
|
126
|
+
'signIn': false,
|
|
127
127
|
'transfer': true,
|
|
128
128
|
'withdraw': true,
|
|
129
129
|
},
|
package/js/src/coinbasepro.js
CHANGED
|
@@ -45,8 +45,8 @@ export default class coinbasepro extends Exchange {
|
|
|
45
45
|
'fetchDepositAddress': false,
|
|
46
46
|
'fetchDeposits': true,
|
|
47
47
|
'fetchDepositsWithdrawals': true,
|
|
48
|
-
'fetchLedger': true,
|
|
49
48
|
'fetchFundingRate': false,
|
|
49
|
+
'fetchLedger': true,
|
|
50
50
|
'fetchMarginMode': false,
|
|
51
51
|
'fetchMarkets': true,
|
|
52
52
|
'fetchMyTrades': true,
|
package/js/src/coinex.js
CHANGED
|
@@ -3517,11 +3517,17 @@ export default class coinex extends Exchange {
|
|
|
3517
3517
|
* @name coinex#fetchPositions
|
|
3518
3518
|
* @description fetch all open positions
|
|
3519
3519
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
|
|
3520
|
-
* @
|
|
3520
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
|
|
3521
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3521
3522
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3523
|
+
* @param {string} [params.method] the method to use 'perpetualPrivateGetPositionPending' or 'perpetualPrivateGetPositionFinished' default is 'perpetualPrivateGetPositionPending'
|
|
3524
|
+
* @param {int} [params.side] *history endpoint only* 0: All, 1: Sell, 2: Buy, default is 0
|
|
3522
3525
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3523
3526
|
*/
|
|
3524
3527
|
await this.loadMarkets();
|
|
3528
|
+
let defaultMethod = undefined;
|
|
3529
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'perpetualPrivateGetPositionPending');
|
|
3530
|
+
const isHistory = (defaultMethod === 'perpetualPrivateGetPositionFinished');
|
|
3525
3531
|
symbols = this.marketSymbols(symbols);
|
|
3526
3532
|
const request = {};
|
|
3527
3533
|
let market = undefined;
|
|
@@ -3540,7 +3546,22 @@ export default class coinex extends Exchange {
|
|
|
3540
3546
|
market = this.market(symbol);
|
|
3541
3547
|
request['market'] = market['id'];
|
|
3542
3548
|
}
|
|
3543
|
-
|
|
3549
|
+
else {
|
|
3550
|
+
if (isHistory) {
|
|
3551
|
+
throw new ArgumentsRequired(this.id + ' fetchPositions() requires a symbol argument for closed positions');
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
if (isHistory) {
|
|
3555
|
+
request['limit'] = 100;
|
|
3556
|
+
request['side'] = this.safeInteger(params, 'side', 0); // 0: All, 1: Sell, 2: Buy
|
|
3557
|
+
}
|
|
3558
|
+
let response = undefined;
|
|
3559
|
+
if (defaultMethod === 'perpetualPrivateGetPositionPending') {
|
|
3560
|
+
response = await this.perpetualPrivateGetPositionPending(this.extend(request, params));
|
|
3561
|
+
}
|
|
3562
|
+
else {
|
|
3563
|
+
response = await this.perpetualPrivateGetPositionFinished(this.extend(request, params));
|
|
3564
|
+
}
|
|
3544
3565
|
//
|
|
3545
3566
|
// {
|
|
3546
3567
|
// "code": 0,
|
package/js/src/okx.js
CHANGED
|
@@ -2917,12 +2917,26 @@ export default class okx extends Exchange {
|
|
|
2917
2917
|
const request = {
|
|
2918
2918
|
'instId': market['id'],
|
|
2919
2919
|
};
|
|
2920
|
+
let isAlgoOrder = undefined;
|
|
2921
|
+
if ((type === 'trigger') || (type === 'conditional') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
|
|
2922
|
+
isAlgoOrder = true;
|
|
2923
|
+
}
|
|
2920
2924
|
const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
|
|
2921
2925
|
if (clientOrderId !== undefined) {
|
|
2922
|
-
|
|
2926
|
+
if (isAlgoOrder) {
|
|
2927
|
+
request['algoClOrdId'] = clientOrderId;
|
|
2928
|
+
}
|
|
2929
|
+
else {
|
|
2930
|
+
request['clOrdId'] = clientOrderId;
|
|
2931
|
+
}
|
|
2923
2932
|
}
|
|
2924
2933
|
else {
|
|
2925
|
-
|
|
2934
|
+
if (isAlgoOrder) {
|
|
2935
|
+
request['algoId'] = id;
|
|
2936
|
+
}
|
|
2937
|
+
else {
|
|
2938
|
+
request['ordId'] = id;
|
|
2939
|
+
}
|
|
2926
2940
|
}
|
|
2927
2941
|
let stopLossTriggerPrice = this.safeValue2(params, 'stopLossPrice', 'newSlTriggerPx');
|
|
2928
2942
|
let stopLossPrice = this.safeValue(params, 'newSlOrdPx');
|
|
@@ -2934,37 +2948,62 @@ export default class okx extends Exchange {
|
|
|
2934
2948
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
2935
2949
|
const stopLossDefined = (stopLoss !== undefined);
|
|
2936
2950
|
const takeProfitDefined = (takeProfit !== undefined);
|
|
2937
|
-
if (
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2951
|
+
if (isAlgoOrder) {
|
|
2952
|
+
if ((stopLossTriggerPrice === undefined) && (takeProfitTriggerPrice === undefined)) {
|
|
2953
|
+
throw new BadRequest(this.id + ' editOrder() requires a stopLossPrice or takeProfitPrice parameter for editing an algo order');
|
|
2954
|
+
}
|
|
2955
|
+
if (stopLossTriggerPrice !== undefined) {
|
|
2956
|
+
if (stopLossPrice === undefined) {
|
|
2957
|
+
throw new BadRequest(this.id + ' editOrder() requires a newSlOrdPx parameter for editing an algo order');
|
|
2958
|
+
}
|
|
2959
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2960
|
+
request['newSlOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2961
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2962
|
+
}
|
|
2963
|
+
if (takeProfitTriggerPrice !== undefined) {
|
|
2964
|
+
if (takeProfitPrice === undefined) {
|
|
2965
|
+
throw new BadRequest(this.id + ' editOrder() requires a newTpOrdPx parameter for editing an algo order');
|
|
2966
|
+
}
|
|
2967
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2968
|
+
request['newTpOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2969
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
else {
|
|
2973
|
+
if (stopLossTriggerPrice !== undefined) {
|
|
2974
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2975
|
+
request['newSlOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2976
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2977
|
+
}
|
|
2978
|
+
if (takeProfitTriggerPrice !== undefined) {
|
|
2979
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2980
|
+
request['newTpOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2981
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2982
|
+
}
|
|
2983
|
+
if (stopLossDefined) {
|
|
2984
|
+
stopLossTriggerPrice = this.safeValue(stopLoss, 'triggerPrice');
|
|
2985
|
+
stopLossPrice = this.safeValue(stopLoss, 'price');
|
|
2986
|
+
const stopLossType = this.safeString(stopLoss, 'type');
|
|
2987
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2988
|
+
request['newSlOrdPx'] = (stopLossType === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2989
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2990
|
+
}
|
|
2991
|
+
if (takeProfitDefined) {
|
|
2992
|
+
takeProfitTriggerPrice = this.safeValue(takeProfit, 'triggerPrice');
|
|
2993
|
+
takeProfitPrice = this.safeValue(takeProfit, 'price');
|
|
2994
|
+
const takeProfitType = this.safeString(takeProfit, 'type');
|
|
2995
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2996
|
+
request['newTpOrdPx'] = (takeProfitType === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2997
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2998
|
+
}
|
|
2962
2999
|
}
|
|
2963
3000
|
if (amount !== undefined) {
|
|
2964
3001
|
request['newSz'] = this.amountToPrecision(symbol, amount);
|
|
2965
3002
|
}
|
|
2966
|
-
if (
|
|
2967
|
-
|
|
3003
|
+
if (!isAlgoOrder) {
|
|
3004
|
+
if (price !== undefined) {
|
|
3005
|
+
request['newPx'] = this.priceToPrecision(symbol, price);
|
|
3006
|
+
}
|
|
2968
3007
|
}
|
|
2969
3008
|
params = this.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit']);
|
|
2970
3009
|
return this.extend(request, params);
|
|
@@ -2974,7 +3013,8 @@ export default class okx extends Exchange {
|
|
|
2974
3013
|
* @method
|
|
2975
3014
|
* @name okx#editOrder
|
|
2976
3015
|
* @description edit a trade order
|
|
2977
|
-
* @see https://www.okx.com/docs-v5/en/#
|
|
3016
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-amend-order
|
|
3017
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-amend-algo-order
|
|
2978
3018
|
* @param {string} id order id
|
|
2979
3019
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2980
3020
|
* @param {string} type 'market' or 'limit'
|
|
@@ -3002,7 +3042,17 @@ export default class okx extends Exchange {
|
|
|
3002
3042
|
await this.loadMarkets();
|
|
3003
3043
|
const market = this.market(symbol);
|
|
3004
3044
|
const request = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
3005
|
-
|
|
3045
|
+
let isAlgoOrder = undefined;
|
|
3046
|
+
if ((type === 'trigger') || (type === 'conditional') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
|
|
3047
|
+
isAlgoOrder = true;
|
|
3048
|
+
}
|
|
3049
|
+
let response = undefined;
|
|
3050
|
+
if (isAlgoOrder) {
|
|
3051
|
+
response = await this.privatePostTradeAmendAlgos(this.extend(request, params));
|
|
3052
|
+
}
|
|
3053
|
+
else {
|
|
3054
|
+
response = await this.privatePostTradeAmendOrder(this.extend(request, params));
|
|
3055
|
+
}
|
|
3006
3056
|
//
|
|
3007
3057
|
// {
|
|
3008
3058
|
// "code": "0",
|
package/js/src/phemex.js
CHANGED
|
@@ -3548,8 +3548,10 @@ export default class phemex extends Exchange {
|
|
|
3548
3548
|
* @description fetch all open positions
|
|
3549
3549
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-trading-account-and-positions
|
|
3550
3550
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
|
|
3551
|
-
* @
|
|
3551
|
+
* @see https://phemex-docs.github.io/#query-account-positions-with-unrealized-pnl
|
|
3552
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3552
3553
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3554
|
+
* @param {string} [param.method] *USDT contracts only* 'privateGetGAccountsAccountPositions' or 'privateGetAccountsPositions' default is 'privateGetGAccountsAccountPositions'
|
|
3553
3555
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3554
3556
|
*/
|
|
3555
3557
|
await this.loadMarkets();
|
|
@@ -3584,7 +3586,14 @@ export default class phemex extends Exchange {
|
|
|
3584
3586
|
};
|
|
3585
3587
|
let response = undefined;
|
|
3586
3588
|
if (isUSDTSettled) {
|
|
3587
|
-
|
|
3589
|
+
let method = undefined;
|
|
3590
|
+
[method, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'privateGetGAccountsAccountPositions');
|
|
3591
|
+
if (method === 'privateGetGAccountsAccountPositions') {
|
|
3592
|
+
response = await this.privateGetGAccountsAccountPositions(this.extend(request, params));
|
|
3593
|
+
}
|
|
3594
|
+
else {
|
|
3595
|
+
response = await this.privateGetAccountsPositions(this.extend(request, params));
|
|
3596
|
+
}
|
|
3588
3597
|
}
|
|
3589
3598
|
else {
|
|
3590
3599
|
response = await this.privateGetAccountsAccountPositions(this.extend(request, params));
|
|
@@ -3760,7 +3769,7 @@ export default class phemex extends Exchange {
|
|
|
3760
3769
|
const contracts = this.safeString(position, 'size');
|
|
3761
3770
|
const contractSize = this.safeValue(market, 'contractSize');
|
|
3762
3771
|
const contractSizeString = this.numberToString(contractSize);
|
|
3763
|
-
const leverage = this.
|
|
3772
|
+
const leverage = this.parseNumber(Precise.stringAbs((this.safeString2(position, 'leverage', 'leverageRr'))));
|
|
3764
3773
|
const entryPriceString = this.safeString2(position, 'avgEntryPrice', 'avgEntryPriceRp');
|
|
3765
3774
|
const rawSide = this.safeString(position, 'side');
|
|
3766
3775
|
let side = undefined;
|
package/js/src/poloniex.js
CHANGED
|
@@ -48,6 +48,7 @@ export default class poloniex extends Exchange {
|
|
|
48
48
|
'fetchDepositsWithdrawals': true,
|
|
49
49
|
'fetchDepositWithdrawFee': 'emulated',
|
|
50
50
|
'fetchDepositWithdrawFees': true,
|
|
51
|
+
'fetchFundingRate': false,
|
|
51
52
|
'fetchMarginMode': false,
|
|
52
53
|
'fetchMarkets': true,
|
|
53
54
|
'fetchMyTrades': true,
|
|
@@ -58,7 +59,6 @@ export default class poloniex extends Exchange {
|
|
|
58
59
|
'fetchOrder': true,
|
|
59
60
|
'fetchOrderBook': true,
|
|
60
61
|
'fetchOrderBooks': false,
|
|
61
|
-
'fetchFundingRate': false,
|
|
62
62
|
'fetchOrderTrades': true,
|
|
63
63
|
'fetchPosition': false,
|
|
64
64
|
'fetchPositionMode': false,
|
package/js/src/pro/binance.js
CHANGED
|
@@ -989,7 +989,7 @@ export default class binance extends binanceRest {
|
|
|
989
989
|
}
|
|
990
990
|
else {
|
|
991
991
|
// take the timestamp of the closing price for candlestick streams
|
|
992
|
-
timestamp = this.
|
|
992
|
+
timestamp = this.safeInteger2(message, 'C', 'E');
|
|
993
993
|
}
|
|
994
994
|
const marketId = this.safeString(message, 's');
|
|
995
995
|
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
package/js/src/pro/bitopro.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import bitoproRest from '../bitopro.js';
|
|
2
|
-
import type { Int, OrderBook, Trade, Ticker, Balances } from '../base/types.js';
|
|
2
|
+
import type { Int, OrderBook, Trade, Ticker, Balances, Market, Str } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class bitopro extends bitoproRest {
|
|
5
5
|
describe(): any;
|
|
@@ -8,6 +8,9 @@ export default class bitopro extends bitoproRest {
|
|
|
8
8
|
handleOrderBook(client: Client, message: any): void;
|
|
9
9
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
10
10
|
handleTrade(client: Client, message: any): void;
|
|
11
|
+
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
12
|
+
handleMyTrade(client: Client, message: any): void;
|
|
13
|
+
parseWsTrade(trade: any, market?: Market): Trade;
|
|
11
14
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
12
15
|
handleTicker(client: Client, message: any): void;
|
|
13
16
|
authenticate(url: any): void;
|