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.
- package/README.md +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +3 -0
- package/dist/cjs/src/base/functions/platform.js +3 -1
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/binance.js +10 -1
- package/dist/cjs/src/bitget.js +3 -0
- package/dist/cjs/src/bitmex.js +1 -0
- package/dist/cjs/src/bybit.js +38 -9
- package/dist/cjs/src/coinex.js +180 -201
- package/dist/cjs/src/hyperliquid.js +24 -2
- package/dist/cjs/src/okx.js +3 -0
- package/dist/cjs/src/phemex.js +17 -6
- package/dist/cjs/src/pro/htx.js +12 -7
- package/dist/cjs/src/pro/kucoinfutures.js +92 -0
- package/dist/cjs/src/pro/woo.js +52 -24
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/bitget.d.ts +3 -0
- package/js/src/abstract/okx.d.ts +3 -0
- package/js/src/ascendex.d.ts +1 -1
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/base/Exchange.js +3 -0
- package/js/src/base/functions/platform.d.ts +2 -1
- package/js/src/base/functions/platform.js +3 -2
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +10 -1
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bitget.d.ts +1 -1
- package/js/src/bitget.js +3 -0
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.d.ts +1 -0
- package/js/src/bybit.js +38 -9
- package/js/src/coinex.d.ts +2 -2
- package/js/src/coinex.js +180 -201
- package/js/src/delta.d.ts +1 -1
- package/js/src/digifinex.d.ts +1 -1
- package/js/src/exmo.d.ts +1 -1
- package/js/src/gate.d.ts +1 -1
- package/js/src/hitbtc.d.ts +1 -1
- package/js/src/hyperliquid.d.ts +1 -1
- package/js/src/hyperliquid.js +24 -2
- package/js/src/okx.d.ts +1 -1
- package/js/src/okx.js +3 -0
- package/js/src/phemex.d.ts +1 -1
- package/js/src/phemex.js +17 -6
- package/js/src/pro/htx.js +12 -7
- package/js/src/pro/kucoinfutures.d.ts +3 -1
- package/js/src/pro/kucoinfutures.js +93 -1
- package/js/src/pro/woo.d.ts +2 -1
- package/js/src/pro/woo.js +52 -24
- package/package.json +1 -1
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -295,7 +295,7 @@ class coinex extends coinex$1 {
|
|
|
295
295
|
'v2': {
|
|
296
296
|
'public': {
|
|
297
297
|
'get': {
|
|
298
|
-
'maintain
|
|
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://
|
|
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
|
|
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
|
-
//
|
|
4186
|
-
//
|
|
4187
|
-
//
|
|
4188
|
-
//
|
|
4189
|
-
//
|
|
4190
|
-
//
|
|
4191
|
-
//
|
|
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.
|
|
4199
|
-
return this.parseLeverageTiers(data, symbols,
|
|
4211
|
+
const data = this.safeList(response, 'data', []);
|
|
4212
|
+
return this.parseLeverageTiers(data, symbols, 'market');
|
|
4200
4213
|
}
|
|
4201
|
-
parseMarketLeverageTiers(
|
|
4214
|
+
parseMarketLeverageTiers(info, market = undefined) {
|
|
4202
4215
|
const tiers = [];
|
|
4216
|
+
const brackets = this.safeList(info, 'level', []);
|
|
4203
4217
|
let minNotional = 0;
|
|
4204
|
-
for (let
|
|
4205
|
-
const
|
|
4206
|
-
const
|
|
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':
|
|
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(
|
|
4213
|
-
'maxLeverage': this.safeInteger(
|
|
4214
|
-
'info':
|
|
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
|
-
'
|
|
4226
|
-
'
|
|
4246
|
+
'market_type': 'FUTURES',
|
|
4247
|
+
'amount': requestAmount,
|
|
4227
4248
|
};
|
|
4228
|
-
const response = await this.
|
|
4249
|
+
const response = await this.v2PrivatePostFuturesAdjustPositionMargin(this.extend(request, params));
|
|
4229
4250
|
//
|
|
4230
4251
|
// {
|
|
4231
4252
|
// "code": 0,
|
|
4232
4253
|
// "data": {
|
|
4233
|
-
// "
|
|
4234
|
-
// "
|
|
4235
|
-
// "
|
|
4236
|
-
// "
|
|
4237
|
-
// "
|
|
4238
|
-
// "
|
|
4239
|
-
// "
|
|
4240
|
-
// "
|
|
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
|
-
// "
|
|
4251
|
-
// "
|
|
4252
|
-
// "
|
|
4253
|
-
// "
|
|
4254
|
-
// "
|
|
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
|
-
// "
|
|
4263
|
-
// "
|
|
4264
|
-
// "
|
|
4265
|
-
// "
|
|
4266
|
-
// "
|
|
4267
|
-
// "
|
|
4268
|
-
// "
|
|
4269
|
-
// "
|
|
4270
|
-
// "
|
|
4271
|
-
// "
|
|
4272
|
-
// "
|
|
4273
|
-
// "
|
|
4274
|
-
// "
|
|
4275
|
-
// "
|
|
4276
|
-
// "
|
|
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.
|
|
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
|
-
//
|
|
4299
|
-
//
|
|
4300
|
-
//
|
|
4301
|
-
//
|
|
4302
|
-
//
|
|
4303
|
-
//
|
|
4304
|
-
//
|
|
4305
|
-
//
|
|
4306
|
-
//
|
|
4307
|
-
//
|
|
4308
|
-
//
|
|
4309
|
-
//
|
|
4310
|
-
//
|
|
4311
|
-
//
|
|
4312
|
-
//
|
|
4313
|
-
//
|
|
4314
|
-
//
|
|
4315
|
-
//
|
|
4316
|
-
//
|
|
4317
|
-
//
|
|
4318
|
-
//
|
|
4319
|
-
//
|
|
4320
|
-
//
|
|
4321
|
-
//
|
|
4322
|
-
//
|
|
4323
|
-
//
|
|
4324
|
-
//
|
|
4325
|
-
//
|
|
4326
|
-
//
|
|
4327
|
-
//
|
|
4328
|
-
//
|
|
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
|
-
//
|
|
4353
|
-
//
|
|
4354
|
-
//
|
|
4355
|
-
//
|
|
4356
|
-
//
|
|
4357
|
-
//
|
|
4358
|
-
//
|
|
4359
|
-
//
|
|
4360
|
-
//
|
|
4361
|
-
//
|
|
4362
|
-
//
|
|
4363
|
-
//
|
|
4364
|
-
//
|
|
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
|
|
4369
|
-
const
|
|
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':
|
|
4357
|
+
'type': undefined,
|
|
4374
4358
|
'marginMode': 'isolated',
|
|
4375
|
-
'amount': this.
|
|
4376
|
-
'total': this.safeNumber(data, '
|
|
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://
|
|
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,
|
|
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://
|
|
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,
|
|
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://
|
|
5945
|
-
* @param {string}
|
|
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
|
|
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
|
-
|
|
5958
|
-
|
|
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
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
'
|
|
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 (
|
|
5976
|
-
request['
|
|
5957
|
+
if (limit !== undefined) {
|
|
5958
|
+
request['limit'] = limit;
|
|
5977
5959
|
}
|
|
5978
|
-
const response = await this.
|
|
5960
|
+
const response = await this.v2PrivateGetFuturesPositionMarginHistory(this.extend(request, params));
|
|
5979
5961
|
//
|
|
5980
|
-
//
|
|
5981
|
-
//
|
|
5982
|
-
//
|
|
5983
|
-
//
|
|
5984
|
-
//
|
|
5985
|
-
//
|
|
5986
|
-
//
|
|
5987
|
-
//
|
|
5988
|
-
//
|
|
5989
|
-
//
|
|
5990
|
-
//
|
|
5991
|
-
//
|
|
5992
|
-
//
|
|
5993
|
-
//
|
|
5994
|
-
//
|
|
5995
|
-
//
|
|
5996
|
-
//
|
|
5997
|
-
//
|
|
5998
|
-
//
|
|
5999
|
-
//
|
|
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.
|
|
6007
|
-
const
|
|
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':
|
|
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'),
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -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,
|