ccxt 4.4.28 → 4.4.30

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 (62) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +59 -7
  5. package/dist/cjs/src/base/Exchange.js +3 -0
  6. package/dist/cjs/src/binance.js +9 -0
  7. package/dist/cjs/src/bitbns.js +12 -12
  8. package/dist/cjs/src/bitfinex.js +9 -9
  9. package/dist/cjs/src/bitget.js +99 -6
  10. package/dist/cjs/src/bitmart.js +53 -53
  11. package/dist/cjs/src/bitopro.js +21 -21
  12. package/dist/cjs/src/bitrue.js +28 -28
  13. package/dist/cjs/src/bitvavo.js +4 -0
  14. package/dist/cjs/src/bybit.js +51 -646
  15. package/dist/cjs/src/coincatch.js +24 -4
  16. package/dist/cjs/src/deribit.js +7 -3
  17. package/dist/cjs/src/hyperliquid.js +108 -4
  18. package/dist/cjs/src/lbank.js +7 -1
  19. package/dist/cjs/src/pro/bitvavo.js +2 -1
  20. package/dist/cjs/src/pro/blofin.js +2 -1
  21. package/dist/cjs/src/pro/mexc.js +198 -30
  22. package/dist/cjs/src/vertex.js +51 -6
  23. package/examples/README.md +0 -2
  24. package/examples/js/cli.js +7 -0
  25. package/js/ccxt.d.ts +1 -1
  26. package/js/ccxt.js +1 -1
  27. package/js/src/abstract/alpaca.d.ts +1 -0
  28. package/js/src/abstract/binance.d.ts +9 -0
  29. package/js/src/abstract/binancecoinm.d.ts +9 -0
  30. package/js/src/abstract/binanceus.d.ts +9 -0
  31. package/js/src/abstract/binanceusdm.d.ts +9 -0
  32. package/js/src/abstract/bybit.d.ts +0 -13
  33. package/js/src/alpaca.d.ts +2 -0
  34. package/js/src/alpaca.js +59 -7
  35. package/js/src/base/Exchange.d.ts +1 -0
  36. package/js/src/base/Exchange.js +3 -0
  37. package/js/src/binance.js +9 -0
  38. package/js/src/bitbns.js +12 -12
  39. package/js/src/bitfinex.js +9 -9
  40. package/js/src/bitfinex2.d.ts +1 -1
  41. package/js/src/bitget.d.ts +2 -1
  42. package/js/src/bitget.js +99 -6
  43. package/js/src/bitmart.d.ts +1 -1
  44. package/js/src/bitmart.js +53 -53
  45. package/js/src/bitopro.js +21 -21
  46. package/js/src/bitrue.js +28 -28
  47. package/js/src/bitvavo.js +4 -0
  48. package/js/src/bybit.d.ts +0 -8
  49. package/js/src/bybit.js +51 -646
  50. package/js/src/coincatch.d.ts +1 -1
  51. package/js/src/coincatch.js +24 -4
  52. package/js/src/deribit.js +7 -3
  53. package/js/src/hyperliquid.d.ts +3 -1
  54. package/js/src/hyperliquid.js +108 -4
  55. package/js/src/lbank.js +7 -1
  56. package/js/src/pro/bitvavo.js +2 -1
  57. package/js/src/pro/blofin.js +2 -1
  58. package/js/src/pro/mexc.js +198 -30
  59. package/js/src/vertex.d.ts +4 -2
  60. package/js/src/vertex.js +51 -6
  61. package/js/src/whitebit.d.ts +1 -1
  62. package/package.json +1 -1
@@ -393,21 +393,6 @@ class bybit extends bybit$1 {
393
393
  'v5/broker/asset/query-sub-member-deposit-record': 10,
394
394
  },
395
395
  'post': {
396
- // Legacy option USDC
397
- 'option/usdc/openapi/private/v1/place-order': 2.5,
398
- 'option/usdc/openapi/private/v1/replace-order': 2.5,
399
- 'option/usdc/openapi/private/v1/cancel-order': 2.5,
400
- 'option/usdc/openapi/private/v1/cancel-all': 2.5,
401
- 'option/usdc/openapi/private/v1/query-active-orders': 2.5,
402
- 'option/usdc/openapi/private/v1/query-order-history': 2.5,
403
- 'option/usdc/openapi/private/v1/execution-list': 2.5,
404
- 'option/usdc/openapi/private/v1/query-position': 2.5,
405
- // Legacy perpetual swap USDC
406
- 'perpetual/usdc/openapi/private/v1/place-order': 2.5,
407
- 'perpetual/usdc/openapi/private/v1/replace-order': 2.5,
408
- 'perpetual/usdc/openapi/private/v1/cancel-order': 2.5,
409
- 'perpetual/usdc/openapi/private/v1/cancel-all': 2.5,
410
- 'perpetual/usdc/openapi/private/v1/position/leverage/save': 2.5,
411
396
  // spot
412
397
  'spot/v3/private/order': 2.5,
413
398
  'spot/v3/private/cancel-order': 2.5,
@@ -2492,6 +2477,13 @@ class bybit extends bybit$1 {
2492
2477
  const fundingTimestamp = this.safeInteger(ticker, 'nextFundingTime');
2493
2478
  const markPrice = this.safeNumber(ticker, 'markPrice');
2494
2479
  const indexPrice = this.safeNumber(ticker, 'indexPrice');
2480
+ const info = this.safeDict(this.safeMarket(marketId, market, undefined, 'swap'), 'info');
2481
+ const fundingInterval = this.safeInteger(info, 'fundingInterval');
2482
+ let intervalString = undefined;
2483
+ if (fundingInterval !== undefined) {
2484
+ const interval = this.parseToInt(fundingInterval / 60);
2485
+ intervalString = interval.toString() + 'h';
2486
+ }
2495
2487
  return {
2496
2488
  'info': ticker,
2497
2489
  'symbol': symbol,
@@ -2510,7 +2502,7 @@ class bybit extends bybit$1 {
2510
2502
  'previousFundingRate': undefined,
2511
2503
  'previousFundingTimestamp': undefined,
2512
2504
  'previousFundingDatetime': undefined,
2513
- 'interval': undefined,
2505
+ 'interval': intervalString,
2514
2506
  };
2515
2507
  }
2516
2508
  async fetchFundingRates(symbols = undefined, params = {}) {
@@ -3672,12 +3664,8 @@ class bybit extends bybit$1 {
3672
3664
  */
3673
3665
  await this.loadMarkets();
3674
3666
  const market = this.market(symbol);
3675
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
3676
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
3677
- const isUsdcSettled = market['settle'] === 'USDC';
3678
- if (isUsdcSettled && !isUnifiedAccount) {
3679
- return await this.createUsdcOrder(symbol, type, side, amount, price, params);
3680
- }
3667
+ const parts = await this.isUnifiedEnabled();
3668
+ const enableUnifiedAccount = parts[1];
3681
3669
  const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
3682
3670
  const isTrailingAmountOrder = trailingAmount !== undefined;
3683
3671
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
@@ -4038,190 +4026,6 @@ class bybit extends bybit$1 {
4038
4026
  //
4039
4027
  return this.parseOrders(data);
4040
4028
  }
4041
- async createUsdcOrder(symbol, type, side, amount, price = undefined, params = {}) {
4042
- await this.loadMarkets();
4043
- const market = this.market(symbol);
4044
- if (type === 'market') {
4045
- throw new errors.NotSupported(this.id + ' createOrder does not allow market orders for ' + symbol + ' markets');
4046
- }
4047
- const lowerCaseType = type.toLowerCase();
4048
- if ((price === undefined) && (lowerCaseType === 'limit')) {
4049
- throw new errors.ArgumentsRequired(this.id + ' createOrder requires a price argument for limit orders');
4050
- }
4051
- const request = {
4052
- 'symbol': market['id'],
4053
- 'side': this.capitalize(side),
4054
- 'orderType': this.capitalize(lowerCaseType),
4055
- 'timeInForce': 'GoodTillCancel',
4056
- 'orderQty': this.getAmount(symbol, amount),
4057
- // 'takeProfit': 123.45, // take profit price, only take effect upon opening the position
4058
- // 'stopLoss': 123.45, // stop loss price, only take effect upon opening the position
4059
- // 'reduceOnly': false, // reduce only, required for linear orders
4060
- // when creating a closing order, bybit recommends a True value for
4061
- // closeOnTrigger to avoid failing due to insufficient available margin
4062
- // 'closeOnTrigger': false, required for linear orders
4063
- // 'orderLinkId': 'string', // unique client order id, max 36 characters
4064
- // 'triggerPrice': 123.45, // trigger price, required for conditional orders
4065
- // 'trigger_by': 'MarkPrice', // IndexPrice, MarkPrice
4066
- // 'tptriggerby': 'MarkPrice', // IndexPrice, MarkPrice
4067
- // 'slTriggerBy': 'MarkPrice', // IndexPrice, MarkPrice
4068
- // 'orderFilter': 'Order' or 'StopOrder'
4069
- // 'mmp': false // market maker protection
4070
- };
4071
- const isMarket = lowerCaseType === 'market';
4072
- const isLimit = lowerCaseType === 'limit';
4073
- if (isLimit !== undefined) {
4074
- request['orderPrice'] = this.getPrice(symbol, this.numberToString(price));
4075
- }
4076
- const exchangeSpecificParam = this.safeString(params, 'time_in_force');
4077
- const timeInForce = this.safeStringLower(params, 'timeInForce');
4078
- const postOnly = this.isPostOnly(isMarket, exchangeSpecificParam === 'PostOnly', params);
4079
- if (postOnly) {
4080
- request['time_in_force'] = 'PostOnly';
4081
- }
4082
- else if (timeInForce === 'gtc') {
4083
- request['time_in_force'] = 'GoodTillCancel';
4084
- }
4085
- else if (timeInForce === 'fok') {
4086
- request['time_in_force'] = 'FillOrKill';
4087
- }
4088
- else if (timeInForce === 'ioc') {
4089
- request['time_in_force'] = 'ImmediateOrCancel';
4090
- }
4091
- if (market['swap']) {
4092
- const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
4093
- const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice', triggerPrice);
4094
- const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4095
- const stopLoss = this.safeValue(params, 'stopLoss');
4096
- const takeProfit = this.safeValue(params, 'takeProfit');
4097
- const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4098
- const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4099
- const isStopLoss = stopLoss !== undefined;
4100
- const isTakeProfit = takeProfit !== undefined;
4101
- const isStopOrder = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
4102
- if (isStopOrder) {
4103
- request['orderFilter'] = 'StopOrder';
4104
- request['trigger_by'] = 'LastPrice';
4105
- const stopPx = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
4106
- const preciseStopPrice = this.getPrice(symbol, stopPx);
4107
- request['triggerPrice'] = preciseStopPrice;
4108
- const delta = this.numberToString(market['precision']['price']);
4109
- request['basePrice'] = isStopLossTriggerOrder ? Precise["default"].stringSub(preciseStopPrice, delta) : Precise["default"].stringAdd(preciseStopPrice, delta);
4110
- }
4111
- else if (isStopLoss || isTakeProfit) {
4112
- if (isStopLoss) {
4113
- const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4114
- request['stopLoss'] = this.getPrice(symbol, slTriggerPrice);
4115
- }
4116
- if (isTakeProfit) {
4117
- const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4118
- request['takeProfit'] = this.getPrice(symbol, tpTriggerPrice);
4119
- }
4120
- }
4121
- else {
4122
- request['orderFilter'] = 'Order';
4123
- }
4124
- }
4125
- const clientOrderId = this.safeString(params, 'clientOrderId');
4126
- if (clientOrderId !== undefined) {
4127
- request['orderLinkId'] = clientOrderId;
4128
- }
4129
- else if (market['option']) {
4130
- // mandatory field for options
4131
- request['orderLinkId'] = this.uuid16();
4132
- }
4133
- params = this.omit(params, ['stopPrice', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId']);
4134
- let response = undefined;
4135
- if (market['option']) {
4136
- response = await this.privatePostOptionUsdcOpenapiPrivateV1PlaceOrder(this.extend(request, params));
4137
- }
4138
- else {
4139
- response = await this.privatePostPerpetualUsdcOpenapiPrivateV1PlaceOrder(this.extend(request, params));
4140
- }
4141
- //
4142
- // {
4143
- // "retCode":0,
4144
- // "retMsg":"",
4145
- // "result":{
4146
- // "orderId":"34450a59-325e-4296-8af0-63c7c524ae33",
4147
- // "orderLinkId":"",
4148
- // "mmp":false,
4149
- // "symbol":"BTCPERP",
4150
- // "orderType":"Limit",
4151
- // "side":"Buy",
4152
- // "orderQty":"0.00100000",
4153
- // "orderPrice":"20000.00",
4154
- // "iv":"0",
4155
- // "timeInForce":"GoodTillCancel",
4156
- // "orderStatus":"Created",
4157
- // "createdAt":"1652261746007873",
4158
- // "basePrice":"0.00",
4159
- // "triggerPrice":"0.00",
4160
- // "takeProfit":"0.00",
4161
- // "stopLoss":"0.00",
4162
- // "slTriggerBy":"UNKNOWN",
4163
- // "tpTriggerBy":"UNKNOWN"
4164
- // }
4165
- //
4166
- const order = this.safeDict(response, 'result', {});
4167
- return this.parseOrder(order, market);
4168
- }
4169
- async editUsdcOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4170
- await this.loadMarkets();
4171
- const market = this.market(symbol);
4172
- const request = {
4173
- 'symbol': market['id'],
4174
- 'orderId': id,
4175
- };
4176
- if (amount !== undefined) {
4177
- request['orderQty'] = this.getAmount(symbol, amount);
4178
- }
4179
- if (price !== undefined) {
4180
- request['orderPrice'] = this.getPrice(symbol, price);
4181
- }
4182
- let response = undefined;
4183
- if (market['option']) {
4184
- response = await this.privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder(this.extend(request, params));
4185
- }
4186
- else {
4187
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
4188
- const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
4189
- const stopLossPrice = this.safeValue(params, 'stopLossPrice');
4190
- const isStopLossOrder = stopLossPrice !== undefined;
4191
- const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
4192
- const isTakeProfitOrder = takeProfitPrice !== undefined;
4193
- const isStopOrder = isStopLossOrder || isTakeProfitOrder || isStop;
4194
- if (isStopOrder) {
4195
- request['orderFilter'] = isStop ? 'StopOrder' : 'Order';
4196
- if (triggerPrice !== undefined) {
4197
- request['triggerPrice'] = this.getPrice(symbol, triggerPrice);
4198
- }
4199
- if (stopLossPrice !== undefined) {
4200
- request['stopLoss'] = this.getPrice(symbol, stopLossPrice);
4201
- }
4202
- if (takeProfitPrice !== undefined) {
4203
- request['takeProfit'] = this.getPrice(symbol, takeProfitPrice);
4204
- }
4205
- }
4206
- params = this.omit(params, ['stop', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
4207
- response = await this.privatePostPerpetualUsdcOpenapiPrivateV1ReplaceOrder(this.extend(request, params));
4208
- }
4209
- //
4210
- // {
4211
- // "retCode": 0,
4212
- // "retMsg": "OK",
4213
- // "result": {
4214
- // "outRequestId": "",
4215
- // "symbol": "BTC-13MAY22-40000-C",
4216
- // "orderId": "8c65df91-91fc-461d-9b14-786379ef138c",
4217
- // "orderLinkId": "AAAAA41133"
4218
- // },
4219
- // "retExtMap": {}
4220
- // }
4221
- //
4222
- const result = this.safeDict(response, 'result', {});
4223
- return this.parseOrder(result, market);
4224
- }
4225
4029
  editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4226
4030
  const market = this.market(symbol);
4227
4031
  const request = {
@@ -4324,16 +4128,9 @@ class bybit extends bybit$1 {
4324
4128
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4325
4129
  */
4326
4130
  await this.loadMarkets();
4327
- const market = this.market(symbol);
4328
4131
  if (symbol === undefined) {
4329
4132
  throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a symbol argument');
4330
4133
  }
4331
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4332
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4333
- const isUsdcSettled = market['settle'] === 'USDC';
4334
- if (isUsdcSettled && !isUnifiedAccount) {
4335
- return await this.editUsdcOrder(id, symbol, type, side, amount, price, params);
4336
- }
4337
4134
  const request = this.editOrderRequest(id, symbol, type, side, amount, price, params);
4338
4135
  const response = await this.privatePostV5OrderAmend(this.extend(request, params));
4339
4136
  //
@@ -4354,46 +4151,6 @@ class bybit extends bybit$1 {
4354
4151
  'id': this.safeString(result, 'orderId'),
4355
4152
  });
4356
4153
  }
4357
- async cancelUsdcOrder(id, symbol = undefined, params = {}) {
4358
- if (symbol === undefined) {
4359
- throw new errors.ArgumentsRequired(this.id + ' cancelUsdcOrder() requires a symbol argument');
4360
- }
4361
- await this.loadMarkets();
4362
- const market = this.market(symbol);
4363
- const request = {
4364
- 'symbol': market['id'],
4365
- // 'orderLinkId': 'string', // one of order_id, stop_order_id or order_link_id is required
4366
- // 'orderId': id,
4367
- };
4368
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
4369
- params = this.omit(params, ['stop', 'trigger']);
4370
- if (id !== undefined) { // The user can also use argument params["order_link_id"]
4371
- request['orderId'] = id;
4372
- }
4373
- let response = undefined;
4374
- if (market['option']) {
4375
- response = await this.privatePostOptionUsdcOpenapiPrivateV1CancelOrder(this.extend(request, params));
4376
- }
4377
- else {
4378
- request['orderFilter'] = isStop ? 'StopOrder' : 'Order';
4379
- response = await this.privatePostPerpetualUsdcOpenapiPrivateV1CancelOrder(this.extend(request, params));
4380
- }
4381
- //
4382
- // {
4383
- // "retCode": 0,
4384
- // "retMsg": "OK",
4385
- // "result": {
4386
- // "outRequestId": "",
4387
- // "symbol": "BTC-13MAY22-40000-C",
4388
- // "orderId": "8c65df91-91fc-461d-9b14-786379ef138c",
4389
- // "orderLinkId": ""
4390
- // },
4391
- // "retExtMap": {}
4392
- // }
4393
- //
4394
- const result = this.safeDict(response, 'result', {});
4395
- return this.parseOrder(result, market);
4396
- }
4397
4154
  cancelOrderRequest(id, symbol = undefined, params = {}) {
4398
4155
  const market = this.market(symbol);
4399
4156
  const request = {
@@ -4405,9 +4162,9 @@ class bybit extends bybit$1 {
4405
4162
  };
4406
4163
  if (market['spot']) {
4407
4164
  // only works for spot market
4408
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
4165
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger', false);
4409
4166
  params = this.omit(params, ['stop', 'trigger']);
4410
- request['orderFilter'] = isStop ? 'StopOrder' : 'Order';
4167
+ request['orderFilter'] = isTrigger ? 'StopOrder' : 'Order';
4411
4168
  }
4412
4169
  if (id !== undefined) { // The user can also use argument params["orderLinkId"]
4413
4170
  request['orderId'] = id;
@@ -4435,7 +4192,8 @@ class bybit extends bybit$1 {
4435
4192
  * @param {string} id order id
4436
4193
  * @param {string} symbol unified symbol of the market the order was made in
4437
4194
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4438
- * @param {boolean} [params.stop] *spot only* whether the order is a stop order
4195
+ * @param {boolean} [params.trigger] *spot only* whether the order is a trigger order
4196
+ * @param {boolean} [params.stop] alias for trigger
4439
4197
  * @param {string} [params.orderFilter] *spot only* 'Order' or 'StopOrder' or 'tpslOrder'
4440
4198
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4441
4199
  */
@@ -4444,12 +4202,6 @@ class bybit extends bybit$1 {
4444
4202
  }
4445
4203
  await this.loadMarkets();
4446
4204
  const market = this.market(symbol);
4447
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4448
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4449
- const isUsdcSettled = market['settle'] === 'USDC';
4450
- if (isUsdcSettled && !isUnifiedAccount) {
4451
- return await this.cancelUsdcOrder(id, symbol, params);
4452
- }
4453
4205
  const requestExtended = this.cancelOrderRequest(id, symbol, params);
4454
4206
  const response = await this.privatePostV5OrderCancel(requestExtended);
4455
4207
  //
@@ -4673,53 +4425,6 @@ class bybit extends bybit$1 {
4673
4425
  const row = this.safeList(result, 'list', []);
4674
4426
  return this.parseOrders(row, undefined);
4675
4427
  }
4676
- async cancelAllUsdcOrders(symbol = undefined, params = {}) {
4677
- if (symbol === undefined) {
4678
- throw new errors.ArgumentsRequired(this.id + ' cancelAllUsdcOrders() requires a symbol argument');
4679
- }
4680
- await this.loadMarkets();
4681
- const market = this.market(symbol);
4682
- const request = {
4683
- 'symbol': market['id'],
4684
- };
4685
- let response = undefined;
4686
- if (market['option']) {
4687
- response = await this.privatePostOptionUsdcOpenapiPrivateV1CancelAll(this.extend(request, params));
4688
- }
4689
- else {
4690
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
4691
- if (isStop) {
4692
- request['orderFilter'] = 'StopOrder';
4693
- }
4694
- else {
4695
- request['orderFilter'] = 'Order';
4696
- }
4697
- params = this.omit(params, ['stop', 'trigger']);
4698
- response = await this.privatePostPerpetualUsdcOpenapiPrivateV1CancelAll(this.extend(request, params));
4699
- }
4700
- //
4701
- // {
4702
- // "retCode": 0,
4703
- // "retMsg": "OK",
4704
- // "retExtMap": {},
4705
- // "result": [
4706
- // {
4707
- // "outRequestId": "cancelAll-290119-1652176443114-0",
4708
- // "symbol": "BTC-13MAY22-40000-C",
4709
- // "orderId": "fa6cd740-56ed-477d-9385-90ccbfee49ca",
4710
- // "orderLinkId": "",
4711
- // "errorCode": 0,
4712
- // "errorDesc": ""
4713
- // }
4714
- // ]
4715
- // }
4716
- //
4717
- const result = this.safeValue(response, 'result', []);
4718
- if (!Array.isArray(result)) {
4719
- return response;
4720
- }
4721
- return this.parseOrders(result, market);
4722
- }
4723
4428
  async cancelAllOrders(symbol = undefined, params = {}) {
4724
4429
  /**
4725
4430
  * @method
@@ -4728,7 +4433,8 @@ class bybit extends bybit$1 {
4728
4433
  * @see https://bybit-exchange.github.io/docs/v5/order/cancel-all
4729
4434
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
4730
4435
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4731
- * @param {boolean} [params.stop] true if stop order
4436
+ * @param {boolean} [params.trigger] true if trigger order
4437
+ * @param {boolean} [params.stop] alias for trigger
4732
4438
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4733
4439
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4734
4440
  * @param {string} [params.baseCoin] Base coin. Supports linear, inverse & option
@@ -4742,10 +4448,6 @@ class bybit extends bybit$1 {
4742
4448
  const request = {};
4743
4449
  if (symbol !== undefined) {
4744
4450
  market = this.market(symbol);
4745
- const isUsdcSettled = market['settle'] === 'USDC';
4746
- if (isUsdcSettled && !isUnifiedAccount) {
4747
- return await this.cancelAllUsdcOrders(symbol, params);
4748
- }
4749
4451
  request['symbol'] = market['id'];
4750
4452
  }
4751
4453
  let type = undefined;
@@ -4761,9 +4463,9 @@ class bybit extends bybit$1 {
4761
4463
  request['settleCoin'] = this.safeString(params, 'settleCoin', defaultSettle);
4762
4464
  }
4763
4465
  }
4764
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
4466
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger', false);
4765
4467
  params = this.omit(params, ['stop', 'trigger']);
4766
- if (isStop) {
4468
+ if (isTrigger) {
4767
4469
  request['orderFilter'] = 'StopOrder';
4768
4470
  }
4769
4471
  const response = await this.privatePostV5OrderCancelAll(this.extend(request, params));
@@ -4802,93 +4504,6 @@ class bybit extends bybit$1 {
4802
4504
  }
4803
4505
  return this.parseOrders(orders, market);
4804
4506
  }
4805
- async fetchUsdcOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4806
- await this.loadMarkets();
4807
- let market = undefined;
4808
- const request = {
4809
- // 'category': '', // Type. PERPETUAL, OPTION
4810
- // 'symbol': '', // Contract name
4811
- // 'baseCoin': '', // Base currency
4812
- // 'orderId': '', // Order ID
4813
- // 'orderLinkId': '', // Custom ID used for cross-platform strategy remarks; a max. of 32 characters
4814
- // 'orderStatus': '', // Order status
4815
- // 'orderFilter': '', // refer to Order Filter
4816
- // 'direction': '', // prev: prev page, next: next page.
4817
- // 'limit': 0, // Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page
4818
- // 'cursor': '', // API pass-through
4819
- };
4820
- if (symbol !== undefined) {
4821
- market = this.market(symbol);
4822
- request['symbol'] = market['id'];
4823
- }
4824
- let type = undefined;
4825
- [type, params] = this.handleMarketTypeAndParams('fetchOrders', market, params);
4826
- if (type === 'swap') {
4827
- request['category'] = 'PERPETUAL';
4828
- }
4829
- else {
4830
- request['category'] = 'OPTION';
4831
- }
4832
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
4833
- params = this.omit(params, ['stop', 'trigger']);
4834
- if (isStop) {
4835
- request['orderFilter'] = 'StopOrder';
4836
- }
4837
- if (limit !== undefined) {
4838
- request['limit'] = limit;
4839
- }
4840
- const response = await this.privatePostOptionUsdcOpenapiPrivateV1QueryOrderHistory(this.extend(request, params));
4841
- //
4842
- // {
4843
- // "result": {
4844
- // "cursor": "640034d1-97ec-4382-9983-694898c03ba3%3A1640854950675%2C640034d1-97ec-4382-9983-694898c03ba3%3A1640854950675",
4845
- // "resultTotalSize": 1,
4846
- // "dataList": [
4847
- // {
4848
- // "symbol": "ETHPERP",
4849
- // "orderType": "Limit",
4850
- // "orderLinkId": "",
4851
- // "orderId": "c04ad17d-ca85-45d1-859e-561e7236f6db",
4852
- // "cancelType": "UNKNOWN",
4853
- // "stopOrderType": "UNKNOWN",
4854
- // "orderStatus": "Filled",
4855
- // "updateTimeStamp": "1666178097006",
4856
- // "takeProfit": "0.0000",
4857
- // "cumExecValue": "12.9825",
4858
- // "createdAt": "1666178096996",
4859
- // "blockTradeId": "",
4860
- // "orderPnl": "",
4861
- // "price": "1300.0",
4862
- // "tpTriggerBy": "UNKNOWN",
4863
- // "timeInForce": "GoodTillCancel",
4864
- // "updatedAt": "1666178097006",
4865
- // "basePrice": "",
4866
- // "realisedPnl": "0.0000",
4867
- // "side": "Buy",
4868
- // "triggerPrice": "0.0",
4869
- // "cumExecFee": "0.0078",
4870
- // "leavesQty": "0.000",
4871
- // "cashFlow": "",
4872
- // "slTriggerBy": "UNKNOWN",
4873
- // "iv": "",
4874
- // "closeOnTrigger": "UNKNOWN",
4875
- // "cumExecQty": "0.010",
4876
- // "reduceOnly": 0,
4877
- // "qty": "0.010",
4878
- // "stopLoss": "0.0000",
4879
- // "triggerBy": "UNKNOWN",
4880
- // "orderIM": ""
4881
- // }
4882
- // ]
4883
- // },
4884
- // "retCode": 0,
4885
- // "retMsg": "Success."
4886
- // }
4887
- //
4888
- const result = this.safeDict(response, 'result', {});
4889
- const data = this.safeList(result, 'dataList', []);
4890
- return this.parseOrders(data, market, since, limit);
4891
- }
4892
4507
  async fetchOrderClassic(id, symbol = undefined, params = {}) {
4893
4508
  /**
4894
4509
  * @method
@@ -5029,7 +4644,8 @@ class bybit extends bybit$1 {
5029
4644
  * @param {int} [since] the earliest time in ms to fetch orders for
5030
4645
  * @param {int} [limit] the maximum number of order structures to retrieve
5031
4646
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5032
- * @param {boolean} [params.stop] true if stop order
4647
+ * @param {boolean} [params.trigger] true if trigger order
4648
+ * @param {boolean} [params.stop] alias for trigger
5033
4649
  * @param {string} [params.type] market type, ['swap', 'option']
5034
4650
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5035
4651
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
@@ -5053,7 +4669,8 @@ class bybit extends bybit$1 {
5053
4669
  * @param {int} [since] the earliest time in ms to fetch orders for
5054
4670
  * @param {int} [limit] the maximum number of order structures to retrieve
5055
4671
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5056
- * @param {boolean} [params.stop] true if stop order
4672
+ * @param {boolean} [params.trigger] true if trigger order
4673
+ * @param {boolean} [params.stop] alias for trigger
5057
4674
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5058
4675
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5059
4676
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
@@ -5067,28 +4684,21 @@ class bybit extends bybit$1 {
5067
4684
  if (paginate) {
5068
4685
  return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
5069
4686
  }
5070
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
5071
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
5072
4687
  const request = {};
5073
4688
  let market = undefined;
5074
- let isUsdcSettled = false;
5075
4689
  if (symbol !== undefined) {
5076
4690
  market = this.market(symbol);
5077
- isUsdcSettled = market['settle'] === 'USDC';
5078
4691
  request['symbol'] = market['id'];
5079
4692
  }
5080
4693
  let type = undefined;
5081
4694
  [type, params] = this.getBybitType('fetchOrders', market, params);
5082
- if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
5083
- return await this.fetchUsdcOrders(symbol, since, limit, params);
5084
- }
5085
4695
  if (type === 'spot') {
5086
4696
  throw new errors.NotSupported(this.id + ' fetchOrders() is not supported for spot markets');
5087
4697
  }
5088
4698
  request['category'] = type;
5089
- const isStop = this.safeBoolN(params, ['trigger', 'stop'], false);
4699
+ const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
5090
4700
  params = this.omit(params, ['trigger', 'stop']);
5091
- if (isStop) {
4701
+ if (isTrigger) {
5092
4702
  request['orderFilter'] = 'StopOrder';
5093
4703
  }
5094
4704
  if (limit !== undefined) {
@@ -5166,7 +4776,8 @@ class bybit extends bybit$1 {
5166
4776
  * @param {string} id order id
5167
4777
  * @param {string} [symbol] unified symbol of the market the order was made in
5168
4778
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5169
- * @param {boolean} [params.stop] set to true for fetching a closed stop order
4779
+ * @param {boolean} [params.trigger] set to true for fetching a closed trigger order
4780
+ * @param {boolean} [params.stop] alias for trigger
5170
4781
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5171
4782
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5172
4783
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
@@ -5197,7 +4808,8 @@ class bybit extends bybit$1 {
5197
4808
  * @param {string} id order id
5198
4809
  * @param {string} [symbol] unified symbol of the market the order was made in
5199
4810
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5200
- * @param {boolean} [params.stop] set to true for fetching an open stop order
4811
+ * @param {boolean} [params.trigger] set to true for fetching an open trigger order
4812
+ * @param {boolean} [params.stop] alias for trigger
5201
4813
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5202
4814
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5203
4815
  * @param {string} [params.baseCoin] Base coin. Supports linear, inverse & option
@@ -5231,7 +4843,8 @@ class bybit extends bybit$1 {
5231
4843
  * @param {int} [since] the earliest time in ms to fetch orders for
5232
4844
  * @param {int} [limit] the maximum number of order structures to retrieve
5233
4845
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5234
- * @param {boolean} [params.stop] set to true for fetching stop orders
4846
+ * @param {boolean} [params.trigger] set to true for fetching trigger orders
4847
+ * @param {boolean} [params.stop] alias for trigger
5235
4848
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5236
4849
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5237
4850
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
@@ -5245,25 +4858,18 @@ class bybit extends bybit$1 {
5245
4858
  if (paginate) {
5246
4859
  return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
5247
4860
  }
5248
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
5249
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
5250
4861
  const request = {};
5251
4862
  let market = undefined;
5252
- let isUsdcSettled = false;
5253
4863
  if (symbol !== undefined) {
5254
4864
  market = this.market(symbol);
5255
- isUsdcSettled = market['settle'] === 'USDC';
5256
4865
  request['symbol'] = market['id'];
5257
4866
  }
5258
4867
  let type = undefined;
5259
4868
  [type, params] = this.getBybitType('fetchCanceledAndClosedOrders', market, params);
5260
- if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
5261
- return await this.fetchUsdcOrders(symbol, since, limit, params);
5262
- }
5263
4869
  request['category'] = type;
5264
- const isStop = this.safeBoolN(params, ['trigger', 'stop'], false);
4870
+ const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
5265
4871
  params = this.omit(params, ['trigger', 'stop']);
5266
- if (isStop) {
4872
+ if (isTrigger) {
5267
4873
  request['orderFilter'] = 'StopOrder';
5268
4874
  }
5269
4875
  if (limit !== undefined) {
@@ -5342,7 +4948,8 @@ class bybit extends bybit$1 {
5342
4948
  * @param {int} [since] the earliest time in ms to fetch orders for
5343
4949
  * @param {int} [limit] the maximum number of order structures to retrieve
5344
4950
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5345
- * @param {boolean} [params.stop] set to true for fetching closed stop orders
4951
+ * @param {boolean} [params.trigger] set to true for fetching closed trigger orders
4952
+ * @param {boolean} [params.stop] alias for trigger
5346
4953
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5347
4954
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5348
4955
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
@@ -5366,7 +4973,8 @@ class bybit extends bybit$1 {
5366
4973
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
5367
4974
  * @param {int} [limit] max number of orders to return, default is undefined
5368
4975
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5369
- * @param {boolean} [params.stop] true if stop order
4976
+ * @param {boolean} [params.trigger] true if trigger order
4977
+ * @param {boolean} [params.stop] alias for trigger
5370
4978
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5371
4979
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5372
4980
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
@@ -5380,48 +4988,6 @@ class bybit extends bybit$1 {
5380
4988
  };
5381
4989
  return await this.fetchCanceledAndClosedOrders(symbol, since, limit, this.extend(request, params));
5382
4990
  }
5383
- async fetchUsdcOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5384
- await this.loadMarkets();
5385
- const request = {};
5386
- let market = undefined;
5387
- if (symbol !== undefined) {
5388
- market = this.market(symbol);
5389
- request['symbol'] = market['id'];
5390
- }
5391
- let type = undefined;
5392
- [type, params] = this.handleMarketTypeAndParams('fetchUsdcOpenOrders', market, params);
5393
- request['category'] = (type === 'swap') ? 'perpetual' : 'option';
5394
- const response = await this.privatePostOptionUsdcOpenapiPrivateV1QueryActiveOrders(this.extend(request, params));
5395
- const result = this.safeDict(response, 'result', {});
5396
- const orders = this.safeList(result, 'dataList', []);
5397
- //
5398
- // {
5399
- // "retCode": 0,
5400
- // "retMsg": "OK",
5401
- // "result": {
5402
- // "resultTotalSize": 1,
5403
- // "cursor": "id%3D1662019818569%23df31e03b-fc00-4b4c-bd1c-b97fd72b5c5c",
5404
- // "dataList": [
5405
- // {
5406
- // "orderId": "df31e03b-fc00-4b4c-bd1c-b97fd72b5c5c",
5407
- // "orderLinkId": "",
5408
- // "symbol": "BTC-2SEP22-18000-C",
5409
- // "orderStatus": "New",
5410
- // "orderPrice": "500",
5411
- // "side": "Buy",
5412
- // "remainingQty": "0.1",
5413
- // "orderType": "Limit",
5414
- // "qty": "0.1",
5415
- // "iv": "0.0000",
5416
- // "cancelType": "",
5417
- // "updateTimestamp": "1662019818579"
5418
- // }
5419
- // ]
5420
- // }
5421
- // }
5422
- //
5423
- return this.parseOrders(orders, market, since, limit);
5424
- }
5425
4991
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5426
4992
  /**
5427
4993
  * @method
@@ -5432,7 +4998,8 @@ class bybit extends bybit$1 {
5432
4998
  * @param {int} [since] the earliest time in ms to fetch open orders for
5433
4999
  * @param {int} [limit] the maximum number of open orders structures to retrieve
5434
5000
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5435
- * @param {boolean} [params.stop] set to true for fetching open stop orders
5001
+ * @param {boolean} [params.trigger] set to true for fetching open trigger orders
5002
+ * @param {boolean} [params.stop] alias for trigger
5436
5003
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
5437
5004
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
5438
5005
  * @param {string} [params.baseCoin] Base coin. Supports linear, inverse & option
@@ -5447,14 +5014,10 @@ class bybit extends bybit$1 {
5447
5014
  if (paginate) {
5448
5015
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
5449
5016
  }
5450
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
5451
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
5452
5017
  const request = {};
5453
5018
  let market = undefined;
5454
- let isUsdcSettled = false;
5455
5019
  if (symbol !== undefined) {
5456
5020
  market = this.market(symbol);
5457
- isUsdcSettled = market['settle'] === 'USDC';
5458
5021
  request['symbol'] = market['id'];
5459
5022
  }
5460
5023
  let type = undefined;
@@ -5465,16 +5028,12 @@ class bybit extends bybit$1 {
5465
5028
  const defaultSettle = this.safeString(this.options, 'defaultSettle', 'USDT');
5466
5029
  const settleCoin = this.safeString(params, 'settleCoin', defaultSettle);
5467
5030
  request['settleCoin'] = settleCoin;
5468
- isUsdcSettled = (settleCoin === 'USDC');
5469
5031
  }
5470
5032
  }
5471
- if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
5472
- return await this.fetchUsdcOpenOrders(symbol, since, limit, params);
5473
- }
5474
5033
  request['category'] = type;
5475
- const isStop = this.safeBool2(params, 'stop', 'trigger', false);
5034
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger', false);
5476
5035
  params = this.omit(params, ['stop', 'trigger']);
5477
- if (isStop) {
5036
+ if (isTrigger) {
5478
5037
  request['orderFilter'] = 'StopOrder';
5479
5038
  }
5480
5039
  if (limit !== undefined) {
@@ -5557,51 +5116,6 @@ class bybit extends bybit$1 {
5557
5116
  params = this.omit(params, ['clientOrderId', 'orderLinkId']);
5558
5117
  return await this.fetchMyTrades(symbol, since, limit, this.extend(request, params));
5559
5118
  }
5560
- async fetchMyUsdcTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5561
- await this.loadMarkets();
5562
- let market = undefined;
5563
- const request = {};
5564
- if (symbol !== undefined) {
5565
- market = this.market(symbol);
5566
- request['symbol'] = market['id'];
5567
- request['category'] = market['option'] ? 'OPTION' : 'PERPETUAL';
5568
- }
5569
- else {
5570
- request['category'] = 'PERPETUAL';
5571
- }
5572
- const response = await this.privatePostOptionUsdcOpenapiPrivateV1ExecutionList(this.extend(request, params));
5573
- //
5574
- // {
5575
- // "result": {
5576
- // "cursor": "29%3A1%2C28%3A1",
5577
- // "resultTotalSize": 2,
5578
- // "dataList": [
5579
- // {
5580
- // "symbol": "ETHPERP",
5581
- // "orderLinkId": "",
5582
- // "side": "Sell",
5583
- // "orderId": "d83f8b4d-2f60-4e04-a64a-a3f207989dc6",
5584
- // "execFee": "0.0210",
5585
- // "feeRate": "0.000600",
5586
- // "blockTradeId": "",
5587
- // "tradeTime": "1669196423581",
5588
- // "execPrice": "1161.45",
5589
- // "lastLiquidityInd": "TAKER",
5590
- // "execValue": "34.8435",
5591
- // "execType": "Trade",
5592
- // "execQty": "0.030",
5593
- // "tradeId": "d9aa8590-9e6a-575e-a1be-d6261e6ed2e5"
5594
- // }, ...
5595
- // ]
5596
- // },
5597
- // "retCode": 0,
5598
- // "retMsg": "Success."
5599
- // }
5600
- //
5601
- const result = this.safeDict(response, 'result', {});
5602
- const dataList = this.safeList(result, 'dataList', []);
5603
- return this.parseTrades(dataList, market, since, limit);
5604
- }
5605
5119
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5606
5120
  /**
5607
5121
  * @method
@@ -5623,23 +5137,16 @@ class bybit extends bybit$1 {
5623
5137
  if (paginate) {
5624
5138
  return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 100);
5625
5139
  }
5626
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
5627
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
5628
5140
  let request = {
5629
5141
  'execType': 'Trade',
5630
5142
  };
5631
5143
  let market = undefined;
5632
- let isUsdcSettled = false;
5633
5144
  if (symbol !== undefined) {
5634
5145
  market = this.market(symbol);
5635
- isUsdcSettled = market['settle'] === 'USDC';
5636
5146
  request['symbol'] = market['id'];
5637
5147
  }
5638
5148
  let type = undefined;
5639
5149
  [type, params] = this.getBybitType('fetchMyTrades', market, params);
5640
- if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
5641
- return await this.fetchMyUsdcTrades(symbol, since, limit, params);
5642
- }
5643
5150
  request['category'] = type;
5644
5151
  if (limit !== undefined) {
5645
5152
  request['limit'] = limit;
@@ -6405,20 +5912,11 @@ class bybit extends bybit$1 {
6405
5912
  const request = {
6406
5913
  'symbol': market['id'],
6407
5914
  };
6408
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
6409
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
6410
- const isUsdcSettled = market['settle'] === 'USDC';
6411
5915
  let response = undefined;
6412
5916
  let type = undefined;
6413
5917
  [type, params] = this.getBybitType('fetchPosition', market, params);
6414
- if ((type === 'option' || isUsdcSettled) && !isUnifiedAccount) {
6415
- request['category'] = (type === 'option') ? 'OPTION' : 'PERPETUAL';
6416
- response = await this.privatePostOptionUsdcOpenapiPrivateV1QueryPosition(this.extend(request, params));
6417
- }
6418
- else {
6419
- request['category'] = type;
6420
- response = await this.privateGetV5PositionList(this.extend(request, params));
6421
- }
5918
+ request['category'] = type;
5919
+ response = await this.privateGetV5PositionList(this.extend(request, params));
6422
5920
  //
6423
5921
  // {
6424
5922
  // "retCode": 0,
@@ -6468,81 +5966,6 @@ class bybit extends bybit$1 {
6468
5966
  position['datetime'] = this.iso8601(timestamp);
6469
5967
  return position;
6470
5968
  }
6471
- async fetchUsdcPositions(symbols = undefined, params = {}) {
6472
- await this.loadMarkets();
6473
- const request = {};
6474
- let market = undefined;
6475
- if (Array.isArray(symbols)) {
6476
- const length = symbols.length;
6477
- if (length !== 1) {
6478
- throw new errors.ArgumentsRequired(this.id + ' fetchUsdcPositions() takes an array with exactly one symbol');
6479
- }
6480
- const symbol = this.safeString(symbols, 0);
6481
- market = this.market(symbol);
6482
- request['symbol'] = market['id'];
6483
- }
6484
- else if (symbols !== undefined) {
6485
- market = this.market(symbols);
6486
- request['symbol'] = market['id'];
6487
- }
6488
- let type = undefined;
6489
- [type, params] = this.getBybitType('fetchUsdcPositions', market, params);
6490
- request['category'] = (type === 'option') ? 'OPTION' : 'PERPETUAL';
6491
- const response = await this.privatePostOptionUsdcOpenapiPrivateV1QueryPosition(this.extend(request, params));
6492
- //
6493
- // {
6494
- // "result": {
6495
- // "cursor": "BTC-31DEC21-24000-P%3A1640834421431%2CBTC-31DEC21-24000-P%3A1640834421431",
6496
- // "resultTotalSize": 1,
6497
- // "dataList": [
6498
- // {
6499
- // "symbol": "BTC-31DEC21-24000-P",
6500
- // "leverage": "",
6501
- // "occClosingFee": "",
6502
- // "liqPrice": "",
6503
- // "positionValue": "",
6504
- // "takeProfit": "",
6505
- // "riskId": "",
6506
- // "trailingStop": "",
6507
- // "unrealisedPnl": "",
6508
- // "createdAt": "1640834421431",
6509
- // "markPrice": "0.00",
6510
- // "cumRealisedPnl": "",
6511
- // "positionMM": "359.5271",
6512
- // "positionIM": "467.0633",
6513
- // "updatedAt": "1640834421431",
6514
- // "tpSLMode": "",
6515
- // "side": "Sell",
6516
- // "bustPrice": "",
6517
- // "deleverageIndicator": 0,
6518
- // "entryPrice": "1.4",
6519
- // "size": "-0.100",
6520
- // "sessionRPL": "",
6521
- // "positionStatus": "",
6522
- // "sessionUPL": "",
6523
- // "stopLoss": "",
6524
- // "orderMargin": "",
6525
- // "sessionAvgPrice": "1.5"
6526
- // }
6527
- // ]
6528
- // },
6529
- // "retCode": 0,
6530
- // "retMsg": "Success."
6531
- // }
6532
- //
6533
- const result = this.safeDict(response, 'result', {});
6534
- const positions = this.safeList(result, 'dataList', []);
6535
- const results = [];
6536
- for (let i = 0; i < positions.length; i++) {
6537
- let rawPosition = positions[i];
6538
- if (('data' in rawPosition) && ('is_valid' in rawPosition)) {
6539
- // futures only
6540
- rawPosition = this.safeDict(rawPosition, 'data');
6541
- }
6542
- results.push(this.parsePosition(rawPosition, market));
6543
- }
6544
- return this.filterByArrayPositions(results, 'symbol', symbols, false);
6545
- }
6546
5969
  async fetchPositions(symbols = undefined, params = {}) {
6547
5970
  /**
6548
5971
  * @method
@@ -6573,16 +5996,12 @@ class bybit extends bybit$1 {
6573
5996
  symbol = symbols;
6574
5997
  symbols = [this.symbol(symbol)];
6575
5998
  }
6576
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
6577
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
6578
5999
  const request = {};
6579
6000
  let market = undefined;
6580
- let isUsdcSettled = false;
6581
6001
  if (symbol !== undefined) {
6582
6002
  market = this.market(symbol);
6583
6003
  symbol = market['symbol'];
6584
6004
  request['symbol'] = market['id'];
6585
- isUsdcSettled = market['settle'] === 'USDC';
6586
6005
  }
6587
6006
  let type = undefined;
6588
6007
  [type, params] = this.getBybitType('fetchPositions', market, params);
@@ -6593,7 +6012,6 @@ class bybit extends bybit$1 {
6593
6012
  const defaultSettle = this.safeString(this.options, 'defaultSettle', 'USDT');
6594
6013
  const settleCoin = this.safeString(params, 'settleCoin', defaultSettle);
6595
6014
  request['settleCoin'] = settleCoin;
6596
- isUsdcSettled = (settleCoin === 'USDC');
6597
6015
  }
6598
6016
  }
6599
6017
  else {
@@ -6603,9 +6021,6 @@ class bybit extends bybit$1 {
6603
6021
  }
6604
6022
  }
6605
6023
  }
6606
- if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
6607
- return await this.fetchUsdcPositions(symbols, params);
6608
- }
6609
6024
  params = this.omit(params, ['type']);
6610
6025
  request['category'] = type;
6611
6026
  const response = await this.privateGetV5PositionList(this.extend(request, params));
@@ -7050,9 +6465,6 @@ class bybit extends bybit$1 {
7050
6465
  const market = this.market(symbol);
7051
6466
  // WARNING: THIS WILL INCREASE LIQUIDATION PRICE FOR OPEN ISOLATED LONG POSITIONS
7052
6467
  // AND DECREASE LIQUIDATION PRICE FOR OPEN ISOLATED SHORT POSITIONS
7053
- const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
7054
- const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
7055
- const isUsdcSettled = market['settle'] === 'USDC';
7056
6468
  // engage in leverage setting
7057
6469
  // we reuse the code here instead of having two methods
7058
6470
  const leverageString = this.numberToString(leverage);
@@ -7061,25 +6473,18 @@ class bybit extends bybit$1 {
7061
6473
  'buyLeverage': leverageString,
7062
6474
  'sellLeverage': leverageString,
7063
6475
  };
7064
- let response = undefined;
7065
- if (isUsdcSettled && !isUnifiedAccount) {
7066
- request['leverage'] = leverageString;
7067
- response = await this.privatePostPerpetualUsdcOpenapiPrivateV1PositionLeverageSave(this.extend(request, params));
6476
+ request['buyLeverage'] = leverageString;
6477
+ request['sellLeverage'] = leverageString;
6478
+ if (market['linear']) {
6479
+ request['category'] = 'linear';
6480
+ }
6481
+ else if (market['inverse']) {
6482
+ request['category'] = 'inverse';
7068
6483
  }
7069
6484
  else {
7070
- request['buyLeverage'] = leverageString;
7071
- request['sellLeverage'] = leverageString;
7072
- if (market['linear']) {
7073
- request['category'] = 'linear';
7074
- }
7075
- else if (market['inverse']) {
7076
- request['category'] = 'inverse';
7077
- }
7078
- else {
7079
- throw new errors.NotSupported(this.id + ' setLeverage() only support linear and inverse market');
7080
- }
7081
- response = await this.privatePostV5PositionSetLeverage(this.extend(request, params));
6485
+ throw new errors.NotSupported(this.id + ' setLeverage() only support linear and inverse market');
7082
6486
  }
6487
+ const response = await this.privatePostV5PositionSetLeverage(this.extend(request, params));
7083
6488
  return response;
7084
6489
  }
7085
6490
  async setPositionMode(hedged, symbol = undefined, params = {}) {