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.
@@ -120,7 +120,7 @@ class htx extends htx$1 {
120
120
  'repayIsolatedMargin': true,
121
121
  'setLeverage': true,
122
122
  'setMarginMode': false,
123
- 'setPositionMode': false,
123
+ 'setPositionMode': true,
124
124
  'signIn': undefined,
125
125
  'transfer': true,
126
126
  'withdraw': true,
@@ -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
- params = this.omit(params, ['stop', 'stopLossTakeProfit']);
3856
- if (stop || stopLossTakeProfit) {
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
- params = this.omit(params, ['stop', 'stopLossTakeProfit']);
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
  //
@@ -5434,8 +5528,9 @@ class htx extends htx$1 {
5434
5528
  * @param {string} id order id
5435
5529
  * @param {string} symbol unified symbol of the market the order was made in
5436
5530
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5437
- * @param {bool} [params.stop] *contract only* if the order is a stop trigger order or not
5438
- * @param {bool} [params.stopLossTakeProfit] *contract only* if the order is a stop-loss or take-profit order
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
5439
5534
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5440
5535
  */
5441
5536
  await this.loadMarkets();
@@ -5490,7 +5585,8 @@ class htx extends htx$1 {
5490
5585
  }
5491
5586
  const stop = this.safeValue(params, 'stop');
5492
5587
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
5493
- params = this.omit(params, ['stop', 'stopLossTakeProfit']);
5588
+ const trailing = this.safeValue(params, 'trailing', false);
5589
+ params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
5494
5590
  if (market['linear']) {
5495
5591
  let marginMode = undefined;
5496
5592
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
@@ -5502,6 +5598,9 @@ class htx extends htx$1 {
5502
5598
  else if (stopLossTakeProfit) {
5503
5599
  response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancel(this.extend(request, params));
5504
5600
  }
5601
+ else if (trailing) {
5602
+ response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancel(this.extend(request, params));
5603
+ }
5505
5604
  else {
5506
5605
  response = await this.contractPrivatePostLinearSwapApiV1SwapCancel(this.extend(request, params));
5507
5606
  }
@@ -5513,6 +5612,9 @@ class htx extends htx$1 {
5513
5612
  else if (stopLossTakeProfit) {
5514
5613
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(this.extend(request, params));
5515
5614
  }
5615
+ else if (trailing) {
5616
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancel(this.extend(request, params));
5617
+ }
5516
5618
  else {
5517
5619
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancel(this.extend(request, params));
5518
5620
  }
@@ -5526,6 +5628,9 @@ class htx extends htx$1 {
5526
5628
  else if (stopLossTakeProfit) {
5527
5629
  response = await this.contractPrivatePostSwapApiV1SwapTpslCancel(this.extend(request, params));
5528
5630
  }
5631
+ else if (trailing) {
5632
+ response = await this.contractPrivatePostSwapApiV1SwapTrackCancel(this.extend(request, params));
5633
+ }
5529
5634
  else {
5530
5635
  response = await this.contractPrivatePostSwapApiV1SwapCancel(this.extend(request, params));
5531
5636
  }
@@ -5537,6 +5642,9 @@ class htx extends htx$1 {
5537
5642
  else if (stopLossTakeProfit) {
5538
5643
  response = await this.contractPrivatePostApiV1ContractTpslCancel(this.extend(request, params));
5539
5644
  }
5645
+ else if (trailing) {
5646
+ response = await this.contractPrivatePostApiV1ContractTrackCancel(this.extend(request, params));
5647
+ }
5540
5648
  else {
5541
5649
  response = await this.contractPrivatePostApiV1ContractCancel(this.extend(request, params));
5542
5650
  }
@@ -5759,8 +5867,9 @@ class htx extends htx$1 {
5759
5867
  * @description cancel all open orders
5760
5868
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
5761
5869
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5762
- * @param {bool} [params.stop] *contract only* if the orders are stop trigger orders or not
5763
- * @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
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
5764
5873
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5765
5874
  */
5766
5875
  await this.loadMarkets();
@@ -5801,7 +5910,8 @@ class htx extends htx$1 {
5801
5910
  request['contract_code'] = market['id'];
5802
5911
  const stop = this.safeValue(params, 'stop');
5803
5912
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
5804
- params = this.omit(params, ['stop', 'stopLossTakeProfit']);
5913
+ const trailing = this.safeValue(params, 'trailing', false);
5914
+ params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
5805
5915
  if (market['linear']) {
5806
5916
  let marginMode = undefined;
5807
5917
  [marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
@@ -5813,6 +5923,9 @@ class htx extends htx$1 {
5813
5923
  else if (stopLossTakeProfit) {
5814
5924
  response = await this.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(this.extend(request, params));
5815
5925
  }
5926
+ else if (trailing) {
5927
+ response = await this.contractPrivatePostLinearSwapApiV1SwapTrackCancelall(this.extend(request, params));
5928
+ }
5816
5929
  else {
5817
5930
  response = await this.contractPrivatePostLinearSwapApiV1SwapCancelall(this.extend(request, params));
5818
5931
  }
@@ -5824,6 +5937,9 @@ class htx extends htx$1 {
5824
5937
  else if (stopLossTakeProfit) {
5825
5938
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(this.extend(request, params));
5826
5939
  }
5940
+ else if (trailing) {
5941
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackCancelall(this.extend(request, params));
5942
+ }
5827
5943
  else {
5828
5944
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(this.extend(request, params));
5829
5945
  }
@@ -5837,6 +5953,9 @@ class htx extends htx$1 {
5837
5953
  else if (stopLossTakeProfit) {
5838
5954
  response = await this.contractPrivatePostSwapApiV1SwapTpslCancelall(this.extend(request, params));
5839
5955
  }
5956
+ else if (trailing) {
5957
+ response = await this.contractPrivatePostSwapApiV1SwapTrackCancelall(this.extend(request, params));
5958
+ }
5840
5959
  else {
5841
5960
  response = await this.contractPrivatePostSwapApiV1SwapCancelall(this.extend(request, params));
5842
5961
  }
@@ -5848,6 +5967,9 @@ class htx extends htx$1 {
5848
5967
  else if (stopLossTakeProfit) {
5849
5968
  response = await this.contractPrivatePostApiV1ContractTpslCancelall(this.extend(request, params));
5850
5969
  }
5970
+ else if (trailing) {
5971
+ response = await this.contractPrivatePostApiV1ContractTrackCancelall(this.extend(request, params));
5972
+ }
5851
5973
  else {
5852
5974
  response = await this.contractPrivatePostApiV1ContractCancelall(this.extend(request, params));
5853
5975
  }
@@ -8835,6 +8957,71 @@ class htx extends htx$1 {
8835
8957
  'datetime': this.iso8601(timestamp),
8836
8958
  });
8837
8959
  }
8960
+ async setPositionMode(hedged, symbol = undefined, params = {}) {
8961
+ /**
8962
+ * @method
8963
+ * @name htx#setPositionMode
8964
+ * @description set hedged to true or false
8965
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
8966
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
8967
+ * @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
8968
+ * @param {string} [symbol] unified market symbol, required for isolated margin mode
8969
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8970
+ * @param {string} [params.marginMode] "cross" (default) or "isolated"
8971
+ * @returns {object} response from the exchange
8972
+ */
8973
+ await this.loadMarkets();
8974
+ const posMode = hedged ? 'dual_side' : 'single_side';
8975
+ let market = undefined;
8976
+ if (symbol !== undefined) {
8977
+ market = this.market(symbol);
8978
+ }
8979
+ let marginMode = undefined;
8980
+ [marginMode, params] = this.handleMarginModeAndParams('setPositionMode', params, 'cross');
8981
+ const request = {
8982
+ 'position_mode': posMode,
8983
+ };
8984
+ let response = undefined;
8985
+ if ((market !== undefined) && (market['inverse'])) {
8986
+ throw new errors.BadRequest(this.id + ' setPositionMode can only be used for linear markets');
8987
+ }
8988
+ if (marginMode === 'isolated') {
8989
+ if (symbol === undefined) {
8990
+ throw new errors.ArgumentsRequired(this.id + ' setPositionMode requires a symbol argument for isolated margin mode');
8991
+ }
8992
+ request['margin_account'] = market['id'];
8993
+ response = await this.contractPrivatePostLinearSwapApiV1SwapSwitchPositionMode(this.extend(request, params));
8994
+ //
8995
+ // {
8996
+ // "status": "ok",
8997
+ // "data": [
8998
+ // {
8999
+ // "margin_account": "BTC-USDT",
9000
+ // "position_mode": "single_side"
9001
+ // }
9002
+ // ],
9003
+ // "ts": 1566899973811
9004
+ // }
9005
+ //
9006
+ }
9007
+ else {
9008
+ request['margin_account'] = 'USDT';
9009
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossSwitchPositionMode(this.extend(request, params));
9010
+ //
9011
+ // {
9012
+ // "status": "ok",
9013
+ // "data": [
9014
+ // {
9015
+ // "margin_account": "USDT",
9016
+ // "position_mode": "single_side"
9017
+ // }
9018
+ // ],
9019
+ // "ts": 1566899973811
9020
+ // }
9021
+ //
9022
+ }
9023
+ return response;
9024
+ }
8838
9025
  }
8839
9026
 
8840
9027
  module.exports = htx;
@@ -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, // {"code": "39996","msg": "Access denied."}
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,
@@ -765,9 +765,9 @@ class woo extends woo$1 {
765
765
  /**
766
766
  * @method
767
767
  * @name woo#createOrder
768
+ * @description create a trade order
768
769
  * @see https://docs.woo.org/#send-order
769
770
  * @see https://docs.woo.org/#send-algo-order
770
- * @description create a trade order
771
771
  * @param {string} symbol unified symbol of the market to create an order in
772
772
  * @param {string} type 'market' or 'limit'
773
773
  * @param {string} side 'buy' or 'sell'
@@ -781,6 +781,9 @@ class woo extends woo$1 {
781
781
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
782
782
  * @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
783
783
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
784
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
785
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
786
+ * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
784
787
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
785
788
  */
786
789
  const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
@@ -797,7 +800,13 @@ class woo extends woo$1 {
797
800
  const stopLoss = this.safeValue(params, 'stopLoss');
798
801
  const takeProfit = this.safeValue(params, 'takeProfit');
799
802
  const algoType = this.safeString(params, 'algoType');
800
- const isStop = stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
803
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
804
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
805
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
806
+ const isTrailingAmountOrder = trailingAmount !== undefined;
807
+ const isTrailingPercentOrder = trailingPercent !== undefined;
808
+ const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
809
+ const isStop = isTrailing || stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
801
810
  const isMarket = orderType === 'MARKET';
802
811
  const timeInForce = this.safeStringLower(params, 'timeInForce');
803
812
  const postOnly = this.isPostOnly(isMarket, undefined, params);
@@ -862,7 +871,21 @@ class woo extends woo$1 {
862
871
  if (clientOrderId !== undefined) {
863
872
  request[clientOrderIdKey] = clientOrderId;
864
873
  }
865
- if (stopPrice !== undefined) {
874
+ if (isTrailing) {
875
+ if (trailingTriggerPrice === undefined) {
876
+ throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a trailingTriggerPrice parameter for trailing orders');
877
+ }
878
+ request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
879
+ request['algoType'] = 'TRAILING_STOP';
880
+ if (isTrailingAmountOrder) {
881
+ request['callbackValue'] = trailingAmount;
882
+ }
883
+ else if (isTrailingPercentOrder) {
884
+ const convertedTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
885
+ request['callbackRate'] = convertedTrailingPercent;
886
+ }
887
+ }
888
+ else if (stopPrice !== undefined) {
866
889
  if (algoType !== 'TRAILING_STOP') {
867
890
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
868
891
  request['algoType'] = 'STOP';
@@ -901,7 +924,7 @@ class woo extends woo$1 {
901
924
  }
902
925
  request['childOrders'] = [outterOrder];
903
926
  }
904
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit']);
927
+ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']);
905
928
  let response = undefined;
906
929
  if (isStop) {
907
930
  response = await this.v3PrivatePostAlgoOrder(this.extend(request, params));
@@ -947,11 +970,11 @@ class woo extends woo$1 {
947
970
  /**
948
971
  * @method
949
972
  * @name woo#editOrder
973
+ * @description edit a trade order
950
974
  * @see https://docs.woo.org/#edit-order
951
975
  * @see https://docs.woo.org/#edit-order-by-client_order_id
952
976
  * @see https://docs.woo.org/#edit-algo-order
953
977
  * @see https://docs.woo.org/#edit-algo-order-by-client_order_id
954
- * @description edit a trade order
955
978
  * @param {string} id order id
956
979
  * @param {string} symbol unified symbol of the market to create an order in
957
980
  * @param {string} type 'market' or 'limit'
@@ -962,6 +985,9 @@ class woo extends woo$1 {
962
985
  * @param {float} [params.triggerPrice] The price a trigger order is triggered at
963
986
  * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
964
987
  * @param {float} [params.takeProfitPrice] price to trigger take-profit orders
988
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
989
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
990
+ * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
965
991
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
966
992
  */
967
993
  await this.loadMarkets();
@@ -983,8 +1009,26 @@ class woo extends woo$1 {
983
1009
  if (stopPrice !== undefined) {
984
1010
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
985
1011
  }
986
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice']);
987
- const isStop = (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
1012
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
1013
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
1014
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
1015
+ const isTrailingAmountOrder = trailingAmount !== undefined;
1016
+ const isTrailingPercentOrder = trailingPercent !== undefined;
1017
+ const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
1018
+ if (isTrailing) {
1019
+ if (trailingTriggerPrice !== undefined) {
1020
+ request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
1021
+ }
1022
+ if (isTrailingAmountOrder) {
1023
+ request['callbackValue'] = trailingAmount;
1024
+ }
1025
+ else if (isTrailingPercentOrder) {
1026
+ const convertedTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
1027
+ request['callbackRate'] = convertedTrailingPercent;
1028
+ }
1029
+ }
1030
+ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent']);
1031
+ const isStop = isTrailing || (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
988
1032
  let response = undefined;
989
1033
  if (isByClientOrder) {
990
1034
  request['client_order_id'] = clientOrderIdExchangeSpecific;
@@ -1184,9 +1228,9 @@ class woo extends woo$1 {
1184
1228
  /**
1185
1229
  * @method
1186
1230
  * @name woo#fetchOrders
1231
+ * @description fetches information on multiple orders made by the user
1187
1232
  * @see https://docs.woo.org/#get-orders
1188
1233
  * @see https://docs.woo.org/#get-algo-orders
1189
- * @description fetches information on multiple orders made by the user
1190
1234
  * @param {string} symbol unified market symbol of the market orders were made in
1191
1235
  * @param {int} [since] the earliest time in ms to fetch orders for
1192
1236
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1194,19 +1238,21 @@ class woo extends woo$1 {
1194
1238
  * @param {boolean} [params.stop] whether the order is a stop/algo order
1195
1239
  * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1196
1240
  * @param {string} [params.side] 'buy' or 'sell'
1241
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1197
1242
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1198
1243
  */
1199
1244
  await this.loadMarkets();
1200
1245
  const request = {};
1201
1246
  let market = undefined;
1202
1247
  const stop = this.safeValue(params, 'stop');
1203
- params = this.omit(params, 'stop');
1248
+ const trailing = this.safeValue(params, 'trailing', false);
1249
+ params = this.omit(params, ['stop', 'trailing']);
1204
1250
  if (symbol !== undefined) {
1205
1251
  market = this.market(symbol);
1206
1252
  request['symbol'] = market['id'];
1207
1253
  }
1208
1254
  if (since !== undefined) {
1209
- if (stop) {
1255
+ if (stop || trailing) {
1210
1256
  request['createdTimeStart'] = since;
1211
1257
  }
1212
1258
  else {
@@ -1216,8 +1262,11 @@ class woo extends woo$1 {
1216
1262
  if (stop) {
1217
1263
  request['algoType'] = 'stop';
1218
1264
  }
1265
+ else if (trailing) {
1266
+ request['algoType'] = 'TRAILING_STOP';
1267
+ }
1219
1268
  let response = undefined;
1220
- if (stop) {
1269
+ if (stop || trailing) {
1221
1270
  response = await this.v3PrivateGetAlgoOrders(this.extend(request, params));
1222
1271
  }
1223
1272
  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.3";
7
+ declare const version = "4.2.5";
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.4';
41
+ const version = '4.2.6';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -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
- const quote = this.safeCurrencyCode(quoteId);
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');
@@ -546,7 +546,7 @@ export default class Exchange {
546
546
  onConnected(client: any, message?: any): void;
547
547
  onError(client: any, error: any): void;
548
548
  onClose(client: any, error: any): void;
549
- close(): Promise<any[]>;
549
+ close(): Promise<void>;
550
550
  loadOrderBook(client: any, messageHash: any, symbol: any, limit?: any, params?: {}): Promise<void>;
551
551
  convertToBigInt(value: string): bigint;
552
552
  stringToCharsArray(value: any): any;