@@ -33987,6 +33987,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
33987
33987
if (quote === 'USDT') {
33988
33988
minCost = this.safeNumber(market, 'minTradeUSDT');
33989
33989
}
33990
+ const contractSize = contract ? 1 : undefined;
33990
33991
return {
33991
33992
'id': marketId,
33992
33993
'symbol': symbol,
@@ -34008,7 +34009,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
34008
34009
'inverse': inverse,
34009
34010
'taker': this.safeNumber(market, 'takerFeeRate'),
34010
34011
'maker': this.safeNumber(market, 'makerFeeRate'),
34011
- 'contractSize': 1 ,
34012
+ 'contractSize': contractSize ,
34012
34013
'expiry': expiry,
34013
34014
'expiryDatetime': expiryDatetime,
34014
34015
'strike': undefined,
@@ -69104,6 +69105,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
69104
69105
'v5/order/spot-borrow-check': 2.5,
69105
69106
'v5/order/realtime': 2.5,
69106
69107
'v5/position/list': 2.5,
69108
+ 'v5/position/switch-mode': 2.5,
69107
69109
'v5/execution/list': 2.5,
69108
69110
'v5/position/closed-pnl': 2.5,
69109
69111
'v5/account/wallet-balance': 2.5,
@@ -76386,7 +76388,22 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76386
76388
return await this[method](this.extend(request, params));
76387
76389
}
76388
76390
async setPositionMode(hedged, symbol = undefined, params = {}) {
76391
+ /**
76392
+ * @method
76393
+ * @name bybit#setPositionMode
76394
+ * @description set hedged to true or false for a market
76395
+ * @see https://bybit-exchange.github.io/docs/v5/position/position-mode
76396
+ * @see https://bybit-exchange.github.io/docs/derivatives/contract/position-mode
76397
+ * @param {bool} hedged
76398
+ * @param {string|undefined} symbol used for unified account with inverse market
76399
+ * @param {object} params extra parameters specific to the bybit api endpoint
76400
+ * @returns {object} response from the exchange
76401
+ */
76389
76402
await this.loadMarkets();
76403
+ let market = undefined;
76404
+ if (symbol !== undefined) {
76405
+ market = this.market(symbol);
76406
+ }
76390
76407
let mode = undefined;
76391
76408
if (hedged) {
76392
76409
mode = 3;
@@ -76401,10 +76418,26 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76401
76418
request['coin'] = 'USDT';
76402
76419
}
76403
76420
else {
76404
- const market = this.market(symbol);
76405
76421
request['symbol'] = market['id'];
76406
76422
}
76423
+ const enableUnified = await this.isUnifiedEnabled();
76424
+ let response = undefined;
76425
+ if (enableUnified[1] || enableUnified[0]) {
76426
+ if (symbol !== undefined) {
76427
+ request['category'] = market['linear'] ? 'linear' : 'inverse';
76428
+ }
76429
+ else {
76430
+ let subType = undefined;
76431
+ [subType, params] = this.handleSubTypeAndParams('setPositionMode', market, params);
76432
+ request['category'] = subType;
76433
+ }
76434
+ response = await this.privatePostV5PositionSwitchMode(this.extend(request, params));
76435
+ }
76436
+ else {
76437
+ response = await this.privatePostContractV3PrivatePositionSwitchMode(this.extend(request, params));
76438
+ }
76407
76439
//
76440
+ // contract v3
76408
76441
// {
76409
76442
// "ret_code": 0,
76410
76443
// "ret_msg": "ok",
@@ -76417,7 +76450,15 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76417
76450
// "rate_limit": 75
76418
76451
// }
76419
76452
//
76420
- return await this.privatePostContractV3PrivatePositionSwitchMode(this.extend(request, params));
76453
+ // v5
76454
+ // {
76455
+ // "retCode": 0,
76456
+ // "retMsg": "OK",
76457
+ // "result": {},
76458
+ // "retExtInfo": {},
76459
+ // "time": 1675249072814
76460
+ // }
76461
+ return response;
76421
76462
}
76422
76463
async fetchDerivativesOpenInterestHistory(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
76423
76464
await this.loadMarkets();
@@ -203572,7 +203613,7 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
203572
203613
messageHash += ':' + symbol;
203573
203614
}
203574
203615
else {
203575
- message['params'] = this.ids ;
203616
+ message['params'] = [] ;
203576
203617
}
203577
203618
const url = this.urls['api']['ws'][type];
203578
203619
const request = this.deepExtend(message, query);
@@ -203878,14 +203919,14 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
203878
203919
// id: 1
203879
203920
// }
203880
203921
//
203881
- const future = this.safeValue(client.futures, 'authenticated') ;
203882
- if (future !== undefined) {
203883
- future .resolve(true );
203884
- }
203922
+ const messageHashSpot = 'authenticated:spot' ;
203923
+ const messageHashSwap = 'authenticated:swap';
203924
+ client .resolve(message, messageHashSpot );
203925
+ client.resolve(message, messageHashSwap);
203885
203926
return message;
203886
203927
}
203887
203928
handleSubscriptionStatus(client, message) {
203888
- const id = this.safeString (message, 'id');
203929
+ const id = this.safeInteger (message, 'id');
203889
203930
const subscription = this.safeValue(client.subscriptions, id);
203890
203931
if (subscription !== undefined) {
203891
203932
const futureIndex = this.safeString(subscription, 'future');
@@ -203904,11 +203945,10 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
203904
203945
const time = this.milliseconds();
203905
203946
if (type === 'spot') {
203906
203947
const messageHash = 'authenticated:spot';
203907
- const authenticated = this.safeValue(client.futures , messageHash);
203908
- if (authenticated !== undefined) {
203909
- return;
203948
+ let future = this.safeValue(client.subscriptions , messageHash);
203949
+ if (future !== undefined) {
203950
+ return future ;
203910
203951
}
203911
- const future = client.future(messageHash);
203912
203952
const requestId = this.requestId();
203913
203953
const subscribe = {
203914
203954
'id': requestId,
@@ -203925,16 +203965,16 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
203925
203965
],
203926
203966
'id': requestId,
203927
203967
};
203928
- this.spawn(this.watch, url, messageHash, request, requestId, subscribe);
203968
+ future = this.watch(url, messageHash, request, requestId, subscribe);
203969
+ client.subscriptions[messageHash] = future;
203929
203970
return future;
203930
203971
}
203931
203972
else {
203932
203973
const messageHash = 'authenticated:swap';
203933
- const authenticated = this.safeValue(client.futures , messageHash);
203934
- if (authenticated !== undefined) {
203935
- return;
203974
+ let future = this.safeValue(client.subscriptions , messageHash);
203975
+ if (future !== undefined) {
203976
+ return future ;
203936
203977
}
203937
- const future = client.future('authenticated:swap');
203938
203978
const requestId = this.requestId();
203939
203979
const subscribe = {
203940
203980
'id': requestId,
@@ -203951,7 +203991,8 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
203951
203991
],
203952
203992
'id': requestId,
203953
203993
};
203954
- this.spawn(this.watch, url, messageHash, request, requestId, subscribe);
203994
+ future = this.watch(url, messageHash, request, requestId, subscribe);
203995
+ client.subscriptions[messageHash] = future;
203955
203996
return future;
203956
203997
}
203957
203998
}
@@ -267973,7 +268014,7 @@ SOFTWARE.
267973
268014
267974
268015
//-----------------------------------------------------------------------------
267975
268016
// this is updated by vss.js when building
267976
- const version = '3.1.3 ';
268017
+ const version = '3.1.5 ';
267977
268018
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
267978
268019
//-----------------------------------------------------------------------------
267979
268020
0 commit comments