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/cjs/src/htx.js
CHANGED
|
@@ -3852,8 +3852,9 @@ class htx extends htx$1 {
|
|
|
3852
3852
|
let response = undefined;
|
|
3853
3853
|
const stop = this.safeValue(params, 'stop');
|
|
3854
3854
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
3855
|
-
|
|
3856
|
-
|
|
3855
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
3856
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
3857
|
+
if (stop || stopLossTakeProfit || trailing) {
|
|
3857
3858
|
if (limit !== undefined) {
|
|
3858
3859
|
request['page_size'] = limit;
|
|
3859
3860
|
}
|
|
@@ -3880,6 +3881,9 @@ class htx extends htx$1 {
|
|
|
3880
3881
|
else if (stopLossTakeProfit) {
|
|
3881
3882
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslHisorders(this.extend(request, params));
|
|
3882
3883
|
}
|
|
3884
|
+
else if (trailing) {
|
|
3885
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackHisorders(this.extend(request, params));
|
|
3886
|
+
}
|
|
3883
3887
|
else {
|
|
3884
3888
|
response = await this.contractPrivatePostLinearSwapApiV3SwapHisorders(this.extend(request, params));
|
|
3885
3889
|
}
|
|
@@ -3891,6 +3895,9 @@ class htx extends htx$1 {
|
|
|
3891
3895
|
else if (stopLossTakeProfit) {
|
|
3892
3896
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders(this.extend(request, params));
|
|
3893
3897
|
}
|
|
3898
|
+
else if (trailing) {
|
|
3899
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackHisorders(this.extend(request, params));
|
|
3900
|
+
}
|
|
3894
3901
|
else {
|
|
3895
3902
|
response = await this.contractPrivatePostLinearSwapApiV3SwapCrossHisorders(this.extend(request, params));
|
|
3896
3903
|
}
|
|
@@ -3904,6 +3911,9 @@ class htx extends htx$1 {
|
|
|
3904
3911
|
else if (stopLossTakeProfit) {
|
|
3905
3912
|
response = await this.contractPrivatePostSwapApiV1SwapTpslHisorders(this.extend(request, params));
|
|
3906
3913
|
}
|
|
3914
|
+
else if (trailing) {
|
|
3915
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackHisorders(this.extend(request, params));
|
|
3916
|
+
}
|
|
3907
3917
|
else {
|
|
3908
3918
|
response = await this.contractPrivatePostSwapApiV3SwapHisorders(this.extend(request, params));
|
|
3909
3919
|
}
|
|
@@ -3916,6 +3926,9 @@ class htx extends htx$1 {
|
|
|
3916
3926
|
else if (stopLossTakeProfit) {
|
|
3917
3927
|
response = await this.contractPrivatePostApiV1ContractTpslHisorders(this.extend(request, params));
|
|
3918
3928
|
}
|
|
3929
|
+
else if (trailing) {
|
|
3930
|
+
response = await this.contractPrivatePostApiV1ContractTrackHisorders(this.extend(request, params));
|
|
3931
|
+
}
|
|
3919
3932
|
else {
|
|
3920
3933
|
response = await this.contractPrivatePostApiV3ContractHisorders(this.extend(request, params));
|
|
3921
3934
|
}
|
|
@@ -4093,6 +4106,7 @@ class htx extends htx$1 {
|
|
|
4093
4106
|
* @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
4094
4107
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
4095
4108
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4109
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
4096
4110
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4097
4111
|
*/
|
|
4098
4112
|
await this.loadMarkets();
|
|
@@ -4165,6 +4179,7 @@ class htx extends htx$1 {
|
|
|
4165
4179
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4166
4180
|
* @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
4167
4181
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
4182
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
4168
4183
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4169
4184
|
*/
|
|
4170
4185
|
await this.loadMarkets();
|
|
@@ -4212,7 +4227,8 @@ class htx extends htx$1 {
|
|
|
4212
4227
|
request['contract_code'] = market['id'];
|
|
4213
4228
|
const stop = this.safeValue(params, 'stop');
|
|
4214
4229
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
4215
|
-
|
|
4230
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
4231
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
4216
4232
|
if (market['linear']) {
|
|
4217
4233
|
let marginMode = undefined;
|
|
4218
4234
|
[marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
@@ -4224,6 +4240,9 @@ class htx extends htx$1 {
|
|
|
4224
4240
|
else if (stopLossTakeProfit) {
|
|
4225
4241
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOpenorders(this.extend(request, params));
|
|
4226
4242
|
}
|
|
4243
|
+
else if (trailing) {
|
|
4244
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOpenorders(this.extend(request, params));
|
|
4245
|
+
}
|
|
4227
4246
|
else {
|
|
4228
4247
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOpenorders(this.extend(request, params));
|
|
4229
4248
|
}
|
|
@@ -4235,6 +4254,9 @@ class htx extends htx$1 {
|
|
|
4235
4254
|
else if (stopLossTakeProfit) {
|
|
4236
4255
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders(this.extend(request, params));
|
|
4237
4256
|
}
|
|
4257
|
+
else if (trailing) {
|
|
4258
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders(this.extend(request, params));
|
|
4259
|
+
}
|
|
4238
4260
|
else {
|
|
4239
4261
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOpenorders(this.extend(request, params));
|
|
4240
4262
|
}
|
|
@@ -4248,6 +4270,9 @@ class htx extends htx$1 {
|
|
|
4248
4270
|
else if (stopLossTakeProfit) {
|
|
4249
4271
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOpenorders(this.extend(request, params));
|
|
4250
4272
|
}
|
|
4273
|
+
else if (trailing) {
|
|
4274
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOpenorders(this.extend(request, params));
|
|
4275
|
+
}
|
|
4251
4276
|
else {
|
|
4252
4277
|
response = await this.contractPrivatePostSwapApiV1SwapOpenorders(this.extend(request, params));
|
|
4253
4278
|
}
|
|
@@ -4260,6 +4285,9 @@ class htx extends htx$1 {
|
|
|
4260
4285
|
else if (stopLossTakeProfit) {
|
|
4261
4286
|
response = await this.contractPrivatePostApiV1ContractTpslOpenorders(this.extend(request, params));
|
|
4262
4287
|
}
|
|
4288
|
+
else if (trailing) {
|
|
4289
|
+
response = await this.contractPrivatePostApiV1ContractTrackOpenorders(this.extend(request, params));
|
|
4290
|
+
}
|
|
4263
4291
|
else {
|
|
4264
4292
|
response = await this.contractPrivatePostApiV1ContractOpenorders(this.extend(request, params));
|
|
4265
4293
|
}
|
|
@@ -4411,6 +4439,45 @@ class htx extends htx$1 {
|
|
|
4411
4439
|
// "ts": 1683179527011
|
|
4412
4440
|
// }
|
|
4413
4441
|
//
|
|
4442
|
+
// trailing
|
|
4443
|
+
//
|
|
4444
|
+
// {
|
|
4445
|
+
// "status": "ok",
|
|
4446
|
+
// "data": {
|
|
4447
|
+
// "orders": [
|
|
4448
|
+
// {
|
|
4449
|
+
// "contract_type": "swap",
|
|
4450
|
+
// "business_type": "swap",
|
|
4451
|
+
// "pair": "BTC-USDT",
|
|
4452
|
+
// "symbol": "BTC",
|
|
4453
|
+
// "contract_code": "BTC-USDT",
|
|
4454
|
+
// "volume": 1.000000000000000000,
|
|
4455
|
+
// "order_type": 1,
|
|
4456
|
+
// "direction": "sell",
|
|
4457
|
+
// "offset": "close",
|
|
4458
|
+
// "lever_rate": 1,
|
|
4459
|
+
// "order_id": 1192021437253877761,
|
|
4460
|
+
// "order_id_str": "1192021437253877761",
|
|
4461
|
+
// "order_source": "api",
|
|
4462
|
+
// "created_at": 1704241657328,
|
|
4463
|
+
// "order_price_type": "formula_price",
|
|
4464
|
+
// "status": 2,
|
|
4465
|
+
// "callback_rate": 0.050000000000000000,
|
|
4466
|
+
// "active_price": 50000.000000000000000000,
|
|
4467
|
+
// "is_active": 0,
|
|
4468
|
+
// "margin_mode": "cross",
|
|
4469
|
+
// "margin_account": "USDT",
|
|
4470
|
+
// "trade_partition": "USDT",
|
|
4471
|
+
// "reduce_only": 1
|
|
4472
|
+
// },
|
|
4473
|
+
// ],
|
|
4474
|
+
// "total_page": 1,
|
|
4475
|
+
// "current_page": 1,
|
|
4476
|
+
// "total_size": 2
|
|
4477
|
+
// },
|
|
4478
|
+
// "ts": 1704242440106
|
|
4479
|
+
// }
|
|
4480
|
+
//
|
|
4414
4481
|
let orders = this.safeValue(response, 'data');
|
|
4415
4482
|
if (!Array.isArray(orders)) {
|
|
4416
4483
|
orders = this.safeValue(orders, 'orders', []);
|
|
@@ -4670,6 +4737,33 @@ class htx extends htx$1 {
|
|
|
4670
4737
|
// "trade_partition": "USDT"
|
|
4671
4738
|
// }
|
|
4672
4739
|
//
|
|
4740
|
+
// trailing: fetchOpenOrders
|
|
4741
|
+
//
|
|
4742
|
+
// {
|
|
4743
|
+
// "contract_type": "swap",
|
|
4744
|
+
// "business_type": "swap",
|
|
4745
|
+
// "pair": "BTC-USDT",
|
|
4746
|
+
// "symbol": "BTC",
|
|
4747
|
+
// "contract_code": "BTC-USDT",
|
|
4748
|
+
// "volume": 1.000000000000000000,
|
|
4749
|
+
// "order_type": 1,
|
|
4750
|
+
// "direction": "sell",
|
|
4751
|
+
// "offset": "close",
|
|
4752
|
+
// "lever_rate": 1,
|
|
4753
|
+
// "order_id": 1192021437253877761,
|
|
4754
|
+
// "order_id_str": "1192021437253877761",
|
|
4755
|
+
// "order_source": "api",
|
|
4756
|
+
// "created_at": 1704241657328,
|
|
4757
|
+
// "order_price_type": "formula_price",
|
|
4758
|
+
// "status": 2,
|
|
4759
|
+
// "callback_rate": 0.050000000000000000,
|
|
4760
|
+
// "active_price": 50000.000000000000000000,
|
|
4761
|
+
// "is_active": 0,
|
|
4762
|
+
// "margin_mode": "cross",
|
|
4763
|
+
// "margin_account": "USDT",
|
|
4764
|
+
// "trade_partition": "USDT",
|
|
4765
|
+
// "reduce_only": 1
|
|
4766
|
+
// }
|
|
4673
4767
|
//
|
|
4674
4768
|
// trigger: fetchOrders
|
|
4675
4769
|
//
|
|
@@ -5014,6 +5108,8 @@ class htx extends htx$1 {
|
|
|
5014
5108
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
5015
5109
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5016
5110
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
5111
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5112
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5017
5113
|
* @returns {object} request to be sent to the exchange
|
|
5018
5114
|
*/
|
|
5019
5115
|
const market = this.market(symbol);
|
|
@@ -5037,6 +5133,9 @@ class htx extends htx$1 {
|
|
|
5037
5133
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
5038
5134
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
5039
5135
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
5136
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
|
|
5137
|
+
const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
|
|
5138
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
5040
5139
|
const isStop = triggerPrice !== undefined;
|
|
5041
5140
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
5042
5141
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
@@ -5064,6 +5163,12 @@ class htx extends htx$1 {
|
|
|
5064
5163
|
}
|
|
5065
5164
|
}
|
|
5066
5165
|
}
|
|
5166
|
+
else if (isTrailingPercentOrder) {
|
|
5167
|
+
const trailingPercentString = Precise["default"].stringDiv(trailingPercent, '100');
|
|
5168
|
+
request['callback_rate'] = this.parseToNumeric(trailingPercentString);
|
|
5169
|
+
request['active_price'] = trailingTriggerPrice;
|
|
5170
|
+
request['order_price_type'] = this.safeString(params, 'order_price_type', 'formula_price');
|
|
5171
|
+
}
|
|
5067
5172
|
else {
|
|
5068
5173
|
const clientOrderId = this.safeInteger2(params, 'client_order_id', 'clientOrderId');
|
|
5069
5174
|
if (clientOrderId !== undefined) {
|
|
@@ -5075,7 +5180,7 @@ class htx extends htx$1 {
|
|
|
5075
5180
|
}
|
|
5076
5181
|
}
|
|
5077
5182
|
if (!isStopLossTriggerOrder && !isTakeProfitTriggerOrder) {
|
|
5078
|
-
const leverRate = this.
|
|
5183
|
+
const leverRate = this.safeIntegerN(params, ['leverRate', 'lever_rate', 'leverage'], 1);
|
|
5079
5184
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only', false);
|
|
5080
5185
|
const openOrClose = (reduceOnly) ? 'close' : 'open';
|
|
5081
5186
|
const offset = this.safeString(params, 'offset', openOrClose);
|
|
@@ -5084,12 +5189,14 @@ class htx extends htx$1 {
|
|
|
5084
5189
|
request['reduce_only'] = 1;
|
|
5085
5190
|
}
|
|
5086
5191
|
request['lever_rate'] = leverRate;
|
|
5087
|
-
|
|
5192
|
+
if (!isTrailingPercentOrder) {
|
|
5193
|
+
request['order_price_type'] = type;
|
|
5194
|
+
}
|
|
5088
5195
|
}
|
|
5089
5196
|
const broker = this.safeValue(this.options, 'broker', {});
|
|
5090
5197
|
const brokerId = this.safeString(broker, 'id');
|
|
5091
5198
|
request['channel_code'] = brokerId;
|
|
5092
|
-
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
|
|
5199
|
+
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
|
|
5093
5200
|
return this.extend(request, params);
|
|
5094
5201
|
}
|
|
5095
5202
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -5122,6 +5229,8 @@ class htx extends htx$1 {
|
|
|
5122
5229
|
* @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
|
|
5123
5230
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
5124
5231
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
5232
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5233
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5125
5234
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5126
5235
|
*/
|
|
5127
5236
|
await this.loadMarkets();
|
|
@@ -5129,11 +5238,16 @@ class htx extends htx$1 {
|
|
|
5129
5238
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
5130
5239
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
5131
5240
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
5241
|
+
const trailingPercent = this.safeNumber(params, 'trailingPercent');
|
|
5242
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
5132
5243
|
const isStop = triggerPrice !== undefined;
|
|
5133
5244
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
5134
5245
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
5135
5246
|
let response = undefined;
|
|
5136
5247
|
if (market['spot']) {
|
|
5248
|
+
if (isTrailingPercentOrder) {
|
|
5249
|
+
throw new errors.NotSupported(this.id + ' createOrder() does not support trailing orders for spot markets');
|
|
5250
|
+
}
|
|
5137
5251
|
const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
|
|
5138
5252
|
response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
|
|
5139
5253
|
}
|
|
@@ -5150,6 +5264,9 @@ class htx extends htx$1 {
|
|
|
5150
5264
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5151
5265
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest);
|
|
5152
5266
|
}
|
|
5267
|
+
else if (isTrailingPercentOrder) {
|
|
5268
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(contractRequest);
|
|
5269
|
+
}
|
|
5153
5270
|
else {
|
|
5154
5271
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest);
|
|
5155
5272
|
}
|
|
@@ -5161,6 +5278,9 @@ class htx extends htx$1 {
|
|
|
5161
5278
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5162
5279
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest);
|
|
5163
5280
|
}
|
|
5281
|
+
else if (isTrailingPercentOrder) {
|
|
5282
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder(contractRequest);
|
|
5283
|
+
}
|
|
5164
5284
|
else {
|
|
5165
5285
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(contractRequest);
|
|
5166
5286
|
}
|
|
@@ -5174,6 +5294,9 @@ class htx extends htx$1 {
|
|
|
5174
5294
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5175
5295
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest);
|
|
5176
5296
|
}
|
|
5297
|
+
else if (isTrailingPercentOrder) {
|
|
5298
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOrder(contractRequest);
|
|
5299
|
+
}
|
|
5177
5300
|
else {
|
|
5178
5301
|
response = await this.contractPrivatePostSwapApiV1SwapOrder(contractRequest);
|
|
5179
5302
|
}
|
|
@@ -5185,6 +5308,9 @@ class htx extends htx$1 {
|
|
|
5185
5308
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5186
5309
|
response = await this.contractPrivatePostApiV1ContractTpslOrder(contractRequest);
|
|
5187
5310
|
}
|
|
5311
|
+
else if (isTrailingPercentOrder) {
|
|
5312
|
+
response = await this.contractPrivatePostApiV1ContractTrackOrder(contractRequest);
|
|
5313
|
+
}
|
|
5188
5314
|
else {
|
|
5189
5315
|
response = await this.contractPrivatePostApiV1ContractOrder(contractRequest);
|
|
5190
5316
|
}
|
|
@@ -5402,8 +5528,9 @@ class htx extends htx$1 {
|
|
|
5402
5528
|
* @param {string} id order id
|
|
5403
5529
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
5404
5530
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5405
|
-
* @param {
|
|
5406
|
-
* @param {
|
|
5531
|
+
* @param {boolean} [params.stop] *contract only* if the order is a stop trigger order or not
|
|
5532
|
+
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the order is a stop-loss or take-profit order
|
|
5533
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel a trailing order
|
|
5407
5534
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5408
5535
|
*/
|
|
5409
5536
|
await this.loadMarkets();
|
|
@@ -5458,7 +5585,8 @@ class htx extends htx$1 {
|
|
|
5458
5585
|
}
|
|
5459
5586
|
const stop = this.safeValue(params, 'stop');
|
|
5460
5587
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
5461
|
-
|
|
5588
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
5589
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
5462
5590
|
if (market['linear']) {
|
|
5463
5591
|
let marginMode = undefined;
|
|
5464
5592
|
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
@@ -5470,6 +5598,9 @@ class htx extends htx$1 {
|
|
|
5470
5598
|
else if (stopLossTakeProfit) {
|
|
5471
5599
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancel(this.extend(request, params));
|
|
5472
5600
|
}
|
|
5601
|
+
else if (trailing) {
|
|
5602
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancel(this.extend(request, params));
|
|
5603
|
+
}
|
|
5473
5604
|
else {
|
|
5474
5605
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCancel(this.extend(request, params));
|
|
5475
5606
|
}
|
|
@@ -5481,6 +5612,9 @@ class htx extends htx$1 {
|
|
|
5481
5612
|
else if (stopLossTakeProfit) {
|
|
5482
5613
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(this.extend(request, params));
|
|
5483
5614
|
}
|
|
5615
|
+
else if (trailing) {
|
|
5616
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancel(this.extend(request, params));
|
|
5617
|
+
}
|
|
5484
5618
|
else {
|
|
5485
5619
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancel(this.extend(request, params));
|
|
5486
5620
|
}
|
|
@@ -5494,6 +5628,9 @@ class htx extends htx$1 {
|
|
|
5494
5628
|
else if (stopLossTakeProfit) {
|
|
5495
5629
|
response = await this.contractPrivatePostSwapApiV1SwapTpslCancel(this.extend(request, params));
|
|
5496
5630
|
}
|
|
5631
|
+
else if (trailing) {
|
|
5632
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackCancel(this.extend(request, params));
|
|
5633
|
+
}
|
|
5497
5634
|
else {
|
|
5498
5635
|
response = await this.contractPrivatePostSwapApiV1SwapCancel(this.extend(request, params));
|
|
5499
5636
|
}
|
|
@@ -5505,6 +5642,9 @@ class htx extends htx$1 {
|
|
|
5505
5642
|
else if (stopLossTakeProfit) {
|
|
5506
5643
|
response = await this.contractPrivatePostApiV1ContractTpslCancel(this.extend(request, params));
|
|
5507
5644
|
}
|
|
5645
|
+
else if (trailing) {
|
|
5646
|
+
response = await this.contractPrivatePostApiV1ContractTrackCancel(this.extend(request, params));
|
|
5647
|
+
}
|
|
5508
5648
|
else {
|
|
5509
5649
|
response = await this.contractPrivatePostApiV1ContractCancel(this.extend(request, params));
|
|
5510
5650
|
}
|
|
@@ -5727,8 +5867,9 @@ class htx extends htx$1 {
|
|
|
5727
5867
|
* @description cancel all open orders
|
|
5728
5868
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
5729
5869
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5730
|
-
* @param {
|
|
5731
|
-
* @param {
|
|
5870
|
+
* @param {boolean} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
5871
|
+
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
5872
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel all trailing orders
|
|
5732
5873
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5733
5874
|
*/
|
|
5734
5875
|
await this.loadMarkets();
|
|
@@ -5769,7 +5910,8 @@ class htx extends htx$1 {
|
|
|
5769
5910
|
request['contract_code'] = market['id'];
|
|
5770
5911
|
const stop = this.safeValue(params, 'stop');
|
|
5771
5912
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
5772
|
-
|
|
5913
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
5914
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
5773
5915
|
if (market['linear']) {
|
|
5774
5916
|
let marginMode = undefined;
|
|
5775
5917
|
[marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
|
|
@@ -5781,6 +5923,9 @@ class htx extends htx$1 {
|
|
|
5781
5923
|
else if (stopLossTakeProfit) {
|
|
5782
5924
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(this.extend(request, params));
|
|
5783
5925
|
}
|
|
5926
|
+
else if (trailing) {
|
|
5927
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancelall(this.extend(request, params));
|
|
5928
|
+
}
|
|
5784
5929
|
else {
|
|
5785
5930
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCancelall(this.extend(request, params));
|
|
5786
5931
|
}
|
|
@@ -5792,6 +5937,9 @@ class htx extends htx$1 {
|
|
|
5792
5937
|
else if (stopLossTakeProfit) {
|
|
5793
5938
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(this.extend(request, params));
|
|
5794
5939
|
}
|
|
5940
|
+
else if (trailing) {
|
|
5941
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancelall(this.extend(request, params));
|
|
5942
|
+
}
|
|
5795
5943
|
else {
|
|
5796
5944
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(this.extend(request, params));
|
|
5797
5945
|
}
|
|
@@ -5805,6 +5953,9 @@ class htx extends htx$1 {
|
|
|
5805
5953
|
else if (stopLossTakeProfit) {
|
|
5806
5954
|
response = await this.contractPrivatePostSwapApiV1SwapTpslCancelall(this.extend(request, params));
|
|
5807
5955
|
}
|
|
5956
|
+
else if (trailing) {
|
|
5957
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackCancelall(this.extend(request, params));
|
|
5958
|
+
}
|
|
5808
5959
|
else {
|
|
5809
5960
|
response = await this.contractPrivatePostSwapApiV1SwapCancelall(this.extend(request, params));
|
|
5810
5961
|
}
|
|
@@ -5816,6 +5967,9 @@ class htx extends htx$1 {
|
|
|
5816
5967
|
else if (stopLossTakeProfit) {
|
|
5817
5968
|
response = await this.contractPrivatePostApiV1ContractTpslCancelall(this.extend(request, params));
|
|
5818
5969
|
}
|
|
5970
|
+
else if (trailing) {
|
|
5971
|
+
response = await this.contractPrivatePostApiV1ContractTrackCancelall(this.extend(request, params));
|
|
5972
|
+
}
|
|
5819
5973
|
else {
|
|
5820
5974
|
response = await this.contractPrivatePostApiV1ContractCancelall(this.extend(request, params));
|
|
5821
5975
|
}
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -3903,6 +3903,7 @@ class okx extends okx$1 {
|
|
|
3903
3903
|
* @description fetches information on multiple closed orders made by the user
|
|
3904
3904
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
|
|
3905
3905
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
|
|
3906
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
|
|
3906
3907
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
3907
3908
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
3908
3909
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -3912,6 +3913,7 @@ class okx extends okx$1 {
|
|
|
3912
3913
|
* @param {string} [params.algoId] Algo ID "'433845797218942976'"
|
|
3913
3914
|
* @param {int} [params.until] timestamp in ms to fetch orders for
|
|
3914
3915
|
* @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)
|
|
3916
|
+
* @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
|
|
3915
3917
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3916
3918
|
*/
|
|
3917
3919
|
await this.loadMarkets();
|
|
@@ -3974,6 +3976,9 @@ class okx extends okx$1 {
|
|
|
3974
3976
|
if (method === 'privateGetTradeOrdersAlgoHistory') {
|
|
3975
3977
|
response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
|
|
3976
3978
|
}
|
|
3979
|
+
else if (method === 'privateGetTradeOrdersHistoryArchive') {
|
|
3980
|
+
response = await this.privateGetTradeOrdersHistoryArchive(this.extend(request, send));
|
|
3981
|
+
}
|
|
3977
3982
|
else {
|
|
3978
3983
|
response = await this.privateGetTradeOrdersHistory(this.extend(request, send));
|
|
3979
3984
|
}
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -439,7 +439,8 @@ class phemex extends phemex$1 {
|
|
|
439
439
|
'34003': errors.PermissionDenied,
|
|
440
440
|
'35104': errors.InsufficientFunds,
|
|
441
441
|
'39995': errors.RateLimitExceeded,
|
|
442
|
-
'39996': errors.PermissionDenied,
|
|
442
|
+
'39996': errors.PermissionDenied,
|
|
443
|
+
'39997': errors.BadSymbol, // {"code":39997,"msg":"Symbol not listed sMOVRUSDT","data":null}
|
|
443
444
|
},
|
|
444
445
|
'broad': {
|
|
445
446
|
'401 Insufficient privilege': errors.PermissionDenied,
|
|
@@ -1485,7 +1486,7 @@ class phemex extends phemex$1 {
|
|
|
1485
1486
|
if (type === 'spot') {
|
|
1486
1487
|
response = await this.v1GetMdSpotTicker24hrAll(query);
|
|
1487
1488
|
}
|
|
1488
|
-
else if (subType === 'inverse' || market
|
|
1489
|
+
else if (subType === 'inverse' || this.safeString(market, 'settle') === 'USD') {
|
|
1489
1490
|
response = await this.v1GetMdTicker24hrAll(query);
|
|
1490
1491
|
}
|
|
1491
1492
|
else {
|
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.4";
|
|
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.5';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -58,6 +58,7 @@ interface Exchange {
|
|
|
58
58
|
privateGetContractPrivateOrderHistory(params?: {}): Promise<implicitReturnType>;
|
|
59
59
|
privateGetContractPrivatePosition(params?: {}): Promise<implicitReturnType>;
|
|
60
60
|
privateGetContractPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
|
|
61
|
+
privateGetContractPrivateCurrentPlanOrder(params?: {}): Promise<implicitReturnType>;
|
|
61
62
|
privateGetContractPrivateTrades(params?: {}): Promise<implicitReturnType>;
|
|
62
63
|
privatePostAccountSubAccountMainV1SubToMain(params?: {}): Promise<implicitReturnType>;
|
|
63
64
|
privatePostAccountSubAccountSubV1SubToMain(params?: {}): Promise<implicitReturnType>;
|
|
@@ -113,6 +113,7 @@ interface Exchange {
|
|
|
113
113
|
privateGetV5PositionList(params?: {}): Promise<implicitReturnType>;
|
|
114
114
|
privateGetV5ExecutionList(params?: {}): Promise<implicitReturnType>;
|
|
115
115
|
privateGetV5PositionClosedPnl(params?: {}): Promise<implicitReturnType>;
|
|
116
|
+
privateGetV5PositionMoveHistory(params?: {}): Promise<implicitReturnType>;
|
|
116
117
|
privateGetV5PreUpgradeOrderHistory(params?: {}): Promise<implicitReturnType>;
|
|
117
118
|
privateGetV5PreUpgradeExecutionList(params?: {}): Promise<implicitReturnType>;
|
|
118
119
|
privateGetV5PreUpgradePositionClosedPnl(params?: {}): Promise<implicitReturnType>;
|
|
@@ -256,6 +257,7 @@ interface Exchange {
|
|
|
256
257
|
privatePostV5PositionTradingStop(params?: {}): Promise<implicitReturnType>;
|
|
257
258
|
privatePostV5PositionSetAutoAddMargin(params?: {}): Promise<implicitReturnType>;
|
|
258
259
|
privatePostV5PositionAddMargin(params?: {}): Promise<implicitReturnType>;
|
|
260
|
+
privatePostV5PositionMovePositions(params?: {}): Promise<implicitReturnType>;
|
|
259
261
|
privatePostV5PositionConfirmPendingMmr(params?: {}): Promise<implicitReturnType>;
|
|
260
262
|
privatePostV5AccountUpgradeToUta(params?: {}): Promise<implicitReturnType>;
|
|
261
263
|
privatePostV5AccountQuickRepayment(params?: {}): Promise<implicitReturnType>;
|
package/js/src/alpaca.js
CHANGED
|
@@ -352,10 +352,16 @@ export default class alpaca extends Exchange {
|
|
|
352
352
|
//
|
|
353
353
|
const marketId = this.safeString(asset, 'symbol');
|
|
354
354
|
const parts = marketId.split('/');
|
|
355
|
+
const assetClass = this.safeString(asset, 'class');
|
|
355
356
|
const baseId = this.safeString(parts, 0);
|
|
356
357
|
const quoteId = this.safeString(parts, 1);
|
|
357
358
|
const base = this.safeCurrencyCode(baseId);
|
|
358
|
-
|
|
359
|
+
let quote = this.safeCurrencyCode(quoteId);
|
|
360
|
+
// Us equity markets do not include quote in symbol.
|
|
361
|
+
// We can safely coerce us_equity quote to USD
|
|
362
|
+
if (quote === undefined && assetClass === 'us_equity') {
|
|
363
|
+
quote = 'USD';
|
|
364
|
+
}
|
|
359
365
|
const symbol = base + '/' + quote;
|
|
360
366
|
const status = this.safeString(asset, 'status');
|
|
361
367
|
const active = (status === 'active');
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -751,8 +751,11 @@ export default class Exchange {
|
|
|
751
751
|
// proxy agents
|
|
752
752
|
const [httpProxy, httpsProxy, socksProxy] = this.checkProxySettings(url, method, headers, body);
|
|
753
753
|
this.checkConflictingProxies(httpProxy || httpsProxy || socksProxy, proxyUrl);
|
|
754
|
-
if (
|
|
755
|
-
|
|
754
|
+
if (isNode) {
|
|
755
|
+
// skip this on the browser
|
|
756
|
+
if (!this.proxyModulesLoaded) {
|
|
757
|
+
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)
|
|
758
|
+
}
|
|
756
759
|
}
|
|
757
760
|
const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
|
|
758
761
|
// user-agent
|
package/js/src/binance.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export default class binance extends Exchange {
|
|
|
58
58
|
fetchCanceledOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
59
59
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
60
60
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
61
|
-
cancelOrders(ids:
|
|
61
|
+
cancelOrders(ids: string[], symbol?: Str, params?: {}): Promise<Order[]>;
|
|
62
62
|
fetchOrderTrades(id: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
63
63
|
fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
64
64
|
fetchMyDustTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export default class bingx extends Exchange {
|
|
|
72
72
|
parseOrderStatus(status: any): string;
|
|
73
73
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
74
74
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
75
|
-
cancelOrders(ids:
|
|
75
|
+
cancelOrders(ids: string[], symbol?: Str, params?: {}): Promise<any>;
|
|
76
76
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
77
77
|
fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
78
78
|
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|