ccxt 4.0.101 → 4.0.103
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 +5 -6
- package/dist/ccxt.browser.js +1130 -2730
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +2 -4
- package/dist/cjs/src/base/errors.js +2 -1
- package/dist/cjs/src/binance.js +8 -0
- package/dist/cjs/src/bingx.js +111 -4
- package/dist/cjs/src/bitget.js +3 -0
- package/dist/cjs/src/bitmart.js +271 -46
- package/dist/cjs/src/bitrue.js +7 -0
- package/dist/cjs/src/bl3p.js +8 -0
- package/dist/cjs/src/bybit.js +79 -55
- package/dist/cjs/src/gate.js +221 -218
- package/dist/cjs/src/gemini.js +1 -0
- package/dist/cjs/src/pro/binance.js +7 -7
- package/dist/cjs/src/pro/bybit.js +18 -17
- package/dist/cjs/src/pro/coinbasepro.js +10 -10
- package/dist/cjs/src/pro/kucoin.js +3 -3
- package/dist/cjs/src/wavesexchange.js +2 -1
- package/js/ccxt.d.ts +3 -6
- package/js/ccxt.js +3 -5
- package/js/src/abstract/binance.d.ts +8 -0
- package/js/src/abstract/binancecoinm.d.ts +8 -0
- package/js/src/abstract/binanceus.d.ts +8 -0
- package/js/src/abstract/binanceusdm.d.ts +8 -0
- package/js/src/abstract/bingx.d.ts +16 -1
- package/js/src/base/errorHierarchy.d.ts +1 -0
- package/js/src/base/errorHierarchy.js +1 -0
- package/js/src/base/errors.d.ts +2 -1
- package/js/src/base/errors.js +2 -2
- package/js/src/binance.js +8 -0
- package/js/src/bingx.d.ts +8 -0
- package/js/src/bingx.js +111 -4
- package/js/src/bitget.js +3 -0
- package/js/src/bitmart.d.ts +46 -5
- package/js/src/bitmart.js +271 -46
- package/js/src/bitrue.js +7 -0
- package/js/src/bl3p.js +8 -0
- package/js/src/bybit.js +80 -56
- package/js/src/gate.js +221 -218
- package/js/src/gemini.js +1 -0
- package/js/src/pro/binance.js +7 -7
- package/js/src/pro/bybit.js +18 -17
- package/js/src/pro/coinbasepro.js +10 -10
- package/js/src/pro/kucoin.js +3 -3
- package/js/src/wavesexchange.js +2 -1
- package/package.json +1 -1
- package/skip-tests.json +5 -7
- package/js/src/abstract/bkex.d.ts +0 -61
- package/js/src/abstract/bkex.js +0 -11
package/js/src/bybit.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/bybit.js';
|
|
9
9
|
import { TICK_SIZE } from './base/functions/number.js';
|
|
10
|
-
import { AuthenticationError, ExchangeError, ArgumentsRequired, PermissionDenied, InvalidOrder, OrderNotFound, InsufficientFunds, BadRequest, RateLimitExceeded, InvalidNonce, NotSupported, RequestTimeout, BadSymbol } from './base/errors.js';
|
|
10
|
+
import { AuthenticationError, ExchangeError, ArgumentsRequired, PermissionDenied, InvalidOrder, OrderNotFound, InsufficientFunds, BadRequest, RateLimitExceeded, InvalidNonce, NotSupported, RequestTimeout, BadSymbol, MarginModeAlreadySet, NoChange } from './base/errors.js';
|
|
11
11
|
import { Precise } from './base/Precise.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
13
13
|
import { rsa } from './base/functions/rsa.js';
|
|
@@ -727,12 +727,12 @@ export default class bybit extends Exchange {
|
|
|
727
727
|
'110021': InvalidOrder,
|
|
728
728
|
'110022': InvalidOrder,
|
|
729
729
|
'110023': InvalidOrder,
|
|
730
|
-
'110024':
|
|
731
|
-
'110025':
|
|
732
|
-
'110026':
|
|
733
|
-
'110027':
|
|
734
|
-
'110028':
|
|
735
|
-
'110029':
|
|
730
|
+
'110024': BadRequest,
|
|
731
|
+
'110025': NoChange,
|
|
732
|
+
'110026': MarginModeAlreadySet,
|
|
733
|
+
'110027': NoChange,
|
|
734
|
+
'110028': BadRequest,
|
|
735
|
+
'110029': BadRequest,
|
|
736
736
|
'110030': InvalidOrder,
|
|
737
737
|
'110031': InvalidOrder,
|
|
738
738
|
'110032': InvalidOrder,
|
|
@@ -3724,12 +3724,12 @@ export default class bybit extends Exchange {
|
|
|
3724
3724
|
}
|
|
3725
3725
|
else if (isStopLoss || isTakeProfit) {
|
|
3726
3726
|
if (isStopLoss) {
|
|
3727
|
-
const
|
|
3728
|
-
request['stopLoss'] = this.priceToPrecision(symbol,
|
|
3727
|
+
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
3728
|
+
request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
|
|
3729
3729
|
}
|
|
3730
3730
|
if (isTakeProfit) {
|
|
3731
|
-
const
|
|
3732
|
-
request['takeProfit'] = this.priceToPrecision(symbol,
|
|
3731
|
+
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
3732
|
+
request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
3733
3733
|
}
|
|
3734
3734
|
}
|
|
3735
3735
|
if (market['spot']) {
|
|
@@ -3838,12 +3838,12 @@ export default class bybit extends Exchange {
|
|
|
3838
3838
|
}
|
|
3839
3839
|
else if (isStopLoss || isTakeProfit) {
|
|
3840
3840
|
if (isStopLoss) {
|
|
3841
|
-
const
|
|
3842
|
-
request['stopLoss'] = this.priceToPrecision(symbol,
|
|
3841
|
+
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
3842
|
+
request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
|
|
3843
3843
|
}
|
|
3844
3844
|
if (isTakeProfit) {
|
|
3845
|
-
const
|
|
3846
|
-
request['takeProfit'] = this.priceToPrecision(symbol,
|
|
3845
|
+
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
3846
|
+
request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
3847
3847
|
}
|
|
3848
3848
|
}
|
|
3849
3849
|
else {
|
|
@@ -4024,12 +4024,12 @@ export default class bybit extends Exchange {
|
|
|
4024
4024
|
}
|
|
4025
4025
|
if (isStopLoss || isTakeProfit) {
|
|
4026
4026
|
if (isStopLoss) {
|
|
4027
|
-
const
|
|
4028
|
-
request['stopLoss'] = this.priceToPrecision(symbol,
|
|
4027
|
+
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
4028
|
+
request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
|
|
4029
4029
|
}
|
|
4030
4030
|
if (isTakeProfit) {
|
|
4031
|
-
const
|
|
4032
|
-
request['takeProfit'] = this.priceToPrecision(symbol,
|
|
4031
|
+
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
4032
|
+
request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
4033
4033
|
}
|
|
4034
4034
|
}
|
|
4035
4035
|
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
@@ -5999,12 +5999,10 @@ export default class bybit extends Exchange {
|
|
|
5999
5999
|
await this.loadMarkets();
|
|
6000
6000
|
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
6001
6001
|
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
6002
|
+
let market = undefined;
|
|
6002
6003
|
let response = undefined;
|
|
6003
|
-
if (
|
|
6004
|
+
if (isUnifiedAccount) {
|
|
6004
6005
|
if (marginMode === 'isolated') {
|
|
6005
|
-
if (!isUnifiedAccount) {
|
|
6006
|
-
throw new NotSupported(this.id + ' setMarginMode() Normal Account not support ISOLATED_MARGIN');
|
|
6007
|
-
}
|
|
6008
6006
|
marginMode = 'ISOLATED_MARGIN';
|
|
6009
6007
|
}
|
|
6010
6008
|
else if (marginMode === 'cross') {
|
|
@@ -6022,44 +6020,70 @@ export default class bybit extends Exchange {
|
|
|
6022
6020
|
response = await this.privatePostV5AccountSetMarginMode(this.extend(request, params));
|
|
6023
6021
|
}
|
|
6024
6022
|
else {
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6023
|
+
if (symbol === undefined) {
|
|
6024
|
+
throw new ArgumentsRequired(this.id + ' setMarginMode() requires a symbol parameter for non unified account');
|
|
6025
|
+
}
|
|
6026
|
+
market = this.market(symbol);
|
|
6027
|
+
const isUsdcSettled = market['settle'] === 'USDC';
|
|
6028
|
+
if (isUsdcSettled) {
|
|
6029
|
+
if (marginMode === 'cross') {
|
|
6030
|
+
marginMode = 'REGULAR_MARGIN';
|
|
6031
6031
|
}
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
throw new NotSupported(this.id + ' setMarginMode() with symbol only support USDT perpetual / inverse contract');
|
|
6032
|
+
else if (marginMode === 'portfolio') {
|
|
6033
|
+
marginMode = 'PORTFOLIO_MARGIN';
|
|
6035
6034
|
}
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
}
|
|
6044
|
-
else if (marginMode === 'isolated') {
|
|
6045
|
-
tradeMode = 1;
|
|
6035
|
+
else {
|
|
6036
|
+
throw new NotSupported(this.id + ' setMarginMode() for usdc market marginMode must be either [cross, portfolio]');
|
|
6037
|
+
}
|
|
6038
|
+
const request = {
|
|
6039
|
+
'setMarginMode': marginMode,
|
|
6040
|
+
};
|
|
6041
|
+
response = await this.privatePostV5AccountSetMarginMode(this.extend(request, params));
|
|
6046
6042
|
}
|
|
6047
6043
|
else {
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6044
|
+
let type = undefined;
|
|
6045
|
+
[type, params] = this.getBybitType('setPositionMode', market, params);
|
|
6046
|
+
let tradeMode = undefined;
|
|
6047
|
+
if (marginMode === 'cross') {
|
|
6048
|
+
tradeMode = 0;
|
|
6049
|
+
}
|
|
6050
|
+
else if (marginMode === 'isolated') {
|
|
6051
|
+
tradeMode = 1;
|
|
6052
|
+
}
|
|
6053
|
+
else {
|
|
6054
|
+
throw new NotSupported(this.id + ' setMarginMode() with symbol marginMode must be either [isolated, cross]');
|
|
6055
|
+
}
|
|
6056
|
+
let sellLeverage = undefined;
|
|
6057
|
+
let buyLeverage = undefined;
|
|
6058
|
+
const leverage = this.safeString(params, 'leverage');
|
|
6059
|
+
if (leverage === undefined) {
|
|
6060
|
+
sellLeverage = this.safeString2(params, 'sell_leverage', 'sellLeverage');
|
|
6061
|
+
buyLeverage = this.safeString2(params, 'buy_leverage', 'buyLeverage');
|
|
6062
|
+
if (sellLeverage === undefined && buyLeverage === undefined) {
|
|
6063
|
+
throw new ArgumentsRequired(this.id + ' setMarginMode() requires a leverage parameter or sell_leverage and buy_leverage parameters');
|
|
6064
|
+
}
|
|
6065
|
+
if (buyLeverage === undefined) {
|
|
6066
|
+
buyLeverage = sellLeverage;
|
|
6067
|
+
}
|
|
6068
|
+
if (sellLeverage === undefined) {
|
|
6069
|
+
sellLeverage = buyLeverage;
|
|
6070
|
+
}
|
|
6071
|
+
params = this.omit(params, ['buy_leverage', 'sell_leverage', 'sellLeverage', 'buyLeverage']);
|
|
6072
|
+
}
|
|
6073
|
+
else {
|
|
6074
|
+
sellLeverage = leverage;
|
|
6075
|
+
buyLeverage = leverage;
|
|
6076
|
+
params = this.omit(params, 'leverage');
|
|
6077
|
+
}
|
|
6078
|
+
const request = {
|
|
6079
|
+
'category': type,
|
|
6080
|
+
'symbol': market['id'],
|
|
6081
|
+
'tradeMode': tradeMode,
|
|
6082
|
+
'buyLeverage': buyLeverage,
|
|
6083
|
+
'sellLeverage': sellLeverage,
|
|
6084
|
+
};
|
|
6085
|
+
response = await this.privatePostV5PositionSwitchIsolated(this.extend(request, params));
|
|
6054
6086
|
}
|
|
6055
|
-
const request = {
|
|
6056
|
-
'category': type,
|
|
6057
|
-
'symbol': market['id'],
|
|
6058
|
-
'tradeMode': tradeMode,
|
|
6059
|
-
'buyLeverage': leverage,
|
|
6060
|
-
'sellLeverage': leverage,
|
|
6061
|
-
};
|
|
6062
|
-
response = await this.privatePostV5PositionSwitchIsolated(this.extend(request, params));
|
|
6063
6087
|
}
|
|
6064
6088
|
return response;
|
|
6065
6089
|
}
|