ccxt 4.2.5 → 4.2.7

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/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 isStop = stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
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 (stopPrice !== undefined) {
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
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice']);
990
- const isStop = (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
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
- params = this.omit(params, 'stop');
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",