ccxt 4.0.111 → 4.0.112

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.
@@ -498,6 +498,7 @@ export default class coinbasepro extends Exchange {
498
498
  /**
499
499
  * @method
500
500
  * @name coinbasepro#fetchOrderBook
501
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductbook
501
502
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
502
503
  * @param {string} symbol unified symbol of the market to fetch the order book for
503
504
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -663,6 +664,7 @@ export default class coinbasepro extends Exchange {
663
664
  /**
664
665
  * @method
665
666
  * @name coinbasepro#fetchTicker
667
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker
666
668
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
667
669
  * @param {string} symbol unified symbol of the market to fetch the ticker for
668
670
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
@@ -776,17 +778,16 @@ export default class coinbasepro extends Exchange {
776
778
  /**
777
779
  * @method
778
780
  * @name coinbasepro#fetchMyTrades
781
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfills
779
782
  * @description fetch all trades made by the user
780
783
  * @param {string} symbol unified market symbol
781
784
  * @param {int} [since] the earliest time in ms to fetch trades for
782
785
  * @param {int} [limit] the maximum number of trades structures to retrieve
783
786
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
787
+ * @param {int} [params.until] the latest time in ms to fetch trades for
784
788
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
785
789
  */
786
- // as of 2018-08-23
787
- if (symbol === undefined) {
788
- throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
789
- }
790
+ this.checkRequiredSymbol('fetchMyTrades', symbol);
790
791
  await this.loadMarkets();
791
792
  const market = this.market(symbol);
792
793
  const request = {
@@ -795,6 +796,14 @@ export default class coinbasepro extends Exchange {
795
796
  if (limit !== undefined) {
796
797
  request['limit'] = limit;
797
798
  }
799
+ if (since !== undefined) {
800
+ request['start_date'] = this.iso8601(since);
801
+ }
802
+ const until = this.safeValue2(params, 'until', 'end_date');
803
+ if (until !== undefined) {
804
+ params = this.omit(params, ['until']);
805
+ request['end_date'] = this.iso8601(until);
806
+ }
798
807
  const response = await this.privateGetFills(this.extend(request, params));
799
808
  return this.parseTrades(response, market, since, limit);
800
809
  }
@@ -802,6 +811,7 @@ export default class coinbasepro extends Exchange {
802
811
  /**
803
812
  * @method
804
813
  * @name coinbasepro#fetchTrades
814
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducttrades
805
815
  * @description get the list of most recent trades for a particular symbol
806
816
  * @param {string} symbol unified symbol of the market to fetch trades for
807
817
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -888,12 +898,14 @@ export default class coinbasepro extends Exchange {
888
898
  /**
889
899
  * @method
890
900
  * @name coinbasepro#fetchOHLCV
901
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles
891
902
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
892
903
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
893
904
  * @param {string} timeframe the length of time each candle represents
894
905
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
895
906
  * @param {int} [limit] the maximum amount of candles to fetch
896
907
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
908
+ * @param {int} [params.until] the latest time in ms to fetch trades for
897
909
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
898
910
  */
899
911
  await this.loadMarkets();
@@ -908,6 +920,8 @@ export default class coinbasepro extends Exchange {
908
920
  else {
909
921
  request['granularity'] = timeframe;
910
922
  }
923
+ const until = this.safeValue2(params, 'until', 'end');
924
+ params = this.omit(params, ['until']);
911
925
  if (since !== undefined) {
912
926
  request['start'] = this.iso8601(since);
913
927
  if (limit === undefined) {
@@ -917,12 +931,17 @@ export default class coinbasepro extends Exchange {
917
931
  else {
918
932
  limit = Math.min(300, limit);
919
933
  }
920
- const parsedTimeframeMilliseconds = parsedTimeframe * 1000;
921
- if (since % parsedTimeframeMilliseconds === 0) {
922
- request['end'] = this.iso8601(this.sum((limit - 1) * parsedTimeframeMilliseconds, since));
934
+ if (until === undefined) {
935
+ const parsedTimeframeMilliseconds = parsedTimeframe * 1000;
936
+ if (since % parsedTimeframeMilliseconds === 0) {
937
+ request['end'] = this.iso8601(this.sum((limit - 1) * parsedTimeframeMilliseconds, since));
938
+ }
939
+ else {
940
+ request['end'] = this.iso8601(this.sum(limit * parsedTimeframeMilliseconds, since));
941
+ }
923
942
  }
924
943
  else {
925
- request['end'] = this.iso8601(this.sum(limit * parsedTimeframeMilliseconds, since));
944
+ request['end'] = this.iso8601(until);
926
945
  }
927
946
  }
928
947
  const response = await this.publicGetProductsIdCandles(this.extend(request, params));
@@ -1042,6 +1061,7 @@ export default class coinbasepro extends Exchange {
1042
1061
  /**
1043
1062
  * @method
1044
1063
  * @name coinbasepro#fetchOrder
1064
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorder
1045
1065
  * @description fetches information on an order made by the user
1046
1066
  * @param {string} symbol not used by coinbasepro fetchOrder
1047
1067
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
@@ -1090,11 +1110,13 @@ export default class coinbasepro extends Exchange {
1090
1110
  /**
1091
1111
  * @method
1092
1112
  * @name coinbasepro#fetchOrders
1113
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders
1093
1114
  * @description fetches information on multiple orders made by the user
1094
1115
  * @param {string} symbol unified market symbol of the market orders were made in
1095
1116
  * @param {int} [since] the earliest time in ms to fetch orders for
1096
1117
  * @param {int} [limit] the maximum number of orde structures to retrieve
1097
1118
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1119
+ * @param {int} [params.until] the latest time in ms to fetch open orders for
1098
1120
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1099
1121
  */
1100
1122
  const request = {
@@ -1106,11 +1128,13 @@ export default class coinbasepro extends Exchange {
1106
1128
  /**
1107
1129
  * @method
1108
1130
  * @name coinbasepro#fetchOpenOrders
1131
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders
1109
1132
  * @description fetch all unfilled currently open orders
1110
1133
  * @param {string} symbol unified market symbol
1111
1134
  * @param {int} [since] the earliest time in ms to fetch open orders for
1112
1135
  * @param {int} [limit] the maximum number of open orders structures to retrieve
1113
1136
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1137
+ * @param {int} [params.until] the latest time in ms to fetch open orders for
1114
1138
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1115
1139
  */
1116
1140
  await this.loadMarkets();
@@ -1123,6 +1147,14 @@ export default class coinbasepro extends Exchange {
1123
1147
  if (limit !== undefined) {
1124
1148
  request['limit'] = limit; // default 100
1125
1149
  }
1150
+ if (since !== undefined) {
1151
+ request['start_date'] = this.iso8601(since);
1152
+ }
1153
+ const until = this.safeValue2(params, 'until', 'end_date');
1154
+ if (until !== undefined) {
1155
+ params = this.omit(params, ['until']);
1156
+ request['end_date'] = this.iso8601(until);
1157
+ }
1126
1158
  const response = await this.privateGetOrders(this.extend(request, params));
1127
1159
  return this.parseOrders(response, market, since, limit);
1128
1160
  }
@@ -1130,11 +1162,13 @@ export default class coinbasepro extends Exchange {
1130
1162
  /**
1131
1163
  * @method
1132
1164
  * @name coinbasepro#fetchClosedOrders
1165
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders
1133
1166
  * @description fetches information on multiple closed orders made by the user
1134
1167
  * @param {string} symbol unified market symbol of the market orders were made in
1135
1168
  * @param {int} [since] the earliest time in ms to fetch orders for
1136
1169
  * @param {int} [limit] the maximum number of orde structures to retrieve
1137
1170
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1171
+ * @param {int} [params.until] the latest time in ms to fetch open orders for
1138
1172
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1139
1173
  */
1140
1174
  const request = {
@@ -1146,6 +1180,7 @@ export default class coinbasepro extends Exchange {
1146
1180
  /**
1147
1181
  * @method
1148
1182
  * @name coinbasepro#createOrder
1183
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders
1149
1184
  * @description create a trade order
1150
1185
  * @param {string} symbol unified symbol of the market to create an order in
1151
1186
  * @param {string} type 'market' or 'limit'
@@ -1241,6 +1276,7 @@ export default class coinbasepro extends Exchange {
1241
1276
  /**
1242
1277
  * @method
1243
1278
  * @name coinbasepro#cancelOrder
1279
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_deleteorder
1244
1280
  * @description cancels an open order
1245
1281
  * @param {string} id order id
1246
1282
  * @param {string} symbol unified symbol of the market the order was made in
@@ -1273,6 +1309,7 @@ export default class coinbasepro extends Exchange {
1273
1309
  /**
1274
1310
  * @method
1275
1311
  * @name coinbasepro#cancelAllOrders
1312
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_deleteorders
1276
1313
  * @description cancel all open orders
1277
1314
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1278
1315
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
@@ -1459,11 +1496,13 @@ export default class coinbasepro extends Exchange {
1459
1496
  /**
1460
1497
  * @method
1461
1498
  * @name coinbasepro#fetchLedger
1499
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger
1462
1500
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1463
1501
  * @param {string} code unified currency code, default is undefined
1464
1502
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1465
1503
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
1466
1504
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1505
+ * @param {int} [params.until] the latest time in ms to fetch trades for
1467
1506
  * @returns {object} a [ledger structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ledger-structure}
1468
1507
  */
1469
1508
  // https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger
@@ -1493,6 +1532,11 @@ export default class coinbasepro extends Exchange {
1493
1532
  if (limit !== undefined) {
1494
1533
  request['limit'] = limit; // default 100
1495
1534
  }
1535
+ const until = this.safeValue2(params, 'until', 'end_date');
1536
+ if (until !== undefined) {
1537
+ params = this.omit(params, ['until']);
1538
+ request['end_date'] = this.iso8601(until);
1539
+ }
1496
1540
  const response = await this.privateGetAccountsIdLedger(this.extend(request, params));
1497
1541
  for (let i = 0; i < response.length; i++) {
1498
1542
  response[i]['currency'] = code;
package/js/src/latoken.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/latoken.js';
9
- import { ExchangeError, AuthenticationError, ArgumentsRequired, InvalidNonce, BadRequest, ExchangeNotAvailable, PermissionDenied, AccountSuspended, RateLimitExceeded, InsufficientFunds, BadSymbol, InvalidOrder } from './base/errors.js';
9
+ import { ExchangeError, AuthenticationError, InvalidNonce, BadRequest, ExchangeNotAvailable, PermissionDenied, AccountSuspended, RateLimitExceeded, InsufficientFunds, BadSymbol, InvalidOrder } from './base/errors.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { sha512 } from './static_dependencies/noble-hashes/sha512.js';
12
12
  // ---------------------------------------------------------------------------
@@ -32,6 +32,10 @@ export default class latoken extends Exchange {
32
32
  'cancelAllOrders': true,
33
33
  'cancelOrder': true,
34
34
  'createOrder': true,
35
+ 'createPostOnlyOrder': false,
36
+ 'createStopOrder': true,
37
+ 'createStopLimitOrder': true,
38
+ 'createStopMarketOrder': false,
35
39
  'fetchBalance': true,
36
40
  'fetchBorrowRate': false,
37
41
  'fetchBorrowRateHistories': false,
@@ -954,16 +958,16 @@ export default class latoken extends Exchange {
954
958
  //
955
959
  // createOrder
956
960
  //
957
- // {
958
- // "orderId":"1563460093.134037.704945@0370:2",
959
- // "cliOrdId":"",
960
- // "pairId":370,
961
- // "symbol":"ETHBTC",
962
- // "side":"sell",
963
- // "orderType":"limit",
964
- // "price":1.0,
965
- // "amount":1.0
966
- // }
961
+ // {
962
+ // "baseCurrency": "f7dac554-8139-4ff6-841f-0e586a5984a0",
963
+ // "quoteCurrency": "a5a7a7a9-e2a3-43f9-8754-29a02f6b709b",
964
+ // "side": "BID",
965
+ // "clientOrderId": "my-wonderful-order-number-71566",
966
+ // "price": "10103.19",
967
+ // "stopPrice": "10103.19",
968
+ // "quantity": "3.21",
969
+ // "timestamp": 1568185507
970
+ // }
967
971
  //
968
972
  // fetchOrder, fetchOpenOrders, fetchOrders
969
973
  //
@@ -1031,6 +1035,7 @@ export default class latoken extends Exchange {
1031
1035
  }
1032
1036
  const clientOrderId = this.safeString(order, 'clientOrderId');
1033
1037
  const timeInForce = this.parseTimeInForce(this.safeString(order, 'condition'));
1038
+ const triggerPrice = this.safeString(order, 'stopPrice');
1034
1039
  return this.safeOrder({
1035
1040
  'id': id,
1036
1041
  'clientOrderId': clientOrderId,
@@ -1045,8 +1050,8 @@ export default class latoken extends Exchange {
1045
1050
  'postOnly': undefined,
1046
1051
  'side': side,
1047
1052
  'price': price,
1048
- 'stopPrice': undefined,
1049
- 'triggerPrice': undefined,
1053
+ 'stopPrice': triggerPrice,
1054
+ 'triggerPrice': triggerPrice,
1050
1055
  'cost': cost,
1051
1056
  'amount': amount,
1052
1057
  'filled': filled,
@@ -1061,22 +1066,33 @@ export default class latoken extends Exchange {
1061
1066
  * @method
1062
1067
  * @name latoken#fetchOpenOrders
1063
1068
  * @description fetch all unfilled currently open orders
1069
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrdersByPair
1070
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyActiveStopOrdersByPair // stop
1064
1071
  * @param {string} symbol unified market symbol
1065
1072
  * @param {int} [since] the earliest time in ms to fetch open orders for
1066
1073
  * @param {int} [limit] the maximum number of open orders structures to retrieve
1067
1074
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1075
+ * @param {boolean} [params.trigger] true if fetching trigger orders
1068
1076
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1069
- */
1070
- if (symbol === undefined) {
1071
- throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
1072
- }
1077
+ */
1073
1078
  await this.loadMarkets();
1074
- const market = this.market(symbol);
1079
+ let response = undefined;
1080
+ let market = undefined;
1081
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1082
+ params = this.omit(params, 'stop');
1083
+ this.checkRequiredSymbol('fetchOpenOrders', symbol);
1084
+ // privateGetAuthOrderActive doesn't work even though its listed at https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrders
1085
+ market = this.market(symbol);
1075
1086
  const request = {
1076
1087
  'currency': market['baseId'],
1077
1088
  'quote': market['quoteId'],
1078
1089
  };
1079
- const response = await this.privateGetAuthOrderPairCurrencyQuoteActive(this.extend(request, params));
1090
+ if (isTrigger) {
1091
+ response = await this.privateGetAuthStopOrderPairCurrencyQuoteActive(this.extend(request, params));
1092
+ }
1093
+ else {
1094
+ response = await this.privateGetAuthOrderPairCurrencyQuoteActive(this.extend(request, params));
1095
+ }
1080
1096
  //
1081
1097
  // [
1082
1098
  // {
@@ -1106,10 +1122,15 @@ export default class latoken extends Exchange {
1106
1122
  * @method
1107
1123
  * @name latoken#fetchOrders
1108
1124
  * @description fetches information on multiple orders made by the user
1125
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrders
1126
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrdersByPair
1127
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrders // stop
1128
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrdersByPair // stop
1109
1129
  * @param {string} symbol unified market symbol of the market orders were made in
1110
1130
  * @param {int} [since] the earliest time in ms to fetch orders for
1111
1131
  * @param {int} [limit] the maximum number of orde structures to retrieve
1112
1132
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1133
+ * @param {boolean} [params.trigger] true if fetching trigger orders
1113
1134
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1114
1135
  */
1115
1136
  await this.loadMarkets();
@@ -1119,18 +1140,32 @@ export default class latoken extends Exchange {
1119
1140
  // 'from': this.milliseconds (),
1120
1141
  // 'limit': limit, // default '100'
1121
1142
  };
1122
- let method = 'privateGetAuthOrder';
1123
1143
  let market = undefined;
1144
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1145
+ params = this.omit(params, ['stop', 'trigger']);
1146
+ if (limit !== undefined) {
1147
+ request['limit'] = limit; // default 100
1148
+ }
1149
+ let response = undefined;
1124
1150
  if (symbol !== undefined) {
1125
1151
  market = this.market(symbol);
1126
1152
  request['currency'] = market['baseId'];
1127
1153
  request['quote'] = market['quoteId'];
1128
- method = 'privateGetAuthOrderPairCurrencyQuote';
1154
+ if (isTrigger) {
1155
+ response = await this.privateGetAuthStopOrderPairCurrencyQuote(this.extend(request, params));
1156
+ }
1157
+ else {
1158
+ response = await this.privateGetAuthOrderPairCurrencyQuote(this.extend(request, params));
1159
+ }
1129
1160
  }
1130
- if (limit !== undefined) {
1131
- request['limit'] = limit; // default 100
1161
+ else {
1162
+ if (isTrigger) {
1163
+ response = await this.privateGetAuthStopOrder(this.extend(request, params));
1164
+ }
1165
+ else {
1166
+ response = await this.privateGetAuthOrder(this.extend(request, params));
1167
+ }
1132
1168
  }
1133
- const response = await this[method](this.extend(request, params));
1134
1169
  //
1135
1170
  // [
1136
1171
  // {
@@ -1160,15 +1195,26 @@ export default class latoken extends Exchange {
1160
1195
  * @method
1161
1196
  * @name latoken#fetchOrder
1162
1197
  * @description fetches information on an order made by the user
1163
- * @param {string} symbol not used by latoken fetchOrder
1198
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getOrderById
1199
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getStopOrderById
1200
+ * @param {string} [symbol] not used by latoken fetchOrder
1164
1201
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1202
+ * @param {boolean} [params.trigger] true if fetching a trigger order
1165
1203
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1166
1204
  */
1167
1205
  await this.loadMarkets();
1168
1206
  const request = {
1169
1207
  'id': id,
1170
1208
  };
1171
- const response = await this.privateGetAuthOrderGetOrderId(this.extend(request, params));
1209
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1210
+ params = this.omit(params, ['stop', 'trigger']);
1211
+ let response = undefined;
1212
+ if (isTrigger) {
1213
+ response = await this.privateGetAuthStopOrderGetOrderId(this.extend(request, params));
1214
+ }
1215
+ else {
1216
+ response = await this.privateGetAuthOrderGetOrderId(this.extend(request, params));
1217
+ }
1172
1218
  //
1173
1219
  // {
1174
1220
  // "id":"a76bd262-3560-4bfb-98ac-1cedd394f4fc",
@@ -1196,12 +1242,19 @@ export default class latoken extends Exchange {
1196
1242
  * @method
1197
1243
  * @name latoken#createOrder
1198
1244
  * @description create a trade order
1245
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/placeOrder
1246
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/placeStopOrder // stop
1199
1247
  * @param {string} symbol unified symbol of the market to create an order in
1200
1248
  * @param {string} type 'market' or 'limit'
1201
1249
  * @param {string} side 'buy' or 'sell'
1202
1250
  * @param {float} amount how much of currency you want to trade in units of base currency
1203
1251
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1204
1252
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1253
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
1254
+ *
1255
+ * EXCHANGE SPECIFIC PARAMETERS
1256
+ * @param {string} [params.condition] "GTC", "IOC", or "FOK"
1257
+ * @param {string} [params.clientOrderId] [ 0 .. 50 ] characters, client's custom order id (free field for your convenience)
1205
1258
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1206
1259
  */
1207
1260
  await this.loadMarkets();
@@ -1213,27 +1266,36 @@ export default class latoken extends Exchange {
1213
1266
  'side': side.toUpperCase(),
1214
1267
  'condition': 'GTC',
1215
1268
  'type': uppercaseType,
1216
- 'clientOrderId': this.uuid(), // 50 characters max
1269
+ 'clientOrderId': this.uuid(),
1217
1270
  // 'price': this.priceToPrecision (symbol, price),
1218
1271
  // 'quantity': this.amountToPrecision (symbol, amount),
1272
+ 'quantity': this.amountToPrecision(symbol, amount),
1273
+ 'timestamp': this.seconds(),
1219
1274
  };
1220
1275
  if (uppercaseType === 'LIMIT') {
1221
1276
  request['price'] = this.priceToPrecision(symbol, price);
1222
1277
  }
1223
- request['quantity'] = this.amountToPrecision(symbol, amount);
1224
- request['timestamp'] = this.seconds();
1225
- const response = await this.privatePostAuthOrderPlace(this.extend(request, params));
1278
+ const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
1279
+ params = this.omit(params, ['triggerPrice', 'stopPrice']);
1280
+ let response = undefined;
1281
+ if (triggerPrice !== undefined) {
1282
+ request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
1283
+ response = await this.privatePostAuthStopOrderPlace(this.extend(request, params));
1284
+ }
1285
+ else {
1286
+ response = await this.privatePostAuthOrderPlace(this.extend(request, params));
1287
+ }
1226
1288
  //
1227
- // {
1228
- // "orderId":"1563460093.134037.704945@0370:2",
1229
- // "cliOrdId":"",
1230
- // "pairId":370,
1231
- // "symbol":"ETHBTC",
1232
- // "side":"sell",
1233
- // "orderType":"limit",
1234
- // "price":1.0,
1235
- // "amount":1.0
1236
- // }
1289
+ // {
1290
+ // "baseCurrency": "f7dac554-8139-4ff6-841f-0e586a5984a0",
1291
+ // "quoteCurrency": "a5a7a7a9-e2a3-43f9-8754-29a02f6b709b",
1292
+ // "side": "BID",
1293
+ // "clientOrderId": "my-wonderful-order-number-71566",
1294
+ // "price": "10103.19",
1295
+ // "stopPrice": "10103.19",
1296
+ // "quantity": "3.21",
1297
+ // "timestamp": 1568185507
1298
+ // }
1237
1299
  //
1238
1300
  return this.parseOrder(response, market);
1239
1301
  }
@@ -1242,16 +1304,27 @@ export default class latoken extends Exchange {
1242
1304
  * @method
1243
1305
  * @name latoken#cancelOrder
1244
1306
  * @description cancels an open order
1307
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelOrder
1308
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/cancelStopOrder // stop
1245
1309
  * @param {string} id order id
1246
1310
  * @param {string} symbol not used by latoken cancelOrder ()
1247
1311
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1312
+ * @param {boolean} [params.trigger] true if cancelling a trigger order
1248
1313
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1249
1314
  */
1250
1315
  await this.loadMarkets();
1251
1316
  const request = {
1252
1317
  'id': id,
1253
1318
  };
1254
- const response = await this.privatePostAuthOrderCancel(this.extend(request, params));
1319
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1320
+ params = this.omit(params, ['stop', 'trigger']);
1321
+ let response = undefined;
1322
+ if (isTrigger) {
1323
+ response = await this.privatePostAuthStopOrderCancel(this.extend(request, params));
1324
+ }
1325
+ else {
1326
+ response = await this.privatePostAuthOrderCancel(this.extend(request, params));
1327
+ }
1255
1328
  //
1256
1329
  // {
1257
1330
  // "id": "12345678-1234-1244-1244-123456789012",
@@ -1268,8 +1341,11 @@ export default class latoken extends Exchange {
1268
1341
  * @method
1269
1342
  * @name latoken#cancelAllOrders
1270
1343
  * @description cancel all open orders in a market
1344
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrders
1345
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrdersByPair
1271
1346
  * @param {string} symbol unified market symbol of the market to cancel orders in
1272
1347
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1348
+ * @param {boolean} [params.trigger] true if cancelling trigger orders
1273
1349
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1274
1350
  */
1275
1351
  await this.loadMarkets();
@@ -1277,15 +1353,29 @@ export default class latoken extends Exchange {
1277
1353
  // 'currency': market['baseId'],
1278
1354
  // 'quote': market['quoteId'],
1279
1355
  };
1280
- let method = 'privatePostAuthOrderCancelAll';
1281
1356
  let market = undefined;
1357
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1358
+ params = this.omit(params, ['stop', 'trigger']);
1359
+ let response = undefined;
1282
1360
  if (symbol !== undefined) {
1283
1361
  market = this.market(symbol);
1284
1362
  request['currency'] = market['baseId'];
1285
1363
  request['quote'] = market['quoteId'];
1286
- method = 'privatePostAuthOrderCancelAllCurrencyQuote';
1364
+ if (isTrigger) {
1365
+ response = await this.privatePostAuthStopOrderCancelAllCurrencyQuote(this.extend(request, params));
1366
+ }
1367
+ else {
1368
+ response = await this.privatePostAuthOrderCancelAllCurrencyQuote(this.extend(request, params));
1369
+ }
1370
+ }
1371
+ else {
1372
+ if (isTrigger) {
1373
+ response = await this.privatePostAuthStopOrderCancelAll(this.extend(request, params));
1374
+ }
1375
+ else {
1376
+ response = await this.privatePostAuthOrderCancelAll(this.extend(request, params));
1377
+ }
1287
1378
  }
1288
- const response = await this[method](this.extend(request, params));
1289
1379
  //
1290
1380
  // {
1291
1381
  // "message":"cancellation request successfully submitted",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.0.111",
3
+ "version": "4.0.112",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",