ccxt 4.4.86 → 4.4.87

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.
Files changed (70) hide show
  1. package/README.md +17 -5
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +11 -1
  4. package/dist/cjs/src/abstract/modetrade.js +9 -0
  5. package/dist/cjs/src/base/Exchange.js +10 -8
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/bitteam.js +31 -0
  8. package/dist/cjs/src/coinmetro.js +5 -1
  9. package/dist/cjs/src/derive.js +4 -5
  10. package/dist/cjs/src/ellipx.js +2 -3
  11. package/dist/cjs/src/gate.js +92 -76
  12. package/dist/cjs/src/htx.js +10 -8
  13. package/dist/cjs/src/hyperliquid.js +32 -16
  14. package/dist/cjs/src/kraken.js +5 -8
  15. package/dist/cjs/src/modetrade.js +2839 -0
  16. package/dist/cjs/src/okx.js +95 -2
  17. package/dist/cjs/src/okxus.js +53 -0
  18. package/dist/cjs/src/paradex.js +6 -1
  19. package/dist/cjs/src/phemex.js +4 -6
  20. package/dist/cjs/src/poloniex.js +181 -170
  21. package/dist/cjs/src/pro/modetrade.js +1334 -0
  22. package/dist/cjs/src/pro/okxus.js +38 -0
  23. package/dist/cjs/src/probit.js +18 -51
  24. package/dist/cjs/src/timex.js +5 -10
  25. package/dist/cjs/src/vertex.js +3 -4
  26. package/dist/cjs/src/whitebit.js +41 -11
  27. package/dist/cjs/src/woo.js +101 -77
  28. package/dist/cjs/src/woofipro.js +24 -21
  29. package/dist/cjs/src/xt.js +36 -44
  30. package/js/ccxt.d.ts +14 -2
  31. package/js/ccxt.js +10 -2
  32. package/js/src/abstract/modetrade.d.ts +122 -0
  33. package/js/src/abstract/modetrade.js +11 -0
  34. package/js/src/abstract/okxus.d.ts +352 -0
  35. package/js/src/abstract/okxus.js +11 -0
  36. package/js/src/base/Exchange.js +10 -8
  37. package/js/src/binance.js +1 -1
  38. package/js/src/bitteam.js +31 -0
  39. package/js/src/coinmetro.js +5 -1
  40. package/js/src/derive.js +4 -3
  41. package/js/src/ellipx.d.ts +1 -1
  42. package/js/src/ellipx.js +3 -5
  43. package/js/src/gate.js +92 -76
  44. package/js/src/htx.js +10 -8
  45. package/js/src/hyperliquid.js +32 -16
  46. package/js/src/kraken.js +5 -8
  47. package/js/src/modetrade.d.ts +475 -0
  48. package/js/src/modetrade.js +2840 -0
  49. package/js/src/okx.d.ts +24 -1
  50. package/js/src/okx.js +95 -2
  51. package/js/src/okxus.d.ts +4 -0
  52. package/js/src/okxus.js +54 -0
  53. package/js/src/paradex.js +6 -1
  54. package/js/src/phemex.js +4 -6
  55. package/js/src/poloniex.d.ts +2 -0
  56. package/js/src/poloniex.js +181 -170
  57. package/js/src/pro/modetrade.d.ts +155 -0
  58. package/js/src/pro/modetrade.js +1335 -0
  59. package/js/src/pro/okxus.d.ts +4 -0
  60. package/js/src/pro/okxus.js +39 -0
  61. package/js/src/probit.js +18 -51
  62. package/js/src/timex.js +5 -10
  63. package/js/src/vertex.js +3 -4
  64. package/js/src/whitebit.js +42 -11
  65. package/js/src/woo.d.ts +2 -0
  66. package/js/src/woo.js +101 -77
  67. package/js/src/woofipro.d.ts +2 -1
  68. package/js/src/woofipro.js +24 -21
  69. package/js/src/xt.js +36 -44
  70. package/package.json +1 -1
@@ -83,7 +83,7 @@ class okx extends okx$1 {
83
83
  'fetchFundingIntervals': false,
84
84
  'fetchFundingRate': true,
85
85
  'fetchFundingRateHistory': true,
86
- 'fetchFundingRates': false,
86
+ 'fetchFundingRates': true,
87
87
  'fetchGreeks': true,
88
88
  'fetchIndexOHLCV': true,
89
89
  'fetchIsolatedBorrowRate': false,
@@ -106,6 +106,7 @@ class okx extends okx$1 {
106
106
  'fetchOHLCV': true,
107
107
  'fetchOpenInterest': true,
108
108
  'fetchOpenInterestHistory': true,
109
+ 'fetchOpenInterests': true,
109
110
  'fetchOpenOrder': undefined,
110
111
  'fetchOpenOrders': true,
111
112
  'fetchOption': true,
@@ -6297,7 +6298,7 @@ class okx extends okx$1 {
6297
6298
  const nextFundingRate = this.safeNumber(contract, 'nextFundingRate');
6298
6299
  const fundingTime = this.safeInteger(contract, 'fundingTime');
6299
6300
  const fundingTimeString = this.safeString(contract, 'fundingTime');
6300
- const nextFundingTimeString = this.safeString(contract, 'nextFundingRate');
6301
+ const nextFundingTimeString = this.safeString(contract, 'nextFundingTime');
6301
6302
  const millisecondsInterval = Precise["default"].stringSub(nextFundingTimeString, fundingTimeString);
6302
6303
  // https://www.okx.com/support/hc/en-us/articles/360053909272-Ⅸ-Introduction-to-perpetual-swap-funding-fee
6303
6304
  // > The current interest is 0.
@@ -6383,6 +6384,39 @@ class okx extends okx$1 {
6383
6384
  const entry = this.safeDict(data, 0, {});
6384
6385
  return this.parseFundingRate(entry, market);
6385
6386
  }
6387
+ /**
6388
+ * @method
6389
+ * @name okx#fetchFundingRates
6390
+ * @description fetches the current funding rates for multiple symbols
6391
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
6392
+ * @param {string[]} symbols unified market symbols
6393
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6394
+ * @returns {object} a dictionary of [funding rates structure]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}
6395
+ */
6396
+ async fetchFundingRates(symbols = undefined, params = {}) {
6397
+ await this.loadMarkets();
6398
+ symbols = this.marketSymbols(symbols, 'swap', true);
6399
+ const request = { 'instId': 'ANY' };
6400
+ const response = await this.publicGetPublicFundingRate(this.extend(request, params));
6401
+ //
6402
+ // {
6403
+ // "code": "0",
6404
+ // "data": [
6405
+ // {
6406
+ // "fundingRate": "0.00027815",
6407
+ // "fundingTime": "1634256000000",
6408
+ // "instId": "BTC-USD-SWAP",
6409
+ // "instType": "SWAP",
6410
+ // "nextFundingRate": "0.00017",
6411
+ // "nextFundingTime": "1634284800000"
6412
+ // }
6413
+ // ],
6414
+ // "msg": ""
6415
+ // }
6416
+ //
6417
+ const data = this.safeList(response, 'data', []);
6418
+ return this.parseFundingRates(data, symbols);
6419
+ }
6386
6420
  /**
6387
6421
  * @method
6388
6422
  * @name okx#fetchFundingHistory
@@ -7387,6 +7421,65 @@ class okx extends okx$1 {
7387
7421
  const data = this.safeList(response, 'data', []);
7388
7422
  return this.parseOpenInterest(data[0], market);
7389
7423
  }
7424
+ /**
7425
+ * @method
7426
+ * @name okx#fetchOpenInterests
7427
+ * @description Retrieves the open interests of some currencies
7428
+ * @see https://www.okx.com/docs-v5/en/#rest-api-public-data-get-open-interest
7429
+ * @param {string[]} symbols Unified CCXT market symbols
7430
+ * @param {object} [params] exchange specific parameters
7431
+ * @param {string} params.instType Instrument type, options: 'SWAP', 'FUTURES', 'OPTION', default to 'SWAP'
7432
+ * @param {string} params.uly Underlying, Applicable to FUTURES/SWAP/OPTION, if instType is 'OPTION', either uly or instFamily is required
7433
+ * @param {string} params.instFamily Instrument family, Applicable to FUTURES/SWAP/OPTION, if instType is 'OPTION', either uly or instFamily is required
7434
+ * @returns {object} an dictionary of [open interest structures]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
7435
+ */
7436
+ async fetchOpenInterests(symbols = undefined, params = {}) {
7437
+ await this.loadMarkets();
7438
+ symbols = this.marketSymbols(symbols, undefined, true, true);
7439
+ let market = undefined;
7440
+ if (symbols !== undefined) {
7441
+ market = this.market(symbols[0]);
7442
+ }
7443
+ let marketType = undefined;
7444
+ [marketType, params] = this.handleSubTypeAndParams('fetchOpenInterests', market, params, 'swap');
7445
+ let instType = 'SWAP';
7446
+ if (marketType === 'future') {
7447
+ instType = 'FUTURES';
7448
+ }
7449
+ else if (instType === 'option') {
7450
+ instType = 'OPTION';
7451
+ }
7452
+ const request = { 'instType': instType };
7453
+ const uly = this.safeString(params, 'uly');
7454
+ if (uly !== undefined) {
7455
+ request['uly'] = uly;
7456
+ }
7457
+ const instFamily = this.safeString(params, 'instFamily');
7458
+ if (instFamily !== undefined) {
7459
+ request['instFamily'] = instFamily;
7460
+ }
7461
+ if (instType === 'OPTION' && uly === undefined && instFamily === undefined) {
7462
+ throw new errors.BadRequest(this.id + ' fetchOpenInterests() requires either uly or instFamily parameter for OPTION markets');
7463
+ }
7464
+ const response = await this.publicGetPublicOpenInterest(this.extend(request, params));
7465
+ //
7466
+ // {
7467
+ // "code": "0",
7468
+ // "data": [
7469
+ // {
7470
+ // "instId": "BTC-USDT-SWAP",
7471
+ // "instType": "SWAP",
7472
+ // "oi": "2125419",
7473
+ // "oiCcy": "21254.19",
7474
+ // "ts": "1664005108969"
7475
+ // }
7476
+ // ],
7477
+ // "msg": ""
7478
+ // }
7479
+ //
7480
+ const data = this.safeList(response, 'data', []);
7481
+ return this.parseOpenInterests(data, symbols);
7482
+ }
7390
7483
  /**
7391
7484
  * @method
7392
7485
  * @name okx#fetchOpenInterestHistory
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var okx = require('./okx.js');
4
+
5
+ // ----------------------------------------------------------------------------
6
+ // ---------------------------------------------------------------------------
7
+ class okxus extends okx {
8
+ describe() {
9
+ return this.deepExtend(super.describe(), {
10
+ 'id': 'okxus',
11
+ 'name': 'OKX (US)',
12
+ 'certified': false,
13
+ 'pro': true,
14
+ 'hostname': 'us.okx.com',
15
+ 'urls': {
16
+ 'logo': 'https://user-images.githubusercontent.com/1294454/152485636-38b19e4a-bece-4dec-979a-5982859ffc04.jpg',
17
+ 'api': {
18
+ 'rest': 'https://{hostname}',
19
+ },
20
+ 'www': 'https://app.okx.com',
21
+ 'doc': 'https://app.okx.com/docs-v5/en/#overview',
22
+ 'fees': 'https://app.okx.com/pages/products/fees.html',
23
+ 'referral': {
24
+ 'url': 'https://www.app.okx.com/join/CCXT2023',
25
+ 'discount': 0.2,
26
+ },
27
+ 'test': {
28
+ 'rest': 'https://{hostname}',
29
+ },
30
+ },
31
+ 'has': {
32
+ 'CORS': undefined,
33
+ 'spot': true,
34
+ 'margin': undefined,
35
+ 'swap': false,
36
+ 'future': false,
37
+ 'option': false,
38
+ },
39
+ 'features': {
40
+ 'swap': {
41
+ 'linear': undefined,
42
+ 'inverse': undefined,
43
+ },
44
+ 'future': {
45
+ 'linear': undefined,
46
+ 'inverse': undefined,
47
+ },
48
+ },
49
+ });
50
+ }
51
+ }
52
+
53
+ module.exports = okxus;
@@ -1260,7 +1260,12 @@ class paradex extends paradex$1 {
1260
1260
  const cancelReason = this.safeString(order, 'cancel_reason');
1261
1261
  let status = this.safeString(order, 'status');
1262
1262
  if (cancelReason !== undefined) {
1263
- status = 'canceled';
1263
+ if (cancelReason === 'NOT_ENOUGH_MARGIN') {
1264
+ status = 'rejected';
1265
+ }
1266
+ else {
1267
+ status = 'canceled';
1268
+ }
1264
1269
  }
1265
1270
  const side = this.safeStringLower(order, 'side');
1266
1271
  const average = this.omitZero(this.safeString(order, 'avg_fill_price'));
@@ -1125,9 +1125,7 @@ class phemex extends phemex$1 {
1125
1125
  for (let i = 0; i < currencies.length; i++) {
1126
1126
  const currency = currencies[i];
1127
1127
  const id = this.safeString(currency, 'currency');
1128
- const name = this.safeString(currency, 'name');
1129
1128
  const code = this.safeCurrencyCode(id);
1130
- const status = this.safeString(currency, 'status');
1131
1129
  const valueScaleString = this.safeString(currency, 'valueScale');
1132
1130
  const valueScale = parseInt(valueScaleString);
1133
1131
  const minValueEv = this.safeString(currency, 'minValueEv');
@@ -1141,12 +1139,12 @@ class phemex extends phemex$1 {
1141
1139
  minAmount = this.parseNumber(Precise["default"].stringMul(minValueEv, precisionString));
1142
1140
  maxAmount = this.parseNumber(Precise["default"].stringMul(maxValueEv, precisionString));
1143
1141
  }
1144
- result[code] = {
1142
+ result[code] = this.safeCurrencyStructure({
1145
1143
  'id': id,
1146
1144
  'info': currency,
1147
1145
  'code': code,
1148
- 'name': name,
1149
- 'active': status === 'Listed',
1146
+ 'name': this.safeString(currency, 'name'),
1147
+ 'active': this.safeString(currency, 'status') === 'Listed',
1150
1148
  'deposit': undefined,
1151
1149
  'withdraw': undefined,
1152
1150
  'fee': undefined,
@@ -1164,7 +1162,7 @@ class phemex extends phemex$1 {
1164
1162
  'valueScale': valueScale,
1165
1163
  'networks': undefined,
1166
1164
  'type': 'crypto',
1167
- };
1165
+ });
1168
1166
  }
1169
1167
  return result;
1170
1168
  }