ccxt 4.3.20 → 4.3.21

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 (44) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/functions/platform.js +3 -1
  4. package/dist/cjs/src/base/functions.js +1 -0
  5. package/dist/cjs/src/binance.js +10 -1
  6. package/dist/cjs/src/bitmex.js +1 -0
  7. package/dist/cjs/src/coinex.js +141 -178
  8. package/dist/cjs/src/hyperliquid.js +24 -2
  9. package/dist/cjs/src/okx.js +3 -0
  10. package/dist/cjs/src/pro/kucoinfutures.js +92 -0
  11. package/dist/cjs/src/pro/woo.js +52 -24
  12. package/js/ccxt.d.ts +1 -1
  13. package/js/ccxt.js +1 -1
  14. package/js/src/abstract/binance.d.ts +1 -0
  15. package/js/src/abstract/binancecoinm.d.ts +1 -0
  16. package/js/src/abstract/binanceus.d.ts +1 -0
  17. package/js/src/abstract/binanceusdm.d.ts +1 -0
  18. package/js/src/abstract/okx.d.ts +3 -0
  19. package/js/src/ascendex.d.ts +1 -1
  20. package/js/src/base/Exchange.d.ts +1 -1
  21. package/js/src/base/functions/platform.d.ts +2 -1
  22. package/js/src/base/functions/platform.js +3 -2
  23. package/js/src/binance.d.ts +1 -1
  24. package/js/src/binance.js +10 -1
  25. package/js/src/bingx.d.ts +1 -1
  26. package/js/src/bitget.d.ts +1 -1
  27. package/js/src/bitmex.js +1 -0
  28. package/js/src/coinex.d.ts +1 -1
  29. package/js/src/coinex.js +141 -178
  30. package/js/src/delta.d.ts +1 -1
  31. package/js/src/digifinex.d.ts +1 -1
  32. package/js/src/exmo.d.ts +1 -1
  33. package/js/src/gate.d.ts +1 -1
  34. package/js/src/hitbtc.d.ts +1 -1
  35. package/js/src/hyperliquid.d.ts +1 -1
  36. package/js/src/hyperliquid.js +24 -2
  37. package/js/src/okx.d.ts +1 -1
  38. package/js/src/okx.js +3 -0
  39. package/js/src/phemex.d.ts +1 -1
  40. package/js/src/pro/kucoinfutures.d.ts +3 -1
  41. package/js/src/pro/kucoinfutures.js +93 -1
  42. package/js/src/pro/woo.d.ts +2 -1
  43. package/js/src/pro/woo.js +52 -24
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -215,13 +215,13 @@ console.log(version, Object.keys(exchanges));
215
215
 
216
216
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
217
217
 
218
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.20/dist/ccxt.browser.js
219
- * unpkg: https://unpkg.com/ccxt@4.3.20/dist/ccxt.browser.js
218
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.21/dist/ccxt.browser.js
219
+ * unpkg: https://unpkg.com/ccxt@4.3.21/dist/ccxt.browser.js
220
220
 
221
221
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
222
222
 
223
223
  ```HTML
224
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.20/dist/ccxt.browser.js"></script>
224
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.21/dist/ccxt.browser.js"></script>
225
225
  ```
226
226
 
227
227
  Creates a global `ccxt` object:
package/dist/cjs/ccxt.js CHANGED
@@ -184,7 +184,7 @@ var woofipro$1 = require('./src/pro/woofipro.js');
184
184
 
185
185
  //-----------------------------------------------------------------------------
186
186
  // this is updated by vss.js when building
187
- const version = '4.3.20';
187
+ const version = '4.3.21';
188
188
  Exchange["default"].ccxtVersion = version;
189
189
  const exchanges = {
190
190
  'ace': ace,
@@ -19,9 +19,11 @@ const isElectron = typeof process !== 'undefined' &&
19
19
  typeof process.versions.electron !== 'undefined';
20
20
  const isWebWorker = typeof WorkerGlobalScope !== 'undefined' && (self instanceof WorkerGlobalScope);
21
21
  const isWindows = typeof process !== 'undefined' && process.platform === "win32";
22
- const isNode = !(isBrowser || isWebWorker);
22
+ const isDeno = typeof Deno !== 'undefined';
23
+ const isNode = !(isBrowser || isWebWorker || isDeno);
23
24
 
24
25
  exports.isBrowser = isBrowser;
26
+ exports.isDeno = isDeno;
25
27
  exports.isElectron = isElectron;
26
28
  exports.isNode = isNode;
27
29
  exports.isWebWorker = isWebWorker;
@@ -17,6 +17,7 @@ var misc = require('./functions/misc.js');
17
17
  /* ------------------------------------------------------------------------ */
18
18
 
19
19
  exports.isBrowser = platform.isBrowser;
20
+ exports.isDeno = platform.isDeno;
20
21
  exports.isElectron = platform.isElectron;
21
22
  exports.isNode = platform.isNode;
22
23
  exports.isWebWorker = platform.isWebWorker;
@@ -130,7 +130,7 @@ class binance extends binance$1 {
130
130
  'fetchPositions': true,
131
131
  'fetchPositionsHistory': false,
132
132
  'fetchPositionsRisk': true,
133
- 'fetchPremiumIndexOHLCV': false,
133
+ 'fetchPremiumIndexOHLCV': true,
134
134
  'fetchSettlementHistory': true,
135
135
  'fetchStatus': true,
136
136
  'fetchTicker': true,
@@ -779,6 +779,7 @@ class binance extends binance$1 {
779
779
  'continuousKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
780
780
  'markPriceKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
781
781
  'indexPriceKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
782
+ 'premiumIndexKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
782
783
  'fundingRate': 1,
783
784
  'fundingInfo': 1,
784
785
  'premiumIndex': 1,
@@ -4296,6 +4297,14 @@ class binance extends binance$1 {
4296
4297
  response = await this.fapiPublicGetIndexPriceKlines(this.extend(request, params));
4297
4298
  }
4298
4299
  }
4300
+ else if (price === 'premiumIndex') {
4301
+ if (market['inverse']) {
4302
+ response = await this.dapiPublicGetPremiumIndexKlines(this.extend(request, params));
4303
+ }
4304
+ else {
4305
+ response = await this.fapiPublicGetPremiumIndexKlines(this.extend(request, params));
4306
+ }
4307
+ }
4299
4308
  else if (market['linear']) {
4300
4309
  response = await this.fapiPublicGetKlines(this.extend(request, params));
4301
4310
  }
@@ -241,6 +241,7 @@ class bitmex extends bitmex$1 {
241
241
  'orderQty is invalid': errors.InvalidOrder,
242
242
  'Invalid price': errors.InvalidOrder,
243
243
  'Invalid stopPx for ordType': errors.InvalidOrder,
244
+ 'Account is restricted': errors.PermissionDenied, // {"error":{"message":"Account is restricted","name":"HTTPError"}}
244
245
  },
245
246
  'broad': {
246
247
  'Signature not valid': errors.AuthenticationError,
@@ -295,7 +295,7 @@ class coinex extends coinex$1 {
295
295
  'v2': {
296
296
  'public': {
297
297
  'get': {
298
- 'maintain-info': 1,
298
+ 'maintain/info': 1,
299
299
  'ping': 1,
300
300
  'time': 1,
301
301
  'spot/market': 1,
@@ -4236,72 +4236,60 @@ class coinex extends coinex$1 {
4236
4236
  async modifyMarginHelper(symbol, amount, addOrReduce, params = {}) {
4237
4237
  await this.loadMarkets();
4238
4238
  const market = this.market(symbol);
4239
+ const rawAmount = this.amountToPrecision(symbol, amount);
4240
+ let requestAmount = rawAmount;
4241
+ if (addOrReduce === 'reduce') {
4242
+ requestAmount = Precise["default"].stringNeg(rawAmount);
4243
+ }
4239
4244
  const request = {
4240
4245
  'market': market['id'],
4241
- 'amount': this.amountToPrecision(symbol, amount),
4242
- 'type': addOrReduce,
4246
+ 'market_type': 'FUTURES',
4247
+ 'amount': requestAmount,
4243
4248
  };
4244
- const response = await this.v1PerpetualPrivatePostPositionAdjustMargin(this.extend(request, params));
4249
+ const response = await this.v2PrivatePostFuturesAdjustPositionMargin(this.extend(request, params));
4245
4250
  //
4246
4251
  // {
4247
4252
  // "code": 0,
4248
4253
  // "data": {
4249
- // "adl_sort": 1,
4250
- // "adl_sort_val": "0.00004320",
4251
- // "amount": "0.0005",
4252
- // "amount_max": "0.0005",
4253
- // "amount_max_margin": "6.57352000000000000000",
4254
- // "bkr_price": "16294.08000000000000011090",
4255
- // "bkr_price_imply": "0.00000000000000000000",
4256
- // "close_left": "0.0005",
4257
- // "create_time": 1651202571.320778,
4258
- // "deal_all": "19.72000000000000000000",
4259
- // "deal_asset_fee": "0.00000000000000000000",
4260
- // "fee_asset": "",
4261
- // "finish_type": 1,
4262
- // "first_price": "39441.12",
4263
- // "insurance": "0.00000000000000000000",
4264
- // "latest_price": "39441.12",
4254
+ // "adl_level": 1,
4255
+ // "ath_margin_size": "2.034928",
4256
+ // "ath_position_amount": "0.0001",
4257
+ // "avg_entry_price": "61047.84",
4258
+ // "bkr_price": "30698.5600000000000004142",
4259
+ // "close_avbl": "0.0001",
4260
+ // "cml_position_value": "6.104784",
4261
+ // "created_at": 1715488472908,
4265
4262
  // "leverage": "3",
4266
- // "liq_amount": "0.00000000000000000000",
4267
- // "liq_order_price": "0",
4268
- // "liq_order_time": 0,
4269
- // "liq_price": "16491.28560000000000011090",
4270
- // "liq_price_imply": "0.00000000000000000000",
4271
- // "liq_profit": "0.00000000000000000000",
4272
- // "liq_time": 0,
4273
- // "mainten_margin": "0.005",
4274
- // "mainten_margin_amount": "0.09860280000000000000",
4275
- // "maker_fee": "0.00000000000000000000",
4276
- // "margin_amount": "11.57352000000000000000",
4263
+ // "liq_price": "30852.82412060301507579316",
4264
+ // "maintenance_margin_rate": "0.005",
4265
+ // "maintenance_margin_value": "0.03051465",
4266
+ // "margin_avbl": "3.034928",
4267
+ // "margin_mode": "isolated",
4277
4268
  // "market": "BTCUSDT",
4278
- // "open_margin": "0.58687582908396110455",
4279
- // "open_margin_imply": "0.00000000000000000000",
4280
- // "open_price": "39441.12000000000000000000",
4281
- // "open_val": "19.72056000000000000000",
4282
- // "open_val_max": "19.72056000000000000000",
4283
- // "position_id": 65171206,
4284
- // "profit_clearing": "-0.00986028000000000000",
4285
- // "profit_real": "-0.00986028000000000000",
4286
- // "profit_unreal": "0.00",
4287
- // "side": 2,
4288
- // "stop_loss_price": "0.00000000000000000000",
4289
- // "stop_loss_type": 0,
4290
- // "s ys": 0,
4291
- // "take_profit_price": "0.00000000000000000000",
4292
- // "take_profit_type": 0,
4293
- // "taker_fee": "0.00000000000000000000",
4294
- // "total": 3464,
4295
- // "type": 1,
4296
- // "update_time": 1651202638.911212,
4297
- // "user_id": 3620173
4269
+ // "market_type": "FUTURES",
4270
+ // "max_position_value": "6.104784",
4271
+ // "open_interest": "0.0001",
4272
+ // "position_id": 306458800,
4273
+ // "position_margin_rate": "0.49713929272518077625",
4274
+ // "realized_pnl": "-0.003052392",
4275
+ // "settle_price": "61047.84",
4276
+ // "settle_value": "6.104784",
4277
+ // "side": "long",
4278
+ // "stop_loss_price": "0",
4279
+ // "stop_loss_type": "",
4280
+ // "take_profit_price": "0",
4281
+ // "take_profit_type": "",
4282
+ // "unrealized_pnl": "0",
4283
+ // "updated_at": 1715488805563
4298
4284
  // },
4299
- // "message":"OK"
4285
+ // "message": "OK"
4300
4286
  // }
4301
4287
  //
4302
4288
  const data = this.safeDict(response, 'data');
4303
- const status = this.safeString(response, 'message');
4289
+ const status = this.safeStringLower(response, 'message');
4290
+ const type = (addOrReduce === 'reduce') ? 'reduce' : 'add';
4304
4291
  return this.extend(this.parseMarginModification(data, market), {
4292
+ 'type': type,
4305
4293
  'amount': this.parseNumber(amount),
4306
4294
  'status': status,
4307
4295
  });
@@ -4310,86 +4298,66 @@ class coinex extends coinex$1 {
4310
4298
  //
4311
4299
  // addMargin/reduceMargin
4312
4300
  //
4313
- // {
4314
- // "adl_sort": 1,
4315
- // "adl_sort_val": "0.00004320",
4316
- // "amount": "0.0005",
4317
- // "amount_max": "0.0005",
4318
- // "amount_max_margin": "6.57352000000000000000",
4319
- // "bkr_price": "16294.08000000000000011090",
4320
- // "bkr_price_imply": "0.00000000000000000000",
4321
- // "close_left": "0.0005",
4322
- // "create_time": 1651202571.320778,
4323
- // "deal_all": "19.72000000000000000000",
4324
- // "deal_asset_fee": "0.00000000000000000000",
4325
- // "fee_asset": "",
4326
- // "finish_type": 1,
4327
- // "first_price": "39441.12",
4328
- // "insurance": "0.00000000000000000000",
4329
- // "latest_price": "39441.12",
4330
- // "leverage": "3",
4331
- // "liq_amount": "0.00000000000000000000",
4332
- // "liq_order_price": "0",
4333
- // "liq_order_time": 0,
4334
- // "liq_price": "16491.28560000000000011090",
4335
- // "liq_price_imply": "0.00000000000000000000",
4336
- // "liq_profit": "0.00000000000000000000",
4337
- // "liq_time": 0,
4338
- // "mainten_margin": "0.005",
4339
- // "mainten_margin_amount": "0.09860280000000000000",
4340
- // "maker_fee": "0.00000000000000000000",
4341
- // "margin_amount": "11.57352000000000000000",
4342
- // "market": "BTCUSDT",
4343
- // "open_margin": "0.58687582908396110455",
4344
- // "open_margin_imply": "0.00000000000000000000",
4345
- // "open_price": "39441.12000000000000000000",
4346
- // "open_val": "19.72056000000000000000",
4347
- // "open_val_max": "19.72056000000000000000",
4348
- // "position_id": 65171206,
4349
- // "profit_clearing": "-0.00986028000000000000",
4350
- // "profit_real": "-0.00986028000000000000",
4351
- // "profit_unreal": "0.00",
4352
- // "side": 2,
4353
- // "stop_loss_price": "0.00000000000000000000",
4354
- // "stop_loss_type": 0,
4355
- // "sy s": 0,
4356
- // "take_profit_price": "0.00000000000000000000",
4357
- // "take_profit_type": 0,
4358
- // "taker_fee": "0.00000000000000000000",
4359
- // "total": 3464,
4360
- // "type": 1,
4361
- // "update_time": 1651202638.911212,
4362
- // "user_id": 3620173
4363
- // }
4301
+ // {
4302
+ // "adl_level": 1,
4303
+ // "ath_margin_size": "2.034928",
4304
+ // "ath_position_amount": "0.0001",
4305
+ // "avg_entry_price": "61047.84",
4306
+ // "bkr_price": "30698.5600000000000004142",
4307
+ // "close_avbl": "0.0001",
4308
+ // "cml_position_value": "6.104784",
4309
+ // "created_at": 1715488472908,
4310
+ // "leverage": "3",
4311
+ // "liq_price": "30852.82412060301507579316",
4312
+ // "maintenance_margin_rate": "0.005",
4313
+ // "maintenance_margin_value": "0.03051465",
4314
+ // "margin_avbl": "3.034928",
4315
+ // "margin_mode": "isolated",
4316
+ // "market": "BTCUSDT",
4317
+ // "market_type": "FUTURES",
4318
+ // "max_position_value": "6.104784",
4319
+ // "open_interest": "0.0001",
4320
+ // "position_id": 306458800,
4321
+ // "position_margin_rate": "0.49713929272518077625",
4322
+ // "realized_pnl": "-0.003052392",
4323
+ // "settle_price": "61047.84",
4324
+ // "settle_value": "6.104784",
4325
+ // "side": "long",
4326
+ // "stop_loss_price": "0",
4327
+ // "stop_loss_type": "",
4328
+ // "take_profit_price": "0",
4329
+ // "take_profit_type": "",
4330
+ // "unrealized_pnl": "0",
4331
+ // "updated_at": 1715488805563
4332
+ // }
4364
4333
  //
4365
4334
  // fetchMarginAdjustmentHistory
4366
4335
  //
4367
- // {
4368
- // bkr_price: '0',
4369
- // leverage: '3',
4370
- // liq_price: '0',
4371
- // margin_amount: '5.33236666666666666666',
4372
- // margin_change: '3',
4373
- // market: 'XRPUSDT',
4374
- // position_amount: '11',
4375
- // position_id: '297155652',
4376
- // position_type: '2',
4377
- // settle_price: '0.6361',
4378
- // time: '1711050906.382891',
4379
- // type: '1',
4380
- // user_id: '3685860'
4381
- // }
4336
+ // {
4337
+ // "bkr_pirce": "24698.56000000000000005224",
4338
+ // "created_at": 1715489978697,
4339
+ // "leverage": "3",
4340
+ // "liq_price": "24822.67336683417085432386",
4341
+ // "margin_avbl": "3.634928",
4342
+ // "margin_change": "-1.5",
4343
+ // "margin_mode": "isolated",
4344
+ // "market": "BTCUSDT",
4345
+ // "market_type": "FUTURES",
4346
+ // "open_interest": "0.0001",
4347
+ // "position_id": 306458800,
4348
+ // "settle_price": "61047.84"
4349
+ // }
4382
4350
  //
4383
4351
  const marketId = this.safeString(data, 'market');
4384
- const type = this.safeString(data, 'type');
4385
- const timestamp = this.safeIntegerProduct2(data, 'time', 'update_time', 1000);
4352
+ const timestamp = this.safeInteger2(data, 'updated_at', 'created_at');
4353
+ const change = this.safeString(data, 'margin_change');
4386
4354
  return {
4387
4355
  'info': data,
4388
4356
  'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
4389
- 'type': (type === '1') ? 'add' : 'reduce',
4357
+ 'type': undefined,
4390
4358
  'marginMode': 'isolated',
4391
- 'amount': this.safeNumber(data, 'margin_change'),
4392
- 'total': this.safeNumber(data, 'position_amount'),
4359
+ 'amount': this.parseNumber(Precise["default"].stringAbs(change)),
4360
+ 'total': this.safeNumber(data, 'margin_avbl'),
4393
4361
  'code': market['quote'],
4394
4362
  'status': undefined,
4395
4363
  'timestamp': timestamp,
@@ -4401,26 +4369,26 @@ class coinex extends coinex$1 {
4401
4369
  * @method
4402
4370
  * @name coinex#addMargin
4403
4371
  * @description add margin
4404
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
4372
+ * @see https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4405
4373
  * @param {string} symbol unified market symbol
4406
4374
  * @param {float} amount amount of margin to add
4407
4375
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4408
4376
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
4409
4377
  */
4410
- return await this.modifyMarginHelper(symbol, amount, 1, params);
4378
+ return await this.modifyMarginHelper(symbol, amount, 'add', params);
4411
4379
  }
4412
4380
  async reduceMargin(symbol, amount, params = {}) {
4413
4381
  /**
4414
4382
  * @method
4415
4383
  * @name coinex#reduceMargin
4416
4384
  * @description remove margin from a position
4417
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
4385
+ * @see https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4418
4386
  * @param {string} symbol unified market symbol
4419
4387
  * @param {float} amount the amount of margin to remove
4420
4388
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4421
4389
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
4422
4390
  */
4423
- return await this.modifyMarginHelper(symbol, amount, 2, params);
4391
+ return await this.modifyMarginHelper(symbol, amount, 'reduce', params);
4424
4392
  }
4425
4393
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4426
4394
  /**
@@ -5957,71 +5925,66 @@ class coinex extends coinex$1 {
5957
5925
  * @method
5958
5926
  * @name coinex#fetchMarginAdjustmentHistory
5959
5927
  * @description fetches the history of margin added or reduced from contract isolated positions
5960
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http046_position_margin_history
5961
- * @param {string} [symbol] unified market symbol
5928
+ * @see https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
5929
+ * @param {string} symbol unified market symbol
5962
5930
  * @param {string} [type] not used by coinex fetchMarginAdjustmentHistory
5963
5931
  * @param {int} [since] timestamp in ms of the earliest change to fetch
5964
- * @param {int} [limit] the maximum amount of changes to fetch, default=100, max=100
5932
+ * @param {int} [limit] the maximum amount of changes to fetch, default is 10
5965
5933
  * @param {object} params extra parameters specific to the exchange api endpoint
5966
5934
  * @param {int} [params.until] timestamp in ms of the latest change to fetch
5967
- *
5968
- * EXCHANGE SPECIFIC PARAMETERS
5969
- * @param {int} [params.offset] offset
5935
+ * @param {int} [params.positionId] the id of the position that you want to retrieve margin adjustment history for
5970
5936
  * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5971
5937
  */
5972
5938
  await this.loadMarkets();
5973
- const until = this.safeInteger(params, 'until');
5974
- params = this.omit(params, 'until');
5975
- if (limit === undefined) {
5976
- limit = 100;
5939
+ if (symbol === undefined) {
5940
+ throw new errors.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory() requires a symbol argument');
5977
5941
  }
5978
- const request = {
5979
- 'market': '',
5980
- 'position_id': 0,
5981
- 'offset': 0,
5982
- 'limit': limit,
5983
- };
5984
- if (symbol !== undefined) {
5985
- const market = this.market(symbol);
5986
- request['market'] = market['id'];
5942
+ const positionId = this.safeInteger2(params, 'positionId', 'position_id');
5943
+ params = this.omit(params, 'positionId');
5944
+ if (positionId === undefined) {
5945
+ throw new errors.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter');
5987
5946
  }
5947
+ const market = this.market(symbol);
5948
+ let request = {
5949
+ 'market': market['id'],
5950
+ 'market_type': 'FUTURES',
5951
+ 'position_id': positionId,
5952
+ };
5953
+ [request, params] = this.handleUntilOption('end_time', request, params);
5988
5954
  if (since !== undefined) {
5989
5955
  request['start_time'] = since;
5990
5956
  }
5991
- if (until !== undefined) {
5992
- request['end_time'] = until;
5957
+ if (limit !== undefined) {
5958
+ request['limit'] = limit;
5993
5959
  }
5994
- const response = await this.v1PerpetualPrivateGetPositionMarginHistory(this.extend(request, params));
5960
+ const response = await this.v2PrivateGetFuturesPositionMarginHistory(this.extend(request, params));
5995
5961
  //
5996
- // {
5997
- // code: '0',
5998
- // data: {
5999
- // limit: '100',
6000
- // offset: '0',
6001
- // records: [
6002
- // {
6003
- // bkr_price: '0',
6004
- // leverage: '3',
6005
- // liq_price: '0',
6006
- // margin_amount: '5.33236666666666666666',
6007
- // margin_change: '3',
6008
- // market: 'XRPUSDT',
6009
- // position_amount: '11',
6010
- // position_id: '297155652',
6011
- // position_type: '2',
6012
- // settle_price: '0.6361',
6013
- // time: '1711050906.382891',
6014
- // type: '1',
6015
- // user_id: '3685860'
6016
- // }
6017
- // ]
6018
- // },
6019
- // message: 'OK'
6020
- // }
5962
+ // {
5963
+ // "code": 0,
5964
+ // "data": [
5965
+ // {
5966
+ // "bkr_pirce": "24698.56000000000000005224",
5967
+ // "created_at": 1715489978697,
5968
+ // "leverage": "3",
5969
+ // "liq_price": "24822.67336683417085432386",
5970
+ // "margin_avbl": "3.634928",
5971
+ // "margin_change": "-1.5",
5972
+ // "margin_mode": "isolated",
5973
+ // "market": "BTCUSDT",
5974
+ // "market_type": "FUTURES",
5975
+ // "open_interest": "0.0001",
5976
+ // "position_id": 306458800,
5977
+ // "settle_price": "61047.84"
5978
+ // },
5979
+ // ],
5980
+ // "message": "OK",
5981
+ // "pagination": {
5982
+ // "has_next": true
5983
+ // }
5984
+ // }
6021
5985
  //
6022
- const data = this.safeDict(response, 'data', {});
6023
- const records = this.safeList(data, 'records', []);
6024
- const modifications = this.parseMarginModifications(records, undefined, 'market', 'swap');
5986
+ const data = this.safeList(response, 'data', []);
5987
+ const modifications = this.parseMarginModifications(data, undefined, 'market', 'swap');
6025
5988
  return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
6026
5989
  }
6027
5990
  }
@@ -1628,14 +1628,17 @@ class hyperliquid extends hyperliquid$1 {
1628
1628
  * @param {int} [limit] the maximum number of open orders structures to retrieve
1629
1629
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1630
1630
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
1631
+ * @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
1631
1632
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1632
1633
  */
1633
1634
  let userAddress = undefined;
1634
1635
  [userAddress, params] = this.handlePublicAddress('fetchOpenOrders', params);
1636
+ let method = undefined;
1637
+ [method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'frontendOpenOrders');
1635
1638
  await this.loadMarkets();
1636
1639
  const market = this.safeMarket(symbol);
1637
1640
  const request = {
1638
- 'type': 'openOrders',
1641
+ 'type': method,
1639
1642
  'user': userAddress,
1640
1643
  };
1641
1644
  const response = await this.publicPostInfo(this.extend(request, params));
@@ -1813,6 +1816,25 @@ class hyperliquid extends hyperliquid$1 {
1813
1816
  // "oid":6195281425
1814
1817
  // }
1815
1818
  // }
1819
+ // frontendOrder
1820
+ // {
1821
+ // "children": [],
1822
+ // "cloid": null,
1823
+ // "coin": "BLUR",
1824
+ // "isPositionTpsl": false,
1825
+ // "isTrigger": true,
1826
+ // "limitPx": "0.5",
1827
+ // "oid": 8670487141,
1828
+ // "orderType": "Stop Limit",
1829
+ // "origSz": "20.0",
1830
+ // "reduceOnly": false,
1831
+ // "side": "B",
1832
+ // "sz": "20.0",
1833
+ // "tif": null,
1834
+ // "timestamp": 1715523663687,
1835
+ // "triggerCondition": "Price above 0.6",
1836
+ // "triggerPx": "0.6"
1837
+ // }
1816
1838
  //
1817
1839
  let entry = this.safeDictN(order, ['order', 'resting', 'filled']);
1818
1840
  if (entry === undefined) {
@@ -1850,7 +1872,7 @@ class hyperliquid extends hyperliquid$1 {
1850
1872
  'lastTradeTimestamp': undefined,
1851
1873
  'lastUpdateTimestamp': undefined,
1852
1874
  'symbol': symbol,
1853
- 'type': this.safeStringLower(entry, 'orderType'),
1875
+ 'type': this.parseOrderType(this.safeStringLower(entry, 'orderType')),
1854
1876
  'timeInForce': this.safeStringUpper(entry, 'tif'),
1855
1877
  'postOnly': undefined,
1856
1878
  'reduceOnly': this.safeBool(entry, 'reduceOnly'),
@@ -245,6 +245,9 @@ class okx extends okx$1 {
245
245
  'sprd/books': 1 / 2,
246
246
  'sprd/ticker': 1,
247
247
  'sprd/public-trades': 1 / 5,
248
+ 'market/sprd-ticker': 2,
249
+ 'market/sprd-candles': 2,
250
+ 'market/sprd-history-candles': 2,
248
251
  'tradingBot/grid/ai-param': 1,
249
252
  'tradingBot/grid/min-investment': 1,
250
253
  'tradingBot/public/rsi-back-testing': 1,