ccxt 4.2.5 → 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 CHANGED
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
209
209
 
210
210
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
211
211
 
212
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.5/dist/ccxt.browser.js
213
- * unpkg: https://unpkg.com/ccxt@4.2.5/dist/ccxt.browser.js
212
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.6/dist/ccxt.browser.js
213
+ * unpkg: https://unpkg.com/ccxt@4.2.6/dist/ccxt.browser.js
214
214
 
215
215
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
216
216
 
217
217
  ```HTML
218
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.5/dist/ccxt.browser.js"></script>
218
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.6/dist/ccxt.browser.js"></script>
219
219
  ```
220
220
 
221
221
  Creates a global `ccxt` object:
@@ -8220,10 +8220,15 @@ class Exchange {
8220
8220
  const closedClients = [];
8221
8221
  for (let i = 0; i < clients.length; i++) {
8222
8222
  const client = clients[i];
8223
- delete this.clients[client.url];
8223
+ client.error = new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeClosedByUser(this.id + ' closedByUser');
8224
8224
  closedClients.push(client.close());
8225
8225
  }
8226
- return Promise.all(closedClients);
8226
+ await Promise.all(closedClients);
8227
+ for (let i = 0; i < clients.length; i++) {
8228
+ const client = clients[i];
8229
+ delete this.clients[client.url];
8230
+ }
8231
+ return;
8227
8232
  }
8228
8233
  async loadOrderBook(client, messageHash, symbol, limit = undefined, params = {}) {
8229
8234
  if (!(symbol in this.orderbooks)) {
@@ -12250,6 +12255,7 @@ __webpack_require__.r(__webpack_exports__);
12250
12255
  /* harmony export */ ContractUnavailable: () => (/* binding */ ContractUnavailable),
12251
12256
  /* harmony export */ DDoSProtection: () => (/* binding */ DDoSProtection),
12252
12257
  /* harmony export */ DuplicateOrderId: () => (/* binding */ DuplicateOrderId),
12258
+ /* harmony export */ ExchangeClosedByUser: () => (/* binding */ ExchangeClosedByUser),
12253
12259
  /* harmony export */ ExchangeError: () => (/* binding */ ExchangeError),
12254
12260
  /* harmony export */ ExchangeNotAvailable: () => (/* binding */ ExchangeNotAvailable),
12255
12261
  /* harmony export */ InsufficientFunds: () => (/* binding */ InsufficientFunds),
@@ -12318,6 +12324,12 @@ class ExchangeError extends Error {
12318
12324
  this.name = 'ExchangeError';
12319
12325
  }
12320
12326
  }
12327
+ class ExchangeClosedByUser extends Error {
12328
+ constructor(message) {
12329
+ super(message);
12330
+ this.name = 'ExchangeClosedByUser';
12331
+ }
12332
+ }
12321
12333
  class AuthenticationError extends ExchangeError {
12322
12334
  constructor(message) {
12323
12335
  super(message);
@@ -12524,7 +12536,7 @@ class RequestTimeout extends NetworkError {
12524
12536
  // // Derived class hierarchy
12525
12537
  // errorHierarchy
12526
12538
  // )
12527
- const errors = { 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, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
12539
+ const errors = { BaseError, ExchangeClosedByUser, 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, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
12528
12540
 
12529
12541
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (errors);
12530
12542
 
@@ -14515,6 +14527,9 @@ class Client {
14515
14527
  // todo: exception types for server-side disconnects
14516
14528
  this.reset(new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.NetworkError('connection closed by remote server, closing code ' + String(event.code)));
14517
14529
  }
14530
+ if (this.error instanceof _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeClosedByUser) {
14531
+ this.reset(this.error);
14532
+ }
14518
14533
  if (this.disconnected !== undefined) {
14519
14534
  this.disconnected.resolve(true);
14520
14535
  }
@@ -14535,6 +14550,7 @@ class Client {
14535
14550
  const future = (0,_Future_js__WEBPACK_IMPORTED_MODULE_2__/* .Future */ .o)();
14536
14551
  if (_base_functions_js__WEBPACK_IMPORTED_MODULE_5__/* .isNode */ .UG) {
14537
14552
  /* eslint-disable no-inner-declarations */
14553
+ /* eslint-disable jsdoc/require-jsdoc */
14538
14554
  function onSendComplete(error) {
14539
14555
  if (error) {
14540
14556
  future.reject(error);
@@ -29295,6 +29311,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
29295
29311
  * @param {string} id order id
29296
29312
  * @param {string} symbol unified symbol of the market the order was made in
29297
29313
  * @param {object} [params] extra parameters specific to the exchange API endpoint
29314
+ * @param {string} [params.clientOrderId] a unique id for the order
29298
29315
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
29299
29316
  */
29300
29317
  if (symbol === undefined) {
@@ -29304,8 +29321,15 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
29304
29321
  const market = this.market(symbol);
29305
29322
  const request = {
29306
29323
  'symbol': market['id'],
29307
- 'orderId': id,
29308
29324
  };
29325
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientOrderID');
29326
+ params = this.omit(params, ['clientOrderId']);
29327
+ if (clientOrderId !== undefined) {
29328
+ request['clientOrderID'] = clientOrderId;
29329
+ }
29330
+ else {
29331
+ request['orderId'] = id;
29332
+ }
29309
29333
  let response = undefined;
29310
29334
  const [marketType, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
29311
29335
  if (marketType === 'spot') {
@@ -56183,14 +56207,15 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
56183
56207
  * @param {object} [params] extra parameters specific to the exchange API endpoint
56184
56208
  * @param {object} [params.triggerPrice] the price at which a trigger order is triggered at
56185
56209
  * @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'above' or 'below'
56210
+ * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
56186
56211
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
56187
56212
  */
56188
56213
  await this.loadMarkets();
56189
56214
  const market = this.market(symbol);
56190
- const orderType = this.capitalize(type);
56215
+ let orderType = this.capitalize(type);
56191
56216
  const reduceOnly = this.safeValue(params, 'reduceOnly');
56192
56217
  if (reduceOnly !== undefined) {
56193
- if ((market['type'] !== 'swap') && (market['type'] !== 'future')) {
56218
+ if ((!market['swap']) && (!market['future'])) {
56194
56219
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap and future markets only');
56195
56220
  }
56196
56221
  }
@@ -56203,44 +56228,54 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
56203
56228
  'ordType': orderType,
56204
56229
  'text': brokerId,
56205
56230
  };
56206
- const customTriggerType = (orderType === 'Stop') || (orderType === 'StopLimit') || (orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched');
56207
56231
  // support for unified trigger format
56208
56232
  const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPx', 'stopPrice']);
56209
- if ((triggerPrice !== undefined) && !customTriggerType) {
56210
- request['stopPx'] = parseFloat(this.priceToPrecision(symbol, triggerPrice));
56233
+ let trailingAmount = this.safeString2(params, 'trailingAmount', 'pegOffsetValue');
56234
+ const isTriggerOrder = triggerPrice !== undefined;
56235
+ const isTrailingAmountOrder = trailingAmount !== undefined;
56236
+ if (isTriggerOrder || isTrailingAmountOrder) {
56211
56237
  const triggerDirection = this.safeString(params, 'triggerDirection');
56212
- params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection']);
56213
56238
  const triggerAbove = (triggerDirection === 'above');
56214
- this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
56215
- this.checkRequiredArgument('createOrder', side, 'side', ['buy', 'sell']);
56239
+ if ((type === 'limit') || (type === 'market')) {
56240
+ this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
56241
+ }
56216
56242
  if (type === 'limit') {
56217
- request['price'] = parseFloat(this.priceToPrecision(symbol, price));
56218
56243
  if (side === 'buy') {
56219
- request['ordType'] = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
56244
+ orderType = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
56220
56245
  }
56221
56246
  else {
56222
- request['ordType'] = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
56247
+ orderType = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
56223
56248
  }
56224
56249
  }
56225
56250
  else if (type === 'market') {
56226
56251
  if (side === 'buy') {
56227
- request['ordType'] = triggerAbove ? 'Stop' : 'MarketIfTouched';
56252
+ orderType = triggerAbove ? 'Stop' : 'MarketIfTouched';
56228
56253
  }
56229
56254
  else {
56230
- request['ordType'] = triggerAbove ? 'MarketIfTouched' : 'Stop';
56255
+ orderType = triggerAbove ? 'MarketIfTouched' : 'Stop';
56231
56256
  }
56232
56257
  }
56233
- }
56234
- else if (customTriggerType) {
56235
- if (triggerPrice === undefined) {
56236
- // if exchange specific trigger types were provided
56237
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder() requires a triggerPrice (stopPx|stopPrice) parameter for the ' + orderType + ' order type');
56258
+ if (isTrailingAmountOrder) {
56259
+ const isStopSellOrder = (side === 'sell') && ((orderType === 'Stop') || (orderType === 'StopLimit'));
56260
+ const isBuyIfTouchedOrder = (side === 'buy') && ((orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched'));
56261
+ if (isStopSellOrder || isBuyIfTouchedOrder) {
56262
+ trailingAmount = '-' + trailingAmount;
56263
+ }
56264
+ request['pegOffsetValue'] = this.parseToNumeric(trailingAmount);
56265
+ request['pegPriceType'] = 'TrailingStopPeg';
56266
+ }
56267
+ else {
56268
+ if (triggerPrice === undefined) {
56269
+ // if exchange specific trigger types were provided
56270
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder() requires a triggerPrice (stopPx|stopPrice) parameter for the ' + orderType + ' order type');
56271
+ }
56272
+ request['stopPx'] = this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice));
56238
56273
  }
56239
- params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopPx']);
56240
- request['stopPx'] = parseFloat(this.priceToPrecision(symbol, triggerPrice));
56274
+ request['ordType'] = orderType;
56275
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection', 'trailingAmount']);
56241
56276
  }
56242
56277
  if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) {
56243
- request['price'] = parseFloat(this.priceToPrecision(symbol, price));
56278
+ request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
56244
56279
  }
56245
56280
  const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId');
56246
56281
  if (clientOrderId !== undefined) {
@@ -56253,6 +56288,39 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
56253
56288
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
56254
56289
  await this.loadMarkets();
56255
56290
  const request = {};
56291
+ let trailingAmount = this.safeString2(params, 'trailingAmount', 'pegOffsetValue');
56292
+ const isTrailingAmountOrder = trailingAmount !== undefined;
56293
+ if (isTrailingAmountOrder) {
56294
+ const triggerDirection = this.safeString(params, 'triggerDirection');
56295
+ const triggerAbove = (triggerDirection === 'above');
56296
+ if ((type === 'limit') || (type === 'market')) {
56297
+ this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
56298
+ }
56299
+ let orderType = undefined;
56300
+ if (type === 'limit') {
56301
+ if (side === 'buy') {
56302
+ orderType = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
56303
+ }
56304
+ else {
56305
+ orderType = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
56306
+ }
56307
+ }
56308
+ else if (type === 'market') {
56309
+ if (side === 'buy') {
56310
+ orderType = triggerAbove ? 'Stop' : 'MarketIfTouched';
56311
+ }
56312
+ else {
56313
+ orderType = triggerAbove ? 'MarketIfTouched' : 'Stop';
56314
+ }
56315
+ }
56316
+ const isStopSellOrder = (side === 'sell') && ((orderType === 'Stop') || (orderType === 'StopLimit'));
56317
+ const isBuyIfTouchedOrder = (side === 'buy') && ((orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched'));
56318
+ if (isStopSellOrder || isBuyIfTouchedOrder) {
56319
+ trailingAmount = '-' + trailingAmount;
56320
+ }
56321
+ request['pegOffsetValue'] = this.parseToNumeric(trailingAmount);
56322
+ params = this.omit(params, ['triggerDirection', 'trailingAmount']);
56323
+ }
56256
56324
  const origClOrdID = this.safeString2(params, 'origClOrdID', 'clientOrderId');
56257
56325
  if (origClOrdID !== undefined) {
56258
56326
  request['origClOrdID'] = origClOrdID;
@@ -138822,7 +138890,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
138822
138890
  'repayIsolatedMargin': true,
138823
138891
  'setLeverage': true,
138824
138892
  'setMarginMode': false,
138825
- 'setPositionMode': false,
138893
+ 'setPositionMode': true,
138826
138894
  'signIn': undefined,
138827
138895
  'transfer': true,
138828
138896
  'withdraw': true,
@@ -147659,6 +147727,71 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
147659
147727
  'datetime': this.iso8601(timestamp),
147660
147728
  });
147661
147729
  }
147730
+ async setPositionMode(hedged, symbol = undefined, params = {}) {
147731
+ /**
147732
+ * @method
147733
+ * @name htx#setPositionMode
147734
+ * @description set hedged to true or false
147735
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
147736
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
147737
+ * @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
147738
+ * @param {string} [symbol] unified market symbol, required for isolated margin mode
147739
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
147740
+ * @param {string} [params.marginMode] "cross" (default) or "isolated"
147741
+ * @returns {object} response from the exchange
147742
+ */
147743
+ await this.loadMarkets();
147744
+ const posMode = hedged ? 'dual_side' : 'single_side';
147745
+ let market = undefined;
147746
+ if (symbol !== undefined) {
147747
+ market = this.market(symbol);
147748
+ }
147749
+ let marginMode = undefined;
147750
+ [marginMode, params] = this.handleMarginModeAndParams('setPositionMode', params, 'cross');
147751
+ const request = {
147752
+ 'position_mode': posMode,
147753
+ };
147754
+ let response = undefined;
147755
+ if ((market !== undefined) && (market['inverse'])) {
147756
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' setPositionMode can only be used for linear markets');
147757
+ }
147758
+ if (marginMode === 'isolated') {
147759
+ if (symbol === undefined) {
147760
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setPositionMode requires a symbol argument for isolated margin mode');
147761
+ }
147762
+ request['margin_account'] = market['id'];
147763
+ response = await this.contractPrivatePostLinearSwapApiV1SwapSwitchPositionMode(this.extend(request, params));
147764
+ //
147765
+ // {
147766
+ // "status": "ok",
147767
+ // "data": [
147768
+ // {
147769
+ // "margin_account": "BTC-USDT",
147770
+ // "position_mode": "single_side"
147771
+ // }
147772
+ // ],
147773
+ // "ts": 1566899973811
147774
+ // }
147775
+ //
147776
+ }
147777
+ else {
147778
+ request['margin_account'] = 'USDT';
147779
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossSwitchPositionMode(this.extend(request, params));
147780
+ //
147781
+ // {
147782
+ // "status": "ok",
147783
+ // "data": [
147784
+ // {
147785
+ // "margin_account": "USDT",
147786
+ // "position_mode": "single_side"
147787
+ // }
147788
+ // ],
147789
+ // "ts": 1566899973811
147790
+ // }
147791
+ //
147792
+ }
147793
+ return response;
147794
+ }
147662
147795
  }
147663
147796
 
147664
147797
 
@@ -280303,9 +280436,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280303
280436
  /**
280304
280437
  * @method
280305
280438
  * @name woo#createOrder
280439
+ * @description create a trade order
280306
280440
  * @see https://docs.woo.org/#send-order
280307
280441
  * @see https://docs.woo.org/#send-algo-order
280308
- * @description create a trade order
280309
280442
  * @param {string} symbol unified symbol of the market to create an order in
280310
280443
  * @param {string} type 'market' or 'limit'
280311
280444
  * @param {string} side 'buy' or 'sell'
@@ -280319,6 +280452,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280319
280452
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
280320
280453
  * @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
280321
280454
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
280455
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
280456
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
280457
+ * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
280322
280458
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
280323
280459
  */
280324
280460
  const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
@@ -280335,7 +280471,13 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280335
280471
  const stopLoss = this.safeValue(params, 'stopLoss');
280336
280472
  const takeProfit = this.safeValue(params, 'takeProfit');
280337
280473
  const algoType = this.safeString(params, 'algoType');
280338
- const isStop = stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
280474
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
280475
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
280476
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
280477
+ const isTrailingAmountOrder = trailingAmount !== undefined;
280478
+ const isTrailingPercentOrder = trailingPercent !== undefined;
280479
+ const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
280480
+ const isStop = isTrailing || stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
280339
280481
  const isMarket = orderType === 'MARKET';
280340
280482
  const timeInForce = this.safeStringLower(params, 'timeInForce');
280341
280483
  const postOnly = this.isPostOnly(isMarket, undefined, params);
@@ -280400,7 +280542,21 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280400
280542
  if (clientOrderId !== undefined) {
280401
280543
  request[clientOrderIdKey] = clientOrderId;
280402
280544
  }
280403
- if (stopPrice !== undefined) {
280545
+ if (isTrailing) {
280546
+ if (trailingTriggerPrice === undefined) {
280547
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder() requires a trailingTriggerPrice parameter for trailing orders');
280548
+ }
280549
+ request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
280550
+ request['algoType'] = 'TRAILING_STOP';
280551
+ if (isTrailingAmountOrder) {
280552
+ request['callbackValue'] = trailingAmount;
280553
+ }
280554
+ else if (isTrailingPercentOrder) {
280555
+ const convertedTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
280556
+ request['callbackRate'] = convertedTrailingPercent;
280557
+ }
280558
+ }
280559
+ else if (stopPrice !== undefined) {
280404
280560
  if (algoType !== 'TRAILING_STOP') {
280405
280561
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
280406
280562
  request['algoType'] = 'STOP';
@@ -280439,7 +280595,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280439
280595
  }
280440
280596
  request['childOrders'] = [outterOrder];
280441
280597
  }
280442
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit']);
280598
+ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']);
280443
280599
  let response = undefined;
280444
280600
  if (isStop) {
280445
280601
  response = await this.v3PrivatePostAlgoOrder(this.extend(request, params));
@@ -280485,11 +280641,11 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280485
280641
  /**
280486
280642
  * @method
280487
280643
  * @name woo#editOrder
280644
+ * @description edit a trade order
280488
280645
  * @see https://docs.woo.org/#edit-order
280489
280646
  * @see https://docs.woo.org/#edit-order-by-client_order_id
280490
280647
  * @see https://docs.woo.org/#edit-algo-order
280491
280648
  * @see https://docs.woo.org/#edit-algo-order-by-client_order_id
280492
- * @description edit a trade order
280493
280649
  * @param {string} id order id
280494
280650
  * @param {string} symbol unified symbol of the market to create an order in
280495
280651
  * @param {string} type 'market' or 'limit'
@@ -280500,6 +280656,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280500
280656
  * @param {float} [params.triggerPrice] The price a trigger order is triggered at
280501
280657
  * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
280502
280658
  * @param {float} [params.takeProfitPrice] price to trigger take-profit orders
280659
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
280660
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
280661
+ * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
280503
280662
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
280504
280663
  */
280505
280664
  await this.loadMarkets();
@@ -280521,8 +280680,26 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280521
280680
  if (stopPrice !== undefined) {
280522
280681
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
280523
280682
  }
280524
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice']);
280525
- const isStop = (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
280683
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
280684
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
280685
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
280686
+ const isTrailingAmountOrder = trailingAmount !== undefined;
280687
+ const isTrailingPercentOrder = trailingPercent !== undefined;
280688
+ const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
280689
+ if (isTrailing) {
280690
+ if (trailingTriggerPrice !== undefined) {
280691
+ request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
280692
+ }
280693
+ if (isTrailingAmountOrder) {
280694
+ request['callbackValue'] = trailingAmount;
280695
+ }
280696
+ else if (isTrailingPercentOrder) {
280697
+ const convertedTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
280698
+ request['callbackRate'] = convertedTrailingPercent;
280699
+ }
280700
+ }
280701
+ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent']);
280702
+ const isStop = isTrailing || (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
280526
280703
  let response = undefined;
280527
280704
  if (isByClientOrder) {
280528
280705
  request['client_order_id'] = clientOrderIdExchangeSpecific;
@@ -280722,9 +280899,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280722
280899
  /**
280723
280900
  * @method
280724
280901
  * @name woo#fetchOrders
280902
+ * @description fetches information on multiple orders made by the user
280725
280903
  * @see https://docs.woo.org/#get-orders
280726
280904
  * @see https://docs.woo.org/#get-algo-orders
280727
- * @description fetches information on multiple orders made by the user
280728
280905
  * @param {string} symbol unified market symbol of the market orders were made in
280729
280906
  * @param {int} [since] the earliest time in ms to fetch orders for
280730
280907
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -280732,19 +280909,21 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280732
280909
  * @param {boolean} [params.stop] whether the order is a stop/algo order
280733
280910
  * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
280734
280911
  * @param {string} [params.side] 'buy' or 'sell'
280912
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
280735
280913
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
280736
280914
  */
280737
280915
  await this.loadMarkets();
280738
280916
  const request = {};
280739
280917
  let market = undefined;
280740
280918
  const stop = this.safeValue(params, 'stop');
280741
- params = this.omit(params, 'stop');
280919
+ const trailing = this.safeValue(params, 'trailing', false);
280920
+ params = this.omit(params, ['stop', 'trailing']);
280742
280921
  if (symbol !== undefined) {
280743
280922
  market = this.market(symbol);
280744
280923
  request['symbol'] = market['id'];
280745
280924
  }
280746
280925
  if (since !== undefined) {
280747
- if (stop) {
280926
+ if (stop || trailing) {
280748
280927
  request['createdTimeStart'] = since;
280749
280928
  }
280750
280929
  else {
@@ -280754,8 +280933,11 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280754
280933
  if (stop) {
280755
280934
  request['algoType'] = 'stop';
280756
280935
  }
280936
+ else if (trailing) {
280937
+ request['algoType'] = 'TRAILING_STOP';
280938
+ }
280757
280939
  let response = undefined;
280758
- if (stop) {
280940
+ if (stop || trailing) {
280759
280941
  response = await this.v3PrivateGetAlgoOrders(this.extend(request, params));
280760
280942
  }
280761
280943
  else {
@@ -291718,7 +291900,7 @@ SOFTWARE.
291718
291900
 
291719
291901
  //-----------------------------------------------------------------------------
291720
291902
  // this is updated by vss.js when building
291721
- const version = '4.2.5';
291903
+ const version = '4.2.6';
291722
291904
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
291723
291905
  //-----------------------------------------------------------------------------
291724
291906