ccxt 4.2.62 → 4.2.64

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/bybit.js CHANGED
@@ -3787,8 +3787,8 @@ export default class bybit extends Exchange {
3787
3787
  const market = this.market(symbols[0]);
3788
3788
  let category = undefined;
3789
3789
  [category, params] = this.getBybitType('createOrders', market, params);
3790
- if ((category === 'spot') || (category === 'inverse')) {
3791
- throw new NotSupported(this.id + ' createOrders does not allow spot or inverse orders');
3790
+ if (category === 'inverse') {
3791
+ throw new NotSupported(this.id + ' createOrders does not allow inverse orders');
3792
3792
  }
3793
3793
  const request = {
3794
3794
  'category': category,
@@ -4268,6 +4268,87 @@ export default class bybit extends Exchange {
4268
4268
  const result = this.safeValue(response, 'result', {});
4269
4269
  return this.parseOrder(result, market);
4270
4270
  }
4271
+ async cancelOrders(ids, symbol = undefined, params = {}) {
4272
+ /**
4273
+ * @method
4274
+ * @name bybit#cancelOrders
4275
+ * @description cancel multiple orders
4276
+ * @see https://bybit-exchange.github.io/docs/v5/order/batch-cancel
4277
+ * @param {string[]} ids order ids
4278
+ * @param {string} symbol unified symbol of the market the order was made in
4279
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4280
+ * @param {string[]} [params.clientOrderIds] client order ids
4281
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4282
+ */
4283
+ if (symbol === undefined) {
4284
+ throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
4285
+ }
4286
+ await this.loadMarkets();
4287
+ const market = this.market(symbol);
4288
+ let category = undefined;
4289
+ [category, params] = this.getBybitType('cancelOrders', market, params);
4290
+ if (category === 'inverse') {
4291
+ throw new NotSupported(this.id + ' cancelOrders does not allow inverse orders');
4292
+ }
4293
+ const ordersRequests = [];
4294
+ const clientOrderIds = this.safeList2(params, 'clientOrderIds', 'clientOids', []);
4295
+ params = this.omit(params, ['clientOrderIds', 'clientOids']);
4296
+ for (let i = 0; i < clientOrderIds.length; i++) {
4297
+ ordersRequests.push({
4298
+ 'symbol': market['id'],
4299
+ 'orderLinkId': this.safeString(clientOrderIds, i),
4300
+ });
4301
+ }
4302
+ for (let i = 0; i < ids.length; i++) {
4303
+ ordersRequests.push({
4304
+ 'symbol': market['id'],
4305
+ 'orderId': this.safeString(ids, i),
4306
+ });
4307
+ }
4308
+ const request = {
4309
+ 'category': category,
4310
+ 'request': ordersRequests,
4311
+ };
4312
+ const response = await this.privatePostV5OrderCancelBatch(this.extend(request, params));
4313
+ //
4314
+ // {
4315
+ // "retCode": "0",
4316
+ // "retMsg": "OK",
4317
+ // "result": {
4318
+ // "list": [
4319
+ // {
4320
+ // "category": "spot",
4321
+ // "symbol": "BTCUSDT",
4322
+ // "orderId": "1636282505818800896",
4323
+ // "orderLinkId": "1636282505818800897"
4324
+ // },
4325
+ // {
4326
+ // "category": "spot",
4327
+ // "symbol": "BTCUSDT",
4328
+ // "orderId": "1636282505818800898",
4329
+ // "orderLinkId": "1636282505818800899"
4330
+ // }
4331
+ // ]
4332
+ // },
4333
+ // "retExtInfo": {
4334
+ // "list": [
4335
+ // {
4336
+ // "code": "0",
4337
+ // "msg": "OK"
4338
+ // },
4339
+ // {
4340
+ // "code": "0",
4341
+ // "msg": "OK"
4342
+ // }
4343
+ // ]
4344
+ // },
4345
+ // "time": "1709796158501"
4346
+ // }
4347
+ //
4348
+ const result = this.safeDict(response, 'result', {});
4349
+ const row = this.safeList(result, 'list', []);
4350
+ return this.parseOrders(row, market);
4351
+ }
4271
4352
  async cancelAllUsdcOrders(symbol = undefined, params = {}) {
4272
4353
  if (symbol === undefined) {
4273
4354
  throw new ArgumentsRequired(this.id + ' cancelAllUsdcOrders() requires a symbol argument');
@@ -7230,7 +7311,8 @@ export default class bybit extends Exchange {
7230
7311
  // }
7231
7312
  //
7232
7313
  const marketId = this.safeString(fee, 'symbol');
7233
- const symbol = this.safeSymbol(marketId, undefined, undefined, 'contract');
7314
+ const defaultType = (market !== undefined) ? market['type'] : 'contract';
7315
+ const symbol = this.safeSymbol(marketId, market, undefined, defaultType);
7234
7316
  return {
7235
7317
  'info': fee,
7236
7318
  'symbol': symbol,
@@ -7250,12 +7332,23 @@ export default class bybit extends Exchange {
7250
7332
  */
7251
7333
  await this.loadMarkets();
7252
7334
  const market = this.market(symbol);
7253
- if (market['spot']) {
7254
- throw new NotSupported(this.id + ' fetchTradingFee() is not supported for spot market');
7255
- }
7256
7335
  const request = {
7257
7336
  'symbol': market['id'],
7258
7337
  };
7338
+ let category = undefined;
7339
+ if (market['linear']) {
7340
+ category = 'linear';
7341
+ }
7342
+ else if (market['inverse']) {
7343
+ category = 'inverse';
7344
+ }
7345
+ else if (market['spot']) {
7346
+ category = 'spot';
7347
+ }
7348
+ else {
7349
+ category = 'option';
7350
+ }
7351
+ request['category'] = category;
7259
7352
  const response = await this.privateGetV5AccountFeeRate(this.extend(request, params));
7260
7353
  //
7261
7354
  // {
@@ -7277,7 +7370,7 @@ export default class bybit extends Exchange {
7277
7370
  const result = this.safeValue(response, 'result', {});
7278
7371
  const fees = this.safeValue(result, 'list', []);
7279
7372
  const first = this.safeValue(fees, 0, {});
7280
- return this.parseTradingFee(first);
7373
+ return this.parseTradingFee(first, market);
7281
7374
  }
7282
7375
  async fetchTradingFees(params = {}) {
7283
7376
  /**
package/js/src/gemini.js CHANGED
@@ -265,12 +265,12 @@ export default class gemini extends Exchange {
265
265
  'webApiEnable': true,
266
266
  'webApiRetries': 10,
267
267
  },
268
+ 'fetchUsdtMarkets': ['btcusdt', 'ethusdt'],
268
269
  'fetchCurrencies': {
269
270
  'webApiEnable': true,
270
271
  'webApiRetries': 5,
271
272
  'webApiMuteFailure': true,
272
273
  },
273
- 'fetchUsdtMarkets': ['btcusdt', 'ethusdt'],
274
274
  'fetchTickerMethod': 'fetchTickerV1',
275
275
  'networks': {
276
276
  'BTC': 'bitcoin',
@@ -409,9 +409,11 @@ export default class gemini extends Exchange {
409
409
  */
410
410
  const method = this.safeValue(this.options, 'fetchMarketsMethod', 'fetch_markets_from_api');
411
411
  if (method === 'fetch_markets_from_web') {
412
- const usdMarkets = await this.fetchMarketsFromWeb(params); // get usd markets
413
- const usdtMarkets = await this.fetchUSDTMarkets(params); // get usdt markets
414
- return this.arrayConcat(usdMarkets, usdtMarkets);
412
+ const promises = [];
413
+ promises.push(this.fetchMarketsFromWeb(params)); // get usd markets
414
+ promises.push(this.fetchUSDTMarkets(params)); // get usdt markets
415
+ const promisesResult = await Promise.all(promises);
416
+ return this.arrayConcat(promisesResult[0], promisesResult[1]);
415
417
  }
416
418
  return await this.fetchMarketsFromAPI(params);
417
419
  }
@@ -519,6 +521,9 @@ export default class gemini extends Exchange {
519
521
  'post_only': true,
520
522
  'limit_only': true,
521
523
  };
524
+ if (status === undefined) {
525
+ return true; // as defaulted below
526
+ }
522
527
  return this.safeBool(statuses, status, true);
523
528
  }
524
529
  async fetchUSDTMarkets(params = {}) {
package/js/src/hitbtc.js CHANGED
@@ -2520,7 +2520,7 @@ export default class hitbtc extends Exchange {
2520
2520
  * @see https://api.hitbtc.com/#get-futures-position-parameters
2521
2521
  * @param {string} symbol unified symbol of the market the order was made in
2522
2522
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2523
- * @returns {object} Struct of MarginMode
2523
+ * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
2524
2524
  */
2525
2525
  await this.loadMarkets();
2526
2526
  let market = undefined;
@@ -149,6 +149,7 @@ export default class krakenfutures extends Exchange {
149
149
  'executions',
150
150
  'triggers',
151
151
  'accountlogcsv',
152
+ 'account-log',
152
153
  'market/{symbol}/orders',
153
154
  'market/{symbol}/executions',
154
155
  ],
package/js/src/kucoin.js CHANGED
@@ -232,7 +232,8 @@ export default class kucoin extends Exchange {
232
232
  'project/list': 10,
233
233
  'project/marketInterestRate': 7.5,
234
234
  'redeem/orders': 10,
235
- 'purchase/orders': 10, // 10SW
235
+ 'purchase/orders': 10,
236
+ 'broker/api/rebase/download': 3,
236
237
  },
237
238
  'post': {
238
239
  // account
@@ -1294,7 +1294,7 @@ export default class bitget extends bitgetRest {
1294
1294
  if (feeAmount !== undefined) {
1295
1295
  const feeCurrency = this.safeString(fee, 'feeCoin');
1296
1296
  feeObject = {
1297
- 'cost': Precise.stringAbs(feeAmount),
1297
+ 'cost': this.parseNumber(Precise.stringAbs(feeAmount)),
1298
1298
  'currency': this.safeCurrencyCode(feeCurrency),
1299
1299
  };
1300
1300
  }
@@ -1307,10 +1307,10 @@ export default class bitget extends bitgetRest {
1307
1307
  if (side === 'buy' && market['spot'] && (type === 'market')) {
1308
1308
  cost = this.safeString(order, 'newSize', cost);
1309
1309
  }
1310
- let filled = this.safeString2(order, 'accBaseVolume', 'baseVolume');
1311
- if (market['spot'] && (rawStatus !== 'live')) {
1312
- filled = Precise.stringDiv(cost, avgPrice);
1313
- }
1310
+ const filled = this.safeString2(order, 'accBaseVolume', 'baseVolume');
1311
+ // if (market['spot'] && (rawStatus !== 'live')) {
1312
+ // filled = Precise.stringDiv (cost, avgPrice);
1313
+ // }
1314
1314
  let amount = this.safeString(order, 'baseVolume');
1315
1315
  if (!market['spot'] || !(side === 'buy' && type === 'market')) {
1316
1316
  amount = this.safeString(order, 'newSize', amount);
@@ -1049,7 +1049,7 @@ export default class coinex extends coinexRest {
1049
1049
  const messageHash = 'authenticated:spot';
1050
1050
  let future = this.safeValue(client.subscriptions, messageHash);
1051
1051
  if (future !== undefined) {
1052
- return future;
1052
+ return await future;
1053
1053
  }
1054
1054
  const requestId = this.requestId();
1055
1055
  const subscribe = {
@@ -1069,13 +1069,13 @@ export default class coinex extends coinexRest {
1069
1069
  };
1070
1070
  future = this.watch(url, messageHash, request, requestId, subscribe);
1071
1071
  client.subscriptions[messageHash] = future;
1072
- return future;
1072
+ return await future;
1073
1073
  }
1074
1074
  else {
1075
1075
  const messageHash = 'authenticated:swap';
1076
1076
  let future = this.safeValue(client.subscriptions, messageHash);
1077
1077
  if (future !== undefined) {
1078
- return future;
1078
+ return await future;
1079
1079
  }
1080
1080
  const requestId = this.requestId();
1081
1081
  const subscribe = {
@@ -1095,7 +1095,7 @@ export default class coinex extends coinexRest {
1095
1095
  };
1096
1096
  future = this.watch(url, messageHash, request, requestId, subscribe);
1097
1097
  client.subscriptions[messageHash] = future;
1098
- return future;
1098
+ return await future;
1099
1099
  }
1100
1100
  }
1101
1101
  }
@@ -175,7 +175,7 @@ export default class lbank extends lbankRest {
175
175
  // },
176
176
  // type: 'kbar',
177
177
  // pair: 'btc_usdt',
178
- // TS: '2022-10-02T12:44:15.864'
178
+ // TS: '2022-10-02T12:44:15.865'
179
179
  // }
180
180
  //
181
181
  const marketId = this.safeString(message, 'pair');
package/js/src/yobit.js CHANGED
@@ -284,15 +284,15 @@ export default class yobit extends Exchange {
284
284
  });
285
285
  }
286
286
  parseBalance(response) {
287
- const balances = this.safeValue(response, 'return', {});
287
+ const balances = this.safeDict(response, 'return', {});
288
288
  const timestamp = this.safeInteger(balances, 'server_time');
289
289
  const result = {
290
290
  'info': response,
291
291
  'timestamp': timestamp,
292
292
  'datetime': this.iso8601(timestamp),
293
293
  };
294
- const free = this.safeValue(balances, 'funds', {});
295
- const total = this.safeValue(balances, 'funds_incl_orders', {});
294
+ const free = this.safeDict(balances, 'funds', {});
295
+ const total = this.safeDict(balances, 'funds_incl_orders', {});
296
296
  const currencyIds = Object.keys(this.extend(free, total));
297
297
  for (let i = 0; i < currencyIds.length; i++) {
298
298
  const currencyId = currencyIds[i];
@@ -370,7 +370,7 @@ export default class yobit extends Exchange {
370
370
  // },
371
371
  // }
372
372
  //
373
- const markets = this.safeValue(response, 'pairs', {});
373
+ const markets = this.safeDict(response, 'pairs', {});
374
374
  const keys = Object.keys(markets);
375
375
  const result = [];
376
376
  for (let i = 0; i < keys.length; i++) {
@@ -658,7 +658,7 @@ export default class yobit extends Exchange {
658
658
  'currency': feeCurrencyCode,
659
659
  };
660
660
  }
661
- const isYourOrder = this.safeValue(trade, 'is_your_order');
661
+ const isYourOrder = this.safeString(trade, 'is_your_order');
662
662
  if (isYourOrder !== undefined) {
663
663
  if (fee === undefined) {
664
664
  const feeInNumbers = this.calculateFee(symbol, type, side, amount, price, 'taker');
@@ -725,7 +725,7 @@ export default class yobit extends Exchange {
725
725
  return [];
726
726
  }
727
727
  }
728
- const result = this.safeValue(response, market['id'], []);
728
+ const result = this.safeList(response, market['id'], []);
729
729
  return this.parseTrades(result, market, since, limit);
730
730
  }
731
731
  async fetchTradingFees(params = {}) {
@@ -758,12 +758,12 @@ export default class yobit extends Exchange {
758
758
  // },
759
759
  // }
760
760
  //
761
- const pairs = this.safeValue(response, 'pairs', {});
761
+ const pairs = this.safeDict(response, 'pairs', {});
762
762
  const marketIds = Object.keys(pairs);
763
763
  const result = {};
764
764
  for (let i = 0; i < marketIds.length; i++) {
765
765
  const marketId = marketIds[i];
766
- const pair = this.safeValue(pairs, marketId, {});
766
+ const pair = this.safeDict(pairs, marketId, {});
767
767
  const symbol = this.safeSymbol(marketId, undefined, '_');
768
768
  const takerString = this.safeString(pair, 'fee_buyer');
769
769
  const makerString = this.safeString(pair, 'fee_seller');
@@ -827,7 +827,7 @@ export default class yobit extends Exchange {
827
827
  // }
828
828
  // }
829
829
  //
830
- const result = this.safeValue(response, 'return');
830
+ const result = this.safeDict(response, 'return');
831
831
  return this.parseOrder(result, market);
832
832
  }
833
833
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -865,7 +865,7 @@ export default class yobit extends Exchange {
865
865
  // }
866
866
  // }
867
867
  //
868
- const result = this.safeValue(response, 'return', {});
868
+ const result = this.safeDict(response, 'return', {});
869
869
  return this.parseOrder(result);
870
870
  }
871
871
  parseOrderStatus(status) {
@@ -996,7 +996,7 @@ export default class yobit extends Exchange {
996
996
  };
997
997
  const response = await this.privatePostOrderInfo(this.extend(request, params));
998
998
  id = id.toString();
999
- const orders = this.safeValue(response, 'return', {});
999
+ const orders = this.safeDict(response, 'return', {});
1000
1000
  //
1001
1001
  // {
1002
1002
  // "success":1,
@@ -1061,7 +1061,7 @@ export default class yobit extends Exchange {
1061
1061
  // }
1062
1062
  // }
1063
1063
  //
1064
- const result = this.safeValue(response, 'return', {});
1064
+ const result = this.safeDict(response, 'return', {});
1065
1065
  return this.parseOrders(result, market, since, limit);
1066
1066
  }
1067
1067
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -1115,7 +1115,7 @@ export default class yobit extends Exchange {
1115
1115
  // }
1116
1116
  // }
1117
1117
  //
1118
- const trades = this.safeValue(response, 'return', {});
1118
+ const trades = this.safeDict(response, 'return', {});
1119
1119
  const ids = Object.keys(trades);
1120
1120
  const result = [];
1121
1121
  for (let i = 0; i < ids.length; i++) {
@@ -1163,7 +1163,7 @@ export default class yobit extends Exchange {
1163
1163
  await this.loadMarkets();
1164
1164
  const currency = this.currency(code);
1165
1165
  let currencyId = currency['id'];
1166
- const networks = this.safeValue(this.options, 'networks', {});
1166
+ const networks = this.safeDict(this.options, 'networks', {});
1167
1167
  let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
1168
1168
  network = this.safeString(networks, network, network); // handle ERC20>ETH alias
1169
1169
  if (network !== undefined) {
@@ -1330,7 +1330,7 @@ export default class yobit extends Exchange {
1330
1330
  //
1331
1331
  // To cover points 1, 2, 3 and 4 combined this handler should work like this:
1332
1332
  //
1333
- let success = this.safeBool(response, 'success', false);
1333
+ let success = this.safeValue(response, 'success'); // don't replace with safeBool here
1334
1334
  if (typeof success === 'string') {
1335
1335
  if ((success === 'true') || (success === '1')) {
1336
1336
  success = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.62",
3
+ "version": "4.2.64",
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",
package/skip-tests.json CHANGED
@@ -220,22 +220,20 @@
220
220
  "deposit": "not provided"
221
221
  },
222
222
  "fetchTicker": {
223
- "spread": "https://app.travis-ci.com/github/ccxt/ccxt/builds/269273148#L3651"
223
+ "spread": "https://app.travis-ci.com/github/ccxt/ccxt/builds/269273148#L3651",
224
+ "ask": "https://app.travis-ci.com/github/ccxt/ccxt/builds/269327874#L3234",
225
+ "open": "https://app.travis-ci.com/github/ccxt/ccxt/builds/269177570#L3624",
226
+ "bidVolume": "sometimes negative",
227
+ "askVolume": "sometimes negative"
224
228
  },
225
229
  "fetchTickers": {
226
- "spread": "same as above",
227
- "open": "https://app.travis-ci.com/github/ccxt/ccxt/builds/269177570#L3624",
228
- "bidVolume": "same",
229
- "askVolume": "same"
230
+ "spread": "same", "ask": "same", "open": "same", "bidVolume": "same", "askVolume": "same"
230
231
  },
231
232
  "watchTicker": {
232
- "spread": "same as above"
233
+ "spread": "same", "ask": "same", "open": "same", "bidVolume": "same", "askVolume": "same"
233
234
  },
234
235
  "watchTickers": {
235
- "spread": "same as above",
236
- "open": "same",
237
- "bidVolume": "same",
238
- "askVolume": "same"
236
+ "spread": "same", "ask": "same", "open": "same", "bidVolume": "same", "askVolume": "same"
239
237
  },
240
238
  "fetchOrderBook": {
241
239
  "bid": "multiple bids might have same value"
@@ -1152,7 +1150,6 @@
1152
1150
  }
1153
1151
  },
1154
1152
  "lbank": {
1155
- "skipWs": true,
1156
1153
  "skipMethods": {
1157
1154
  "loadMarkets": "settle must be defined when contract is true",
1158
1155
  "fetchTickers": {
@@ -1162,6 +1159,12 @@
1162
1159
  "fetchTicker": {
1163
1160
  "quoteVolume": "quoteVolume >= baseVolume * low is failing",
1164
1161
  "baseVolume": "quoteVolume >= baseVolume * low is failing"
1162
+ },
1163
+ "watchTrades": {
1164
+ "timestamp": "ts several hours ahead in in future :)"
1165
+ },
1166
+ "watchOHLCV": {
1167
+ "0": "ts several hours ahead in in future :)"
1165
1168
  }
1166
1169
  }
1167
1170
  },