ccxt 4.2.3 → 4.2.5
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 +4 -4
- package/dist/ccxt.browser.js +247 -47
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +7 -1
- package/dist/cjs/src/base/Exchange.js +5 -2
- package/dist/cjs/src/bingx.js +17 -18
- package/dist/cjs/src/bitmart.js +18 -8
- package/dist/cjs/src/bybit.js +4 -0
- package/dist/cjs/src/coinsph.js +20 -2
- package/dist/cjs/src/delta.js +2 -2
- package/dist/cjs/src/htx.js +166 -12
- package/dist/cjs/src/okx.js +5 -0
- package/dist/cjs/src/phemex.js +3 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmart.d.ts +1 -0
- package/js/src/abstract/bybit.d.ts +2 -0
- package/js/src/alpaca.js +7 -1
- package/js/src/base/Exchange.js +5 -2
- package/js/src/binance.d.ts +1 -1
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bingx.js +17 -18
- package/js/src/bitmart.js +18 -8
- package/js/src/bybit.js +4 -0
- package/js/src/coinsph.js +20 -2
- package/js/src/delta.js +2 -2
- package/js/src/htx.js +166 -12
- package/js/src/okx.js +5 -0
- package/js/src/phemex.js +3 -2
- package/package.json +1 -1
- package/skip-tests.json +4 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -2835,10 +2835,16 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
2835
2835
|
//
|
|
2836
2836
|
const marketId = this.safeString(asset, 'symbol');
|
|
2837
2837
|
const parts = marketId.split('/');
|
|
2838
|
+
const assetClass = this.safeString(asset, 'class');
|
|
2838
2839
|
const baseId = this.safeString(parts, 0);
|
|
2839
2840
|
const quoteId = this.safeString(parts, 1);
|
|
2840
2841
|
const base = this.safeCurrencyCode(baseId);
|
|
2841
|
-
|
|
2842
|
+
let quote = this.safeCurrencyCode(quoteId);
|
|
2843
|
+
// Us equity markets do not include quote in symbol.
|
|
2844
|
+
// We can safely coerce us_equity quote to USD
|
|
2845
|
+
if (quote === undefined && assetClass === 'us_equity') {
|
|
2846
|
+
quote = 'USD';
|
|
2847
|
+
}
|
|
2842
2848
|
const symbol = base + '/' + quote;
|
|
2843
2849
|
const status = this.safeString(asset, 'status');
|
|
2844
2850
|
const active = (status === 'active');
|
|
@@ -7738,8 +7744,11 @@ class Exchange {
|
|
|
7738
7744
|
// proxy agents
|
|
7739
7745
|
const [httpProxy, httpsProxy, socksProxy] = this.checkProxySettings(url, method, headers, body);
|
|
7740
7746
|
this.checkConflictingProxies(httpProxy || httpsProxy || socksProxy, proxyUrl);
|
|
7741
|
-
if (
|
|
7742
|
-
|
|
7747
|
+
if (isNode) {
|
|
7748
|
+
// skip this on the browser
|
|
7749
|
+
if (!this.proxyModulesLoaded) {
|
|
7750
|
+
await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
|
|
7751
|
+
}
|
|
7743
7752
|
}
|
|
7744
7753
|
const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
|
|
7745
7754
|
// user-agent
|
|
@@ -28386,18 +28395,11 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
28386
28395
|
const close = this.safeString(ticker, 'lastPrice');
|
|
28387
28396
|
const quoteVolume = this.safeString(ticker, 'quoteVolume');
|
|
28388
28397
|
const baseVolume = this.safeString(ticker, 'volume');
|
|
28389
|
-
let percentage =
|
|
28390
|
-
|
|
28391
|
-
|
|
28392
|
-
// right now only swap uses the 24h change, spot will be added soon
|
|
28393
|
-
percentage = this.safeString(ticker, 'priceChangePercent');
|
|
28394
|
-
change = this.safeString(ticker, 'priceChange');
|
|
28398
|
+
let percentage = this.safeString(ticker, 'priceChangePercent');
|
|
28399
|
+
if (percentage !== undefined) {
|
|
28400
|
+
percentage = percentage.replace('%', '');
|
|
28395
28401
|
}
|
|
28396
|
-
|
|
28397
|
-
// if (percentage !== undefined) {
|
|
28398
|
-
// percentage = percentage.replace ('%', '');
|
|
28399
|
-
// } similarly to change, it's not ccxt's percentage because it does priceChange/open, and priceChange is high-low
|
|
28400
|
-
// const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
|
|
28402
|
+
const change = this.safeString(ticker, 'priceChange');
|
|
28401
28403
|
const ts = this.safeInteger(ticker, 'closeTime');
|
|
28402
28404
|
const datetime = this.iso8601(ts);
|
|
28403
28405
|
const bid = this.safeString(ticker, 'bidPrice');
|
|
@@ -28726,6 +28728,11 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
28726
28728
|
};
|
|
28727
28729
|
const isMarketOrder = type === 'MARKET';
|
|
28728
28730
|
const isSpot = marketType === 'spot';
|
|
28731
|
+
const exchangeClientOrderId = isSpot ? 'newClientOrderId' : 'clientOrderID';
|
|
28732
|
+
const clientOrderId = this.safeString2(params, exchangeClientOrderId, 'clientOrderId');
|
|
28733
|
+
if (clientOrderId !== undefined) {
|
|
28734
|
+
request[exchangeClientOrderId] = clientOrderId;
|
|
28735
|
+
}
|
|
28729
28736
|
const timeInForce = this.safeStringUpper(params, 'timeInForce');
|
|
28730
28737
|
if (timeInForce === 'IOC') {
|
|
28731
28738
|
request['timeInForce'] = 'IOC';
|
|
@@ -28870,7 +28877,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
28870
28877
|
}
|
|
28871
28878
|
request['positionSide'] = positionSide;
|
|
28872
28879
|
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
28873
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss']);
|
|
28880
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
28874
28881
|
}
|
|
28875
28882
|
return this.extend(request, params);
|
|
28876
28883
|
}
|
|
@@ -28887,6 +28894,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
28887
28894
|
* @param {float} amount how much you want to trade in units of the base currency
|
|
28888
28895
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
28889
28896
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
28897
|
+
* @param {string} [params.clientOrderId] a unique id for the order
|
|
28890
28898
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
28891
28899
|
* @param {string} [params.timeInForce] spot supports 'PO' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
|
|
28892
28900
|
* @param {bool} [params.reduceOnly] *swap only* true or false whether the order is reduce only
|
|
@@ -28951,7 +28959,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
28951
28959
|
// }
|
|
28952
28960
|
//
|
|
28953
28961
|
if (typeof response === 'string') {
|
|
28954
|
-
response =
|
|
28962
|
+
response = this.parseJson(response);
|
|
28955
28963
|
}
|
|
28956
28964
|
const data = this.safeValue(response, 'data', {});
|
|
28957
28965
|
const order = this.safeValue(data, 'order', data);
|
|
@@ -29212,7 +29220,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29212
29220
|
'currency': feeCurrencyCode,
|
|
29213
29221
|
'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
|
|
29214
29222
|
};
|
|
29215
|
-
const clientOrderId = this.
|
|
29223
|
+
const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
|
|
29216
29224
|
let stopLoss = this.safeValue(order, 'stopLoss');
|
|
29217
29225
|
let stopLossPrice = undefined;
|
|
29218
29226
|
if (stopLoss !== undefined) {
|
|
@@ -29221,7 +29229,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29221
29229
|
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
|
|
29222
29230
|
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
|
29223
29231
|
if (typeof stopLoss === 'string') {
|
|
29224
|
-
stopLoss =
|
|
29232
|
+
stopLoss = this.parseJson(stopLoss);
|
|
29225
29233
|
}
|
|
29226
29234
|
stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
|
|
29227
29235
|
}
|
|
@@ -29233,7 +29241,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29233
29241
|
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
|
|
29234
29242
|
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
|
29235
29243
|
if (typeof takeProfit === 'string') {
|
|
29236
|
-
takeProfit =
|
|
29244
|
+
takeProfit = this.parseJson(takeProfit);
|
|
29237
29245
|
}
|
|
29238
29246
|
takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
|
|
29239
29247
|
}
|
|
@@ -29473,7 +29481,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29473
29481
|
}
|
|
29474
29482
|
let response = undefined;
|
|
29475
29483
|
if (market['spot']) {
|
|
29476
|
-
const spotReqKey = areClientOrderIds ? '
|
|
29484
|
+
const spotReqKey = areClientOrderIds ? 'clientOrderIDs' : 'orderIds';
|
|
29477
29485
|
request[spotReqKey] = parsedIds.join(',');
|
|
29478
29486
|
response = await this.spotV1PrivatePostTradeCancelOrders(this.extend(request, params));
|
|
29479
29487
|
}
|
|
@@ -50159,6 +50167,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
50159
50167
|
'contract/private/order-history': 10,
|
|
50160
50168
|
'contract/private/position': 10,
|
|
50161
50169
|
'contract/private/get-open-orders': 1.2,
|
|
50170
|
+
'contract/private/current-plan-order': 1.2,
|
|
50162
50171
|
'contract/private/trades': 10,
|
|
50163
50172
|
},
|
|
50164
50173
|
'post': {
|
|
@@ -52641,6 +52650,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52641
52650
|
* @name bitmart#fetchOpenOrders
|
|
52642
52651
|
* @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
|
|
52643
52652
|
* @see https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
|
|
52653
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-all-current-plan-orders-keyed
|
|
52644
52654
|
* @description fetch all unfilled currently open orders
|
|
52645
52655
|
* @param {string} symbol unified market symbol
|
|
52646
52656
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
@@ -52652,6 +52662,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52652
52662
|
* @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
|
|
52653
52663
|
* @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
|
|
52654
52664
|
* @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
|
|
52665
|
+
* @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
|
|
52655
52666
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
52656
52667
|
*/
|
|
52657
52668
|
await this.loadMarkets();
|
|
@@ -52684,16 +52695,23 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
52684
52695
|
response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
|
|
52685
52696
|
}
|
|
52686
52697
|
else if (type === 'swap') {
|
|
52687
|
-
const
|
|
52688
|
-
|
|
52689
|
-
|
|
52690
|
-
|
|
52691
|
-
orderType = 'trailing';
|
|
52698
|
+
const isStop = this.safeValue2(params, 'stop', 'trigger');
|
|
52699
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
52700
|
+
if (isStop) {
|
|
52701
|
+
response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
|
|
52692
52702
|
}
|
|
52693
|
-
|
|
52694
|
-
|
|
52703
|
+
else {
|
|
52704
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
52705
|
+
let orderType = this.safeString(params, 'orderType');
|
|
52706
|
+
params = this.omit(params, ['orderType', 'trailing']);
|
|
52707
|
+
if (trailing) {
|
|
52708
|
+
orderType = 'trailing';
|
|
52709
|
+
}
|
|
52710
|
+
if (orderType !== undefined) {
|
|
52711
|
+
request['type'] = orderType;
|
|
52712
|
+
}
|
|
52713
|
+
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
52695
52714
|
}
|
|
52696
|
-
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
52697
52715
|
}
|
|
52698
52716
|
else {
|
|
52699
52717
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' orders, only spot and swap orders are accepted');
|
|
@@ -78040,6 +78058,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
78040
78058
|
'v5/position/list': 5,
|
|
78041
78059
|
'v5/execution/list': 5,
|
|
78042
78060
|
'v5/position/closed-pnl': 5,
|
|
78061
|
+
'v5/position/move-history': 5,
|
|
78043
78062
|
// pre-upgrade
|
|
78044
78063
|
'v5/pre-upgrade/order/history': 5,
|
|
78045
78064
|
'v5/pre-upgrade/execution/list': 5,
|
|
@@ -78204,6 +78223,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
78204
78223
|
'v5/position/trading-stop': 5,
|
|
78205
78224
|
'v5/position/set-auto-add-margin': 5,
|
|
78206
78225
|
'v5/position/add-margin': 5,
|
|
78226
|
+
'v5/position/move-positions': 5,
|
|
78207
78227
|
'v5/position/confirm-pending-mmr': 5,
|
|
78208
78228
|
// account
|
|
78209
78229
|
'v5/account/upgrade-to-uta': 5,
|
|
@@ -78386,6 +78406,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
78386
78406
|
'131215': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
|
|
78387
78407
|
'131216': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
|
|
78388
78408
|
'131217': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
|
|
78409
|
+
'131231': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported,
|
|
78410
|
+
'131232': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported,
|
|
78389
78411
|
'131002': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
|
|
78390
78412
|
'131003': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
|
|
78391
78413
|
'131004': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError,
|
|
@@ -103696,7 +103718,16 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
103696
103718
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
103697
103719
|
const options = this.safeValue(this.options, 'fetchTickers', {});
|
|
103698
103720
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
103699
|
-
|
|
103721
|
+
let tickers = undefined;
|
|
103722
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
103723
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
103724
|
+
}
|
|
103725
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
103726
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
103727
|
+
}
|
|
103728
|
+
else {
|
|
103729
|
+
tickers = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
103730
|
+
}
|
|
103700
103731
|
return this.parseTickers(tickers, symbols, params);
|
|
103701
103732
|
}
|
|
103702
103733
|
async fetchTicker(symbol, params = {}) {
|
|
@@ -103716,7 +103747,16 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
103716
103747
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
103717
103748
|
const options = this.safeValue(this.options, 'fetchTicker', {});
|
|
103718
103749
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
103719
|
-
|
|
103750
|
+
let ticker = undefined;
|
|
103751
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
103752
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
103753
|
+
}
|
|
103754
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
103755
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
103756
|
+
}
|
|
103757
|
+
else {
|
|
103758
|
+
ticker = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
103759
|
+
}
|
|
103720
103760
|
return this.parseTicker(ticker, market);
|
|
103721
103761
|
}
|
|
103722
103762
|
parseTicker(ticker, market = undefined) {
|
|
@@ -110919,14 +110959,14 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
110919
110959
|
const markets = this.markets_by_id[symbol];
|
|
110920
110960
|
return markets[0];
|
|
110921
110961
|
}
|
|
110922
|
-
else if ((symbol.
|
|
110962
|
+
else if ((symbol.endsWith('-C')) || (symbol.endsWith('-P')) || (symbol.startsWith('C-')) || (symbol.startsWith('P-'))) {
|
|
110923
110963
|
return this.createExpiredOptionMarket(symbol);
|
|
110924
110964
|
}
|
|
110925
110965
|
}
|
|
110926
110966
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' does not have market symbol ' + symbol);
|
|
110927
110967
|
}
|
|
110928
110968
|
safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
|
|
110929
|
-
const isOption = (marketId !== undefined) && ((marketId.
|
|
110969
|
+
const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')) || (marketId.startsWith('C-')) || (marketId.startsWith('P-')));
|
|
110930
110970
|
if (isOption && !(marketId in this.markets_by_id)) {
|
|
110931
110971
|
// handle expired option contracts
|
|
110932
110972
|
return this.createExpiredOptionMarket(marketId);
|
|
@@ -142514,8 +142554,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142514
142554
|
let response = undefined;
|
|
142515
142555
|
const stop = this.safeValue(params, 'stop');
|
|
142516
142556
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
142517
|
-
|
|
142518
|
-
|
|
142557
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
142558
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
142559
|
+
if (stop || stopLossTakeProfit || trailing) {
|
|
142519
142560
|
if (limit !== undefined) {
|
|
142520
142561
|
request['page_size'] = limit;
|
|
142521
142562
|
}
|
|
@@ -142542,6 +142583,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142542
142583
|
else if (stopLossTakeProfit) {
|
|
142543
142584
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslHisorders(this.extend(request, params));
|
|
142544
142585
|
}
|
|
142586
|
+
else if (trailing) {
|
|
142587
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackHisorders(this.extend(request, params));
|
|
142588
|
+
}
|
|
142545
142589
|
else {
|
|
142546
142590
|
response = await this.contractPrivatePostLinearSwapApiV3SwapHisorders(this.extend(request, params));
|
|
142547
142591
|
}
|
|
@@ -142553,6 +142597,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142553
142597
|
else if (stopLossTakeProfit) {
|
|
142554
142598
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders(this.extend(request, params));
|
|
142555
142599
|
}
|
|
142600
|
+
else if (trailing) {
|
|
142601
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackHisorders(this.extend(request, params));
|
|
142602
|
+
}
|
|
142556
142603
|
else {
|
|
142557
142604
|
response = await this.contractPrivatePostLinearSwapApiV3SwapCrossHisorders(this.extend(request, params));
|
|
142558
142605
|
}
|
|
@@ -142566,6 +142613,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142566
142613
|
else if (stopLossTakeProfit) {
|
|
142567
142614
|
response = await this.contractPrivatePostSwapApiV1SwapTpslHisorders(this.extend(request, params));
|
|
142568
142615
|
}
|
|
142616
|
+
else if (trailing) {
|
|
142617
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackHisorders(this.extend(request, params));
|
|
142618
|
+
}
|
|
142569
142619
|
else {
|
|
142570
142620
|
response = await this.contractPrivatePostSwapApiV3SwapHisorders(this.extend(request, params));
|
|
142571
142621
|
}
|
|
@@ -142578,6 +142628,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142578
142628
|
else if (stopLossTakeProfit) {
|
|
142579
142629
|
response = await this.contractPrivatePostApiV1ContractTpslHisorders(this.extend(request, params));
|
|
142580
142630
|
}
|
|
142631
|
+
else if (trailing) {
|
|
142632
|
+
response = await this.contractPrivatePostApiV1ContractTrackHisorders(this.extend(request, params));
|
|
142633
|
+
}
|
|
142581
142634
|
else {
|
|
142582
142635
|
response = await this.contractPrivatePostApiV3ContractHisorders(this.extend(request, params));
|
|
142583
142636
|
}
|
|
@@ -142755,6 +142808,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142755
142808
|
* @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
142756
142809
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
142757
142810
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
142811
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
142758
142812
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
142759
142813
|
*/
|
|
142760
142814
|
await this.loadMarkets();
|
|
@@ -142827,6 +142881,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142827
142881
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
142828
142882
|
* @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
142829
142883
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
142884
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
142830
142885
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
142831
142886
|
*/
|
|
142832
142887
|
await this.loadMarkets();
|
|
@@ -142874,7 +142929,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142874
142929
|
request['contract_code'] = market['id'];
|
|
142875
142930
|
const stop = this.safeValue(params, 'stop');
|
|
142876
142931
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
142877
|
-
|
|
142932
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
142933
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
142878
142934
|
if (market['linear']) {
|
|
142879
142935
|
let marginMode = undefined;
|
|
142880
142936
|
[marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
@@ -142886,6 +142942,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142886
142942
|
else if (stopLossTakeProfit) {
|
|
142887
142943
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOpenorders(this.extend(request, params));
|
|
142888
142944
|
}
|
|
142945
|
+
else if (trailing) {
|
|
142946
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOpenorders(this.extend(request, params));
|
|
142947
|
+
}
|
|
142889
142948
|
else {
|
|
142890
142949
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOpenorders(this.extend(request, params));
|
|
142891
142950
|
}
|
|
@@ -142897,6 +142956,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142897
142956
|
else if (stopLossTakeProfit) {
|
|
142898
142957
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders(this.extend(request, params));
|
|
142899
142958
|
}
|
|
142959
|
+
else if (trailing) {
|
|
142960
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders(this.extend(request, params));
|
|
142961
|
+
}
|
|
142900
142962
|
else {
|
|
142901
142963
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOpenorders(this.extend(request, params));
|
|
142902
142964
|
}
|
|
@@ -142910,6 +142972,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142910
142972
|
else if (stopLossTakeProfit) {
|
|
142911
142973
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOpenorders(this.extend(request, params));
|
|
142912
142974
|
}
|
|
142975
|
+
else if (trailing) {
|
|
142976
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOpenorders(this.extend(request, params));
|
|
142977
|
+
}
|
|
142913
142978
|
else {
|
|
142914
142979
|
response = await this.contractPrivatePostSwapApiV1SwapOpenorders(this.extend(request, params));
|
|
142915
142980
|
}
|
|
@@ -142922,6 +142987,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
142922
142987
|
else if (stopLossTakeProfit) {
|
|
142923
142988
|
response = await this.contractPrivatePostApiV1ContractTpslOpenorders(this.extend(request, params));
|
|
142924
142989
|
}
|
|
142990
|
+
else if (trailing) {
|
|
142991
|
+
response = await this.contractPrivatePostApiV1ContractTrackOpenorders(this.extend(request, params));
|
|
142992
|
+
}
|
|
142925
142993
|
else {
|
|
142926
142994
|
response = await this.contractPrivatePostApiV1ContractOpenorders(this.extend(request, params));
|
|
142927
142995
|
}
|
|
@@ -143073,6 +143141,45 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143073
143141
|
// "ts": 1683179527011
|
|
143074
143142
|
// }
|
|
143075
143143
|
//
|
|
143144
|
+
// trailing
|
|
143145
|
+
//
|
|
143146
|
+
// {
|
|
143147
|
+
// "status": "ok",
|
|
143148
|
+
// "data": {
|
|
143149
|
+
// "orders": [
|
|
143150
|
+
// {
|
|
143151
|
+
// "contract_type": "swap",
|
|
143152
|
+
// "business_type": "swap",
|
|
143153
|
+
// "pair": "BTC-USDT",
|
|
143154
|
+
// "symbol": "BTC",
|
|
143155
|
+
// "contract_code": "BTC-USDT",
|
|
143156
|
+
// "volume": 1.000000000000000000,
|
|
143157
|
+
// "order_type": 1,
|
|
143158
|
+
// "direction": "sell",
|
|
143159
|
+
// "offset": "close",
|
|
143160
|
+
// "lever_rate": 1,
|
|
143161
|
+
// "order_id": 1192021437253877761,
|
|
143162
|
+
// "order_id_str": "1192021437253877761",
|
|
143163
|
+
// "order_source": "api",
|
|
143164
|
+
// "created_at": 1704241657328,
|
|
143165
|
+
// "order_price_type": "formula_price",
|
|
143166
|
+
// "status": 2,
|
|
143167
|
+
// "callback_rate": 0.050000000000000000,
|
|
143168
|
+
// "active_price": 50000.000000000000000000,
|
|
143169
|
+
// "is_active": 0,
|
|
143170
|
+
// "margin_mode": "cross",
|
|
143171
|
+
// "margin_account": "USDT",
|
|
143172
|
+
// "trade_partition": "USDT",
|
|
143173
|
+
// "reduce_only": 1
|
|
143174
|
+
// },
|
|
143175
|
+
// ],
|
|
143176
|
+
// "total_page": 1,
|
|
143177
|
+
// "current_page": 1,
|
|
143178
|
+
// "total_size": 2
|
|
143179
|
+
// },
|
|
143180
|
+
// "ts": 1704242440106
|
|
143181
|
+
// }
|
|
143182
|
+
//
|
|
143076
143183
|
let orders = this.safeValue(response, 'data');
|
|
143077
143184
|
if (!Array.isArray(orders)) {
|
|
143078
143185
|
orders = this.safeValue(orders, 'orders', []);
|
|
@@ -143332,6 +143439,33 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143332
143439
|
// "trade_partition": "USDT"
|
|
143333
143440
|
// }
|
|
143334
143441
|
//
|
|
143442
|
+
// trailing: fetchOpenOrders
|
|
143443
|
+
//
|
|
143444
|
+
// {
|
|
143445
|
+
// "contract_type": "swap",
|
|
143446
|
+
// "business_type": "swap",
|
|
143447
|
+
// "pair": "BTC-USDT",
|
|
143448
|
+
// "symbol": "BTC",
|
|
143449
|
+
// "contract_code": "BTC-USDT",
|
|
143450
|
+
// "volume": 1.000000000000000000,
|
|
143451
|
+
// "order_type": 1,
|
|
143452
|
+
// "direction": "sell",
|
|
143453
|
+
// "offset": "close",
|
|
143454
|
+
// "lever_rate": 1,
|
|
143455
|
+
// "order_id": 1192021437253877761,
|
|
143456
|
+
// "order_id_str": "1192021437253877761",
|
|
143457
|
+
// "order_source": "api",
|
|
143458
|
+
// "created_at": 1704241657328,
|
|
143459
|
+
// "order_price_type": "formula_price",
|
|
143460
|
+
// "status": 2,
|
|
143461
|
+
// "callback_rate": 0.050000000000000000,
|
|
143462
|
+
// "active_price": 50000.000000000000000000,
|
|
143463
|
+
// "is_active": 0,
|
|
143464
|
+
// "margin_mode": "cross",
|
|
143465
|
+
// "margin_account": "USDT",
|
|
143466
|
+
// "trade_partition": "USDT",
|
|
143467
|
+
// "reduce_only": 1
|
|
143468
|
+
// }
|
|
143335
143469
|
//
|
|
143336
143470
|
// trigger: fetchOrders
|
|
143337
143471
|
//
|
|
@@ -143676,6 +143810,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143676
143810
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
143677
143811
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
143678
143812
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
143813
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
143814
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
143679
143815
|
* @returns {object} request to be sent to the exchange
|
|
143680
143816
|
*/
|
|
143681
143817
|
const market = this.market(symbol);
|
|
@@ -143699,6 +143835,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143699
143835
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
143700
143836
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
143701
143837
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
143838
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
|
|
143839
|
+
const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
|
|
143840
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
143702
143841
|
const isStop = triggerPrice !== undefined;
|
|
143703
143842
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
143704
143843
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
@@ -143726,6 +143865,12 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143726
143865
|
}
|
|
143727
143866
|
}
|
|
143728
143867
|
}
|
|
143868
|
+
else if (isTrailingPercentOrder) {
|
|
143869
|
+
const trailingPercentString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
|
|
143870
|
+
request['callback_rate'] = this.parseToNumeric(trailingPercentString);
|
|
143871
|
+
request['active_price'] = trailingTriggerPrice;
|
|
143872
|
+
request['order_price_type'] = this.safeString(params, 'order_price_type', 'formula_price');
|
|
143873
|
+
}
|
|
143729
143874
|
else {
|
|
143730
143875
|
const clientOrderId = this.safeInteger2(params, 'client_order_id', 'clientOrderId');
|
|
143731
143876
|
if (clientOrderId !== undefined) {
|
|
@@ -143737,7 +143882,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143737
143882
|
}
|
|
143738
143883
|
}
|
|
143739
143884
|
if (!isStopLossTriggerOrder && !isTakeProfitTriggerOrder) {
|
|
143740
|
-
const leverRate = this.
|
|
143885
|
+
const leverRate = this.safeIntegerN(params, ['leverRate', 'lever_rate', 'leverage'], 1);
|
|
143741
143886
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only', false);
|
|
143742
143887
|
const openOrClose = (reduceOnly) ? 'close' : 'open';
|
|
143743
143888
|
const offset = this.safeString(params, 'offset', openOrClose);
|
|
@@ -143746,12 +143891,14 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143746
143891
|
request['reduce_only'] = 1;
|
|
143747
143892
|
}
|
|
143748
143893
|
request['lever_rate'] = leverRate;
|
|
143749
|
-
|
|
143894
|
+
if (!isTrailingPercentOrder) {
|
|
143895
|
+
request['order_price_type'] = type;
|
|
143896
|
+
}
|
|
143750
143897
|
}
|
|
143751
143898
|
const broker = this.safeValue(this.options, 'broker', {});
|
|
143752
143899
|
const brokerId = this.safeString(broker, 'id');
|
|
143753
143900
|
request['channel_code'] = brokerId;
|
|
143754
|
-
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
|
|
143901
|
+
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
|
|
143755
143902
|
return this.extend(request, params);
|
|
143756
143903
|
}
|
|
143757
143904
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -143784,6 +143931,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143784
143931
|
* @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
|
|
143785
143932
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
143786
143933
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
143934
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
143935
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
143787
143936
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
143788
143937
|
*/
|
|
143789
143938
|
await this.loadMarkets();
|
|
@@ -143791,11 +143940,16 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143791
143940
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
143792
143941
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
143793
143942
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
143943
|
+
const trailingPercent = this.safeNumber(params, 'trailingPercent');
|
|
143944
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
143794
143945
|
const isStop = triggerPrice !== undefined;
|
|
143795
143946
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
143796
143947
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
143797
143948
|
let response = undefined;
|
|
143798
143949
|
if (market['spot']) {
|
|
143950
|
+
if (isTrailingPercentOrder) {
|
|
143951
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createOrder() does not support trailing orders for spot markets');
|
|
143952
|
+
}
|
|
143799
143953
|
const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
|
|
143800
143954
|
response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
|
|
143801
143955
|
}
|
|
@@ -143812,6 +143966,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143812
143966
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
143813
143967
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest);
|
|
143814
143968
|
}
|
|
143969
|
+
else if (isTrailingPercentOrder) {
|
|
143970
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(contractRequest);
|
|
143971
|
+
}
|
|
143815
143972
|
else {
|
|
143816
143973
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest);
|
|
143817
143974
|
}
|
|
@@ -143823,6 +143980,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143823
143980
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
143824
143981
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest);
|
|
143825
143982
|
}
|
|
143983
|
+
else if (isTrailingPercentOrder) {
|
|
143984
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder(contractRequest);
|
|
143985
|
+
}
|
|
143826
143986
|
else {
|
|
143827
143987
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(contractRequest);
|
|
143828
143988
|
}
|
|
@@ -143836,6 +143996,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143836
143996
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
143837
143997
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest);
|
|
143838
143998
|
}
|
|
143999
|
+
else if (isTrailingPercentOrder) {
|
|
144000
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOrder(contractRequest);
|
|
144001
|
+
}
|
|
143839
144002
|
else {
|
|
143840
144003
|
response = await this.contractPrivatePostSwapApiV1SwapOrder(contractRequest);
|
|
143841
144004
|
}
|
|
@@ -143847,6 +144010,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
143847
144010
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
143848
144011
|
response = await this.contractPrivatePostApiV1ContractTpslOrder(contractRequest);
|
|
143849
144012
|
}
|
|
144013
|
+
else if (isTrailingPercentOrder) {
|
|
144014
|
+
response = await this.contractPrivatePostApiV1ContractTrackOrder(contractRequest);
|
|
144015
|
+
}
|
|
143850
144016
|
else {
|
|
143851
144017
|
response = await this.contractPrivatePostApiV1ContractOrder(contractRequest);
|
|
143852
144018
|
}
|
|
@@ -144064,8 +144230,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144064
144230
|
* @param {string} id order id
|
|
144065
144231
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
144066
144232
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
144067
|
-
* @param {
|
|
144068
|
-
* @param {
|
|
144233
|
+
* @param {boolean} [params.stop] *contract only* if the order is a stop trigger order or not
|
|
144234
|
+
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the order is a stop-loss or take-profit order
|
|
144235
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel a trailing order
|
|
144069
144236
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
144070
144237
|
*/
|
|
144071
144238
|
await this.loadMarkets();
|
|
@@ -144120,7 +144287,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144120
144287
|
}
|
|
144121
144288
|
const stop = this.safeValue(params, 'stop');
|
|
144122
144289
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
144123
|
-
|
|
144290
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
144291
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
144124
144292
|
if (market['linear']) {
|
|
144125
144293
|
let marginMode = undefined;
|
|
144126
144294
|
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
@@ -144132,6 +144300,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144132
144300
|
else if (stopLossTakeProfit) {
|
|
144133
144301
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancel(this.extend(request, params));
|
|
144134
144302
|
}
|
|
144303
|
+
else if (trailing) {
|
|
144304
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancel(this.extend(request, params));
|
|
144305
|
+
}
|
|
144135
144306
|
else {
|
|
144136
144307
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCancel(this.extend(request, params));
|
|
144137
144308
|
}
|
|
@@ -144143,6 +144314,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144143
144314
|
else if (stopLossTakeProfit) {
|
|
144144
144315
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(this.extend(request, params));
|
|
144145
144316
|
}
|
|
144317
|
+
else if (trailing) {
|
|
144318
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancel(this.extend(request, params));
|
|
144319
|
+
}
|
|
144146
144320
|
else {
|
|
144147
144321
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancel(this.extend(request, params));
|
|
144148
144322
|
}
|
|
@@ -144156,6 +144330,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144156
144330
|
else if (stopLossTakeProfit) {
|
|
144157
144331
|
response = await this.contractPrivatePostSwapApiV1SwapTpslCancel(this.extend(request, params));
|
|
144158
144332
|
}
|
|
144333
|
+
else if (trailing) {
|
|
144334
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackCancel(this.extend(request, params));
|
|
144335
|
+
}
|
|
144159
144336
|
else {
|
|
144160
144337
|
response = await this.contractPrivatePostSwapApiV1SwapCancel(this.extend(request, params));
|
|
144161
144338
|
}
|
|
@@ -144167,6 +144344,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144167
144344
|
else if (stopLossTakeProfit) {
|
|
144168
144345
|
response = await this.contractPrivatePostApiV1ContractTpslCancel(this.extend(request, params));
|
|
144169
144346
|
}
|
|
144347
|
+
else if (trailing) {
|
|
144348
|
+
response = await this.contractPrivatePostApiV1ContractTrackCancel(this.extend(request, params));
|
|
144349
|
+
}
|
|
144170
144350
|
else {
|
|
144171
144351
|
response = await this.contractPrivatePostApiV1ContractCancel(this.extend(request, params));
|
|
144172
144352
|
}
|
|
@@ -144389,8 +144569,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144389
144569
|
* @description cancel all open orders
|
|
144390
144570
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
144391
144571
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
144392
|
-
* @param {
|
|
144393
|
-
* @param {
|
|
144572
|
+
* @param {boolean} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
144573
|
+
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
144574
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel all trailing orders
|
|
144394
144575
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
144395
144576
|
*/
|
|
144396
144577
|
await this.loadMarkets();
|
|
@@ -144431,7 +144612,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144431
144612
|
request['contract_code'] = market['id'];
|
|
144432
144613
|
const stop = this.safeValue(params, 'stop');
|
|
144433
144614
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
144434
|
-
|
|
144615
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
144616
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
144435
144617
|
if (market['linear']) {
|
|
144436
144618
|
let marginMode = undefined;
|
|
144437
144619
|
[marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
|
|
@@ -144443,6 +144625,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144443
144625
|
else if (stopLossTakeProfit) {
|
|
144444
144626
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(this.extend(request, params));
|
|
144445
144627
|
}
|
|
144628
|
+
else if (trailing) {
|
|
144629
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancelall(this.extend(request, params));
|
|
144630
|
+
}
|
|
144446
144631
|
else {
|
|
144447
144632
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCancelall(this.extend(request, params));
|
|
144448
144633
|
}
|
|
@@ -144454,6 +144639,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144454
144639
|
else if (stopLossTakeProfit) {
|
|
144455
144640
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(this.extend(request, params));
|
|
144456
144641
|
}
|
|
144642
|
+
else if (trailing) {
|
|
144643
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancelall(this.extend(request, params));
|
|
144644
|
+
}
|
|
144457
144645
|
else {
|
|
144458
144646
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(this.extend(request, params));
|
|
144459
144647
|
}
|
|
@@ -144467,6 +144655,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144467
144655
|
else if (stopLossTakeProfit) {
|
|
144468
144656
|
response = await this.contractPrivatePostSwapApiV1SwapTpslCancelall(this.extend(request, params));
|
|
144469
144657
|
}
|
|
144658
|
+
else if (trailing) {
|
|
144659
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackCancelall(this.extend(request, params));
|
|
144660
|
+
}
|
|
144470
144661
|
else {
|
|
144471
144662
|
response = await this.contractPrivatePostSwapApiV1SwapCancelall(this.extend(request, params));
|
|
144472
144663
|
}
|
|
@@ -144478,6 +144669,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
144478
144669
|
else if (stopLossTakeProfit) {
|
|
144479
144670
|
response = await this.contractPrivatePostApiV1ContractTpslCancelall(this.extend(request, params));
|
|
144480
144671
|
}
|
|
144672
|
+
else if (trailing) {
|
|
144673
|
+
response = await this.contractPrivatePostApiV1ContractTrackCancelall(this.extend(request, params));
|
|
144674
|
+
}
|
|
144481
144675
|
else {
|
|
144482
144676
|
response = await this.contractPrivatePostApiV1ContractCancelall(this.extend(request, params));
|
|
144483
144677
|
}
|
|
@@ -192561,6 +192755,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
192561
192755
|
* @description fetches information on multiple closed orders made by the user
|
|
192562
192756
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
|
|
192563
192757
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
|
|
192758
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
|
|
192564
192759
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
192565
192760
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
192566
192761
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -192570,6 +192765,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
192570
192765
|
* @param {string} [params.algoId] Algo ID "'433845797218942976'"
|
|
192571
192766
|
* @param {int} [params.until] timestamp in ms to fetch orders for
|
|
192572
192767
|
* @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)
|
|
192768
|
+
* @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
|
|
192573
192769
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
192574
192770
|
*/
|
|
192575
192771
|
await this.loadMarkets();
|
|
@@ -192632,6 +192828,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
192632
192828
|
if (method === 'privateGetTradeOrdersAlgoHistory') {
|
|
192633
192829
|
response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
|
|
192634
192830
|
}
|
|
192831
|
+
else if (method === 'privateGetTradeOrdersHistoryArchive') {
|
|
192832
|
+
response = await this.privateGetTradeOrdersHistoryArchive(this.extend(request, send));
|
|
192833
|
+
}
|
|
192635
192834
|
else {
|
|
192636
192835
|
response = await this.privateGetTradeOrdersHistory(this.extend(request, send));
|
|
192637
192836
|
}
|
|
@@ -198249,7 +198448,8 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
198249
198448
|
'34003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
|
|
198250
198449
|
'35104': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
|
|
198251
198450
|
'39995': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded,
|
|
198252
|
-
'39996': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
|
|
198451
|
+
'39996': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
|
|
198452
|
+
'39997': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol, // {"code":39997,"msg":"Symbol not listed sMOVRUSDT","data":null}
|
|
198253
198453
|
},
|
|
198254
198454
|
'broad': {
|
|
198255
198455
|
'401 Insufficient privilege': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
|
|
@@ -199295,7 +199495,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
199295
199495
|
if (type === 'spot') {
|
|
199296
199496
|
response = await this.v1GetMdSpotTicker24hrAll(query);
|
|
199297
199497
|
}
|
|
199298
|
-
else if (subType === 'inverse' || market
|
|
199498
|
+
else if (subType === 'inverse' || this.safeString(market, 'settle') === 'USD') {
|
|
199299
199499
|
response = await this.v1GetMdTicker24hrAll(query);
|
|
199300
199500
|
}
|
|
199301
199501
|
else {
|
|
@@ -291518,7 +291718,7 @@ SOFTWARE.
|
|
|
291518
291718
|
|
|
291519
291719
|
//-----------------------------------------------------------------------------
|
|
291520
291720
|
// this is updated by vss.js when building
|
|
291521
|
-
const version = '4.2.
|
|
291721
|
+
const version = '4.2.5';
|
|
291522
291722
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
291523
291723
|
//-----------------------------------------------------------------------------
|
|
291524
291724
|
|