ccxt 4.2.21 → 4.2.23
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/ccxt.browser.js +574 -81
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/binance.js +14 -3
- package/dist/cjs/src/bitfinex2.js +89 -0
- package/dist/cjs/src/bitget.js +11 -1
- package/dist/cjs/src/bitrue.js +1 -0
- package/dist/cjs/src/bybit.js +57 -9
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/coinex.js +60 -14
- package/dist/cjs/src/deribit.js +164 -0
- package/dist/cjs/src/okcoin.js +3 -0
- package/dist/cjs/src/okx.js +81 -31
- package/dist/cjs/src/phemex.js +17 -5
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/bequant.js +6 -1
- package/dist/cjs/src/pro/binance.js +8 -5
- package/dist/cjs/src/pro/binancecoinm.js +6 -1
- package/dist/cjs/src/pro/binanceus.js +6 -1
- package/dist/cjs/src/pro/bitcoincom.js +6 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitrue.js +6 -1
- package/dist/cjs/src/pro/hitbtc.js +6 -0
- package/dist/cjs/src/pro/okx.js +23 -5
- package/dist/cjs/src/woo.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +3 -0
- package/js/src/abstract/binancecoinm.d.ts +3 -0
- package/js/src/abstract/binanceus.d.ts +4 -0
- package/js/src/abstract/binanceusdm.d.ts +3 -0
- package/js/src/bigone.js +1 -0
- package/js/src/binance.js +14 -3
- package/js/src/bitfinex2.d.ts +2 -0
- package/js/src/bitfinex2.js +89 -0
- package/js/src/bitget.js +11 -1
- package/js/src/bitrue.js +1 -0
- package/js/src/bybit.d.ts +2 -1
- package/js/src/bybit.js +57 -9
- package/js/src/coinbasepro.js +1 -0
- package/js/src/coinex.d.ts +1 -0
- package/js/src/coinex.js +60 -14
- package/js/src/deribit.d.ts +6 -1
- package/js/src/deribit.js +164 -0
- package/js/src/okcoin.js +3 -0
- package/js/src/okx.js +81 -31
- package/js/src/phemex.js +17 -5
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/bequant.js +6 -1
- package/js/src/pro/binance.js +8 -5
- package/js/src/pro/binancecoinm.js +6 -1
- package/js/src/pro/binanceus.js +6 -1
- package/js/src/pro/bitcoincom.js +6 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitrue.js +6 -1
- package/js/src/pro/hitbtc.js +6 -0
- package/js/src/pro/okx.js +23 -5
- package/js/src/woo.js +1 -1
- package/jsdoc2md.js +38 -16
- package/package.json +4 -1
- package/skip-tests.json +4 -0
package/dist/cjs/ccxt.js
CHANGED
|
@@ -174,7 +174,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
174
174
|
|
|
175
175
|
//-----------------------------------------------------------------------------
|
|
176
176
|
// this is updated by vss.js when building
|
|
177
|
-
const version = '4.2.
|
|
177
|
+
const version = '4.2.23';
|
|
178
178
|
Exchange["default"].ccxtVersion = version;
|
|
179
179
|
const exchanges = {
|
|
180
180
|
'ace': ace,
|
package/dist/cjs/src/bigone.js
CHANGED
package/dist/cjs/src/binance.js
CHANGED
|
@@ -308,6 +308,7 @@ class binance extends binance$1 {
|
|
|
308
308
|
'convert/exchangeInfo': 50,
|
|
309
309
|
'convert/assetInfo': 10,
|
|
310
310
|
'convert/orderStatus': 0.6667,
|
|
311
|
+
'convert/limit/queryOpenOrders': 20.001,
|
|
311
312
|
'account/status': 0.1,
|
|
312
313
|
'account/apiTradingStatus': 0.1,
|
|
313
314
|
'account/apiRestrictions/ipRestriction': 0.1,
|
|
@@ -579,6 +580,8 @@ class binance extends binance$1 {
|
|
|
579
580
|
'loan/vip/repay': 40.002,
|
|
580
581
|
'convert/getQuote': 1.3334,
|
|
581
582
|
'convert/acceptQuote': 3.3335,
|
|
583
|
+
'convert/limit/placeOrder': 3.3335,
|
|
584
|
+
'convert/limit/cancelOrder': 1.3334,
|
|
582
585
|
'portfolio/auto-collection': 150,
|
|
583
586
|
'portfolio/asset-collection': 6,
|
|
584
587
|
'portfolio/bnb-transfer': 150,
|
|
@@ -7965,12 +7968,20 @@ class binance extends binance$1 {
|
|
|
7965
7968
|
/**
|
|
7966
7969
|
* @method
|
|
7967
7970
|
* @name binance#fetchPositions
|
|
7971
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
|
|
7972
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
|
|
7973
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
7974
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
7975
|
+
* @see https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
|
|
7968
7976
|
* @description fetch all open positions
|
|
7969
|
-
* @param {string[]
|
|
7977
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
7970
7978
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7979
|
+
* @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
|
7971
7980
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
7972
7981
|
*/
|
|
7973
|
-
const
|
|
7982
|
+
const defaultValue = this.safeString(this.options, 'fetchPositions', 'positionRisk');
|
|
7983
|
+
let defaultMethod = undefined;
|
|
7984
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', defaultValue);
|
|
7974
7985
|
if (defaultMethod === 'positionRisk') {
|
|
7975
7986
|
return await this.fetchPositionsRisk(symbols, params);
|
|
7976
7987
|
}
|
|
@@ -7981,7 +7992,7 @@ class binance extends binance$1 {
|
|
|
7981
7992
|
return await this.fetchOptionPositions(symbols, params);
|
|
7982
7993
|
}
|
|
7983
7994
|
else {
|
|
7984
|
-
throw new errors.NotSupported(this.id + '.options["fetchPositions"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
|
|
7995
|
+
throw new errors.NotSupported(this.id + '.options["fetchPositions"]/params["method"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
|
|
7985
7996
|
}
|
|
7986
7997
|
}
|
|
7987
7998
|
async fetchAccountPositions(symbols = undefined, params = {}) {
|
|
@@ -54,6 +54,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
54
54
|
'fetchMarkOHLCV': false,
|
|
55
55
|
'fetchMyTrades': true,
|
|
56
56
|
'fetchOHLCV': true,
|
|
57
|
+
'fetchOpenInterest': true,
|
|
57
58
|
'fetchOpenOrder': true,
|
|
58
59
|
'fetchOpenOrders': true,
|
|
59
60
|
'fetchOrder': true,
|
|
@@ -2985,6 +2986,94 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2985
2986
|
'previousFundingDatetime': undefined,
|
|
2986
2987
|
};
|
|
2987
2988
|
}
|
|
2989
|
+
async fetchOpenInterest(symbol, params = {}) {
|
|
2990
|
+
/**
|
|
2991
|
+
* @method
|
|
2992
|
+
* @name bitfinex2#fetchOpenInterest
|
|
2993
|
+
* @description retrieves the open interest of a contract trading pair
|
|
2994
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2995
|
+
* @param {string} symbol unified CCXT market symbol
|
|
2996
|
+
* @param {object} [params] exchange specific parameters
|
|
2997
|
+
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
2998
|
+
*/
|
|
2999
|
+
await this.loadMarkets();
|
|
3000
|
+
const market = this.market(symbol);
|
|
3001
|
+
const request = {
|
|
3002
|
+
'keys': market['id'],
|
|
3003
|
+
};
|
|
3004
|
+
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3005
|
+
//
|
|
3006
|
+
// [
|
|
3007
|
+
// [
|
|
3008
|
+
// "tXRPF0:USTF0", // market id
|
|
3009
|
+
// 1706256986000, // millisecond timestamp
|
|
3010
|
+
// null,
|
|
3011
|
+
// 0.512705, // derivative mid price
|
|
3012
|
+
// 0.512395, // underlying spot mid price
|
|
3013
|
+
// null,
|
|
3014
|
+
// 37671483.04, // insurance fund balance
|
|
3015
|
+
// null,
|
|
3016
|
+
// 1706284800000, // timestamp of next funding
|
|
3017
|
+
// 0.00002353, // accrued funding for next period
|
|
3018
|
+
// 317, // next funding step
|
|
3019
|
+
// null,
|
|
3020
|
+
// 0, // current funding
|
|
3021
|
+
// null,
|
|
3022
|
+
// null,
|
|
3023
|
+
// 0.5123016, // mark price
|
|
3024
|
+
// null,
|
|
3025
|
+
// null,
|
|
3026
|
+
// 2233562.03115, // open interest in contracts
|
|
3027
|
+
// null,
|
|
3028
|
+
// null,
|
|
3029
|
+
// null,
|
|
3030
|
+
// 0.0005, // average spread without funding payment
|
|
3031
|
+
// 0.0025 // funding payment cap
|
|
3032
|
+
// ]
|
|
3033
|
+
// ]
|
|
3034
|
+
//
|
|
3035
|
+
return this.parseOpenInterest(response[0], market);
|
|
3036
|
+
}
|
|
3037
|
+
parseOpenInterest(interest, market = undefined) {
|
|
3038
|
+
//
|
|
3039
|
+
// [
|
|
3040
|
+
// "tXRPF0:USTF0", // market id
|
|
3041
|
+
// 1706256986000, // millisecond timestamp
|
|
3042
|
+
// null,
|
|
3043
|
+
// 0.512705, // derivative mid price
|
|
3044
|
+
// 0.512395, // underlying spot mid price
|
|
3045
|
+
// null,
|
|
3046
|
+
// 37671483.04, // insurance fund balance
|
|
3047
|
+
// null,
|
|
3048
|
+
// 1706284800000, // timestamp of next funding
|
|
3049
|
+
// 0.00002353, // accrued funding for next period
|
|
3050
|
+
// 317, // next funding step
|
|
3051
|
+
// null,
|
|
3052
|
+
// 0, // current funding
|
|
3053
|
+
// null,
|
|
3054
|
+
// null,
|
|
3055
|
+
// 0.5123016, // mark price
|
|
3056
|
+
// null,
|
|
3057
|
+
// null,
|
|
3058
|
+
// 2233562.03115, // open interest in contracts
|
|
3059
|
+
// null,
|
|
3060
|
+
// null,
|
|
3061
|
+
// null,
|
|
3062
|
+
// 0.0005, // average spread without funding payment
|
|
3063
|
+
// 0.0025 // funding payment cap
|
|
3064
|
+
// ]
|
|
3065
|
+
//
|
|
3066
|
+
const timestamp = this.safeInteger(interest, 1);
|
|
3067
|
+
const marketId = this.safeString(interest, 0);
|
|
3068
|
+
return this.safeOpenInterest({
|
|
3069
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3070
|
+
'openInterestAmount': this.safeNumber(interest, 18),
|
|
3071
|
+
'openInterestValue': undefined,
|
|
3072
|
+
'timestamp': timestamp,
|
|
3073
|
+
'datetime': this.iso8601(timestamp),
|
|
3074
|
+
'info': interest,
|
|
3075
|
+
}, market);
|
|
3076
|
+
}
|
|
2988
3077
|
}
|
|
2989
3078
|
|
|
2990
3079
|
module.exports = bitfinex2;
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -37,15 +37,21 @@ class bitget extends bitget$1 {
|
|
|
37
37
|
'cancelOrders': true,
|
|
38
38
|
'closeAllPositions': true,
|
|
39
39
|
'closePosition': true,
|
|
40
|
+
'createDepositAddress': false,
|
|
40
41
|
'createMarketBuyOrderWithCost': true,
|
|
41
42
|
'createMarketOrderWithCost': false,
|
|
42
43
|
'createMarketSellOrderWithCost': false,
|
|
43
44
|
'createOrder': true,
|
|
44
45
|
'createOrders': true,
|
|
45
46
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
47
|
+
'createPostOnlyOrder': true,
|
|
46
48
|
'createReduceOnlyOrder': false,
|
|
49
|
+
'createStopLimitOrder': true,
|
|
47
50
|
'createStopLossOrder': true,
|
|
51
|
+
'createStopMarketOrder': true,
|
|
52
|
+
'createStopOrder': true,
|
|
48
53
|
'createTakeProfitOrder': true,
|
|
54
|
+
'createTrailingAmountOrder': false,
|
|
49
55
|
'createTrailingPercentOrder': true,
|
|
50
56
|
'createTriggerOrder': true,
|
|
51
57
|
'editOrder': true,
|
|
@@ -63,6 +69,7 @@ class bitget extends bitget$1 {
|
|
|
63
69
|
'fetchDepositAddress': true,
|
|
64
70
|
'fetchDepositAddresses': false,
|
|
65
71
|
'fetchDeposits': true,
|
|
72
|
+
'fetchDepositsWithdrawals': false,
|
|
66
73
|
'fetchDepositWithdrawFee': 'emulated',
|
|
67
74
|
'fetchDepositWithdrawFees': true,
|
|
68
75
|
'fetchFundingHistory': true,
|
|
@@ -76,7 +83,7 @@ class bitget extends bitget$1 {
|
|
|
76
83
|
'fetchLeverage': true,
|
|
77
84
|
'fetchLeverageTiers': false,
|
|
78
85
|
'fetchLiquidations': false,
|
|
79
|
-
'fetchMarginMode':
|
|
86
|
+
'fetchMarginMode': false,
|
|
80
87
|
'fetchMarketLeverageTiers': true,
|
|
81
88
|
'fetchMarkets': true,
|
|
82
89
|
'fetchMarkOHLCV': true,
|
|
@@ -101,8 +108,10 @@ class bitget extends bitget$1 {
|
|
|
101
108
|
'fetchTrades': true,
|
|
102
109
|
'fetchTradingFee': true,
|
|
103
110
|
'fetchTradingFees': true,
|
|
111
|
+
'fetchTransactions': false,
|
|
104
112
|
'fetchTransfer': false,
|
|
105
113
|
'fetchTransfers': true,
|
|
114
|
+
'fetchWithdrawAddresses': false,
|
|
106
115
|
'fetchWithdrawal': false,
|
|
107
116
|
'fetchWithdrawals': true,
|
|
108
117
|
'reduceMargin': true,
|
|
@@ -111,6 +120,7 @@ class bitget extends bitget$1 {
|
|
|
111
120
|
'setLeverage': true,
|
|
112
121
|
'setMarginMode': true,
|
|
113
122
|
'setPositionMode': true,
|
|
123
|
+
'signIn': false,
|
|
114
124
|
'transfer': true,
|
|
115
125
|
'withdraw': true,
|
|
116
126
|
},
|
package/dist/cjs/src/bitrue.js
CHANGED
|
@@ -52,6 +52,7 @@ class bitrue extends bitrue$1 {
|
|
|
52
52
|
'fetchDepositsWithdrawals': false,
|
|
53
53
|
'fetchDepositWithdrawFee': 'emulated',
|
|
54
54
|
'fetchDepositWithdrawFees': true,
|
|
55
|
+
'fetchFundingRate': false,
|
|
55
56
|
'fetchIsolatedBorrowRate': false,
|
|
56
57
|
'fetchIsolatedBorrowRates': false,
|
|
57
58
|
'fetchMarginMode': false,
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -38,7 +38,7 @@ class bybit extends bybit$1 {
|
|
|
38
38
|
'closeAllPositions': false,
|
|
39
39
|
'closePosition': false,
|
|
40
40
|
'createMarketBuyOrderWithCost': true,
|
|
41
|
-
'createMarketSellOrderWithCost':
|
|
41
|
+
'createMarketSellOrderWithCost': true,
|
|
42
42
|
'createOrder': true,
|
|
43
43
|
'createOrders': true,
|
|
44
44
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
@@ -3468,8 +3468,30 @@ class bybit extends bybit$1 {
|
|
|
3468
3468
|
if (!market['spot']) {
|
|
3469
3469
|
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
3470
3470
|
}
|
|
3471
|
-
|
|
3472
|
-
|
|
3471
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, 1, params);
|
|
3472
|
+
}
|
|
3473
|
+
async createMarketSellOrderWithCost(symbol, cost, params = {}) {
|
|
3474
|
+
/**
|
|
3475
|
+
* @method
|
|
3476
|
+
* @name bybit#createMarkeSellOrderWithCost
|
|
3477
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/create-order
|
|
3478
|
+
* @description create a market sell order by providing the symbol and cost
|
|
3479
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3480
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
3481
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3482
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3483
|
+
*/
|
|
3484
|
+
await this.loadMarkets();
|
|
3485
|
+
const types = await this.isUnifiedEnabled();
|
|
3486
|
+
const enableUnifiedAccount = types[1];
|
|
3487
|
+
if (!enableUnifiedAccount) {
|
|
3488
|
+
throw new errors.NotSupported(this.id + ' createMarketSellOrderWithCost() supports UTA accounts only');
|
|
3489
|
+
}
|
|
3490
|
+
const market = this.market(symbol);
|
|
3491
|
+
if (!market['spot']) {
|
|
3492
|
+
throw new errors.NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot orders only');
|
|
3493
|
+
}
|
|
3494
|
+
return await this.createOrder(symbol, 'market', 'sell', cost, 1, params);
|
|
3473
3495
|
}
|
|
3474
3496
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
3475
3497
|
/**
|
|
@@ -3513,7 +3535,7 @@ class bybit extends bybit$1 {
|
|
|
3513
3535
|
}
|
|
3514
3536
|
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3515
3537
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3516
|
-
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
3538
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
|
|
3517
3539
|
let response = undefined;
|
|
3518
3540
|
if (isTrailingAmountOrder) {
|
|
3519
3541
|
response = await this.privatePostV5PositionTradingStop(orderRequest);
|
|
@@ -3536,7 +3558,7 @@ class bybit extends bybit$1 {
|
|
|
3536
3558
|
const order = this.safeValue(response, 'result', {});
|
|
3537
3559
|
return this.parseOrder(order, market);
|
|
3538
3560
|
}
|
|
3539
|
-
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
3561
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}, isUTA = true) {
|
|
3540
3562
|
const market = this.market(symbol);
|
|
3541
3563
|
symbol = market['symbol'];
|
|
3542
3564
|
const lowerCaseType = type.toLowerCase();
|
|
@@ -3580,12 +3602,36 @@ class bybit extends bybit$1 {
|
|
|
3580
3602
|
else if (market['option']) {
|
|
3581
3603
|
request['category'] = 'option';
|
|
3582
3604
|
}
|
|
3583
|
-
|
|
3605
|
+
const cost = this.safeString(params, 'cost');
|
|
3606
|
+
params = this.omit(params, 'cost');
|
|
3607
|
+
// if the cost is inferable, let's keep the old logic and ignore marketUnit, to minimize the impact of the changes
|
|
3608
|
+
const isMarketBuyAndCostInferable = (lowerCaseType === 'market') && (side === 'buy') && ((price !== undefined) || (cost !== undefined));
|
|
3609
|
+
if (market['spot'] && (type === 'market') && isUTA && !isMarketBuyAndCostInferable) {
|
|
3610
|
+
// UTA account can specify the cost of the order on both sides
|
|
3611
|
+
if ((cost !== undefined) || (price !== undefined)) {
|
|
3612
|
+
request['marketUnit'] = 'quoteCoin';
|
|
3613
|
+
let orderCost = undefined;
|
|
3614
|
+
if (cost !== undefined) {
|
|
3615
|
+
orderCost = cost;
|
|
3616
|
+
}
|
|
3617
|
+
else {
|
|
3618
|
+
const amountString = this.numberToString(amount);
|
|
3619
|
+
const priceString = this.numberToString(price);
|
|
3620
|
+
const quoteAmount = Precise["default"].stringMul(amountString, priceString);
|
|
3621
|
+
orderCost = quoteAmount;
|
|
3622
|
+
}
|
|
3623
|
+
request['qty'] = this.costToPrecision(symbol, orderCost);
|
|
3624
|
+
}
|
|
3625
|
+
else {
|
|
3626
|
+
request['marketUnit'] = 'baseCoin';
|
|
3627
|
+
request['qty'] = this.amountToPrecision(symbol, amount);
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
else if (market['spot'] && (type === 'market') && (side === 'buy')) {
|
|
3631
|
+
// classic accounts
|
|
3584
3632
|
// for market buy it requires the amount of quote currency to spend
|
|
3585
3633
|
let createMarketBuyOrderRequiresPrice = true;
|
|
3586
3634
|
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
3587
|
-
const cost = this.safeNumber(params, 'cost');
|
|
3588
|
-
params = this.omit(params, 'cost');
|
|
3589
3635
|
if (createMarketBuyOrderRequiresPrice) {
|
|
3590
3636
|
if ((price === undefined) && (cost === undefined)) {
|
|
3591
3637
|
throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
|
|
@@ -3712,6 +3758,8 @@ class bybit extends bybit$1 {
|
|
|
3712
3758
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3713
3759
|
*/
|
|
3714
3760
|
await this.loadMarkets();
|
|
3761
|
+
const accounts = await this.isUnifiedEnabled();
|
|
3762
|
+
const isUta = accounts[1];
|
|
3715
3763
|
const ordersRequests = [];
|
|
3716
3764
|
const orderSymbols = [];
|
|
3717
3765
|
for (let i = 0; i < orders.length; i++) {
|
|
@@ -3723,7 +3771,7 @@ class bybit extends bybit$1 {
|
|
|
3723
3771
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
3724
3772
|
const price = this.safeValue(rawOrder, 'price');
|
|
3725
3773
|
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
3726
|
-
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
3774
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams, isUta);
|
|
3727
3775
|
ordersRequests.push(orderRequest);
|
|
3728
3776
|
}
|
|
3729
3777
|
const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -1577,8 +1577,9 @@ class coinex extends coinex$1 {
|
|
|
1577
1577
|
*/
|
|
1578
1578
|
let marketType = undefined;
|
|
1579
1579
|
[marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1580
|
-
|
|
1581
|
-
|
|
1580
|
+
let marginMode = undefined;
|
|
1581
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
1582
|
+
marketType = (marginMode !== undefined) ? 'margin' : marketType;
|
|
1582
1583
|
params = this.omit(params, 'margin');
|
|
1583
1584
|
if (marketType === 'margin') {
|
|
1584
1585
|
return await this.fetchMarginBalance(params);
|
|
@@ -2108,8 +2109,9 @@ class coinex extends coinex$1 {
|
|
|
2108
2109
|
}
|
|
2109
2110
|
}
|
|
2110
2111
|
const accountId = this.safeInteger(params, 'account_id');
|
|
2111
|
-
|
|
2112
|
-
|
|
2112
|
+
let marginMode = undefined;
|
|
2113
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
2114
|
+
if (marginMode !== undefined) {
|
|
2113
2115
|
if (accountId === undefined) {
|
|
2114
2116
|
throw new errors.BadRequest(this.id + ' createOrder() requires an account_id parameter for margin orders');
|
|
2115
2117
|
}
|
|
@@ -2628,9 +2630,10 @@ class coinex extends coinex$1 {
|
|
|
2628
2630
|
'market': market['id'],
|
|
2629
2631
|
};
|
|
2630
2632
|
const accountId = this.safeInteger(params, 'account_id');
|
|
2631
|
-
|
|
2633
|
+
let marginMode = undefined;
|
|
2634
|
+
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
2632
2635
|
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
2633
|
-
if (
|
|
2636
|
+
if (marginMode !== undefined) {
|
|
2634
2637
|
if (accountId === undefined) {
|
|
2635
2638
|
throw new errors.BadRequest(this.id + ' cancelOrder() requires an account_id parameter for margin orders');
|
|
2636
2639
|
}
|
|
@@ -3002,8 +3005,9 @@ class coinex extends coinex$1 {
|
|
|
3002
3005
|
}
|
|
3003
3006
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
3004
3007
|
const accountId = this.safeInteger(params, 'account_id');
|
|
3005
|
-
|
|
3006
|
-
|
|
3008
|
+
let marginMode = undefined;
|
|
3009
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
|
|
3010
|
+
if (marginMode !== undefined) {
|
|
3007
3011
|
if (accountId === undefined) {
|
|
3008
3012
|
throw new errors.BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
|
|
3009
3013
|
}
|
|
@@ -3406,8 +3410,9 @@ class coinex extends coinex$1 {
|
|
|
3406
3410
|
}
|
|
3407
3411
|
const swap = (type === 'swap');
|
|
3408
3412
|
const accountId = this.safeInteger(params, 'account_id');
|
|
3409
|
-
|
|
3410
|
-
|
|
3413
|
+
let marginMode = undefined;
|
|
3414
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
3415
|
+
if (marginMode !== undefined) {
|
|
3411
3416
|
if (accountId === undefined) {
|
|
3412
3417
|
throw new errors.BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
|
|
3413
3418
|
}
|
|
@@ -3509,11 +3514,17 @@ class coinex extends coinex$1 {
|
|
|
3509
3514
|
* @name coinex#fetchPositions
|
|
3510
3515
|
* @description fetch all open positions
|
|
3511
3516
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
|
|
3512
|
-
* @
|
|
3517
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
|
|
3518
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3513
3519
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3520
|
+
* @param {string} [params.method] the method to use 'perpetualPrivateGetPositionPending' or 'perpetualPrivateGetPositionFinished' default is 'perpetualPrivateGetPositionPending'
|
|
3521
|
+
* @param {int} [params.side] *history endpoint only* 0: All, 1: Sell, 2: Buy, default is 0
|
|
3514
3522
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3515
3523
|
*/
|
|
3516
3524
|
await this.loadMarkets();
|
|
3525
|
+
let defaultMethod = undefined;
|
|
3526
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'perpetualPrivateGetPositionPending');
|
|
3527
|
+
const isHistory = (defaultMethod === 'perpetualPrivateGetPositionFinished');
|
|
3517
3528
|
symbols = this.marketSymbols(symbols);
|
|
3518
3529
|
const request = {};
|
|
3519
3530
|
let market = undefined;
|
|
@@ -3532,7 +3543,22 @@ class coinex extends coinex$1 {
|
|
|
3532
3543
|
market = this.market(symbol);
|
|
3533
3544
|
request['market'] = market['id'];
|
|
3534
3545
|
}
|
|
3535
|
-
|
|
3546
|
+
else {
|
|
3547
|
+
if (isHistory) {
|
|
3548
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchPositions() requires a symbol argument for closed positions');
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
if (isHistory) {
|
|
3552
|
+
request['limit'] = 100;
|
|
3553
|
+
request['side'] = this.safeInteger(params, 'side', 0); // 0: All, 1: Sell, 2: Buy
|
|
3554
|
+
}
|
|
3555
|
+
let response = undefined;
|
|
3556
|
+
if (defaultMethod === 'perpetualPrivateGetPositionPending') {
|
|
3557
|
+
response = await this.perpetualPrivateGetPositionPending(this.extend(request, params));
|
|
3558
|
+
}
|
|
3559
|
+
else {
|
|
3560
|
+
response = await this.perpetualPrivateGetPositionFinished(this.extend(request, params));
|
|
3561
|
+
}
|
|
3536
3562
|
//
|
|
3537
3563
|
// {
|
|
3538
3564
|
// "code": 0,
|
|
@@ -4732,9 +4758,10 @@ class coinex extends coinex$1 {
|
|
|
4732
4758
|
request['limit'] = 100;
|
|
4733
4759
|
}
|
|
4734
4760
|
params = this.omit(params, 'page');
|
|
4735
|
-
|
|
4761
|
+
let marginMode = undefined;
|
|
4762
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
|
|
4736
4763
|
let response = undefined;
|
|
4737
|
-
if (
|
|
4764
|
+
if (marginMode !== undefined) {
|
|
4738
4765
|
response = await this.privateGetMarginTransferHistory(this.extend(request, params));
|
|
4739
4766
|
}
|
|
4740
4767
|
else {
|
|
@@ -5315,6 +5342,25 @@ class coinex extends coinex$1 {
|
|
|
5315
5342
|
}
|
|
5316
5343
|
return depositWithdrawFees;
|
|
5317
5344
|
}
|
|
5345
|
+
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
5346
|
+
/**
|
|
5347
|
+
* @ignore
|
|
5348
|
+
* @method
|
|
5349
|
+
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
|
|
5350
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
5351
|
+
* @returns {Array} the marginMode in lowercase
|
|
5352
|
+
*/
|
|
5353
|
+
const defaultType = this.safeString(this.options, 'defaultType');
|
|
5354
|
+
const isMargin = this.safeValue(params, 'margin', false);
|
|
5355
|
+
let marginMode = undefined;
|
|
5356
|
+
[marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
|
|
5357
|
+
if (marginMode === undefined) {
|
|
5358
|
+
if ((defaultType === 'margin') || (isMargin === true)) {
|
|
5359
|
+
marginMode = 'isolated';
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
return [marginMode, params];
|
|
5363
|
+
}
|
|
5318
5364
|
nonce() {
|
|
5319
5365
|
return this.milliseconds();
|
|
5320
5366
|
}
|