ccxt 4.3.19 → 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 (56) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +3 -0
  4. package/dist/cjs/src/base/functions/platform.js +3 -1
  5. package/dist/cjs/src/base/functions.js +1 -0
  6. package/dist/cjs/src/binance.js +10 -1
  7. package/dist/cjs/src/bitget.js +3 -0
  8. package/dist/cjs/src/bitmex.js +1 -0
  9. package/dist/cjs/src/bybit.js +38 -9
  10. package/dist/cjs/src/coinex.js +180 -201
  11. package/dist/cjs/src/hyperliquid.js +24 -2
  12. package/dist/cjs/src/okx.js +3 -0
  13. package/dist/cjs/src/phemex.js +17 -6
  14. package/dist/cjs/src/pro/htx.js +12 -7
  15. package/dist/cjs/src/pro/kucoinfutures.js +92 -0
  16. package/dist/cjs/src/pro/woo.js +52 -24
  17. package/js/ccxt.d.ts +1 -1
  18. package/js/ccxt.js +1 -1
  19. package/js/src/abstract/binance.d.ts +1 -0
  20. package/js/src/abstract/binancecoinm.d.ts +1 -0
  21. package/js/src/abstract/binanceus.d.ts +1 -0
  22. package/js/src/abstract/binanceusdm.d.ts +1 -0
  23. package/js/src/abstract/bitget.d.ts +3 -0
  24. package/js/src/abstract/okx.d.ts +3 -0
  25. package/js/src/ascendex.d.ts +1 -1
  26. package/js/src/base/Exchange.d.ts +1 -1
  27. package/js/src/base/Exchange.js +3 -0
  28. package/js/src/base/functions/platform.d.ts +2 -1
  29. package/js/src/base/functions/platform.js +3 -2
  30. package/js/src/binance.d.ts +1 -1
  31. package/js/src/binance.js +10 -1
  32. package/js/src/bingx.d.ts +1 -1
  33. package/js/src/bitget.d.ts +1 -1
  34. package/js/src/bitget.js +3 -0
  35. package/js/src/bitmex.js +1 -0
  36. package/js/src/bybit.d.ts +1 -0
  37. package/js/src/bybit.js +38 -9
  38. package/js/src/coinex.d.ts +2 -2
  39. package/js/src/coinex.js +180 -201
  40. package/js/src/delta.d.ts +1 -1
  41. package/js/src/digifinex.d.ts +1 -1
  42. package/js/src/exmo.d.ts +1 -1
  43. package/js/src/gate.d.ts +1 -1
  44. package/js/src/hitbtc.d.ts +1 -1
  45. package/js/src/hyperliquid.d.ts +1 -1
  46. package/js/src/hyperliquid.js +24 -2
  47. package/js/src/okx.d.ts +1 -1
  48. package/js/src/okx.js +3 -0
  49. package/js/src/phemex.d.ts +1 -1
  50. package/js/src/phemex.js +17 -6
  51. package/js/src/pro/htx.js +12 -7
  52. package/js/src/pro/kucoinfutures.d.ts +3 -1
  53. package/js/src/pro/kucoinfutures.js +93 -1
  54. package/js/src/pro/woo.d.ts +2 -1
  55. package/js/src/pro/woo.js +52 -24
  56. package/package.json +1 -1
@@ -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,
@@ -4171,47 +4171,63 @@ class coinex extends coinex$1 {
4171
4171
  * @method
4172
4172
  * @name coinex#fetchLeverageTiers
4173
4173
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
4174
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http007_market_limit
4174
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
4175
4175
  * @param {string[]|undefined} symbols list of unified market symbols
4176
4176
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4177
4177
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
4178
4178
  */
4179
4179
  await this.loadMarkets();
4180
- const response = await this.v1PerpetualPublicGetMarketLimitConfig(params);
4180
+ const request = {};
4181
+ if (symbols !== undefined) {
4182
+ const marketIds = this.marketIds(symbols);
4183
+ request['market'] = marketIds.join(',');
4184
+ }
4185
+ const response = await this.v2PublicGetFuturesPositionLevel(this.extend(request, params));
4181
4186
  //
4182
4187
  // {
4183
4188
  // "code": 0,
4184
- // "data": {
4185
- // "BTCUSD": [
4186
- // ["500001", "100", "0.005"],
4187
- // ["1000001", "50", "0.01"],
4188
- // ["2000001", "30", "0.015"],
4189
- // ["5000001", "20", "0.02"],
4190
- // ["10000001", "15", "0.025"],
4191
- // ["20000001", "10", "0.03"]
4192
- // ],
4193
- // ...
4194
- // },
4189
+ // "data": [
4190
+ // {
4191
+ // "level": [
4192
+ // {
4193
+ // "amount": "20001",
4194
+ // "leverage": "20",
4195
+ // "maintenance_margin_rate": "0.02",
4196
+ // "min_initial_margin_rate": "0.05"
4197
+ // },
4198
+ // {
4199
+ // "amount": "50001",
4200
+ // "leverage": "10",
4201
+ // "maintenance_margin_rate": "0.04",
4202
+ // "min_initial_margin_rate": "0.1"
4203
+ // },
4204
+ // ],
4205
+ // "market": "MINAUSDT"
4206
+ // },
4207
+ // ],
4195
4208
  // "message": "OK"
4196
4209
  // }
4197
4210
  //
4198
- const data = this.safeValue(response, 'data', {});
4199
- return this.parseLeverageTiers(data, symbols, undefined);
4211
+ const data = this.safeList(response, 'data', []);
4212
+ return this.parseLeverageTiers(data, symbols, 'market');
4200
4213
  }
4201
- parseMarketLeverageTiers(item, market = undefined) {
4214
+ parseMarketLeverageTiers(info, market = undefined) {
4202
4215
  const tiers = [];
4216
+ const brackets = this.safeList(info, 'level', []);
4203
4217
  let minNotional = 0;
4204
- for (let j = 0; j < item.length; j++) {
4205
- const bracket = item[j];
4206
- const maxNotional = this.safeNumber(bracket, 0);
4218
+ for (let i = 0; i < brackets.length; i++) {
4219
+ const tier = brackets[i];
4220
+ const marketId = this.safeString(info, 'market');
4221
+ market = this.safeMarket(marketId, market, undefined, 'swap');
4222
+ const maxNotional = this.safeNumber(tier, 'amount');
4207
4223
  tiers.push({
4208
- 'tier': j + 1,
4224
+ 'tier': this.sum(i, 1),
4209
4225
  'currency': market['linear'] ? market['base'] : market['quote'],
4210
4226
  'minNotional': minNotional,
4211
4227
  'maxNotional': maxNotional,
4212
- 'maintenanceMarginRate': this.safeNumber(bracket, 2),
4213
- 'maxLeverage': this.safeInteger(bracket, 1),
4214
- 'info': bracket,
4228
+ 'maintenanceMarginRate': this.safeNumber(tier, 'maintenance_margin_rate'),
4229
+ 'maxLeverage': this.safeInteger(tier, 'leverage'),
4230
+ 'info': tier,
4215
4231
  });
4216
4232
  minNotional = maxNotional;
4217
4233
  }
@@ -4220,72 +4236,60 @@ class coinex extends coinex$1 {
4220
4236
  async modifyMarginHelper(symbol, amount, addOrReduce, params = {}) {
4221
4237
  await this.loadMarkets();
4222
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
+ }
4223
4244
  const request = {
4224
4245
  'market': market['id'],
4225
- 'amount': this.amountToPrecision(symbol, amount),
4226
- 'type': addOrReduce,
4246
+ 'market_type': 'FUTURES',
4247
+ 'amount': requestAmount,
4227
4248
  };
4228
- const response = await this.v1PerpetualPrivatePostPositionAdjustMargin(this.extend(request, params));
4249
+ const response = await this.v2PrivatePostFuturesAdjustPositionMargin(this.extend(request, params));
4229
4250
  //
4230
4251
  // {
4231
4252
  // "code": 0,
4232
4253
  // "data": {
4233
- // "adl_sort": 1,
4234
- // "adl_sort_val": "0.00004320",
4235
- // "amount": "0.0005",
4236
- // "amount_max": "0.0005",
4237
- // "amount_max_margin": "6.57352000000000000000",
4238
- // "bkr_price": "16294.08000000000000011090",
4239
- // "bkr_price_imply": "0.00000000000000000000",
4240
- // "close_left": "0.0005",
4241
- // "create_time": 1651202571.320778,
4242
- // "deal_all": "19.72000000000000000000",
4243
- // "deal_asset_fee": "0.00000000000000000000",
4244
- // "fee_asset": "",
4245
- // "finish_type": 1,
4246
- // "first_price": "39441.12",
4247
- // "insurance": "0.00000000000000000000",
4248
- // "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,
4249
4262
  // "leverage": "3",
4250
- // "liq_amount": "0.00000000000000000000",
4251
- // "liq_order_price": "0",
4252
- // "liq_order_time": 0,
4253
- // "liq_price": "16491.28560000000000011090",
4254
- // "liq_price_imply": "0.00000000000000000000",
4255
- // "liq_profit": "0.00000000000000000000",
4256
- // "liq_time": 0,
4257
- // "mainten_margin": "0.005",
4258
- // "mainten_margin_amount": "0.09860280000000000000",
4259
- // "maker_fee": "0.00000000000000000000",
4260
- // "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",
4261
4268
  // "market": "BTCUSDT",
4262
- // "open_margin": "0.58687582908396110455",
4263
- // "open_margin_imply": "0.00000000000000000000",
4264
- // "open_price": "39441.12000000000000000000",
4265
- // "open_val": "19.72056000000000000000",
4266
- // "open_val_max": "19.72056000000000000000",
4267
- // "position_id": 65171206,
4268
- // "profit_clearing": "-0.00986028000000000000",
4269
- // "profit_real": "-0.00986028000000000000",
4270
- // "profit_unreal": "0.00",
4271
- // "side": 2,
4272
- // "stop_loss_price": "0.00000000000000000000",
4273
- // "stop_loss_type": 0,
4274
- // "s ys": 0,
4275
- // "take_profit_price": "0.00000000000000000000",
4276
- // "take_profit_type": 0,
4277
- // "taker_fee": "0.00000000000000000000",
4278
- // "total": 3464,
4279
- // "type": 1,
4280
- // "update_time": 1651202638.911212,
4281
- // "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
4282
4284
  // },
4283
- // "message":"OK"
4285
+ // "message": "OK"
4284
4286
  // }
4285
4287
  //
4286
4288
  const data = this.safeDict(response, 'data');
4287
- const status = this.safeString(response, 'message');
4289
+ const status = this.safeStringLower(response, 'message');
4290
+ const type = (addOrReduce === 'reduce') ? 'reduce' : 'add';
4288
4291
  return this.extend(this.parseMarginModification(data, market), {
4292
+ 'type': type,
4289
4293
  'amount': this.parseNumber(amount),
4290
4294
  'status': status,
4291
4295
  });
@@ -4294,86 +4298,66 @@ class coinex extends coinex$1 {
4294
4298
  //
4295
4299
  // addMargin/reduceMargin
4296
4300
  //
4297
- // {
4298
- // "adl_sort": 1,
4299
- // "adl_sort_val": "0.00004320",
4300
- // "amount": "0.0005",
4301
- // "amount_max": "0.0005",
4302
- // "amount_max_margin": "6.57352000000000000000",
4303
- // "bkr_price": "16294.08000000000000011090",
4304
- // "bkr_price_imply": "0.00000000000000000000",
4305
- // "close_left": "0.0005",
4306
- // "create_time": 1651202571.320778,
4307
- // "deal_all": "19.72000000000000000000",
4308
- // "deal_asset_fee": "0.00000000000000000000",
4309
- // "fee_asset": "",
4310
- // "finish_type": 1,
4311
- // "first_price": "39441.12",
4312
- // "insurance": "0.00000000000000000000",
4313
- // "latest_price": "39441.12",
4314
- // "leverage": "3",
4315
- // "liq_amount": "0.00000000000000000000",
4316
- // "liq_order_price": "0",
4317
- // "liq_order_time": 0,
4318
- // "liq_price": "16491.28560000000000011090",
4319
- // "liq_price_imply": "0.00000000000000000000",
4320
- // "liq_profit": "0.00000000000000000000",
4321
- // "liq_time": 0,
4322
- // "mainten_margin": "0.005",
4323
- // "mainten_margin_amount": "0.09860280000000000000",
4324
- // "maker_fee": "0.00000000000000000000",
4325
- // "margin_amount": "11.57352000000000000000",
4326
- // "market": "BTCUSDT",
4327
- // "open_margin": "0.58687582908396110455",
4328
- // "open_margin_imply": "0.00000000000000000000",
4329
- // "open_price": "39441.12000000000000000000",
4330
- // "open_val": "19.72056000000000000000",
4331
- // "open_val_max": "19.72056000000000000000",
4332
- // "position_id": 65171206,
4333
- // "profit_clearing": "-0.00986028000000000000",
4334
- // "profit_real": "-0.00986028000000000000",
4335
- // "profit_unreal": "0.00",
4336
- // "side": 2,
4337
- // "stop_loss_price": "0.00000000000000000000",
4338
- // "stop_loss_type": 0,
4339
- // "sy s": 0,
4340
- // "take_profit_price": "0.00000000000000000000",
4341
- // "take_profit_type": 0,
4342
- // "taker_fee": "0.00000000000000000000",
4343
- // "total": 3464,
4344
- // "type": 1,
4345
- // "update_time": 1651202638.911212,
4346
- // "user_id": 3620173
4347
- // }
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
+ // }
4348
4333
  //
4349
4334
  // fetchMarginAdjustmentHistory
4350
4335
  //
4351
- // {
4352
- // bkr_price: '0',
4353
- // leverage: '3',
4354
- // liq_price: '0',
4355
- // margin_amount: '5.33236666666666666666',
4356
- // margin_change: '3',
4357
- // market: 'XRPUSDT',
4358
- // position_amount: '11',
4359
- // position_id: '297155652',
4360
- // position_type: '2',
4361
- // settle_price: '0.6361',
4362
- // time: '1711050906.382891',
4363
- // type: '1',
4364
- // user_id: '3685860'
4365
- // }
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
+ // }
4366
4350
  //
4367
4351
  const marketId = this.safeString(data, 'market');
4368
- const type = this.safeString(data, 'type');
4369
- 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');
4370
4354
  return {
4371
4355
  'info': data,
4372
4356
  'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
4373
- 'type': (type === '1') ? 'add' : 'reduce',
4357
+ 'type': undefined,
4374
4358
  'marginMode': 'isolated',
4375
- 'amount': this.safeNumber(data, 'margin_change'),
4376
- 'total': this.safeNumber(data, 'position_amount'),
4359
+ 'amount': this.parseNumber(Precise["default"].stringAbs(change)),
4360
+ 'total': this.safeNumber(data, 'margin_avbl'),
4377
4361
  'code': market['quote'],
4378
4362
  'status': undefined,
4379
4363
  'timestamp': timestamp,
@@ -4385,26 +4369,26 @@ class coinex extends coinex$1 {
4385
4369
  * @method
4386
4370
  * @name coinex#addMargin
4387
4371
  * @description add margin
4388
- * @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
4389
4373
  * @param {string} symbol unified market symbol
4390
4374
  * @param {float} amount amount of margin to add
4391
4375
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4392
4376
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
4393
4377
  */
4394
- return await this.modifyMarginHelper(symbol, amount, 1, params);
4378
+ return await this.modifyMarginHelper(symbol, amount, 'add', params);
4395
4379
  }
4396
4380
  async reduceMargin(symbol, amount, params = {}) {
4397
4381
  /**
4398
4382
  * @method
4399
4383
  * @name coinex#reduceMargin
4400
4384
  * @description remove margin from a position
4401
- * @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
4402
4386
  * @param {string} symbol unified market symbol
4403
4387
  * @param {float} amount the amount of margin to remove
4404
4388
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4405
4389
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
4406
4390
  */
4407
- return await this.modifyMarginHelper(symbol, amount, 2, params);
4391
+ return await this.modifyMarginHelper(symbol, amount, 'reduce', params);
4408
4392
  }
4409
4393
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4410
4394
  /**
@@ -5941,71 +5925,66 @@ class coinex extends coinex$1 {
5941
5925
  * @method
5942
5926
  * @name coinex#fetchMarginAdjustmentHistory
5943
5927
  * @description fetches the history of margin added or reduced from contract isolated positions
5944
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http046_position_margin_history
5945
- * @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
5946
5930
  * @param {string} [type] not used by coinex fetchMarginAdjustmentHistory
5947
5931
  * @param {int} [since] timestamp in ms of the earliest change to fetch
5948
- * @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
5949
5933
  * @param {object} params extra parameters specific to the exchange api endpoint
5950
5934
  * @param {int} [params.until] timestamp in ms of the latest change to fetch
5951
- *
5952
- * EXCHANGE SPECIFIC PARAMETERS
5953
- * @param {int} [params.offset] offset
5935
+ * @param {int} [params.positionId] the id of the position that you want to retrieve margin adjustment history for
5954
5936
  * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5955
5937
  */
5956
5938
  await this.loadMarkets();
5957
- const until = this.safeInteger(params, 'until');
5958
- params = this.omit(params, 'until');
5959
- if (limit === undefined) {
5960
- limit = 100;
5939
+ if (symbol === undefined) {
5940
+ throw new errors.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory() requires a symbol argument');
5961
5941
  }
5962
- const request = {
5963
- 'market': '',
5964
- 'position_id': 0,
5965
- 'offset': 0,
5966
- 'limit': limit,
5967
- };
5968
- if (symbol !== undefined) {
5969
- const market = this.market(symbol);
5970
- 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');
5971
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);
5972
5954
  if (since !== undefined) {
5973
5955
  request['start_time'] = since;
5974
5956
  }
5975
- if (until !== undefined) {
5976
- request['end_time'] = until;
5957
+ if (limit !== undefined) {
5958
+ request['limit'] = limit;
5977
5959
  }
5978
- const response = await this.v1PerpetualPrivateGetPositionMarginHistory(this.extend(request, params));
5960
+ const response = await this.v2PrivateGetFuturesPositionMarginHistory(this.extend(request, params));
5979
5961
  //
5980
- // {
5981
- // code: '0',
5982
- // data: {
5983
- // limit: '100',
5984
- // offset: '0',
5985
- // records: [
5986
- // {
5987
- // bkr_price: '0',
5988
- // leverage: '3',
5989
- // liq_price: '0',
5990
- // margin_amount: '5.33236666666666666666',
5991
- // margin_change: '3',
5992
- // market: 'XRPUSDT',
5993
- // position_amount: '11',
5994
- // position_id: '297155652',
5995
- // position_type: '2',
5996
- // settle_price: '0.6361',
5997
- // time: '1711050906.382891',
5998
- // type: '1',
5999
- // user_id: '3685860'
6000
- // }
6001
- // ]
6002
- // },
6003
- // message: 'OK'
6004
- // }
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
+ // }
6005
5985
  //
6006
- const data = this.safeDict(response, 'data', {});
6007
- const records = this.safeList(data, 'records', []);
6008
- const modifications = this.parseMarginModifications(records, undefined, 'market', 'swap');
5986
+ const data = this.safeList(response, 'data', []);
5987
+ const modifications = this.parseMarginModifications(data, undefined, 'market', 'swap');
6009
5988
  return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
6010
5989
  }
6011
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,