ccxt 4.2.70 → 4.2.72

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 (50) hide show
  1. package/README.md +4 -4
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +979 -195
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +3 -1
  6. package/dist/cjs/src/ascendex.js +149 -2
  7. package/dist/cjs/src/bitget.js +14 -6
  8. package/dist/cjs/src/coinbase.js +108 -89
  9. package/dist/cjs/src/digifinex.js +2 -1
  10. package/dist/cjs/src/hyperliquid.js +1 -1
  11. package/dist/cjs/src/kraken.js +1 -0
  12. package/dist/cjs/src/mexc.js +9 -0
  13. package/dist/cjs/src/pro/bingx.js +29 -6
  14. package/dist/cjs/src/pro/hitbtc.js +16 -7
  15. package/dist/cjs/src/pro/hyperliquid.js +556 -0
  16. package/js/ccxt.d.ts +4 -1
  17. package/js/ccxt.js +3 -1
  18. package/js/src/abstract/coinbase.d.ts +2 -0
  19. package/js/src/ascendex.d.ts +5 -1
  20. package/js/src/ascendex.js +149 -2
  21. package/js/src/base/Exchange.d.ts +56 -56
  22. package/js/src/base/types.d.ts +58 -48
  23. package/js/src/binance.d.ts +1 -1
  24. package/js/src/bitfinex2.d.ts +1 -1
  25. package/js/src/bitget.js +14 -6
  26. package/js/src/bitrue.d.ts +3 -3
  27. package/js/src/cex.d.ts +1 -1
  28. package/js/src/coinbase.d.ts +1 -1
  29. package/js/src/coinbase.js +108 -89
  30. package/js/src/digifinex.js +2 -1
  31. package/js/src/gate.d.ts +1 -1
  32. package/js/src/htx.d.ts +1 -1
  33. package/js/src/hyperliquid.js +1 -1
  34. package/js/src/idex.d.ts +1 -1
  35. package/js/src/kraken.js +1 -0
  36. package/js/src/kucoinfutures.d.ts +1 -1
  37. package/js/src/mexc.js +9 -0
  38. package/js/src/poloniexfutures.d.ts +2 -2
  39. package/js/src/pro/bingx.d.ts +1 -0
  40. package/js/src/pro/bingx.js +29 -6
  41. package/js/src/pro/bitvavo.d.ts +8 -8
  42. package/js/src/pro/bybit.d.ts +1 -1
  43. package/js/src/pro/cex.d.ts +5 -5
  44. package/js/src/pro/coinbase.d.ts +2 -2
  45. package/js/src/pro/hitbtc.js +16 -7
  46. package/js/src/pro/hyperliquid.d.ts +23 -0
  47. package/js/src/pro/hyperliquid.js +557 -0
  48. package/js/src/pro/poloniex.d.ts +3 -3
  49. package/package.json +1 -1
  50. package/skip-tests.json +33 -58
package/dist/cjs/ccxt.js CHANGED
@@ -152,6 +152,7 @@ var hollaex$1 = require('./src/pro/hollaex.js');
152
152
  var htx$1 = require('./src/pro/htx.js');
153
153
  var huobi$1 = require('./src/pro/huobi.js');
154
154
  var huobijp$1 = require('./src/pro/huobijp.js');
155
+ var hyperliquid$1 = require('./src/pro/hyperliquid.js');
155
156
  var idex$1 = require('./src/pro/idex.js');
156
157
  var independentreserve$1 = require('./src/pro/independentreserve.js');
157
158
  var kraken$1 = require('./src/pro/kraken.js');
@@ -177,7 +178,7 @@ var woo$1 = require('./src/pro/woo.js');
177
178
 
178
179
  //-----------------------------------------------------------------------------
179
180
  // this is updated by vss.js when building
180
- const version = '4.2.70';
181
+ const version = '4.2.72';
181
182
  Exchange["default"].ccxtVersion = version;
182
183
  const exchanges = {
183
184
  'ace': ace,
@@ -322,6 +323,7 @@ const pro = {
322
323
  'htx': htx$1,
323
324
  'huobi': huobi$1,
324
325
  'huobijp': huobijp$1,
326
+ 'hyperliquid': hyperliquid$1,
325
327
  'idex': idex$1,
326
328
  'independentreserve': independentreserve$1,
327
329
  'kraken': kraken$1,
@@ -57,9 +57,11 @@ class ascendex extends ascendex$1 {
57
57
  'fetchFundingRateHistory': false,
58
58
  'fetchFundingRates': true,
59
59
  'fetchIndexOHLCV': false,
60
- 'fetchLeverage': false,
60
+ 'fetchLeverage': 'emulated',
61
+ 'fetchLeverages': true,
61
62
  'fetchLeverageTiers': true,
62
- 'fetchMarginMode': false,
63
+ 'fetchMarginMode': 'emulated',
64
+ 'fetchMarginModes': true,
63
65
  'fetchMarketLeverageTiers': 'emulated',
64
66
  'fetchMarkets': true,
65
67
  'fetchMarkOHLCV': false,
@@ -3275,6 +3277,151 @@ class ascendex extends ascendex$1 {
3275
3277
  'amount': this.safeNumber(income, 'paymentInUSDT'),
3276
3278
  };
3277
3279
  }
3280
+ async fetchMarginModes(symbols = undefined, params = {}) {
3281
+ /**
3282
+ * @method
3283
+ * @name ascendex#fetchMarginMode
3284
+ * @description fetches the set margin mode of the user
3285
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3286
+ * @param {string[]} [symbols] a list of unified market symbols
3287
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3288
+ * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
3289
+ */
3290
+ await this.loadMarkets();
3291
+ await this.loadAccounts();
3292
+ const account = this.safeValue(this.accounts, 0, {});
3293
+ const accountGroup = this.safeString(account, 'id');
3294
+ const request = {
3295
+ 'account-group': accountGroup,
3296
+ };
3297
+ const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
3298
+ //
3299
+ // {
3300
+ // "code": 0,
3301
+ // "data": {
3302
+ // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
3303
+ // "ac": "FUTURES",
3304
+ // "collaterals": [
3305
+ // {
3306
+ // "asset": "USDT",
3307
+ // "balance": "44.570287262",
3308
+ // "referencePrice": "1",
3309
+ // "discountFactor": "1"
3310
+ // }
3311
+ // ],
3312
+ // "contracts": [
3313
+ // {
3314
+ // "symbol": "BTC-PERP",
3315
+ // "side": "LONG",
3316
+ // "position": "0.0001",
3317
+ // "referenceCost": "-3.12277254",
3318
+ // "unrealizedPnl": "-0.001700233",
3319
+ // "realizedPnl": "0",
3320
+ // "avgOpenPrice": "31209",
3321
+ // "marginType": "isolated",
3322
+ // "isolatedMargin": "1.654972977",
3323
+ // "leverage": "2",
3324
+ // "takeProfitPrice": "0",
3325
+ // "takeProfitTrigger": "market",
3326
+ // "stopLossPrice": "0",
3327
+ // "stopLossTrigger": "market",
3328
+ // "buyOpenOrderNotional": "0",
3329
+ // "sellOpenOrderNotional": "0",
3330
+ // "markPrice": "31210.723063672",
3331
+ // "indexPrice": "31223.148857925"
3332
+ // },
3333
+ // ]
3334
+ // }
3335
+ // }
3336
+ //
3337
+ const data = this.safeDict(response, 'data', {});
3338
+ const marginModes = this.safeList(data, 'contracts', []);
3339
+ return this.parseMarginModes(marginModes, symbols, 'symbol');
3340
+ }
3341
+ parseMarginMode(marginMode, market = undefined) {
3342
+ const marketId = this.safeString(marginMode, 'symbol');
3343
+ const marginType = this.safeString(marginMode, 'marginType');
3344
+ const margin = (marginType === 'crossed') ? 'cross' : 'isolated';
3345
+ return {
3346
+ 'info': marginMode,
3347
+ 'symbol': this.safeSymbol(marketId, market),
3348
+ 'marginMode': margin,
3349
+ };
3350
+ }
3351
+ async fetchLeverages(symbols = undefined, params = {}) {
3352
+ /**
3353
+ * @method
3354
+ * @name ascendex#fetchLeverages
3355
+ * @description fetch the set leverage for all contract markets
3356
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3357
+ * @param {string[]} [symbols] a list of unified market symbols
3358
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3359
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
3360
+ */
3361
+ await this.loadMarkets();
3362
+ await this.loadAccounts();
3363
+ const account = this.safeValue(this.accounts, 0, {});
3364
+ const accountGroup = this.safeString(account, 'id');
3365
+ const request = {
3366
+ 'account-group': accountGroup,
3367
+ };
3368
+ const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
3369
+ //
3370
+ // {
3371
+ // "code": 0,
3372
+ // "data": {
3373
+ // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
3374
+ // "ac": "FUTURES",
3375
+ // "collaterals": [
3376
+ // {
3377
+ // "asset": "USDT",
3378
+ // "balance": "44.570287262",
3379
+ // "referencePrice": "1",
3380
+ // "discountFactor": "1"
3381
+ // }
3382
+ // ],
3383
+ // "contracts": [
3384
+ // {
3385
+ // "symbol": "BTC-PERP",
3386
+ // "side": "LONG",
3387
+ // "position": "0.0001",
3388
+ // "referenceCost": "-3.12277254",
3389
+ // "unrealizedPnl": "-0.001700233",
3390
+ // "realizedPnl": "0",
3391
+ // "avgOpenPrice": "31209",
3392
+ // "marginType": "isolated",
3393
+ // "isolatedMargin": "1.654972977",
3394
+ // "leverage": "2",
3395
+ // "takeProfitPrice": "0",
3396
+ // "takeProfitTrigger": "market",
3397
+ // "stopLossPrice": "0",
3398
+ // "stopLossTrigger": "market",
3399
+ // "buyOpenOrderNotional": "0",
3400
+ // "sellOpenOrderNotional": "0",
3401
+ // "markPrice": "31210.723063672",
3402
+ // "indexPrice": "31223.148857925"
3403
+ // },
3404
+ // ]
3405
+ // }
3406
+ // }
3407
+ //
3408
+ const data = this.safeDict(response, 'data', {});
3409
+ const leverages = this.safeList(data, 'contracts', []);
3410
+ return this.parseLeverages(leverages, symbols, 'symbol');
3411
+ }
3412
+ parseLeverage(leverage, market = undefined) {
3413
+ const marketId = this.safeString(leverage, 'symbol');
3414
+ const leverageValue = this.safeInteger(leverage, 'leverage');
3415
+ const marginType = this.safeString(leverage, 'marginType');
3416
+ const marginMode = (marginType === 'crossed') ? 'cross' : 'isolated';
3417
+ return {
3418
+ 'info': leverage,
3419
+ 'symbol': this.safeSymbol(marketId, market),
3420
+ 'marginMode': marginMode,
3421
+ 'longLeverage': leverageValue,
3422
+ 'shortLeverage': leverageValue,
3423
+ };
3424
+ }
3278
3425
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3279
3426
  const version = api[0];
3280
3427
  const access = api[1];
@@ -6308,11 +6308,13 @@ class bitget extends bitget$1 {
6308
6308
  * @description fetch all open positions
6309
6309
  * @see https://www.bitget.com/api-doc/contract/position/get-all-position
6310
6310
  * @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
6311
- * @param {string[]|undefined} symbols list of unified market symbols
6311
+ * @param {string[]} [symbols] list of unified market symbols
6312
6312
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6313
6313
  * @param {string} [params.marginCoin] the settle currency of the positions, needs to match the productType
6314
6314
  * @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
6315
6315
  * @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)
6316
+ * @param {boolean} [params.useHistoryEndpoint] default false, when true will use the historic endpoint to fetch positions
6317
+ * @param {string} [params.method] either (default) 'privateMixGetV2MixPositionAllPosition' or 'privateMixGetV2MixPositionHistoryPosition'
6316
6318
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
6317
6319
  */
6318
6320
  await this.loadMarkets();
@@ -6321,8 +6323,14 @@ class bitget extends bitget$1 {
6321
6323
  if (paginate) {
6322
6324
  return await this.fetchPaginatedCallCursor('fetchPositions', undefined, undefined, undefined, params, 'endId', 'idLessThan');
6323
6325
  }
6324
- const fetchPositionsOptions = this.safeValue(this.options, 'fetchPositions', {});
6325
- const method = this.safeString(fetchPositionsOptions, 'method', 'privateMixGetV2MixPositionAllPosition');
6326
+ let method = undefined;
6327
+ const useHistoryEndpoint = this.safeBool(params, 'useHistoryEndpoint', false);
6328
+ if (useHistoryEndpoint) {
6329
+ method = 'privateMixGetV2MixPositionHistoryPosition';
6330
+ }
6331
+ else {
6332
+ [method, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'privateMixGetV2MixPositionAllPosition');
6333
+ }
6326
6334
  let market = undefined;
6327
6335
  if (symbols !== undefined) {
6328
6336
  const first = this.safeString(symbols, 0);
@@ -6438,11 +6446,11 @@ class bitget extends bitget$1 {
6438
6446
  //
6439
6447
  let position = [];
6440
6448
  if (!isHistory) {
6441
- position = this.safeValue(response, 'data', []);
6449
+ position = this.safeList(response, 'data', []);
6442
6450
  }
6443
6451
  else {
6444
- const data = this.safeValue(response, 'data', {});
6445
- position = this.safeValue(data, 'list', []);
6452
+ const data = this.safeDict(response, 'data', {});
6453
+ position = this.safeList(data, 'list', []);
6446
6454
  }
6447
6455
  const result = [];
6448
6456
  for (let i = 0; i < position.length; i++) {