ccxt 4.3.57 → 4.3.58

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/bingx.js CHANGED
@@ -823,13 +823,14 @@ export default class bingx extends Exchange {
823
823
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
824
824
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
825
825
  * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
826
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20K-line%20Data
826
827
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
827
828
  * @param {string} timeframe the length of time each candle represents
828
829
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
829
830
  * @param {int} [limit] the maximum amount of candles to fetch
830
831
  * @param {object} [params] extra parameters specific to the exchange API endpoint
831
832
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
832
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
833
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
833
834
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
834
835
  */
835
836
  await this.loadMarkets();
@@ -859,13 +860,18 @@ export default class bingx extends Exchange {
859
860
  response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
860
861
  }
861
862
  else {
862
- const price = this.safeString(params, 'price');
863
- params = this.omit(params, 'price');
864
- if (price === 'mark') {
865
- response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
863
+ if (market['inverse']) {
864
+ response = await this.cswapV1PublicGetMarketKlines(this.extend(request, params));
866
865
  }
867
866
  else {
868
- response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
867
+ const price = this.safeString(params, 'price');
868
+ params = this.omit(params, 'price');
869
+ if (price === 'mark') {
870
+ response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
871
+ }
872
+ else {
873
+ response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
874
+ }
869
875
  }
870
876
  }
871
877
  //
@@ -1177,6 +1183,7 @@ export default class bingx extends Exchange {
1177
1183
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1178
1184
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20depth%20information
1179
1185
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Market%20Depth
1186
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%20Depth%20Data
1180
1187
  * @param {string} symbol unified symbol of the market to fetch the order book for
1181
1188
  * @param {int} [limit] the maximum amount of order book entries to return
1182
1189
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1197,7 +1204,12 @@ export default class bingx extends Exchange {
1197
1204
  response = await this.spotV1PublicGetMarketDepth(this.extend(request, params));
1198
1205
  }
1199
1206
  else {
1200
- response = await this.swapV2PublicGetQuoteDepth(this.extend(request, params));
1207
+ if (market['inverse']) {
1208
+ response = await this.cswapV1PublicGetMarketDepth(this.extend(request, params));
1209
+ }
1210
+ else {
1211
+ response = await this.swapV2PublicGetQuoteDepth(this.extend(request, params));
1212
+ }
1201
1213
  }
1202
1214
  //
1203
1215
  // spot
@@ -1266,6 +1278,7 @@ export default class bingx extends Exchange {
1266
1278
  * @name bingx#fetchFundingRate
1267
1279
  * @description fetch the current funding rate
1268
1280
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
1281
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Price%20&%20Current%20Funding%20Rate
1269
1282
  * @param {string} symbol unified market symbol
1270
1283
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1271
1284
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1275,7 +1288,13 @@ export default class bingx extends Exchange {
1275
1288
  const request = {
1276
1289
  'symbol': market['id'],
1277
1290
  };
1278
- const response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(request, params));
1291
+ let response = undefined;
1292
+ if (market['inverse']) {
1293
+ response = await this.cswapV1PublicGetMarketPremiumIndex(this.extend(request, params));
1294
+ }
1295
+ else {
1296
+ response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(request, params));
1297
+ }
1279
1298
  //
1280
1299
  // {
1281
1300
  // "code":0,
@@ -1427,9 +1446,10 @@ export default class bingx extends Exchange {
1427
1446
  /**
1428
1447
  * @method
1429
1448
  * @name bingx#fetchOpenInterest
1430
- * @description Retrieves the open interest of a currency
1449
+ * @description retrieves the open interest of a trading pair
1431
1450
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Swap%20Open%20Positions
1432
- * @param {string} symbol Unified CCXT market symbol
1451
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20Swap%20Open%20Positions
1452
+ * @param {string} symbol unified CCXT market symbol
1433
1453
  * @param {object} [params] exchange specific parameters
1434
1454
  * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
1435
1455
  */
@@ -1438,7 +1458,15 @@ export default class bingx extends Exchange {
1438
1458
  const request = {
1439
1459
  'symbol': market['id'],
1440
1460
  };
1441
- const response = await this.swapV2PublicGetQuoteOpenInterest(this.extend(request, params));
1461
+ let response = undefined;
1462
+ if (market['inverse']) {
1463
+ response = await this.cswapV1PublicGetMarketOpenInterest(this.extend(request, params));
1464
+ }
1465
+ else {
1466
+ response = await this.swapV2PublicGetQuoteOpenInterest(this.extend(request, params));
1467
+ }
1468
+ //
1469
+ // linear swap
1442
1470
  //
1443
1471
  // {
1444
1472
  // "code": 0,
@@ -1450,18 +1478,50 @@ export default class bingx extends Exchange {
1450
1478
  // }
1451
1479
  // }
1452
1480
  //
1453
- const data = this.safeDict(response, 'data', {});
1454
- return this.parseOpenInterest(data, market);
1481
+ // inverse swap
1482
+ //
1483
+ // {
1484
+ // "code": 0,
1485
+ // "msg": "",
1486
+ // "timestamp": 1720328247986,
1487
+ // "data": [
1488
+ // {
1489
+ // "symbol": "BTC-USD",
1490
+ // "openInterest": "749.1160",
1491
+ // "timestamp": 1720310400000
1492
+ // }
1493
+ // ]
1494
+ // }
1495
+ //
1496
+ let result = {};
1497
+ if (market['inverse']) {
1498
+ const data = this.safeList(response, 'data', []);
1499
+ result = this.safeDict(data, 0, {});
1500
+ }
1501
+ else {
1502
+ result = this.safeDict(response, 'data', {});
1503
+ }
1504
+ return this.parseOpenInterest(result, market);
1455
1505
  }
1456
1506
  parseOpenInterest(interest, market = undefined) {
1457
1507
  //
1458
- // {
1459
- // "openInterest": "3289641547.10",
1460
- // "symbol": "BTC-USDT",
1461
- // "time": 1672026617364
1462
- // }
1508
+ // linear swap
1509
+ //
1510
+ // {
1511
+ // "openInterest": "3289641547.10",
1512
+ // "symbol": "BTC-USDT",
1513
+ // "time": 1672026617364
1514
+ // }
1515
+ //
1516
+ // inverse swap
1517
+ //
1518
+ // {
1519
+ // "symbol": "BTC-USD",
1520
+ // "openInterest": "749.1160",
1521
+ // "timestamp": 1720310400000
1522
+ // }
1463
1523
  //
1464
- const timestamp = this.safeInteger(interest, 'time');
1524
+ const timestamp = this.safeInteger2(interest, 'time', 'timestamp');
1465
1525
  const id = this.safeString(interest, 'symbol');
1466
1526
  const symbol = this.safeSymbol(id, market, '-', 'swap');
1467
1527
  const openInterest = this.safeNumber(interest, 'openInterest');
@@ -21,7 +21,7 @@ export default class coinmate extends Exchange {
21
21
  'id': 'coinmate',
22
22
  'name': 'CoinMate',
23
23
  'countries': ['GB', 'CZ', 'EU'],
24
- 'rateLimit': 1000,
24
+ 'rateLimit': 600,
25
25
  'has': {
26
26
  'CORS': true,
27
27
  'spot': true,
@@ -170,28 +170,28 @@ export default class coinmate extends Exchange {
170
170
  'trading': {
171
171
  'tierBased': true,
172
172
  'percentage': true,
173
- 'maker': this.parseNumber('0.0012'),
174
- 'taker': this.parseNumber('0.0025'),
173
+ 'taker': this.parseNumber('0.006'),
174
+ 'maker': this.parseNumber('0.004'),
175
175
  'tiers': {
176
176
  'taker': [
177
- [this.parseNumber('0'), this.parseNumber('0.0035')],
178
- [this.parseNumber('10000'), this.parseNumber('0.0023')],
179
- [this.parseNumber('100000'), this.parseNumber('0.0021')],
180
- [this.parseNumber('250000'), this.parseNumber('0.0020')],
181
- [this.parseNumber('500000'), this.parseNumber('0.0015')],
182
- [this.parseNumber('1000000'), this.parseNumber('0.0013')],
183
- [this.parseNumber('3000000'), this.parseNumber('0.0010')],
184
- [this.parseNumber('15000000'), this.parseNumber('0.0005')],
177
+ [this.parseNumber('0'), this.parseNumber('0.006')],
178
+ [this.parseNumber('10000'), this.parseNumber('0.003')],
179
+ [this.parseNumber('100000'), this.parseNumber('0.0023')],
180
+ [this.parseNumber('250000'), this.parseNumber('0.0021')],
181
+ [this.parseNumber('500000'), this.parseNumber('0.0018')],
182
+ [this.parseNumber('1000000'), this.parseNumber('0.0015')],
183
+ [this.parseNumber('3000000'), this.parseNumber('0.0012')],
184
+ [this.parseNumber('15000000'), this.parseNumber('0.001')],
185
185
  ],
186
186
  'maker': [
187
- [this.parseNumber('0'), this.parseNumber('0.003')],
188
- [this.parseNumber('10000'), this.parseNumber('0.0011')],
189
- [this.parseNumber('100000'), this.parseNumber('0.0010')],
190
- [this.parseNumber('250000'), this.parseNumber('0.0008')],
187
+ [this.parseNumber('0'), this.parseNumber('0.004')],
188
+ [this.parseNumber('10000'), this.parseNumber('0.002')],
189
+ [this.parseNumber('100000'), this.parseNumber('0.0012')],
190
+ [this.parseNumber('250000'), this.parseNumber('0.0009')],
191
191
  [this.parseNumber('500000'), this.parseNumber('0.0005')],
192
192
  [this.parseNumber('1000000'), this.parseNumber('0.0003')],
193
193
  [this.parseNumber('3000000'), this.parseNumber('0.0002')],
194
- [this.parseNumber('15000000'), this.parseNumber('0')],
194
+ [this.parseNumber('15000000'), this.parseNumber('-0.0004')],
195
195
  ],
196
196
  },
197
197
  },
@@ -1096,26 +1096,19 @@ export default class coinmate extends Exchange {
1096
1096
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1097
1097
  }
1098
1098
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1099
- if (response !== undefined) {
1100
- if ('error' in response) {
1101
- // {"error":true,"errorMessage":"Minimum Order Size 0.01 ETH","data":null}
1102
- if (response['error']) {
1103
- const message = this.safeString(response, 'errorMessage');
1104
- const feedback = this.id + ' ' + message;
1105
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1106
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1107
- throw new ExchangeError(this.id + ' ' + this.json(response));
1108
- }
1109
- }
1099
+ if (response === undefined) {
1100
+ return undefined; // fallback to default error handler
1110
1101
  }
1111
- if (code > 400) {
1112
- if (body) {
1113
- const feedback = this.id + ' ' + body;
1114
- this.throwExactlyMatchedException(this.exceptions['exact'], body, feedback);
1115
- this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
1116
- throw new ExchangeError(feedback); // unknown message
1117
- }
1118
- throw new ExchangeError(this.id + ' ' + body);
1102
+ //
1103
+ // {"error":true,"errorMessage":"Api internal error","data":null}
1104
+ // {"error":true,"errorMessage":"Access denied.","data":null}
1105
+ //
1106
+ const errorMessage = this.safeString(response, 'errorMessage');
1107
+ if (errorMessage !== undefined) {
1108
+ const feedback = this.id + ' ' + body;
1109
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorMessage, feedback);
1110
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
1111
+ throw new ExchangeError(feedback); // unknown message
1119
1112
  }
1120
1113
  return undefined;
1121
1114
  }
package/js/src/coinone.js CHANGED
@@ -1173,7 +1173,7 @@ export default class coinone extends Exchange {
1173
1173
  // {"result":"error","error_code":"108","error_msg":"Unknown CryptoCurrency"}
1174
1174
  //
1175
1175
  const errorCode = this.safeString(response, 'error_code');
1176
- if (errorCode !== '0') {
1176
+ if (errorCode !== undefined && errorCode !== '0') {
1177
1177
  const feedback = this.id + ' ' + body;
1178
1178
  this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
1179
1179
  throw new ExchangeError(feedback); // unknown message
package/js/src/gate.js CHANGED
@@ -4022,7 +4022,7 @@ export default class gate extends Exchange {
4022
4022
  request['price'] = price; // set to 0 for market orders
4023
4023
  }
4024
4024
  else {
4025
- request['price'] = this.priceToPrecision(symbol, price);
4025
+ request['price'] = (price === 0) ? '0' : this.priceToPrecision(symbol, price);
4026
4026
  }
4027
4027
  if (reduceOnly !== undefined) {
4028
4028
  request['reduce_only'] = reduceOnly;
@@ -4113,8 +4113,8 @@ export default class gate extends Exchange {
4113
4113
  request = {
4114
4114
  'initial': {
4115
4115
  'contract': market['id'],
4116
- 'size': amount,
4117
- 'price': this.priceToPrecision(symbol, price), // set to 0 to use market price
4116
+ 'size': amount, // positive = buy, negative = sell, set to 0 to close the position
4117
+ // 'price': (price === 0) ? '0' : this.priceToPrecision (symbol, price), // set to 0 to use market price
4118
4118
  // 'close': false, // set to true if trying to close the position
4119
4119
  // 'tif': 'gtc', // gtc, ioc, if using market price, only ioc is supported
4120
4120
  // 'text': clientOrderId, // web, api, app
@@ -4122,6 +4122,12 @@ export default class gate extends Exchange {
4122
4122
  },
4123
4123
  'settle': market['settleId'],
4124
4124
  };
4125
+ if (type === 'market') {
4126
+ request['initial']['price'] = '0';
4127
+ }
4128
+ else {
4129
+ request['initial']['price'] = (price === 0) ? '0' : this.priceToPrecision(symbol, price);
4130
+ }
4125
4131
  if (trigger === undefined) {
4126
4132
  let rule = undefined;
4127
4133
  let triggerOrderPrice = undefined;
package/js/src/htx.js CHANGED
@@ -3233,6 +3233,7 @@ export default class htx extends Exchange {
3233
3233
  const instStatus = this.safeString(entry, 'instStatus');
3234
3234
  const currencyActive = instStatus === 'normal';
3235
3235
  let minPrecision = undefined;
3236
+ let minDeposit = undefined;
3236
3237
  let minWithdraw = undefined;
3237
3238
  let maxWithdraw = undefined;
3238
3239
  let deposit = false;
@@ -3244,6 +3245,7 @@ export default class htx extends Exchange {
3244
3245
  this.options['networkChainIdsByNames'][code][title] = uniqueChainId;
3245
3246
  this.options['networkNamesByChainIds'][uniqueChainId] = title;
3246
3247
  const networkCode = this.networkIdToCode(uniqueChainId);
3248
+ minDeposit = this.safeNumber(chainEntry, 'minDepositAmt');
3247
3249
  minWithdraw = this.safeNumber(chainEntry, 'minWithdrawAmt');
3248
3250
  maxWithdraw = this.safeNumber(chainEntry, 'maxWithdrawAmt');
3249
3251
  const withdrawStatus = this.safeString(chainEntry, 'withdrawStatus');
@@ -3264,7 +3266,7 @@ export default class htx extends Exchange {
3264
3266
  'network': networkCode,
3265
3267
  'limits': {
3266
3268
  'deposit': {
3267
- 'min': undefined,
3269
+ 'min': minDeposit,
3268
3270
  'max': undefined,
3269
3271
  },
3270
3272
  'withdraw': {
package/js/src/kucoin.js CHANGED
@@ -243,6 +243,8 @@ export default class kucoin extends Exchange {
243
243
  'purchase/orders': 10,
244
244
  // broker
245
245
  'broker/api/rebase/download': 3,
246
+ // affiliate
247
+ 'affiliate/inviter/statistics': 30,
246
248
  },
247
249
  'post': {
248
250
  // account
@@ -684,6 +686,7 @@ export default class kucoin extends Exchange {
684
686
  'redeem/orders': 'v3',
685
687
  'purchase/orders': 'v3',
686
688
  'margin/symbols': 'v3',
689
+ 'affiliate/inviter/statistics': 'v2',
687
690
  },
688
691
  'POST': {
689
692
  // account
@@ -45,7 +45,7 @@ export default class latoken extends Exchange {
45
45
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
46
46
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
47
47
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
48
- cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
48
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
49
49
  fetchTransactions(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
50
50
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
51
51
  parseTransactionStatus(status: Str): string;
package/js/src/latoken.js CHANGED
@@ -1419,7 +1419,11 @@ export default class latoken extends Exchange {
1419
1419
  // "status":"SUCCESS"
1420
1420
  // }
1421
1421
  //
1422
- return response;
1422
+ return [
1423
+ this.safeOrder({
1424
+ 'info': response,
1425
+ }),
1426
+ ];
1423
1427
  }
1424
1428
  async fetchTransactions(code = undefined, since = undefined, limit = undefined, params = {}) {
1425
1429
  /**
package/js/src/okx.js CHANGED
@@ -7356,6 +7356,9 @@ export default class okx extends Exchange {
7356
7356
  }
7357
7357
  depositWithdrawFees[code]['info'][currencyId] = feeInfo;
7358
7358
  const chain = this.safeString(feeInfo, 'chain');
7359
+ if (chain === undefined) {
7360
+ continue;
7361
+ }
7359
7362
  const chainSplit = chain.split('-');
7360
7363
  const networkId = this.safeValue(chainSplit, 1);
7361
7364
  const withdrawFee = this.safeNumber(feeInfo, 'minFee');
package/js/src/pro/okx.js CHANGED
@@ -1685,7 +1685,7 @@ export default class okx extends okxRest {
1685
1685
  if (this.isEmpty(args)) {
1686
1686
  const method = this.safeString(message, 'op');
1687
1687
  const stringMsg = this.json(message);
1688
- this.handleErrors(undefined, undefined, client.url, method, undefined, stringMsg, stringMsg, undefined, undefined);
1688
+ this.handleErrors(undefined, undefined, client.url, method, undefined, stringMsg, message, undefined, undefined);
1689
1689
  }
1690
1690
  const orders = this.parseOrders(args, undefined, undefined, undefined);
1691
1691
  const first = this.safeDict(orders, 0, {});
@@ -1860,8 +1860,8 @@ export default class okx extends okxRest {
1860
1860
  future.resolve(true);
1861
1861
  }
1862
1862
  ping(client) {
1863
- // okex does not support built-in ws protocol-level ping-pong
1864
- // instead it requires custom text-based ping-pong
1863
+ // OKX does not support the built-in WebSocket protocol-level ping-pong.
1864
+ // Instead, it requires a custom text-based ping-pong mechanism.
1865
1865
  return 'ping';
1866
1866
  }
1867
1867
  handlePong(client, message) {
package/js/src/woo.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/woo.js';
9
- import { AuthenticationError, RateLimitExceeded, BadRequest, ExchangeError, InvalidOrder, ArgumentsRequired, NotSupported, OnMaintenance } from './base/errors.js';
9
+ import { AuthenticationError, RateLimitExceeded, BadRequest, OperationFailed, ExchangeError, InvalidOrder, ArgumentsRequired, NotSupported, OnMaintenance } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { TICK_SIZE } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
@@ -309,7 +309,7 @@ export default class woo extends Exchange {
309
309
  'commonCurrencies': {},
310
310
  'exceptions': {
311
311
  'exact': {
312
- '-1000': ExchangeError,
312
+ '-1000': OperationFailed,
313
313
  '-1001': AuthenticationError,
314
314
  '-1002': AuthenticationError,
315
315
  '-1003': RateLimitExceeded,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.57",
3
+ "version": "4.3.58",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",