ccxt 4.2.1 → 4.2.3

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.
@@ -3029,12 +3029,13 @@ class okx extends okx$1 {
3029
3029
  * @param {string} id order id
3030
3030
  * @param {string} symbol unified symbol of the market the order was made in
3031
3031
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3032
+ * @param {boolean} [params.trigger] true if trigger orders
3032
3033
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3033
3034
  */
3034
3035
  if (symbol === undefined) {
3035
3036
  throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
3036
3037
  }
3037
- const stop = this.safeValue(params, 'stop');
3038
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3038
3039
  if (stop) {
3039
3040
  const orderInner = await this.cancelOrders([id], symbol, params);
3040
3041
  return this.safeValue(orderInner, 0);
@@ -3406,6 +3407,7 @@ class okx extends okx$1 {
3406
3407
  * @param {string} id the order id
3407
3408
  * @param {string} symbol unified market symbol
3408
3409
  * @param {object} [params] extra and exchange specific parameters
3410
+ * @param {boolean} [params.trigger] true if fetching trigger orders
3409
3411
  * @returns [an order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3410
3412
  */
3411
3413
  if (symbol === undefined) {
@@ -3423,7 +3425,7 @@ class okx extends okx$1 {
3423
3425
  const options = this.safeValue(this.options, 'fetchOrder', {});
3424
3426
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrder');
3425
3427
  let method = this.safeString(params, 'method', defaultMethod);
3426
- const stop = this.safeValue(params, 'stop');
3428
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3427
3429
  if (stop) {
3428
3430
  method = 'privateGetTradeOrderAlgo';
3429
3431
  if (clientOrderId !== undefined) {
@@ -3441,7 +3443,7 @@ class okx extends okx$1 {
3441
3443
  request['ordId'] = id;
3442
3444
  }
3443
3445
  }
3444
- const query = this.omit(params, ['method', 'clOrdId', 'clientOrderId', 'stop']);
3446
+ const query = this.omit(params, ['method', 'clOrdId', 'clientOrderId', 'stop', 'trigger']);
3445
3447
  let response = undefined;
3446
3448
  if (method === 'privateGetTradeOrderAlgo') {
3447
3449
  response = await this.privateGetTradeOrderAlgo(this.extend(request, query));
@@ -3597,7 +3599,7 @@ class okx extends okx$1 {
3597
3599
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersPending');
3598
3600
  let method = this.safeString(params, 'method', defaultMethod);
3599
3601
  const ordType = this.safeString(params, 'ordType');
3600
- const stop = this.safeValue(params, 'stop');
3602
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3601
3603
  if (stop || (ordType in algoOrderTypes)) {
3602
3604
  method = 'privateGetTradeOrdersAlgoPending';
3603
3605
  if (stop) {
@@ -3606,7 +3608,7 @@ class okx extends okx$1 {
3606
3608
  }
3607
3609
  }
3608
3610
  }
3609
- const query = this.omit(params, ['method', 'stop']);
3611
+ const query = this.omit(params, ['method', 'stop', 'trigger']);
3610
3612
  let response = undefined;
3611
3613
  if (method === 'privateGetTradeOrdersAlgoPending') {
3612
3614
  response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
@@ -3759,7 +3761,7 @@ class okx extends okx$1 {
3759
3761
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
3760
3762
  let method = this.safeString(params, 'method', defaultMethod);
3761
3763
  const ordType = this.safeString(params, 'ordType');
3762
- const stop = this.safeValue(params, 'stop');
3764
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3763
3765
  if (stop || (ordType in algoOrderTypes)) {
3764
3766
  method = 'privateGetTradeOrdersAlgoHistory';
3765
3767
  const algoId = this.safeString(params, 'algoId');
@@ -3784,7 +3786,7 @@ class okx extends okx$1 {
3784
3786
  query = this.omit(query, ['until', 'till']);
3785
3787
  }
3786
3788
  }
3787
- const send = this.omit(query, ['method', 'stop', 'ordType']);
3789
+ const send = this.omit(query, ['method', 'stop', 'ordType', 'trigger']);
3788
3790
  let response = undefined;
3789
3791
  if (method === 'privateGetTradeOrdersAlgoHistory') {
3790
3792
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -3946,7 +3948,7 @@ class okx extends okx$1 {
3946
3948
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
3947
3949
  let method = this.safeString(params, 'method', defaultMethod);
3948
3950
  const ordType = this.safeString(params, 'ordType');
3949
- const stop = this.safeValue(params, 'stop');
3951
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3950
3952
  if (stop || (ordType in algoOrderTypes)) {
3951
3953
  method = 'privateGetTradeOrdersAlgoHistory';
3952
3954
  if (stop) {
@@ -3967,7 +3969,7 @@ class okx extends okx$1 {
3967
3969
  }
3968
3970
  request['state'] = 'filled';
3969
3971
  }
3970
- const send = this.omit(query, ['method', 'stop']);
3972
+ const send = this.omit(query, ['method', 'stop', 'trigger']);
3971
3973
  let response = undefined;
3972
3974
  if (method === 'privateGetTradeOrdersAlgoHistory') {
3973
3975
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -1189,9 +1189,15 @@ class poloniexfutures extends poloniexfutures$1 {
1189
1189
  if (symbol !== undefined) {
1190
1190
  request['symbol'] = this.marketId(symbol);
1191
1191
  }
1192
- const stop = this.safeValue(params, 'stop');
1193
- const method = stop ? 'privateDeleteStopOrders' : 'privateDeleteOrders';
1194
- const response = await this[method](this.extend(request, params));
1192
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1193
+ params = this.omit(params, ['stop', 'trigger']);
1194
+ let response = undefined;
1195
+ if (stop) {
1196
+ response = await this.privateDeleteStopOrders(this.extend(request, params));
1197
+ }
1198
+ else {
1199
+ response = await this.privateDeleteOrders(this.extend(request, params));
1200
+ }
1195
1201
  //
1196
1202
  // {
1197
1203
  // "code": "200000",
@@ -1253,9 +1259,9 @@ class poloniexfutures extends poloniexfutures$1 {
1253
1259
  * @returns An [array of order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1254
1260
  */
1255
1261
  await this.loadMarkets();
1256
- const stop = this.safeValue(params, 'stop');
1262
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1257
1263
  const until = this.safeInteger2(params, 'until', 'till');
1258
- params = this.omit(params, ['stop', 'until', 'till']);
1264
+ params = this.omit(params, ['triger', 'stop', 'until', 'till']);
1259
1265
  if (status === 'closed') {
1260
1266
  status = 'done';
1261
1267
  }
@@ -1277,8 +1283,13 @@ class poloniexfutures extends poloniexfutures$1 {
1277
1283
  if (until !== undefined) {
1278
1284
  request['endAt'] = until;
1279
1285
  }
1280
- const method = stop ? 'privateGetStopOrders' : 'privateGetOrders';
1281
- const response = await this[method](this.extend(request, params));
1286
+ let response = undefined;
1287
+ if (stop) {
1288
+ response = await this.privateGetStopOrders(this.extend(request, params));
1289
+ }
1290
+ else {
1291
+ response = await this.privateGetOrders(this.extend(request, params));
1292
+ }
1282
1293
  //
1283
1294
  // {
1284
1295
  // "code": "200000",
@@ -1388,20 +1399,20 @@ class poloniexfutures extends poloniexfutures$1 {
1388
1399
  */
1389
1400
  await this.loadMarkets();
1390
1401
  const request = {};
1391
- let method = 'privateGetOrdersOrderId';
1402
+ let response = undefined;
1392
1403
  if (id === undefined) {
1393
1404
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
1394
1405
  if (clientOrderId === undefined) {
1395
1406
  throw new errors.InvalidOrder(this.id + ' fetchOrder() requires parameter id or params.clientOid');
1396
1407
  }
1397
1408
  request['clientOid'] = clientOrderId;
1398
- method = 'privateGetOrdersByClientOid';
1399
1409
  params = this.omit(params, ['clientOid', 'clientOrderId']);
1410
+ response = await this.privateGetClientOrderIdClientOid(this.extend(request, params));
1400
1411
  }
1401
1412
  else {
1402
1413
  request['order-id'] = id;
1414
+ response = await this.privateGetOrdersOrderId(this.extend(request, params));
1403
1415
  }
1404
- const response = await this[method](this.extend(request, params));
1405
1416
  //
1406
1417
  // {
1407
1418
  // "code": "200000",
@@ -1721,7 +1732,7 @@ class poloniexfutures extends poloniexfutures$1 {
1721
1732
  const version = this.safeString(params, 'version', defaultVersion);
1722
1733
  const tail = '/api/' + version + '/' + this.implodeParams(path, params);
1723
1734
  url += tail;
1724
- const query = this.omit(params, path);
1735
+ const query = this.omit(params, this.extractParams(path));
1725
1736
  const queryLength = Object.keys(query).length;
1726
1737
  if (api === 'public') {
1727
1738
  if (queryLength) {
@@ -1114,25 +1114,27 @@ class binance extends binance$1 {
1114
1114
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
1115
1115
  const delay = this.sum(listenKeyRefreshRate, 10000);
1116
1116
  if (time - lastAuthenticatedTime > delay) {
1117
- let method = 'publicPostUserDataStream';
1117
+ let response = undefined;
1118
1118
  if (type === 'future') {
1119
- method = 'fapiPrivatePostListenKey';
1119
+ response = await this.fapiPrivatePostListenKey(query);
1120
1120
  }
1121
1121
  else if (type === 'delivery') {
1122
- method = 'dapiPrivatePostListenKey';
1122
+ response = await this.dapiPrivatePostListenKey(query);
1123
1123
  }
1124
1124
  else if (type === 'margin' && isCrossMargin) {
1125
- method = 'sapiPostUserDataStream';
1125
+ response = await this.sapiPostUserDataStream(query);
1126
1126
  }
1127
1127
  else if (isIsolatedMargin) {
1128
- method = 'sapiPostUserDataStreamIsolated';
1129
1128
  if (symbol === undefined) {
1130
1129
  throw new errors.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
1131
1130
  }
1132
1131
  const marketId = this.marketId(symbol);
1133
1132
  query = this.extend(query, { 'symbol': marketId });
1133
+ response = await this.sapiPostUserDataStreamIsolated(query);
1134
+ }
1135
+ else {
1136
+ response = await this.publicPostUserDataStream(query);
1134
1137
  }
1135
- const response = await this[method](query);
1136
1138
  this.options[type] = this.extend(options, {
1137
1139
  'listenKey': this.safeString(response, 'listenKey'),
1138
1140
  'lastAuthenticatedTime': time,
@@ -1158,26 +1160,27 @@ class binance extends binance$1 {
1158
1160
  // A network error happened: we can't renew a listen key that does not exist.
1159
1161
  return;
1160
1162
  }
1161
- let method = 'publicPutUserDataStream';
1162
1163
  const request = {};
1163
1164
  const symbol = this.safeString(params, 'symbol');
1164
1165
  const sendParams = this.omit(params, ['type', 'symbol']);
1165
- if (type === 'future') {
1166
- method = 'fapiPrivatePutListenKey';
1167
- }
1168
- else if (type === 'delivery') {
1169
- method = 'dapiPrivatePutListenKey';
1170
- }
1171
- else {
1172
- request['listenKey'] = listenKey;
1173
- if (type === 'margin') {
1174
- request['symbol'] = symbol;
1175
- method = 'sapiPutUserDataStream';
1176
- }
1177
- }
1178
1166
  const time = this.milliseconds();
1179
1167
  try {
1180
- await this[method](this.extend(request, sendParams));
1168
+ if (type === 'future') {
1169
+ await this.fapiPrivatePutListenKey(this.extend(request, sendParams));
1170
+ }
1171
+ else if (type === 'delivery') {
1172
+ await this.dapiPrivatePutListenKey(this.extend(request, sendParams));
1173
+ }
1174
+ else {
1175
+ request['listenKey'] = listenKey;
1176
+ if (type === 'margin') {
1177
+ request['symbol'] = symbol;
1178
+ await this.sapiPutUserDataStream(this.extend(request, sendParams));
1179
+ }
1180
+ else {
1181
+ await this.publicPutUserDataStream(this.extend(request, sendParams));
1182
+ }
1183
+ }
1181
1184
  }
1182
1185
  catch (error) {
1183
1186
  const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
@@ -30,6 +30,7 @@ class bingx extends bingx$1 {
30
30
  },
31
31
  },
32
32
  'options': {
33
+ 'listenKeyRefreshRate': 3540000,
33
34
  'ws': {
34
35
  'gunzip': true,
35
36
  },
@@ -627,7 +628,7 @@ class bingx extends bingx$1 {
627
628
  const lastAuthenticatedTime = this.safeInteger(this.options, 'lastAuthenticatedTime', 0);
628
629
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000); // 1 hour
629
630
  if (time - lastAuthenticatedTime > listenKeyRefreshRate) {
630
- const response = await this.userAuthPrivatePostUserDataStream({ 'listenKey': listenKey }); // extend the expiry
631
+ const response = await this.userAuthPrivatePutUserDataStream({ 'listenKey': listenKey }); // extend the expiry
631
632
  this.options['listenKey'] = this.safeString(response, 'listenKey');
632
633
  this.options['lastAuthenticatedTime'] = time;
633
634
  }
@@ -208,7 +208,7 @@ class bybit extends bybit$1 {
208
208
  */
209
209
  await this.loadMarkets();
210
210
  symbols = this.marketSymbols(symbols, undefined, false);
211
- const messageHash = 'tickers::' + symbols.join(',');
211
+ const messageHashes = [];
212
212
  const url = this.getUrlByMarketType(symbols[0], false, params);
213
213
  params = this.cleanParams(params);
214
214
  const options = this.safeValue(this.options, 'watchTickers', {});
@@ -218,8 +218,9 @@ class bybit extends bybit$1 {
218
218
  for (let i = 0; i < marketIds.length; i++) {
219
219
  const marketId = marketIds[i];
220
220
  topics.push(topic + '.' + marketId);
221
+ messageHashes.push('ticker:' + symbols[i]);
221
222
  }
222
- const ticker = await this.watchTopics(url, messageHash, topics, params);
223
+ const ticker = await this.watchTopics(url, messageHashes, topics, params);
223
224
  if (this.newUpdates) {
224
225
  return ticker;
225
226
  }
@@ -355,17 +356,6 @@ class bybit extends bybit$1 {
355
356
  this.tickers[symbol] = parsed;
356
357
  const messageHash = 'ticker:' + symbol;
357
358
  client.resolve(this.tickers[symbol], messageHash);
358
- // watchTickers part
359
- const messageHashes = this.findMessageHashes(client, 'tickers::');
360
- for (let i = 0; i < messageHashes.length; i++) {
361
- const messageHashTicker = messageHashes[i];
362
- const parts = messageHashTicker.split('::');
363
- const symbolsString = parts[1];
364
- const symbols = symbolsString.split(',');
365
- if (this.inArray(parsed['symbol'], symbols)) {
366
- client.resolve(parsed, messageHashTicker);
367
- }
368
- }
369
359
  }
370
360
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
371
361
  /**
@@ -886,10 +876,15 @@ class bybit extends bybit$1 {
886
876
  }
887
877
  const trades = this.myTrades;
888
878
  const symbols = {};
889
- const method = spot ? 'parseWsTrade' : 'parseTrade';
890
879
  for (let i = 0; i < data.length; i++) {
891
880
  const rawTrade = data[i];
892
- const parsed = this[method](rawTrade);
881
+ let parsed = undefined;
882
+ if (spot) {
883
+ parsed = this.parseWsTrade(rawTrade);
884
+ }
885
+ else {
886
+ parsed = this.parseTrade(rawTrade);
887
+ }
893
888
  const symbol = parsed['symbol'];
894
889
  symbols[symbol] = true;
895
890
  trades.append(parsed);
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.0";
7
+ declare const version = "4.2.2";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.1';
41
+ const version = '4.2.3';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -9,11 +9,13 @@ interface Exchange {
9
9
  spotV1PrivateGetTradeQuery(params?: {}): Promise<implicitReturnType>;
10
10
  spotV1PrivateGetTradeOpenOrders(params?: {}): Promise<implicitReturnType>;
11
11
  spotV1PrivateGetTradeHistoryOrders(params?: {}): Promise<implicitReturnType>;
12
+ spotV1PrivateGetUserCommissionRate(params?: {}): Promise<implicitReturnType>;
12
13
  spotV1PrivateGetAccountBalance(params?: {}): Promise<implicitReturnType>;
13
14
  spotV1PrivatePostTradeOrder(params?: {}): Promise<implicitReturnType>;
14
15
  spotV1PrivatePostTradeCancel(params?: {}): Promise<implicitReturnType>;
15
16
  spotV1PrivatePostTradeBatchOrders(params?: {}): Promise<implicitReturnType>;
16
17
  spotV1PrivatePostTradeCancelOrders(params?: {}): Promise<implicitReturnType>;
18
+ spotV1PrivatePostTradeCancelOpenOrders(params?: {}): Promise<implicitReturnType>;
17
19
  spotV3PrivateGetGetAssetTransfer(params?: {}): Promise<implicitReturnType>;
18
20
  spotV3PrivateGetAssetTransfer(params?: {}): Promise<implicitReturnType>;
19
21
  spotV3PrivateGetCapitalDepositHisrec(params?: {}): Promise<implicitReturnType>;
@@ -80,6 +82,7 @@ interface Exchange {
80
82
  accountV1PrivateGetUid(params?: {}): Promise<implicitReturnType>;
81
83
  accountV1PrivatePostInnerTransferAuthorizeSubAccount(params?: {}): Promise<implicitReturnType>;
82
84
  userAuthPrivatePostUserDataStream(params?: {}): Promise<implicitReturnType>;
85
+ userAuthPrivatePutUserDataStream(params?: {}): Promise<implicitReturnType>;
83
86
  copyTradingV1PrivateGetSwapTraceCurrentTrack(params?: {}): Promise<implicitReturnType>;
84
87
  copyTradingV1PrivatePostSwapTraceCloseTrackOrder(params?: {}): Promise<implicitReturnType>;
85
88
  copyTradingV1PrivatePostSwapTraceSetTPSL(params?: {}): Promise<implicitReturnType>;
package/js/src/alpaca.js CHANGED
@@ -53,7 +53,7 @@ export default class alpaca extends Exchange {
53
53
  'closeAllPositions': false,
54
54
  'closePosition': false,
55
55
  'createOrder': true,
56
- 'fetchBalance': true,
56
+ 'fetchBalance': false,
57
57
  'fetchBidsAsks': false,
58
58
  'fetchClosedOrders': true,
59
59
  'fetchCurrencies': false,
package/js/src/binance.js CHANGED
@@ -1595,6 +1595,7 @@ export default class binance extends Exchange {
1595
1595
  '-4046': AuthenticationError,
1596
1596
  '-4047': BadRequest,
1597
1597
  '-4054': BadRequest,
1598
+ '-4164': InvalidOrder,
1598
1599
  '-5001': BadRequest,
1599
1600
  '-5002': InsufficientFunds,
1600
1601
  '-5003': InsufficientFunds,