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/js/src/bybit.js
CHANGED
|
@@ -8155,6 +8155,35 @@ export default class bybit extends Exchange {
|
|
|
8155
8155
|
'datetime': this.iso8601(timestamp),
|
|
8156
8156
|
});
|
|
8157
8157
|
}
|
|
8158
|
+
async getLeverageTiersPaginated(symbol = undefined, params = {}) {
|
|
8159
|
+
await this.loadMarkets();
|
|
8160
|
+
let market = undefined;
|
|
8161
|
+
if (symbol !== undefined) {
|
|
8162
|
+
market = this.market(symbol);
|
|
8163
|
+
}
|
|
8164
|
+
let paginate = false;
|
|
8165
|
+
[paginate, params] = this.handleOptionAndParams(params, 'getLeverageTiersPaginated', 'paginate');
|
|
8166
|
+
if (paginate) {
|
|
8167
|
+
return await this.fetchPaginatedCallCursor('getLeverageTiersPaginated', symbol, undefined, undefined, params, 'nextPageCursor', 'cursor', undefined, 100);
|
|
8168
|
+
}
|
|
8169
|
+
let subType = undefined;
|
|
8170
|
+
[subType, params] = this.handleSubTypeAndParams('getLeverageTiersPaginated', market, params, 'linear');
|
|
8171
|
+
const request = {
|
|
8172
|
+
'category': subType,
|
|
8173
|
+
};
|
|
8174
|
+
const response = await this.publicGetV5MarketRiskLimit(this.extend(request, params));
|
|
8175
|
+
const result = this.addPaginationCursorToResult(response);
|
|
8176
|
+
const first = this.safeDict(result, 0);
|
|
8177
|
+
const total = result.length;
|
|
8178
|
+
const lastIndex = total - 1;
|
|
8179
|
+
const last = this.safeDict(result, lastIndex);
|
|
8180
|
+
const cursorValue = this.safeString(first, 'nextPageCursor');
|
|
8181
|
+
last['info'] = {
|
|
8182
|
+
'nextPageCursor': cursorValue,
|
|
8183
|
+
};
|
|
8184
|
+
result[lastIndex] = last;
|
|
8185
|
+
return result;
|
|
8186
|
+
}
|
|
8158
8187
|
async fetchLeverageTiers(symbols = undefined, params = {}) {
|
|
8159
8188
|
/**
|
|
8160
8189
|
* @method
|
|
@@ -8164,24 +8193,20 @@ export default class bybit extends Exchange {
|
|
|
8164
8193
|
* @param {string[]} [symbols] a list of unified market symbols
|
|
8165
8194
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8166
8195
|
* @param {string} [params.subType] market subType, ['linear', 'inverse'], default is 'linear'
|
|
8196
|
+
* @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)
|
|
8167
8197
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
8168
8198
|
*/
|
|
8169
8199
|
await this.loadMarkets();
|
|
8170
8200
|
let market = undefined;
|
|
8201
|
+
let symbol = undefined;
|
|
8171
8202
|
if (symbols !== undefined) {
|
|
8172
8203
|
market = this.market(symbols[0]);
|
|
8173
8204
|
if (market['spot']) {
|
|
8174
8205
|
throw new NotSupported(this.id + ' fetchLeverageTiers() is not supported for spot market');
|
|
8175
8206
|
}
|
|
8207
|
+
symbol = market['symbol'];
|
|
8176
8208
|
}
|
|
8177
|
-
|
|
8178
|
-
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params, 'linear');
|
|
8179
|
-
const request = {
|
|
8180
|
-
'category': subType,
|
|
8181
|
-
};
|
|
8182
|
-
const response = await this.publicGetV5MarketRiskLimit(this.extend(request, params));
|
|
8183
|
-
const result = this.safeDict(response, 'result', {});
|
|
8184
|
-
const data = this.safeList(result, 'list', []);
|
|
8209
|
+
const data = await this.getLeverageTiersPaginated(symbol, this.extend({ 'paginate': true, 'paginationCalls': 20 }, params));
|
|
8185
8210
|
symbols = this.marketSymbols(symbols);
|
|
8186
8211
|
return this.parseLeverageTiers(data, symbols, 'symbol');
|
|
8187
8212
|
}
|
|
@@ -8207,9 +8232,13 @@ export default class bybit extends Exchange {
|
|
|
8207
8232
|
for (let i = 0; i < keys.length; i++) {
|
|
8208
8233
|
const marketId = keys[i];
|
|
8209
8234
|
const entry = grouped[marketId];
|
|
8235
|
+
for (let j = 0; j < entry.length; j++) {
|
|
8236
|
+
const id = this.safeInteger(entry[j], 'id');
|
|
8237
|
+
entry[j]['id'] = id;
|
|
8238
|
+
}
|
|
8210
8239
|
const market = this.safeMarket(marketId, undefined, undefined, 'contract');
|
|
8211
8240
|
const symbol = market['symbol'];
|
|
8212
|
-
tiers[symbol] = this.parseMarketLeverageTiers(entry, market);
|
|
8241
|
+
tiers[symbol] = this.parseMarketLeverageTiers(this.sortBy(entry, 'id'), market);
|
|
8213
8242
|
}
|
|
8214
8243
|
return tiers;
|
|
8215
8244
|
}
|
package/js/src/coinex.d.ts
CHANGED
|
@@ -71,9 +71,9 @@ export default class coinex extends Exchange {
|
|
|
71
71
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
72
72
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
73
73
|
fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<{}>;
|
|
74
|
-
parseMarketLeverageTiers(
|
|
74
|
+
parseMarketLeverageTiers(info: any, market?: Market): any[];
|
|
75
75
|
modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
|
|
76
|
-
parseMarginModification(data:
|
|
76
|
+
parseMarginModification(data: Dict, market?: Market): MarginModification;
|
|
77
77
|
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
78
78
|
reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
79
79
|
fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
|
package/js/src/coinex.js
CHANGED
|
@@ -298,7 +298,7 @@ export default class coinex extends Exchange {
|
|
|
298
298
|
'v2': {
|
|
299
299
|
'public': {
|
|
300
300
|
'get': {
|
|
301
|
-
'maintain
|
|
301
|
+
'maintain/info': 1,
|
|
302
302
|
'ping': 1,
|
|
303
303
|
'time': 1,
|
|
304
304
|
'spot/market': 1,
|
|
@@ -4174,47 +4174,63 @@ export default class coinex extends Exchange {
|
|
|
4174
4174
|
* @method
|
|
4175
4175
|
* @name coinex#fetchLeverageTiers
|
|
4176
4176
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
|
4177
|
-
* @see https://
|
|
4177
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
|
|
4178
4178
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
4179
4179
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4180
4180
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
4181
4181
|
*/
|
|
4182
4182
|
await this.loadMarkets();
|
|
4183
|
-
const
|
|
4183
|
+
const request = {};
|
|
4184
|
+
if (symbols !== undefined) {
|
|
4185
|
+
const marketIds = this.marketIds(symbols);
|
|
4186
|
+
request['market'] = marketIds.join(',');
|
|
4187
|
+
}
|
|
4188
|
+
const response = await this.v2PublicGetFuturesPositionLevel(this.extend(request, params));
|
|
4184
4189
|
//
|
|
4185
4190
|
// {
|
|
4186
4191
|
// "code": 0,
|
|
4187
|
-
// "data":
|
|
4188
|
-
//
|
|
4189
|
-
//
|
|
4190
|
-
//
|
|
4191
|
-
//
|
|
4192
|
-
//
|
|
4193
|
-
//
|
|
4194
|
-
//
|
|
4195
|
-
//
|
|
4196
|
-
//
|
|
4197
|
-
//
|
|
4192
|
+
// "data": [
|
|
4193
|
+
// {
|
|
4194
|
+
// "level": [
|
|
4195
|
+
// {
|
|
4196
|
+
// "amount": "20001",
|
|
4197
|
+
// "leverage": "20",
|
|
4198
|
+
// "maintenance_margin_rate": "0.02",
|
|
4199
|
+
// "min_initial_margin_rate": "0.05"
|
|
4200
|
+
// },
|
|
4201
|
+
// {
|
|
4202
|
+
// "amount": "50001",
|
|
4203
|
+
// "leverage": "10",
|
|
4204
|
+
// "maintenance_margin_rate": "0.04",
|
|
4205
|
+
// "min_initial_margin_rate": "0.1"
|
|
4206
|
+
// },
|
|
4207
|
+
// ],
|
|
4208
|
+
// "market": "MINAUSDT"
|
|
4209
|
+
// },
|
|
4210
|
+
// ],
|
|
4198
4211
|
// "message": "OK"
|
|
4199
4212
|
// }
|
|
4200
4213
|
//
|
|
4201
|
-
const data = this.
|
|
4202
|
-
return this.parseLeverageTiers(data, symbols,
|
|
4214
|
+
const data = this.safeList(response, 'data', []);
|
|
4215
|
+
return this.parseLeverageTiers(data, symbols, 'market');
|
|
4203
4216
|
}
|
|
4204
|
-
parseMarketLeverageTiers(
|
|
4217
|
+
parseMarketLeverageTiers(info, market = undefined) {
|
|
4205
4218
|
const tiers = [];
|
|
4219
|
+
const brackets = this.safeList(info, 'level', []);
|
|
4206
4220
|
let minNotional = 0;
|
|
4207
|
-
for (let
|
|
4208
|
-
const
|
|
4209
|
-
const
|
|
4221
|
+
for (let i = 0; i < brackets.length; i++) {
|
|
4222
|
+
const tier = brackets[i];
|
|
4223
|
+
const marketId = this.safeString(info, 'market');
|
|
4224
|
+
market = this.safeMarket(marketId, market, undefined, 'swap');
|
|
4225
|
+
const maxNotional = this.safeNumber(tier, 'amount');
|
|
4210
4226
|
tiers.push({
|
|
4211
|
-
'tier':
|
|
4227
|
+
'tier': this.sum(i, 1),
|
|
4212
4228
|
'currency': market['linear'] ? market['base'] : market['quote'],
|
|
4213
4229
|
'minNotional': minNotional,
|
|
4214
4230
|
'maxNotional': maxNotional,
|
|
4215
|
-
'maintenanceMarginRate': this.safeNumber(
|
|
4216
|
-
'maxLeverage': this.safeInteger(
|
|
4217
|
-
'info':
|
|
4231
|
+
'maintenanceMarginRate': this.safeNumber(tier, 'maintenance_margin_rate'),
|
|
4232
|
+
'maxLeverage': this.safeInteger(tier, 'leverage'),
|
|
4233
|
+
'info': tier,
|
|
4218
4234
|
});
|
|
4219
4235
|
minNotional = maxNotional;
|
|
4220
4236
|
}
|
|
@@ -4223,72 +4239,60 @@ export default class coinex extends Exchange {
|
|
|
4223
4239
|
async modifyMarginHelper(symbol, amount, addOrReduce, params = {}) {
|
|
4224
4240
|
await this.loadMarkets();
|
|
4225
4241
|
const market = this.market(symbol);
|
|
4242
|
+
const rawAmount = this.amountToPrecision(symbol, amount);
|
|
4243
|
+
let requestAmount = rawAmount;
|
|
4244
|
+
if (addOrReduce === 'reduce') {
|
|
4245
|
+
requestAmount = Precise.stringNeg(rawAmount);
|
|
4246
|
+
}
|
|
4226
4247
|
const request = {
|
|
4227
4248
|
'market': market['id'],
|
|
4228
|
-
'
|
|
4229
|
-
'
|
|
4249
|
+
'market_type': 'FUTURES',
|
|
4250
|
+
'amount': requestAmount,
|
|
4230
4251
|
};
|
|
4231
|
-
const response = await this.
|
|
4252
|
+
const response = await this.v2PrivatePostFuturesAdjustPositionMargin(this.extend(request, params));
|
|
4232
4253
|
//
|
|
4233
4254
|
// {
|
|
4234
4255
|
// "code": 0,
|
|
4235
4256
|
// "data": {
|
|
4236
|
-
// "
|
|
4237
|
-
// "
|
|
4238
|
-
// "
|
|
4239
|
-
// "
|
|
4240
|
-
// "
|
|
4241
|
-
// "
|
|
4242
|
-
// "
|
|
4243
|
-
// "
|
|
4244
|
-
// "create_time": 1651202571.320778,
|
|
4245
|
-
// "deal_all": "19.72000000000000000000",
|
|
4246
|
-
// "deal_asset_fee": "0.00000000000000000000",
|
|
4247
|
-
// "fee_asset": "",
|
|
4248
|
-
// "finish_type": 1,
|
|
4249
|
-
// "first_price": "39441.12",
|
|
4250
|
-
// "insurance": "0.00000000000000000000",
|
|
4251
|
-
// "latest_price": "39441.12",
|
|
4257
|
+
// "adl_level": 1,
|
|
4258
|
+
// "ath_margin_size": "2.034928",
|
|
4259
|
+
// "ath_position_amount": "0.0001",
|
|
4260
|
+
// "avg_entry_price": "61047.84",
|
|
4261
|
+
// "bkr_price": "30698.5600000000000004142",
|
|
4262
|
+
// "close_avbl": "0.0001",
|
|
4263
|
+
// "cml_position_value": "6.104784",
|
|
4264
|
+
// "created_at": 1715488472908,
|
|
4252
4265
|
// "leverage": "3",
|
|
4253
|
-
// "
|
|
4254
|
-
// "
|
|
4255
|
-
// "
|
|
4256
|
-
// "
|
|
4257
|
-
// "
|
|
4258
|
-
// "liq_profit": "0.00000000000000000000",
|
|
4259
|
-
// "liq_time": 0,
|
|
4260
|
-
// "mainten_margin": "0.005",
|
|
4261
|
-
// "mainten_margin_amount": "0.09860280000000000000",
|
|
4262
|
-
// "maker_fee": "0.00000000000000000000",
|
|
4263
|
-
// "margin_amount": "11.57352000000000000000",
|
|
4266
|
+
// "liq_price": "30852.82412060301507579316",
|
|
4267
|
+
// "maintenance_margin_rate": "0.005",
|
|
4268
|
+
// "maintenance_margin_value": "0.03051465",
|
|
4269
|
+
// "margin_avbl": "3.034928",
|
|
4270
|
+
// "margin_mode": "isolated",
|
|
4264
4271
|
// "market": "BTCUSDT",
|
|
4265
|
-
// "
|
|
4266
|
-
// "
|
|
4267
|
-
// "
|
|
4268
|
-
// "
|
|
4269
|
-
// "
|
|
4270
|
-
// "
|
|
4271
|
-
// "
|
|
4272
|
-
// "
|
|
4273
|
-
// "
|
|
4274
|
-
// "
|
|
4275
|
-
// "
|
|
4276
|
-
// "
|
|
4277
|
-
// "
|
|
4278
|
-
// "
|
|
4279
|
-
// "
|
|
4280
|
-
// "taker_fee": "0.00000000000000000000",
|
|
4281
|
-
// "total": 3464,
|
|
4282
|
-
// "type": 1,
|
|
4283
|
-
// "update_time": 1651202638.911212,
|
|
4284
|
-
// "user_id": 3620173
|
|
4272
|
+
// "market_type": "FUTURES",
|
|
4273
|
+
// "max_position_value": "6.104784",
|
|
4274
|
+
// "open_interest": "0.0001",
|
|
4275
|
+
// "position_id": 306458800,
|
|
4276
|
+
// "position_margin_rate": "0.49713929272518077625",
|
|
4277
|
+
// "realized_pnl": "-0.003052392",
|
|
4278
|
+
// "settle_price": "61047.84",
|
|
4279
|
+
// "settle_value": "6.104784",
|
|
4280
|
+
// "side": "long",
|
|
4281
|
+
// "stop_loss_price": "0",
|
|
4282
|
+
// "stop_loss_type": "",
|
|
4283
|
+
// "take_profit_price": "0",
|
|
4284
|
+
// "take_profit_type": "",
|
|
4285
|
+
// "unrealized_pnl": "0",
|
|
4286
|
+
// "updated_at": 1715488805563
|
|
4285
4287
|
// },
|
|
4286
|
-
// "message":"OK"
|
|
4288
|
+
// "message": "OK"
|
|
4287
4289
|
// }
|
|
4288
4290
|
//
|
|
4289
4291
|
const data = this.safeDict(response, 'data');
|
|
4290
|
-
const status = this.
|
|
4292
|
+
const status = this.safeStringLower(response, 'message');
|
|
4293
|
+
const type = (addOrReduce === 'reduce') ? 'reduce' : 'add';
|
|
4291
4294
|
return this.extend(this.parseMarginModification(data, market), {
|
|
4295
|
+
'type': type,
|
|
4292
4296
|
'amount': this.parseNumber(amount),
|
|
4293
4297
|
'status': status,
|
|
4294
4298
|
});
|
|
@@ -4297,86 +4301,66 @@ export default class coinex extends Exchange {
|
|
|
4297
4301
|
//
|
|
4298
4302
|
// addMargin/reduceMargin
|
|
4299
4303
|
//
|
|
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
|
-
//
|
|
4330
|
-
//
|
|
4331
|
-
//
|
|
4332
|
-
// "open_price": "39441.12000000000000000000",
|
|
4333
|
-
// "open_val": "19.72056000000000000000",
|
|
4334
|
-
// "open_val_max": "19.72056000000000000000",
|
|
4335
|
-
// "position_id": 65171206,
|
|
4336
|
-
// "profit_clearing": "-0.00986028000000000000",
|
|
4337
|
-
// "profit_real": "-0.00986028000000000000",
|
|
4338
|
-
// "profit_unreal": "0.00",
|
|
4339
|
-
// "side": 2,
|
|
4340
|
-
// "stop_loss_price": "0.00000000000000000000",
|
|
4341
|
-
// "stop_loss_type": 0,
|
|
4342
|
-
// "sy s": 0,
|
|
4343
|
-
// "take_profit_price": "0.00000000000000000000",
|
|
4344
|
-
// "take_profit_type": 0,
|
|
4345
|
-
// "taker_fee": "0.00000000000000000000",
|
|
4346
|
-
// "total": 3464,
|
|
4347
|
-
// "type": 1,
|
|
4348
|
-
// "update_time": 1651202638.911212,
|
|
4349
|
-
// "user_id": 3620173
|
|
4350
|
-
// }
|
|
4304
|
+
// {
|
|
4305
|
+
// "adl_level": 1,
|
|
4306
|
+
// "ath_margin_size": "2.034928",
|
|
4307
|
+
// "ath_position_amount": "0.0001",
|
|
4308
|
+
// "avg_entry_price": "61047.84",
|
|
4309
|
+
// "bkr_price": "30698.5600000000000004142",
|
|
4310
|
+
// "close_avbl": "0.0001",
|
|
4311
|
+
// "cml_position_value": "6.104784",
|
|
4312
|
+
// "created_at": 1715488472908,
|
|
4313
|
+
// "leverage": "3",
|
|
4314
|
+
// "liq_price": "30852.82412060301507579316",
|
|
4315
|
+
// "maintenance_margin_rate": "0.005",
|
|
4316
|
+
// "maintenance_margin_value": "0.03051465",
|
|
4317
|
+
// "margin_avbl": "3.034928",
|
|
4318
|
+
// "margin_mode": "isolated",
|
|
4319
|
+
// "market": "BTCUSDT",
|
|
4320
|
+
// "market_type": "FUTURES",
|
|
4321
|
+
// "max_position_value": "6.104784",
|
|
4322
|
+
// "open_interest": "0.0001",
|
|
4323
|
+
// "position_id": 306458800,
|
|
4324
|
+
// "position_margin_rate": "0.49713929272518077625",
|
|
4325
|
+
// "realized_pnl": "-0.003052392",
|
|
4326
|
+
// "settle_price": "61047.84",
|
|
4327
|
+
// "settle_value": "6.104784",
|
|
4328
|
+
// "side": "long",
|
|
4329
|
+
// "stop_loss_price": "0",
|
|
4330
|
+
// "stop_loss_type": "",
|
|
4331
|
+
// "take_profit_price": "0",
|
|
4332
|
+
// "take_profit_type": "",
|
|
4333
|
+
// "unrealized_pnl": "0",
|
|
4334
|
+
// "updated_at": 1715488805563
|
|
4335
|
+
// }
|
|
4351
4336
|
//
|
|
4352
4337
|
// fetchMarginAdjustmentHistory
|
|
4353
4338
|
//
|
|
4354
|
-
//
|
|
4355
|
-
//
|
|
4356
|
-
//
|
|
4357
|
-
//
|
|
4358
|
-
//
|
|
4359
|
-
//
|
|
4360
|
-
//
|
|
4361
|
-
//
|
|
4362
|
-
//
|
|
4363
|
-
//
|
|
4364
|
-
//
|
|
4365
|
-
//
|
|
4366
|
-
//
|
|
4367
|
-
//
|
|
4368
|
-
// }
|
|
4339
|
+
// {
|
|
4340
|
+
// "bkr_pirce": "24698.56000000000000005224",
|
|
4341
|
+
// "created_at": 1715489978697,
|
|
4342
|
+
// "leverage": "3",
|
|
4343
|
+
// "liq_price": "24822.67336683417085432386",
|
|
4344
|
+
// "margin_avbl": "3.634928",
|
|
4345
|
+
// "margin_change": "-1.5",
|
|
4346
|
+
// "margin_mode": "isolated",
|
|
4347
|
+
// "market": "BTCUSDT",
|
|
4348
|
+
// "market_type": "FUTURES",
|
|
4349
|
+
// "open_interest": "0.0001",
|
|
4350
|
+
// "position_id": 306458800,
|
|
4351
|
+
// "settle_price": "61047.84"
|
|
4352
|
+
// }
|
|
4369
4353
|
//
|
|
4370
4354
|
const marketId = this.safeString(data, 'market');
|
|
4371
|
-
const
|
|
4372
|
-
const
|
|
4355
|
+
const timestamp = this.safeInteger2(data, 'updated_at', 'created_at');
|
|
4356
|
+
const change = this.safeString(data, 'margin_change');
|
|
4373
4357
|
return {
|
|
4374
4358
|
'info': data,
|
|
4375
4359
|
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
4376
|
-
'type':
|
|
4360
|
+
'type': undefined,
|
|
4377
4361
|
'marginMode': 'isolated',
|
|
4378
|
-
'amount': this.
|
|
4379
|
-
'total': this.safeNumber(data, '
|
|
4362
|
+
'amount': this.parseNumber(Precise.stringAbs(change)),
|
|
4363
|
+
'total': this.safeNumber(data, 'margin_avbl'),
|
|
4380
4364
|
'code': market['quote'],
|
|
4381
4365
|
'status': undefined,
|
|
4382
4366
|
'timestamp': timestamp,
|
|
@@ -4388,26 +4372,26 @@ export default class coinex extends Exchange {
|
|
|
4388
4372
|
* @method
|
|
4389
4373
|
* @name coinex#addMargin
|
|
4390
4374
|
* @description add margin
|
|
4391
|
-
* @see https://
|
|
4375
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
|
|
4392
4376
|
* @param {string} symbol unified market symbol
|
|
4393
4377
|
* @param {float} amount amount of margin to add
|
|
4394
4378
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4395
4379
|
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
4396
4380
|
*/
|
|
4397
|
-
return await this.modifyMarginHelper(symbol, amount,
|
|
4381
|
+
return await this.modifyMarginHelper(symbol, amount, 'add', params);
|
|
4398
4382
|
}
|
|
4399
4383
|
async reduceMargin(symbol, amount, params = {}) {
|
|
4400
4384
|
/**
|
|
4401
4385
|
* @method
|
|
4402
4386
|
* @name coinex#reduceMargin
|
|
4403
4387
|
* @description remove margin from a position
|
|
4404
|
-
* @see https://
|
|
4388
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
|
|
4405
4389
|
* @param {string} symbol unified market symbol
|
|
4406
4390
|
* @param {float} amount the amount of margin to remove
|
|
4407
4391
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4408
4392
|
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
|
|
4409
4393
|
*/
|
|
4410
|
-
return await this.modifyMarginHelper(symbol, amount,
|
|
4394
|
+
return await this.modifyMarginHelper(symbol, amount, 'reduce', params);
|
|
4411
4395
|
}
|
|
4412
4396
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4413
4397
|
/**
|
|
@@ -5944,71 +5928,66 @@ export default class coinex extends Exchange {
|
|
|
5944
5928
|
* @method
|
|
5945
5929
|
* @name coinex#fetchMarginAdjustmentHistory
|
|
5946
5930
|
* @description fetches the history of margin added or reduced from contract isolated positions
|
|
5947
|
-
* @see https://
|
|
5948
|
-
* @param {string}
|
|
5931
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
|
|
5932
|
+
* @param {string} symbol unified market symbol
|
|
5949
5933
|
* @param {string} [type] not used by coinex fetchMarginAdjustmentHistory
|
|
5950
5934
|
* @param {int} [since] timestamp in ms of the earliest change to fetch
|
|
5951
|
-
* @param {int} [limit] the maximum amount of changes to fetch, default
|
|
5935
|
+
* @param {int} [limit] the maximum amount of changes to fetch, default is 10
|
|
5952
5936
|
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
5953
5937
|
* @param {int} [params.until] timestamp in ms of the latest change to fetch
|
|
5954
|
-
*
|
|
5955
|
-
* EXCHANGE SPECIFIC PARAMETERS
|
|
5956
|
-
* @param {int} [params.offset] offset
|
|
5938
|
+
* @param {int} [params.positionId] the id of the position that you want to retrieve margin adjustment history for
|
|
5957
5939
|
* @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
5958
5940
|
*/
|
|
5959
5941
|
await this.loadMarkets();
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
if (limit === undefined) {
|
|
5963
|
-
limit = 100;
|
|
5942
|
+
if (symbol === undefined) {
|
|
5943
|
+
throw new ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory() requires a symbol argument');
|
|
5964
5944
|
}
|
|
5965
|
-
const
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
'
|
|
5969
|
-
'limit': limit,
|
|
5970
|
-
};
|
|
5971
|
-
if (symbol !== undefined) {
|
|
5972
|
-
const market = this.market(symbol);
|
|
5973
|
-
request['market'] = market['id'];
|
|
5945
|
+
const positionId = this.safeInteger2(params, 'positionId', 'position_id');
|
|
5946
|
+
params = this.omit(params, 'positionId');
|
|
5947
|
+
if (positionId === undefined) {
|
|
5948
|
+
throw new ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter');
|
|
5974
5949
|
}
|
|
5950
|
+
const market = this.market(symbol);
|
|
5951
|
+
let request = {
|
|
5952
|
+
'market': market['id'],
|
|
5953
|
+
'market_type': 'FUTURES',
|
|
5954
|
+
'position_id': positionId,
|
|
5955
|
+
};
|
|
5956
|
+
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
5975
5957
|
if (since !== undefined) {
|
|
5976
5958
|
request['start_time'] = since;
|
|
5977
5959
|
}
|
|
5978
|
-
if (
|
|
5979
|
-
request['
|
|
5960
|
+
if (limit !== undefined) {
|
|
5961
|
+
request['limit'] = limit;
|
|
5980
5962
|
}
|
|
5981
|
-
const response = await this.
|
|
5963
|
+
const response = await this.v2PrivateGetFuturesPositionMarginHistory(this.extend(request, params));
|
|
5982
5964
|
//
|
|
5983
|
-
//
|
|
5984
|
-
//
|
|
5985
|
-
//
|
|
5986
|
-
//
|
|
5987
|
-
//
|
|
5988
|
-
//
|
|
5989
|
-
//
|
|
5990
|
-
//
|
|
5991
|
-
//
|
|
5992
|
-
//
|
|
5993
|
-
//
|
|
5994
|
-
//
|
|
5995
|
-
//
|
|
5996
|
-
//
|
|
5997
|
-
//
|
|
5998
|
-
//
|
|
5999
|
-
//
|
|
6000
|
-
//
|
|
6001
|
-
//
|
|
6002
|
-
//
|
|
6003
|
-
//
|
|
6004
|
-
//
|
|
6005
|
-
//
|
|
6006
|
-
// message: 'OK'
|
|
6007
|
-
// }
|
|
5965
|
+
// {
|
|
5966
|
+
// "code": 0,
|
|
5967
|
+
// "data": [
|
|
5968
|
+
// {
|
|
5969
|
+
// "bkr_pirce": "24698.56000000000000005224",
|
|
5970
|
+
// "created_at": 1715489978697,
|
|
5971
|
+
// "leverage": "3",
|
|
5972
|
+
// "liq_price": "24822.67336683417085432386",
|
|
5973
|
+
// "margin_avbl": "3.634928",
|
|
5974
|
+
// "margin_change": "-1.5",
|
|
5975
|
+
// "margin_mode": "isolated",
|
|
5976
|
+
// "market": "BTCUSDT",
|
|
5977
|
+
// "market_type": "FUTURES",
|
|
5978
|
+
// "open_interest": "0.0001",
|
|
5979
|
+
// "position_id": 306458800,
|
|
5980
|
+
// "settle_price": "61047.84"
|
|
5981
|
+
// },
|
|
5982
|
+
// ],
|
|
5983
|
+
// "message": "OK",
|
|
5984
|
+
// "pagination": {
|
|
5985
|
+
// "has_next": true
|
|
5986
|
+
// }
|
|
5987
|
+
// }
|
|
6008
5988
|
//
|
|
6009
|
-
const data = this.
|
|
6010
|
-
const
|
|
6011
|
-
const modifications = this.parseMarginModifications(records, undefined, 'market', 'swap');
|
|
5989
|
+
const data = this.safeList(response, 'data', []);
|
|
5990
|
+
const modifications = this.parseMarginModifications(data, undefined, 'market', 'swap');
|
|
6012
5991
|
return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
|
|
6013
5992
|
}
|
|
6014
5993
|
}
|
package/js/src/delta.d.ts
CHANGED
|
@@ -118,7 +118,7 @@ export default class delta extends Exchange {
|
|
|
118
118
|
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
119
119
|
reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
120
120
|
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
121
|
-
parseMarginModification(data:
|
|
121
|
+
parseMarginModification(data: Dict, market?: Market): MarginModification;
|
|
122
122
|
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
123
123
|
parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
|
|
124
124
|
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
package/js/src/digifinex.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ export default class digifinex extends Exchange {
|
|
|
136
136
|
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
137
137
|
reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
138
138
|
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
139
|
-
parseMarginModification(data:
|
|
139
|
+
parseMarginModification(data: Dict, market?: Market): MarginModification;
|
|
140
140
|
fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").FundingHistory[]>;
|
|
141
141
|
parseIncome(income: any, market?: Market): {
|
|
142
142
|
info: any;
|
package/js/src/exmo.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { Dict, Int, Order, OrderSide, OrderType, Trade, OrderBook, OHLCV, B
|
|
|
7
7
|
export default class exmo extends Exchange {
|
|
8
8
|
describe(): any;
|
|
9
9
|
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
10
|
-
parseMarginModification(data:
|
|
10
|
+
parseMarginModification(data: Dict, market?: Market): MarginModification;
|
|
11
11
|
reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
12
12
|
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
13
13
|
fetchTradingFees(params?: {}): Promise<TradingFees>;
|