ccxt 4.0.111 → 4.1.1

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.
@@ -29,6 +29,10 @@ class latoken extends latoken$1 {
29
29
  'cancelAllOrders': true,
30
30
  'cancelOrder': true,
31
31
  'createOrder': true,
32
+ 'createPostOnlyOrder': false,
33
+ 'createStopLimitOrder': true,
34
+ 'createStopMarketOrder': false,
35
+ 'createStopOrder': true,
32
36
  'fetchBalance': true,
33
37
  'fetchBorrowRate': false,
34
38
  'fetchBorrowRateHistories': false,
@@ -951,16 +955,16 @@ class latoken extends latoken$1 {
951
955
  //
952
956
  // createOrder
953
957
  //
954
- // {
955
- // "orderId":"1563460093.134037.704945@0370:2",
956
- // "cliOrdId":"",
957
- // "pairId":370,
958
- // "symbol":"ETHBTC",
959
- // "side":"sell",
960
- // "orderType":"limit",
961
- // "price":1.0,
962
- // "amount":1.0
963
- // }
958
+ // {
959
+ // "baseCurrency": "f7dac554-8139-4ff6-841f-0e586a5984a0",
960
+ // "quoteCurrency": "a5a7a7a9-e2a3-43f9-8754-29a02f6b709b",
961
+ // "side": "BID",
962
+ // "clientOrderId": "my-wonderful-order-number-71566",
963
+ // "price": "10103.19",
964
+ // "stopPrice": "10103.19",
965
+ // "quantity": "3.21",
966
+ // "timestamp": 1568185507
967
+ // }
964
968
  //
965
969
  // fetchOrder, fetchOpenOrders, fetchOrders
966
970
  //
@@ -1028,6 +1032,7 @@ class latoken extends latoken$1 {
1028
1032
  }
1029
1033
  const clientOrderId = this.safeString(order, 'clientOrderId');
1030
1034
  const timeInForce = this.parseTimeInForce(this.safeString(order, 'condition'));
1035
+ const triggerPrice = this.safeString(order, 'stopPrice');
1031
1036
  return this.safeOrder({
1032
1037
  'id': id,
1033
1038
  'clientOrderId': clientOrderId,
@@ -1042,8 +1047,8 @@ class latoken extends latoken$1 {
1042
1047
  'postOnly': undefined,
1043
1048
  'side': side,
1044
1049
  'price': price,
1045
- 'stopPrice': undefined,
1046
- 'triggerPrice': undefined,
1050
+ 'stopPrice': triggerPrice,
1051
+ 'triggerPrice': triggerPrice,
1047
1052
  'cost': cost,
1048
1053
  'amount': amount,
1049
1054
  'filled': filled,
@@ -1058,22 +1063,33 @@ class latoken extends latoken$1 {
1058
1063
  * @method
1059
1064
  * @name latoken#fetchOpenOrders
1060
1065
  * @description fetch all unfilled currently open orders
1066
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrdersByPair
1067
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyActiveStopOrdersByPair // stop
1061
1068
  * @param {string} symbol unified market symbol
1062
1069
  * @param {int} [since] the earliest time in ms to fetch open orders for
1063
1070
  * @param {int} [limit] the maximum number of open orders structures to retrieve
1064
1071
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1072
+ * @param {boolean} [params.trigger] true if fetching trigger orders
1065
1073
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1066
- */
1067
- if (symbol === undefined) {
1068
- throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
1069
- }
1074
+ */
1070
1075
  await this.loadMarkets();
1071
- const market = this.market(symbol);
1076
+ let response = undefined;
1077
+ let market = undefined;
1078
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1079
+ params = this.omit(params, 'stop');
1080
+ this.checkRequiredSymbol('fetchOpenOrders', symbol);
1081
+ // privateGetAuthOrderActive doesn't work even though its listed at https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrders
1082
+ market = this.market(symbol);
1072
1083
  const request = {
1073
1084
  'currency': market['baseId'],
1074
1085
  'quote': market['quoteId'],
1075
1086
  };
1076
- const response = await this.privateGetAuthOrderPairCurrencyQuoteActive(this.extend(request, params));
1087
+ if (isTrigger) {
1088
+ response = await this.privateGetAuthStopOrderPairCurrencyQuoteActive(this.extend(request, params));
1089
+ }
1090
+ else {
1091
+ response = await this.privateGetAuthOrderPairCurrencyQuoteActive(this.extend(request, params));
1092
+ }
1077
1093
  //
1078
1094
  // [
1079
1095
  // {
@@ -1103,10 +1119,15 @@ class latoken extends latoken$1 {
1103
1119
  * @method
1104
1120
  * @name latoken#fetchOrders
1105
1121
  * @description fetches information on multiple orders made by the user
1122
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrders
1123
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrdersByPair
1124
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrders // stop
1125
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrdersByPair // stop
1106
1126
  * @param {string} symbol unified market symbol of the market orders were made in
1107
1127
  * @param {int} [since] the earliest time in ms to fetch orders for
1108
1128
  * @param {int} [limit] the maximum number of orde structures to retrieve
1109
1129
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1130
+ * @param {boolean} [params.trigger] true if fetching trigger orders
1110
1131
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1111
1132
  */
1112
1133
  await this.loadMarkets();
@@ -1116,18 +1137,32 @@ class latoken extends latoken$1 {
1116
1137
  // 'from': this.milliseconds (),
1117
1138
  // 'limit': limit, // default '100'
1118
1139
  };
1119
- let method = 'privateGetAuthOrder';
1120
1140
  let market = undefined;
1141
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1142
+ params = this.omit(params, ['stop', 'trigger']);
1143
+ if (limit !== undefined) {
1144
+ request['limit'] = limit; // default 100
1145
+ }
1146
+ let response = undefined;
1121
1147
  if (symbol !== undefined) {
1122
1148
  market = this.market(symbol);
1123
1149
  request['currency'] = market['baseId'];
1124
1150
  request['quote'] = market['quoteId'];
1125
- method = 'privateGetAuthOrderPairCurrencyQuote';
1151
+ if (isTrigger) {
1152
+ response = await this.privateGetAuthStopOrderPairCurrencyQuote(this.extend(request, params));
1153
+ }
1154
+ else {
1155
+ response = await this.privateGetAuthOrderPairCurrencyQuote(this.extend(request, params));
1156
+ }
1126
1157
  }
1127
- if (limit !== undefined) {
1128
- request['limit'] = limit; // default 100
1158
+ else {
1159
+ if (isTrigger) {
1160
+ response = await this.privateGetAuthStopOrder(this.extend(request, params));
1161
+ }
1162
+ else {
1163
+ response = await this.privateGetAuthOrder(this.extend(request, params));
1164
+ }
1129
1165
  }
1130
- const response = await this[method](this.extend(request, params));
1131
1166
  //
1132
1167
  // [
1133
1168
  // {
@@ -1157,15 +1192,26 @@ class latoken extends latoken$1 {
1157
1192
  * @method
1158
1193
  * @name latoken#fetchOrder
1159
1194
  * @description fetches information on an order made by the user
1160
- * @param {string} symbol not used by latoken fetchOrder
1195
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/getOrderById
1196
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getStopOrderById
1197
+ * @param {string} [symbol] not used by latoken fetchOrder
1161
1198
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1199
+ * @param {boolean} [params.trigger] true if fetching a trigger order
1162
1200
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1163
1201
  */
1164
1202
  await this.loadMarkets();
1165
1203
  const request = {
1166
1204
  'id': id,
1167
1205
  };
1168
- const response = await this.privateGetAuthOrderGetOrderId(this.extend(request, params));
1206
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1207
+ params = this.omit(params, ['stop', 'trigger']);
1208
+ let response = undefined;
1209
+ if (isTrigger) {
1210
+ response = await this.privateGetAuthStopOrderGetOrderId(this.extend(request, params));
1211
+ }
1212
+ else {
1213
+ response = await this.privateGetAuthOrderGetOrderId(this.extend(request, params));
1214
+ }
1169
1215
  //
1170
1216
  // {
1171
1217
  // "id":"a76bd262-3560-4bfb-98ac-1cedd394f4fc",
@@ -1193,12 +1239,19 @@ class latoken extends latoken$1 {
1193
1239
  * @method
1194
1240
  * @name latoken#createOrder
1195
1241
  * @description create a trade order
1242
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/placeOrder
1243
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/placeStopOrder // stop
1196
1244
  * @param {string} symbol unified symbol of the market to create an order in
1197
1245
  * @param {string} type 'market' or 'limit'
1198
1246
  * @param {string} side 'buy' or 'sell'
1199
1247
  * @param {float} amount how much of currency you want to trade in units of base currency
1200
1248
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1201
1249
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1250
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
1251
+ *
1252
+ * EXCHANGE SPECIFIC PARAMETERS
1253
+ * @param {string} [params.condition] "GTC", "IOC", or "FOK"
1254
+ * @param {string} [params.clientOrderId] [ 0 .. 50 ] characters, client's custom order id (free field for your convenience)
1202
1255
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1203
1256
  */
1204
1257
  await this.loadMarkets();
@@ -1210,27 +1263,36 @@ class latoken extends latoken$1 {
1210
1263
  'side': side.toUpperCase(),
1211
1264
  'condition': 'GTC',
1212
1265
  'type': uppercaseType,
1213
- 'clientOrderId': this.uuid(), // 50 characters max
1266
+ 'clientOrderId': this.uuid(),
1214
1267
  // 'price': this.priceToPrecision (symbol, price),
1215
1268
  // 'quantity': this.amountToPrecision (symbol, amount),
1269
+ 'quantity': this.amountToPrecision(symbol, amount),
1270
+ 'timestamp': this.seconds(),
1216
1271
  };
1217
1272
  if (uppercaseType === 'LIMIT') {
1218
1273
  request['price'] = this.priceToPrecision(symbol, price);
1219
1274
  }
1220
- request['quantity'] = this.amountToPrecision(symbol, amount);
1221
- request['timestamp'] = this.seconds();
1222
- const response = await this.privatePostAuthOrderPlace(this.extend(request, params));
1275
+ const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
1276
+ params = this.omit(params, ['triggerPrice', 'stopPrice']);
1277
+ let response = undefined;
1278
+ if (triggerPrice !== undefined) {
1279
+ request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
1280
+ response = await this.privatePostAuthStopOrderPlace(this.extend(request, params));
1281
+ }
1282
+ else {
1283
+ response = await this.privatePostAuthOrderPlace(this.extend(request, params));
1284
+ }
1223
1285
  //
1224
- // {
1225
- // "orderId":"1563460093.134037.704945@0370:2",
1226
- // "cliOrdId":"",
1227
- // "pairId":370,
1228
- // "symbol":"ETHBTC",
1229
- // "side":"sell",
1230
- // "orderType":"limit",
1231
- // "price":1.0,
1232
- // "amount":1.0
1233
- // }
1286
+ // {
1287
+ // "baseCurrency": "f7dac554-8139-4ff6-841f-0e586a5984a0",
1288
+ // "quoteCurrency": "a5a7a7a9-e2a3-43f9-8754-29a02f6b709b",
1289
+ // "side": "BID",
1290
+ // "clientOrderId": "my-wonderful-order-number-71566",
1291
+ // "price": "10103.19",
1292
+ // "stopPrice": "10103.19",
1293
+ // "quantity": "3.21",
1294
+ // "timestamp": 1568185507
1295
+ // }
1234
1296
  //
1235
1297
  return this.parseOrder(response, market);
1236
1298
  }
@@ -1239,16 +1301,27 @@ class latoken extends latoken$1 {
1239
1301
  * @method
1240
1302
  * @name latoken#cancelOrder
1241
1303
  * @description cancels an open order
1304
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelOrder
1305
+ * @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/cancelStopOrder // stop
1242
1306
  * @param {string} id order id
1243
1307
  * @param {string} symbol not used by latoken cancelOrder ()
1244
1308
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1309
+ * @param {boolean} [params.trigger] true if cancelling a trigger order
1245
1310
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1246
1311
  */
1247
1312
  await this.loadMarkets();
1248
1313
  const request = {
1249
1314
  'id': id,
1250
1315
  };
1251
- const response = await this.privatePostAuthOrderCancel(this.extend(request, params));
1316
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1317
+ params = this.omit(params, ['stop', 'trigger']);
1318
+ let response = undefined;
1319
+ if (isTrigger) {
1320
+ response = await this.privatePostAuthStopOrderCancel(this.extend(request, params));
1321
+ }
1322
+ else {
1323
+ response = await this.privatePostAuthOrderCancel(this.extend(request, params));
1324
+ }
1252
1325
  //
1253
1326
  // {
1254
1327
  // "id": "12345678-1234-1244-1244-123456789012",
@@ -1265,8 +1338,11 @@ class latoken extends latoken$1 {
1265
1338
  * @method
1266
1339
  * @name latoken#cancelAllOrders
1267
1340
  * @description cancel all open orders in a market
1341
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrders
1342
+ * @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrdersByPair
1268
1343
  * @param {string} symbol unified market symbol of the market to cancel orders in
1269
1344
  * @param {object} [params] extra parameters specific to the latoken api endpoint
1345
+ * @param {boolean} [params.trigger] true if cancelling trigger orders
1270
1346
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1271
1347
  */
1272
1348
  await this.loadMarkets();
@@ -1274,15 +1350,29 @@ class latoken extends latoken$1 {
1274
1350
  // 'currency': market['baseId'],
1275
1351
  // 'quote': market['quoteId'],
1276
1352
  };
1277
- let method = 'privatePostAuthOrderCancelAll';
1278
1353
  let market = undefined;
1354
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
1355
+ params = this.omit(params, ['stop', 'trigger']);
1356
+ let response = undefined;
1279
1357
  if (symbol !== undefined) {
1280
1358
  market = this.market(symbol);
1281
1359
  request['currency'] = market['baseId'];
1282
1360
  request['quote'] = market['quoteId'];
1283
- method = 'privatePostAuthOrderCancelAllCurrencyQuote';
1361
+ if (isTrigger) {
1362
+ response = await this.privatePostAuthStopOrderCancelAllCurrencyQuote(this.extend(request, params));
1363
+ }
1364
+ else {
1365
+ response = await this.privatePostAuthOrderCancelAllCurrencyQuote(this.extend(request, params));
1366
+ }
1367
+ }
1368
+ else {
1369
+ if (isTrigger) {
1370
+ response = await this.privatePostAuthStopOrderCancelAll(this.extend(request, params));
1371
+ }
1372
+ else {
1373
+ response = await this.privatePostAuthOrderCancelAll(this.extend(request, params));
1374
+ }
1284
1375
  }
1285
- const response = await this[method](this.extend(request, params));
1286
1376
  //
1287
1377
  // {
1288
1378
  // "message":"cancellation request successfully submitted",
@@ -1034,8 +1034,8 @@ class okx extends okx$1 {
1034
1034
  // filter orders with no last trade id
1035
1035
  for (let i = 0; i < rawOrders.length; i++) {
1036
1036
  const rawOrder = rawOrders[i];
1037
- const tradeId = this.safeString(rawOrder, 'tradeId');
1038
- if (!this.isEmpty(tradeId)) {
1037
+ const tradeId = this.safeString(rawOrder, 'tradeId', '');
1038
+ if (tradeId.length > 0) {
1039
1039
  const order = this.parseOrder(rawOrder);
1040
1040
  filteredOrders.push(order);
1041
1041
  }
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } 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.0.110";
7
+ declare const version = "4.1.0";
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.0.111';
41
+ const version = '4.1.1';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
package/js/src/bybit.js CHANGED
@@ -4066,16 +4066,16 @@ export default class bybit extends Exchange {
4066
4066
  triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
4067
4067
  }
4068
4068
  if (triggerPrice !== undefined) {
4069
- request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
4069
+ request['triggerPrice'] = triggerPrice;
4070
4070
  }
4071
4071
  if (isStopLoss || isTakeProfit) {
4072
4072
  if (isStopLoss) {
4073
4073
  const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4074
- request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
4074
+ request['stopLoss'] = slTriggerPrice;
4075
4075
  }
4076
4076
  if (isTakeProfit) {
4077
4077
  const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4078
- request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
4078
+ request['takeProfit'] = tpTriggerPrice;
4079
4079
  }
4080
4080
  }
4081
4081
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -6622,9 +6622,8 @@ export default class bybit extends Exchange {
6622
6622
  // "time": 1670988271677
6623
6623
  // }
6624
6624
  //
6625
- const data = this.safeValue(response, 'result', {});
6626
- const transfers = this.safeValue(data, 'list', []);
6627
- return this.parseTransfers(transfers, currency, since, limit);
6625
+ const data = this.addPaginationCursorToResult(response);
6626
+ return this.parseTransfers(data, currency, since, limit);
6628
6627
  }
6629
6628
  async borrowMargin(code, amount, symbol = undefined, params = {}) {
6630
6629
  /**
@@ -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;