ccxt 4.2.4 → 4.2.6
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 +380 -68
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +7 -1
- package/dist/cjs/src/base/Exchange.js +7 -2
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/base/ws/Client.js +4 -0
- package/dist/cjs/src/bingx.js +26 -19
- package/dist/cjs/src/bitmex.js +65 -21
- package/dist/cjs/src/bybit.js +2 -0
- package/dist/cjs/src/delta.js +2 -2
- package/dist/cjs/src/htx.js +197 -10
- package/dist/cjs/src/phemex.js +2 -1
- package/dist/cjs/src/woo.js +60 -11
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bybit.d.ts +2 -0
- package/js/src/alpaca.js +7 -1
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/base/Exchange.js +8 -3
- package/js/src/base/errorHierarchy.d.ts +1 -0
- package/js/src/base/errorHierarchy.js +1 -0
- package/js/src/base/errors.d.ts +5 -1
- package/js/src/base/errors.js +8 -2
- package/js/src/base/ws/Client.js +5 -1
- package/js/src/binance.d.ts +1 -1
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bingx.js +26 -19
- package/js/src/bitmex.js +65 -21
- package/js/src/bybit.js +2 -0
- package/js/src/delta.js +2 -2
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +197 -10
- package/js/src/phemex.js +2 -1
- package/js/src/woo.js +60 -11
- package/package.json +1 -1
- package/skip-tests.json +4 -1
package/js/src/htx.js
CHANGED
|
@@ -123,7 +123,7 @@ export default class htx extends Exchange {
|
|
|
123
123
|
'repayIsolatedMargin': true,
|
|
124
124
|
'setLeverage': true,
|
|
125
125
|
'setMarginMode': false,
|
|
126
|
-
'setPositionMode':
|
|
126
|
+
'setPositionMode': true,
|
|
127
127
|
'signIn': undefined,
|
|
128
128
|
'transfer': true,
|
|
129
129
|
'withdraw': true,
|
|
@@ -3855,8 +3855,9 @@ export default class htx extends Exchange {
|
|
|
3855
3855
|
let response = undefined;
|
|
3856
3856
|
const stop = this.safeValue(params, 'stop');
|
|
3857
3857
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
3858
|
-
|
|
3859
|
-
|
|
3858
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
3859
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
3860
|
+
if (stop || stopLossTakeProfit || trailing) {
|
|
3860
3861
|
if (limit !== undefined) {
|
|
3861
3862
|
request['page_size'] = limit;
|
|
3862
3863
|
}
|
|
@@ -3883,6 +3884,9 @@ export default class htx extends Exchange {
|
|
|
3883
3884
|
else if (stopLossTakeProfit) {
|
|
3884
3885
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslHisorders(this.extend(request, params));
|
|
3885
3886
|
}
|
|
3887
|
+
else if (trailing) {
|
|
3888
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackHisorders(this.extend(request, params));
|
|
3889
|
+
}
|
|
3886
3890
|
else {
|
|
3887
3891
|
response = await this.contractPrivatePostLinearSwapApiV3SwapHisorders(this.extend(request, params));
|
|
3888
3892
|
}
|
|
@@ -3894,6 +3898,9 @@ export default class htx extends Exchange {
|
|
|
3894
3898
|
else if (stopLossTakeProfit) {
|
|
3895
3899
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders(this.extend(request, params));
|
|
3896
3900
|
}
|
|
3901
|
+
else if (trailing) {
|
|
3902
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackHisorders(this.extend(request, params));
|
|
3903
|
+
}
|
|
3897
3904
|
else {
|
|
3898
3905
|
response = await this.contractPrivatePostLinearSwapApiV3SwapCrossHisorders(this.extend(request, params));
|
|
3899
3906
|
}
|
|
@@ -3907,6 +3914,9 @@ export default class htx extends Exchange {
|
|
|
3907
3914
|
else if (stopLossTakeProfit) {
|
|
3908
3915
|
response = await this.contractPrivatePostSwapApiV1SwapTpslHisorders(this.extend(request, params));
|
|
3909
3916
|
}
|
|
3917
|
+
else if (trailing) {
|
|
3918
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackHisorders(this.extend(request, params));
|
|
3919
|
+
}
|
|
3910
3920
|
else {
|
|
3911
3921
|
response = await this.contractPrivatePostSwapApiV3SwapHisorders(this.extend(request, params));
|
|
3912
3922
|
}
|
|
@@ -3919,6 +3929,9 @@ export default class htx extends Exchange {
|
|
|
3919
3929
|
else if (stopLossTakeProfit) {
|
|
3920
3930
|
response = await this.contractPrivatePostApiV1ContractTpslHisorders(this.extend(request, params));
|
|
3921
3931
|
}
|
|
3932
|
+
else if (trailing) {
|
|
3933
|
+
response = await this.contractPrivatePostApiV1ContractTrackHisorders(this.extend(request, params));
|
|
3934
|
+
}
|
|
3922
3935
|
else {
|
|
3923
3936
|
response = await this.contractPrivatePostApiV3ContractHisorders(this.extend(request, params));
|
|
3924
3937
|
}
|
|
@@ -4096,6 +4109,7 @@ export default class htx extends Exchange {
|
|
|
4096
4109
|
* @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
4097
4110
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
4098
4111
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4112
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
4099
4113
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4100
4114
|
*/
|
|
4101
4115
|
await this.loadMarkets();
|
|
@@ -4168,6 +4182,7 @@ export default class htx extends Exchange {
|
|
|
4168
4182
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4169
4183
|
* @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
4170
4184
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
4185
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
4171
4186
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4172
4187
|
*/
|
|
4173
4188
|
await this.loadMarkets();
|
|
@@ -4215,7 +4230,8 @@ export default class htx extends Exchange {
|
|
|
4215
4230
|
request['contract_code'] = market['id'];
|
|
4216
4231
|
const stop = this.safeValue(params, 'stop');
|
|
4217
4232
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
4218
|
-
|
|
4233
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
4234
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
4219
4235
|
if (market['linear']) {
|
|
4220
4236
|
let marginMode = undefined;
|
|
4221
4237
|
[marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
@@ -4227,6 +4243,9 @@ export default class htx extends Exchange {
|
|
|
4227
4243
|
else if (stopLossTakeProfit) {
|
|
4228
4244
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOpenorders(this.extend(request, params));
|
|
4229
4245
|
}
|
|
4246
|
+
else if (trailing) {
|
|
4247
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOpenorders(this.extend(request, params));
|
|
4248
|
+
}
|
|
4230
4249
|
else {
|
|
4231
4250
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOpenorders(this.extend(request, params));
|
|
4232
4251
|
}
|
|
@@ -4238,6 +4257,9 @@ export default class htx extends Exchange {
|
|
|
4238
4257
|
else if (stopLossTakeProfit) {
|
|
4239
4258
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders(this.extend(request, params));
|
|
4240
4259
|
}
|
|
4260
|
+
else if (trailing) {
|
|
4261
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders(this.extend(request, params));
|
|
4262
|
+
}
|
|
4241
4263
|
else {
|
|
4242
4264
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOpenorders(this.extend(request, params));
|
|
4243
4265
|
}
|
|
@@ -4251,6 +4273,9 @@ export default class htx extends Exchange {
|
|
|
4251
4273
|
else if (stopLossTakeProfit) {
|
|
4252
4274
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOpenorders(this.extend(request, params));
|
|
4253
4275
|
}
|
|
4276
|
+
else if (trailing) {
|
|
4277
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOpenorders(this.extend(request, params));
|
|
4278
|
+
}
|
|
4254
4279
|
else {
|
|
4255
4280
|
response = await this.contractPrivatePostSwapApiV1SwapOpenorders(this.extend(request, params));
|
|
4256
4281
|
}
|
|
@@ -4263,6 +4288,9 @@ export default class htx extends Exchange {
|
|
|
4263
4288
|
else if (stopLossTakeProfit) {
|
|
4264
4289
|
response = await this.contractPrivatePostApiV1ContractTpslOpenorders(this.extend(request, params));
|
|
4265
4290
|
}
|
|
4291
|
+
else if (trailing) {
|
|
4292
|
+
response = await this.contractPrivatePostApiV1ContractTrackOpenorders(this.extend(request, params));
|
|
4293
|
+
}
|
|
4266
4294
|
else {
|
|
4267
4295
|
response = await this.contractPrivatePostApiV1ContractOpenorders(this.extend(request, params));
|
|
4268
4296
|
}
|
|
@@ -4414,6 +4442,45 @@ export default class htx extends Exchange {
|
|
|
4414
4442
|
// "ts": 1683179527011
|
|
4415
4443
|
// }
|
|
4416
4444
|
//
|
|
4445
|
+
// trailing
|
|
4446
|
+
//
|
|
4447
|
+
// {
|
|
4448
|
+
// "status": "ok",
|
|
4449
|
+
// "data": {
|
|
4450
|
+
// "orders": [
|
|
4451
|
+
// {
|
|
4452
|
+
// "contract_type": "swap",
|
|
4453
|
+
// "business_type": "swap",
|
|
4454
|
+
// "pair": "BTC-USDT",
|
|
4455
|
+
// "symbol": "BTC",
|
|
4456
|
+
// "contract_code": "BTC-USDT",
|
|
4457
|
+
// "volume": 1.000000000000000000,
|
|
4458
|
+
// "order_type": 1,
|
|
4459
|
+
// "direction": "sell",
|
|
4460
|
+
// "offset": "close",
|
|
4461
|
+
// "lever_rate": 1,
|
|
4462
|
+
// "order_id": 1192021437253877761,
|
|
4463
|
+
// "order_id_str": "1192021437253877761",
|
|
4464
|
+
// "order_source": "api",
|
|
4465
|
+
// "created_at": 1704241657328,
|
|
4466
|
+
// "order_price_type": "formula_price",
|
|
4467
|
+
// "status": 2,
|
|
4468
|
+
// "callback_rate": 0.050000000000000000,
|
|
4469
|
+
// "active_price": 50000.000000000000000000,
|
|
4470
|
+
// "is_active": 0,
|
|
4471
|
+
// "margin_mode": "cross",
|
|
4472
|
+
// "margin_account": "USDT",
|
|
4473
|
+
// "trade_partition": "USDT",
|
|
4474
|
+
// "reduce_only": 1
|
|
4475
|
+
// },
|
|
4476
|
+
// ],
|
|
4477
|
+
// "total_page": 1,
|
|
4478
|
+
// "current_page": 1,
|
|
4479
|
+
// "total_size": 2
|
|
4480
|
+
// },
|
|
4481
|
+
// "ts": 1704242440106
|
|
4482
|
+
// }
|
|
4483
|
+
//
|
|
4417
4484
|
let orders = this.safeValue(response, 'data');
|
|
4418
4485
|
if (!Array.isArray(orders)) {
|
|
4419
4486
|
orders = this.safeValue(orders, 'orders', []);
|
|
@@ -4673,6 +4740,33 @@ export default class htx extends Exchange {
|
|
|
4673
4740
|
// "trade_partition": "USDT"
|
|
4674
4741
|
// }
|
|
4675
4742
|
//
|
|
4743
|
+
// trailing: fetchOpenOrders
|
|
4744
|
+
//
|
|
4745
|
+
// {
|
|
4746
|
+
// "contract_type": "swap",
|
|
4747
|
+
// "business_type": "swap",
|
|
4748
|
+
// "pair": "BTC-USDT",
|
|
4749
|
+
// "symbol": "BTC",
|
|
4750
|
+
// "contract_code": "BTC-USDT",
|
|
4751
|
+
// "volume": 1.000000000000000000,
|
|
4752
|
+
// "order_type": 1,
|
|
4753
|
+
// "direction": "sell",
|
|
4754
|
+
// "offset": "close",
|
|
4755
|
+
// "lever_rate": 1,
|
|
4756
|
+
// "order_id": 1192021437253877761,
|
|
4757
|
+
// "order_id_str": "1192021437253877761",
|
|
4758
|
+
// "order_source": "api",
|
|
4759
|
+
// "created_at": 1704241657328,
|
|
4760
|
+
// "order_price_type": "formula_price",
|
|
4761
|
+
// "status": 2,
|
|
4762
|
+
// "callback_rate": 0.050000000000000000,
|
|
4763
|
+
// "active_price": 50000.000000000000000000,
|
|
4764
|
+
// "is_active": 0,
|
|
4765
|
+
// "margin_mode": "cross",
|
|
4766
|
+
// "margin_account": "USDT",
|
|
4767
|
+
// "trade_partition": "USDT",
|
|
4768
|
+
// "reduce_only": 1
|
|
4769
|
+
// }
|
|
4676
4770
|
//
|
|
4677
4771
|
// trigger: fetchOrders
|
|
4678
4772
|
//
|
|
@@ -5437,8 +5531,9 @@ export default class htx extends Exchange {
|
|
|
5437
5531
|
* @param {string} id order id
|
|
5438
5532
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
5439
5533
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5440
|
-
* @param {
|
|
5441
|
-
* @param {
|
|
5534
|
+
* @param {boolean} [params.stop] *contract only* if the order is a stop trigger order or not
|
|
5535
|
+
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the order is a stop-loss or take-profit order
|
|
5536
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel a trailing order
|
|
5442
5537
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5443
5538
|
*/
|
|
5444
5539
|
await this.loadMarkets();
|
|
@@ -5493,7 +5588,8 @@ export default class htx extends Exchange {
|
|
|
5493
5588
|
}
|
|
5494
5589
|
const stop = this.safeValue(params, 'stop');
|
|
5495
5590
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
5496
|
-
|
|
5591
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
5592
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
5497
5593
|
if (market['linear']) {
|
|
5498
5594
|
let marginMode = undefined;
|
|
5499
5595
|
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
@@ -5505,6 +5601,9 @@ export default class htx extends Exchange {
|
|
|
5505
5601
|
else if (stopLossTakeProfit) {
|
|
5506
5602
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancel(this.extend(request, params));
|
|
5507
5603
|
}
|
|
5604
|
+
else if (trailing) {
|
|
5605
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancel(this.extend(request, params));
|
|
5606
|
+
}
|
|
5508
5607
|
else {
|
|
5509
5608
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCancel(this.extend(request, params));
|
|
5510
5609
|
}
|
|
@@ -5516,6 +5615,9 @@ export default class htx extends Exchange {
|
|
|
5516
5615
|
else if (stopLossTakeProfit) {
|
|
5517
5616
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(this.extend(request, params));
|
|
5518
5617
|
}
|
|
5618
|
+
else if (trailing) {
|
|
5619
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancel(this.extend(request, params));
|
|
5620
|
+
}
|
|
5519
5621
|
else {
|
|
5520
5622
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancel(this.extend(request, params));
|
|
5521
5623
|
}
|
|
@@ -5529,6 +5631,9 @@ export default class htx extends Exchange {
|
|
|
5529
5631
|
else if (stopLossTakeProfit) {
|
|
5530
5632
|
response = await this.contractPrivatePostSwapApiV1SwapTpslCancel(this.extend(request, params));
|
|
5531
5633
|
}
|
|
5634
|
+
else if (trailing) {
|
|
5635
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackCancel(this.extend(request, params));
|
|
5636
|
+
}
|
|
5532
5637
|
else {
|
|
5533
5638
|
response = await this.contractPrivatePostSwapApiV1SwapCancel(this.extend(request, params));
|
|
5534
5639
|
}
|
|
@@ -5540,6 +5645,9 @@ export default class htx extends Exchange {
|
|
|
5540
5645
|
else if (stopLossTakeProfit) {
|
|
5541
5646
|
response = await this.contractPrivatePostApiV1ContractTpslCancel(this.extend(request, params));
|
|
5542
5647
|
}
|
|
5648
|
+
else if (trailing) {
|
|
5649
|
+
response = await this.contractPrivatePostApiV1ContractTrackCancel(this.extend(request, params));
|
|
5650
|
+
}
|
|
5543
5651
|
else {
|
|
5544
5652
|
response = await this.contractPrivatePostApiV1ContractCancel(this.extend(request, params));
|
|
5545
5653
|
}
|
|
@@ -5762,8 +5870,9 @@ export default class htx extends Exchange {
|
|
|
5762
5870
|
* @description cancel all open orders
|
|
5763
5871
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
5764
5872
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5765
|
-
* @param {
|
|
5766
|
-
* @param {
|
|
5873
|
+
* @param {boolean} [params.stop] *contract only* if the orders are stop trigger orders or not
|
|
5874
|
+
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
5875
|
+
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel all trailing orders
|
|
5767
5876
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5768
5877
|
*/
|
|
5769
5878
|
await this.loadMarkets();
|
|
@@ -5804,7 +5913,8 @@ export default class htx extends Exchange {
|
|
|
5804
5913
|
request['contract_code'] = market['id'];
|
|
5805
5914
|
const stop = this.safeValue(params, 'stop');
|
|
5806
5915
|
const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
|
|
5807
|
-
|
|
5916
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
5917
|
+
params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
|
|
5808
5918
|
if (market['linear']) {
|
|
5809
5919
|
let marginMode = undefined;
|
|
5810
5920
|
[marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
|
|
@@ -5816,6 +5926,9 @@ export default class htx extends Exchange {
|
|
|
5816
5926
|
else if (stopLossTakeProfit) {
|
|
5817
5927
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(this.extend(request, params));
|
|
5818
5928
|
}
|
|
5929
|
+
else if (trailing) {
|
|
5930
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancelall(this.extend(request, params));
|
|
5931
|
+
}
|
|
5819
5932
|
else {
|
|
5820
5933
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCancelall(this.extend(request, params));
|
|
5821
5934
|
}
|
|
@@ -5827,6 +5940,9 @@ export default class htx extends Exchange {
|
|
|
5827
5940
|
else if (stopLossTakeProfit) {
|
|
5828
5941
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(this.extend(request, params));
|
|
5829
5942
|
}
|
|
5943
|
+
else if (trailing) {
|
|
5944
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancelall(this.extend(request, params));
|
|
5945
|
+
}
|
|
5830
5946
|
else {
|
|
5831
5947
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(this.extend(request, params));
|
|
5832
5948
|
}
|
|
@@ -5840,6 +5956,9 @@ export default class htx extends Exchange {
|
|
|
5840
5956
|
else if (stopLossTakeProfit) {
|
|
5841
5957
|
response = await this.contractPrivatePostSwapApiV1SwapTpslCancelall(this.extend(request, params));
|
|
5842
5958
|
}
|
|
5959
|
+
else if (trailing) {
|
|
5960
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackCancelall(this.extend(request, params));
|
|
5961
|
+
}
|
|
5843
5962
|
else {
|
|
5844
5963
|
response = await this.contractPrivatePostSwapApiV1SwapCancelall(this.extend(request, params));
|
|
5845
5964
|
}
|
|
@@ -5851,6 +5970,9 @@ export default class htx extends Exchange {
|
|
|
5851
5970
|
else if (stopLossTakeProfit) {
|
|
5852
5971
|
response = await this.contractPrivatePostApiV1ContractTpslCancelall(this.extend(request, params));
|
|
5853
5972
|
}
|
|
5973
|
+
else if (trailing) {
|
|
5974
|
+
response = await this.contractPrivatePostApiV1ContractTrackCancelall(this.extend(request, params));
|
|
5975
|
+
}
|
|
5854
5976
|
else {
|
|
5855
5977
|
response = await this.contractPrivatePostApiV1ContractCancelall(this.extend(request, params));
|
|
5856
5978
|
}
|
|
@@ -8838,4 +8960,69 @@ export default class htx extends Exchange {
|
|
|
8838
8960
|
'datetime': this.iso8601(timestamp),
|
|
8839
8961
|
});
|
|
8840
8962
|
}
|
|
8963
|
+
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
8964
|
+
/**
|
|
8965
|
+
* @method
|
|
8966
|
+
* @name htx#setPositionMode
|
|
8967
|
+
* @description set hedged to true or false
|
|
8968
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
|
|
8969
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
|
|
8970
|
+
* @param {bool} hedged set to true to for hedged mode, must be set separately for each market in isolated margin mode, only valid for linear markets
|
|
8971
|
+
* @param {string} [symbol] unified market symbol, required for isolated margin mode
|
|
8972
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8973
|
+
* @param {string} [params.marginMode] "cross" (default) or "isolated"
|
|
8974
|
+
* @returns {object} response from the exchange
|
|
8975
|
+
*/
|
|
8976
|
+
await this.loadMarkets();
|
|
8977
|
+
const posMode = hedged ? 'dual_side' : 'single_side';
|
|
8978
|
+
let market = undefined;
|
|
8979
|
+
if (symbol !== undefined) {
|
|
8980
|
+
market = this.market(symbol);
|
|
8981
|
+
}
|
|
8982
|
+
let marginMode = undefined;
|
|
8983
|
+
[marginMode, params] = this.handleMarginModeAndParams('setPositionMode', params, 'cross');
|
|
8984
|
+
const request = {
|
|
8985
|
+
'position_mode': posMode,
|
|
8986
|
+
};
|
|
8987
|
+
let response = undefined;
|
|
8988
|
+
if ((market !== undefined) && (market['inverse'])) {
|
|
8989
|
+
throw new BadRequest(this.id + ' setPositionMode can only be used for linear markets');
|
|
8990
|
+
}
|
|
8991
|
+
if (marginMode === 'isolated') {
|
|
8992
|
+
if (symbol === undefined) {
|
|
8993
|
+
throw new ArgumentsRequired(this.id + ' setPositionMode requires a symbol argument for isolated margin mode');
|
|
8994
|
+
}
|
|
8995
|
+
request['margin_account'] = market['id'];
|
|
8996
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapSwitchPositionMode(this.extend(request, params));
|
|
8997
|
+
//
|
|
8998
|
+
// {
|
|
8999
|
+
// "status": "ok",
|
|
9000
|
+
// "data": [
|
|
9001
|
+
// {
|
|
9002
|
+
// "margin_account": "BTC-USDT",
|
|
9003
|
+
// "position_mode": "single_side"
|
|
9004
|
+
// }
|
|
9005
|
+
// ],
|
|
9006
|
+
// "ts": 1566899973811
|
|
9007
|
+
// }
|
|
9008
|
+
//
|
|
9009
|
+
}
|
|
9010
|
+
else {
|
|
9011
|
+
request['margin_account'] = 'USDT';
|
|
9012
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossSwitchPositionMode(this.extend(request, params));
|
|
9013
|
+
//
|
|
9014
|
+
// {
|
|
9015
|
+
// "status": "ok",
|
|
9016
|
+
// "data": [
|
|
9017
|
+
// {
|
|
9018
|
+
// "margin_account": "USDT",
|
|
9019
|
+
// "position_mode": "single_side"
|
|
9020
|
+
// }
|
|
9021
|
+
// ],
|
|
9022
|
+
// "ts": 1566899973811
|
|
9023
|
+
// }
|
|
9024
|
+
//
|
|
9025
|
+
}
|
|
9026
|
+
return response;
|
|
9027
|
+
}
|
|
8841
9028
|
}
|
package/js/src/phemex.js
CHANGED
|
@@ -442,7 +442,8 @@ export default class phemex extends Exchange {
|
|
|
442
442
|
'34003': PermissionDenied,
|
|
443
443
|
'35104': InsufficientFunds,
|
|
444
444
|
'39995': RateLimitExceeded,
|
|
445
|
-
'39996': PermissionDenied,
|
|
445
|
+
'39996': PermissionDenied,
|
|
446
|
+
'39997': BadSymbol, // {"code":39997,"msg":"Symbol not listed sMOVRUSDT","data":null}
|
|
446
447
|
},
|
|
447
448
|
'broad': {
|
|
448
449
|
'401 Insufficient privilege': PermissionDenied,
|
package/js/src/woo.js
CHANGED
|
@@ -768,9 +768,9 @@ export default class woo extends Exchange {
|
|
|
768
768
|
/**
|
|
769
769
|
* @method
|
|
770
770
|
* @name woo#createOrder
|
|
771
|
+
* @description create a trade order
|
|
771
772
|
* @see https://docs.woo.org/#send-order
|
|
772
773
|
* @see https://docs.woo.org/#send-algo-order
|
|
773
|
-
* @description create a trade order
|
|
774
774
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
775
775
|
* @param {string} type 'market' or 'limit'
|
|
776
776
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -784,6 +784,9 @@ export default class woo extends Exchange {
|
|
|
784
784
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
785
785
|
* @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
786
786
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
787
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
788
|
+
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
789
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
787
790
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
788
791
|
*/
|
|
789
792
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
@@ -800,7 +803,13 @@ export default class woo extends Exchange {
|
|
|
800
803
|
const stopLoss = this.safeValue(params, 'stopLoss');
|
|
801
804
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
802
805
|
const algoType = this.safeString(params, 'algoType');
|
|
803
|
-
const
|
|
806
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
|
|
807
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
|
|
808
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
809
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
810
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
811
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
812
|
+
const isStop = isTrailing || stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
|
|
804
813
|
const isMarket = orderType === 'MARKET';
|
|
805
814
|
const timeInForce = this.safeStringLower(params, 'timeInForce');
|
|
806
815
|
const postOnly = this.isPostOnly(isMarket, undefined, params);
|
|
@@ -865,7 +874,21 @@ export default class woo extends Exchange {
|
|
|
865
874
|
if (clientOrderId !== undefined) {
|
|
866
875
|
request[clientOrderIdKey] = clientOrderId;
|
|
867
876
|
}
|
|
868
|
-
if (
|
|
877
|
+
if (isTrailing) {
|
|
878
|
+
if (trailingTriggerPrice === undefined) {
|
|
879
|
+
throw new ArgumentsRequired(this.id + ' createOrder() requires a trailingTriggerPrice parameter for trailing orders');
|
|
880
|
+
}
|
|
881
|
+
request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
882
|
+
request['algoType'] = 'TRAILING_STOP';
|
|
883
|
+
if (isTrailingAmountOrder) {
|
|
884
|
+
request['callbackValue'] = trailingAmount;
|
|
885
|
+
}
|
|
886
|
+
else if (isTrailingPercentOrder) {
|
|
887
|
+
const convertedTrailingPercent = Precise.stringDiv(trailingPercent, '100');
|
|
888
|
+
request['callbackRate'] = convertedTrailingPercent;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
else if (stopPrice !== undefined) {
|
|
869
892
|
if (algoType !== 'TRAILING_STOP') {
|
|
870
893
|
request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
871
894
|
request['algoType'] = 'STOP';
|
|
@@ -904,7 +927,7 @@ export default class woo extends Exchange {
|
|
|
904
927
|
}
|
|
905
928
|
request['childOrders'] = [outterOrder];
|
|
906
929
|
}
|
|
907
|
-
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit']);
|
|
930
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']);
|
|
908
931
|
let response = undefined;
|
|
909
932
|
if (isStop) {
|
|
910
933
|
response = await this.v3PrivatePostAlgoOrder(this.extend(request, params));
|
|
@@ -950,11 +973,11 @@ export default class woo extends Exchange {
|
|
|
950
973
|
/**
|
|
951
974
|
* @method
|
|
952
975
|
* @name woo#editOrder
|
|
976
|
+
* @description edit a trade order
|
|
953
977
|
* @see https://docs.woo.org/#edit-order
|
|
954
978
|
* @see https://docs.woo.org/#edit-order-by-client_order_id
|
|
955
979
|
* @see https://docs.woo.org/#edit-algo-order
|
|
956
980
|
* @see https://docs.woo.org/#edit-algo-order-by-client_order_id
|
|
957
|
-
* @description edit a trade order
|
|
958
981
|
* @param {string} id order id
|
|
959
982
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
960
983
|
* @param {string} type 'market' or 'limit'
|
|
@@ -965,6 +988,9 @@ export default class woo extends Exchange {
|
|
|
965
988
|
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
|
|
966
989
|
* @param {float} [params.stopLossPrice] price to trigger stop-loss orders
|
|
967
990
|
* @param {float} [params.takeProfitPrice] price to trigger take-profit orders
|
|
991
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
992
|
+
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
993
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
968
994
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
969
995
|
*/
|
|
970
996
|
await this.loadMarkets();
|
|
@@ -986,8 +1012,26 @@ export default class woo extends Exchange {
|
|
|
986
1012
|
if (stopPrice !== undefined) {
|
|
987
1013
|
request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
988
1014
|
}
|
|
989
|
-
|
|
990
|
-
const
|
|
1015
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
|
|
1016
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
|
|
1017
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
1018
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1019
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
1020
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
1021
|
+
if (isTrailing) {
|
|
1022
|
+
if (trailingTriggerPrice !== undefined) {
|
|
1023
|
+
request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
1024
|
+
}
|
|
1025
|
+
if (isTrailingAmountOrder) {
|
|
1026
|
+
request['callbackValue'] = trailingAmount;
|
|
1027
|
+
}
|
|
1028
|
+
else if (isTrailingPercentOrder) {
|
|
1029
|
+
const convertedTrailingPercent = Precise.stringDiv(trailingPercent, '100');
|
|
1030
|
+
request['callbackRate'] = convertedTrailingPercent;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent']);
|
|
1034
|
+
const isStop = isTrailing || (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
|
|
991
1035
|
let response = undefined;
|
|
992
1036
|
if (isByClientOrder) {
|
|
993
1037
|
request['client_order_id'] = clientOrderIdExchangeSpecific;
|
|
@@ -1187,9 +1231,9 @@ export default class woo extends Exchange {
|
|
|
1187
1231
|
/**
|
|
1188
1232
|
* @method
|
|
1189
1233
|
* @name woo#fetchOrders
|
|
1234
|
+
* @description fetches information on multiple orders made by the user
|
|
1190
1235
|
* @see https://docs.woo.org/#get-orders
|
|
1191
1236
|
* @see https://docs.woo.org/#get-algo-orders
|
|
1192
|
-
* @description fetches information on multiple orders made by the user
|
|
1193
1237
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1194
1238
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1195
1239
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -1197,19 +1241,21 @@ export default class woo extends Exchange {
|
|
|
1197
1241
|
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
1198
1242
|
* @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
|
|
1199
1243
|
* @param {string} [params.side] 'buy' or 'sell'
|
|
1244
|
+
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
|
1200
1245
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1201
1246
|
*/
|
|
1202
1247
|
await this.loadMarkets();
|
|
1203
1248
|
const request = {};
|
|
1204
1249
|
let market = undefined;
|
|
1205
1250
|
const stop = this.safeValue(params, 'stop');
|
|
1206
|
-
|
|
1251
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
1252
|
+
params = this.omit(params, ['stop', 'trailing']);
|
|
1207
1253
|
if (symbol !== undefined) {
|
|
1208
1254
|
market = this.market(symbol);
|
|
1209
1255
|
request['symbol'] = market['id'];
|
|
1210
1256
|
}
|
|
1211
1257
|
if (since !== undefined) {
|
|
1212
|
-
if (stop) {
|
|
1258
|
+
if (stop || trailing) {
|
|
1213
1259
|
request['createdTimeStart'] = since;
|
|
1214
1260
|
}
|
|
1215
1261
|
else {
|
|
@@ -1219,8 +1265,11 @@ export default class woo extends Exchange {
|
|
|
1219
1265
|
if (stop) {
|
|
1220
1266
|
request['algoType'] = 'stop';
|
|
1221
1267
|
}
|
|
1268
|
+
else if (trailing) {
|
|
1269
|
+
request['algoType'] = 'TRAILING_STOP';
|
|
1270
|
+
}
|
|
1222
1271
|
let response = undefined;
|
|
1223
|
-
if (stop) {
|
|
1272
|
+
if (stop || trailing) {
|
|
1224
1273
|
response = await this.v3PrivateGetAlgoOrders(this.extend(request, params));
|
|
1225
1274
|
}
|
|
1226
1275
|
else {
|
package/package.json
CHANGED
package/skip-tests.json
CHANGED
|
@@ -106,7 +106,8 @@
|
|
|
106
106
|
},
|
|
107
107
|
"watchTicker": {
|
|
108
108
|
"quoteVolume": "https://app.travis-ci.com/github/ccxt/ccxt/builds/267900037#L2466"
|
|
109
|
-
}
|
|
109
|
+
},
|
|
110
|
+
"watchOrderBook": "out of order update"
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
113
|
"binanceusdm": {
|
|
@@ -743,6 +744,7 @@
|
|
|
743
744
|
}
|
|
744
745
|
},
|
|
745
746
|
"cryptocom": {
|
|
747
|
+
"skipWs": "timeout",
|
|
746
748
|
"skipMethods": {
|
|
747
749
|
"proxies": "probably they do not permit our proxy",
|
|
748
750
|
"loadMarkets": {
|
|
@@ -1653,6 +1655,7 @@
|
|
|
1653
1655
|
}
|
|
1654
1656
|
},
|
|
1655
1657
|
"bitteam": {
|
|
1658
|
+
"skip": "tmp timeout",
|
|
1656
1659
|
"skipPhpAsync": true,
|
|
1657
1660
|
"skipMethods": {
|
|
1658
1661
|
"loadMarkets": {
|