ccxt 4.0.101 → 4.0.102
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 +616 -2458
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -4
- package/dist/cjs/src/binance.js +8 -0
- package/dist/cjs/src/bingx.js +41 -4
- package/dist/cjs/src/bitmart.js +69 -0
- package/dist/cjs/src/bl3p.js +8 -0
- package/dist/cjs/src/bybit.js +73 -49
- 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/js/ccxt.d.ts +2 -5
- package/js/ccxt.js +2 -4
- 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/binance.js +8 -0
- package/js/src/bingx.js +41 -4
- package/js/src/bitmart.d.ts +38 -0
- package/js/src/bitmart.js +69 -0
- package/js/src/bl3p.js +8 -0
- package/js/src/bybit.js +73 -49
- 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/package.json +1 -1
- package/skip-tests.json +3 -7
- package/js/src/abstract/bkex.d.ts +0 -61
- package/js/src/abstract/bkex.js +0 -11
package/dist/cjs/ccxt.js
CHANGED
|
@@ -43,7 +43,6 @@ var bitstamp = require('./src/bitstamp.js');
|
|
|
43
43
|
var bitstamp1 = require('./src/bitstamp1.js');
|
|
44
44
|
var bittrex = require('./src/bittrex.js');
|
|
45
45
|
var bitvavo = require('./src/bitvavo.js');
|
|
46
|
-
var bkex = require('./src/bkex.js');
|
|
47
46
|
var bl3p = require('./src/bl3p.js');
|
|
48
47
|
var blockchaincom = require('./src/blockchaincom.js');
|
|
49
48
|
var btcalpha = require('./src/btcalpha.js');
|
|
@@ -180,7 +179,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
180
179
|
|
|
181
180
|
//-----------------------------------------------------------------------------
|
|
182
181
|
// this is updated by vss.js when building
|
|
183
|
-
const version = '4.0.
|
|
182
|
+
const version = '4.0.102';
|
|
184
183
|
Exchange["default"].ccxtVersion = version;
|
|
185
184
|
const exchanges = {
|
|
186
185
|
'ace': ace,
|
|
@@ -214,7 +213,6 @@ const exchanges = {
|
|
|
214
213
|
'bitstamp1': bitstamp1,
|
|
215
214
|
'bittrex': bittrex,
|
|
216
215
|
'bitvavo': bitvavo,
|
|
217
|
-
'bkex': bkex,
|
|
218
216
|
'bl3p': bl3p,
|
|
219
217
|
'blockchaincom': blockchaincom,
|
|
220
218
|
'btcalpha': btcalpha,
|
|
@@ -422,7 +420,6 @@ exports.bitstamp = bitstamp;
|
|
|
422
420
|
exports.bitstamp1 = bitstamp1;
|
|
423
421
|
exports.bittrex = bittrex;
|
|
424
422
|
exports.bitvavo = bitvavo;
|
|
425
|
-
exports.bkex = bkex;
|
|
426
423
|
exports.bl3p = bl3p;
|
|
427
424
|
exports.blockchaincom = blockchaincom;
|
|
428
425
|
exports.btcalpha = btcalpha;
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -400,6 +400,7 @@ class binance extends binance$1 {
|
|
|
400
400
|
'portfolio/interest-history': 0.6667,
|
|
401
401
|
'portfolio/asset-index-price': 0.1,
|
|
402
402
|
'portfolio/repay-futures-switch': 3,
|
|
403
|
+
'portfolio/margin-asset-leverage': 5,
|
|
403
404
|
// staking
|
|
404
405
|
'staking/productList': 0.1,
|
|
405
406
|
'staking/position': 0.1,
|
|
@@ -412,6 +413,11 @@ class binance extends binance$1 {
|
|
|
412
413
|
'lending/auto-invest/plan/list': 0.1,
|
|
413
414
|
'lending/auto-invest/plan/id': 0.1,
|
|
414
415
|
'lending/auto-invest/history/list': 0.1,
|
|
416
|
+
'lending/auto-invest/index/info': 0.1,
|
|
417
|
+
'lending/auto-invest/index/user-summary': 0.1,
|
|
418
|
+
'lending/auto-invest/one-off/status': 0.1,
|
|
419
|
+
'lending/auto-invest/redeem/history': 0.1,
|
|
420
|
+
'lending/auto-invest/rebalance/history': 0.1,
|
|
415
421
|
// simple earn
|
|
416
422
|
'simple-earn/flexible/list': 15,
|
|
417
423
|
'simple-earn/locked/list': 15,
|
|
@@ -539,6 +545,8 @@ class binance extends binance$1 {
|
|
|
539
545
|
'lending/auto-invest/plan/add': 0.1,
|
|
540
546
|
'lending/auto-invest/plan/edit': 0.1,
|
|
541
547
|
'lending/auto-invest/plan/edit-status': 0.1,
|
|
548
|
+
'lending/auto-invest/one-off': 0.1,
|
|
549
|
+
'lending/auto-invest/redeem': 0.1,
|
|
542
550
|
// simple earn
|
|
543
551
|
'simple-earn/flexible/subscribe': 0.1,
|
|
544
552
|
'simple-earn/locked/subscribe': 0.1,
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -136,6 +136,7 @@ class bingx extends bingx$1 {
|
|
|
136
136
|
'quote/klines': 1,
|
|
137
137
|
'quote/openInterest': 1,
|
|
138
138
|
'quote/ticker': 1,
|
|
139
|
+
'quote/bookTicker': 1,
|
|
139
140
|
},
|
|
140
141
|
},
|
|
141
142
|
'private': {
|
|
@@ -187,11 +188,17 @@ class bingx extends bingx$1 {
|
|
|
187
188
|
'private': {
|
|
188
189
|
'get': {
|
|
189
190
|
'capital/config/getall': 3,
|
|
191
|
+
'capital/deposit/address': 1,
|
|
192
|
+
'capital/innerTransfer/records': 1,
|
|
193
|
+
'capital/subAccount/deposit/address': 1,
|
|
194
|
+
'capital/deposit/subHisrec': 1,
|
|
195
|
+
'capital/subAccount/innerTransfer/records': 1,
|
|
190
196
|
},
|
|
191
197
|
'post': {
|
|
192
198
|
'capital/withdraw/apply': 3,
|
|
193
199
|
'capital/innerTransfer/apply': 3,
|
|
194
200
|
'capital/subAccountInnerTransfer/apply': 3,
|
|
201
|
+
'capital/deposit/createSubAddress': 1,
|
|
195
202
|
},
|
|
196
203
|
},
|
|
197
204
|
},
|
|
@@ -202,6 +209,7 @@ class bingx extends bingx$1 {
|
|
|
202
209
|
'get': {
|
|
203
210
|
'list': 3,
|
|
204
211
|
'assets': 3,
|
|
212
|
+
'apiKey/query': 1,
|
|
205
213
|
},
|
|
206
214
|
'post': {
|
|
207
215
|
'create': 3,
|
|
@@ -216,13 +224,42 @@ class bingx extends bingx$1 {
|
|
|
216
224
|
'account': {
|
|
217
225
|
'v1': {
|
|
218
226
|
'private': {
|
|
227
|
+
'get': {
|
|
228
|
+
'uid': 1,
|
|
229
|
+
},
|
|
219
230
|
'post': {
|
|
220
|
-
'uid': 3,
|
|
221
231
|
'innerTransfer/authorizeSubAccount': 3,
|
|
222
232
|
},
|
|
223
233
|
},
|
|
224
234
|
},
|
|
225
235
|
},
|
|
236
|
+
'copyTrading': {
|
|
237
|
+
'v1': {
|
|
238
|
+
'private': {
|
|
239
|
+
'get': {
|
|
240
|
+
'swap/trace/currentTrack': 1,
|
|
241
|
+
},
|
|
242
|
+
'post': {
|
|
243
|
+
'swap/trace/closeTrackOrder': 1,
|
|
244
|
+
'swap/trace/setTPSL': 1,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
'api': {
|
|
250
|
+
'v3': {
|
|
251
|
+
'private': {
|
|
252
|
+
'get': {
|
|
253
|
+
'asset/transfer': 1,
|
|
254
|
+
'capital/deposit/hisrec': 1,
|
|
255
|
+
'capital/withdraw/history': 1,
|
|
256
|
+
},
|
|
257
|
+
'post': {
|
|
258
|
+
'post/asset/transfer': 1,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
226
263
|
},
|
|
227
264
|
'timeframes': {
|
|
228
265
|
'1m': '1m',
|
|
@@ -1486,9 +1523,9 @@ class bingx extends bingx$1 {
|
|
|
1486
1523
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1487
1524
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
1488
1525
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
1489
|
-
* @param {
|
|
1490
|
-
* @param {float} [params.stopLossPrice] stop loss trigger price
|
|
1491
|
-
* @param {float} [params.takeProfitPrice] take profit trigger price
|
|
1526
|
+
* @param {float} [params.triggerPrice] *swap only* triggerPrice at which the attached take profit / stop loss order will be triggered
|
|
1527
|
+
* @param {float} [params.stopLossPrice] *swap only* stop loss trigger price
|
|
1528
|
+
* @param {float} [params.takeProfitPrice] *swap only* take profit trigger price
|
|
1492
1529
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
1493
1530
|
*/
|
|
1494
1531
|
await this.loadMarkets();
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -57,6 +57,9 @@ class bitmart extends bitmart$1 {
|
|
|
57
57
|
'fetchDepositWithdrawFee': true,
|
|
58
58
|
'fetchDepositWithdrawFees': false,
|
|
59
59
|
'fetchFundingHistory': undefined,
|
|
60
|
+
'fetchFundingRate': true,
|
|
61
|
+
'fetchFundingRateHistory': false,
|
|
62
|
+
'fetchFundingRates': false,
|
|
60
63
|
'fetchMarginMode': false,
|
|
61
64
|
'fetchMarkets': true,
|
|
62
65
|
'fetchMyTrades': true,
|
|
@@ -3250,6 +3253,72 @@ class bitmart extends bitmart$1 {
|
|
|
3250
3253
|
};
|
|
3251
3254
|
return await this.privatePostContractPrivateSubmitLeverage(this.extend(request, params));
|
|
3252
3255
|
}
|
|
3256
|
+
async fetchFundingRate(symbol, params = {}) {
|
|
3257
|
+
/**
|
|
3258
|
+
* @method
|
|
3259
|
+
* @name bitmart#fetchFundingRate
|
|
3260
|
+
* @description fetch the current funding rate
|
|
3261
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-current-funding-rate
|
|
3262
|
+
* @param {string} symbol unified market symbol
|
|
3263
|
+
* @param {object} [params] extra parameters specific to the bitmart api endpoint
|
|
3264
|
+
* @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
|
|
3265
|
+
*/
|
|
3266
|
+
await this.loadMarkets();
|
|
3267
|
+
const market = this.market(symbol);
|
|
3268
|
+
if (!market['swap']) {
|
|
3269
|
+
throw new errors.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
|
|
3270
|
+
}
|
|
3271
|
+
const request = {
|
|
3272
|
+
'symbol': market['id'],
|
|
3273
|
+
};
|
|
3274
|
+
const response = await this.publicGetContractPublicFundingRate(this.extend(request, params));
|
|
3275
|
+
//
|
|
3276
|
+
// {
|
|
3277
|
+
// "code": 1000,
|
|
3278
|
+
// "message": "Ok",
|
|
3279
|
+
// "data": {
|
|
3280
|
+
// "timestamp": 1695184410697,
|
|
3281
|
+
// "symbol": "BTCUSDT",
|
|
3282
|
+
// "rate_value": "-0.00002614",
|
|
3283
|
+
// "expected_rate": "-0.00002"
|
|
3284
|
+
// },
|
|
3285
|
+
// "trace": "4cad855074654097ac7ba5257c47305d.54.16951844206655589"
|
|
3286
|
+
// }
|
|
3287
|
+
//
|
|
3288
|
+
const data = this.safeValue(response, 'data', {});
|
|
3289
|
+
return this.parseFundingRate(data, market);
|
|
3290
|
+
}
|
|
3291
|
+
parseFundingRate(contract, market = undefined) {
|
|
3292
|
+
//
|
|
3293
|
+
// {
|
|
3294
|
+
// "timestamp": 1695184410697,
|
|
3295
|
+
// "symbol": "BTCUSDT",
|
|
3296
|
+
// "rate_value": "-0.00002614",
|
|
3297
|
+
// "expected_rate": "-0.00002"
|
|
3298
|
+
// }
|
|
3299
|
+
//
|
|
3300
|
+
const marketId = this.safeString(contract, 'symbol');
|
|
3301
|
+
const timestamp = this.safeInteger(contract, 'timestamp');
|
|
3302
|
+
return {
|
|
3303
|
+
'info': contract,
|
|
3304
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3305
|
+
'markPrice': undefined,
|
|
3306
|
+
'indexPrice': undefined,
|
|
3307
|
+
'interestRate': undefined,
|
|
3308
|
+
'estimatedSettlePrice': undefined,
|
|
3309
|
+
'timestamp': timestamp,
|
|
3310
|
+
'datetime': this.iso8601(timestamp),
|
|
3311
|
+
'fundingRate': this.safeNumber(contract, 'expected_rate'),
|
|
3312
|
+
'fundingTimestamp': undefined,
|
|
3313
|
+
'fundingDatetime': undefined,
|
|
3314
|
+
'nextFundingRate': undefined,
|
|
3315
|
+
'nextFundingTimestamp': undefined,
|
|
3316
|
+
'nextFundingDatetime': undefined,
|
|
3317
|
+
'previousFundingRate': this.safeNumber(contract, 'rate_value'),
|
|
3318
|
+
'previousFundingTimestamp': undefined,
|
|
3319
|
+
'previousFundingDatetime': undefined,
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3253
3322
|
nonce() {
|
|
3254
3323
|
return this.milliseconds();
|
|
3255
3324
|
}
|
package/dist/cjs/src/bl3p.js
CHANGED
|
@@ -32,6 +32,9 @@ class bl3p extends bl3p$1 {
|
|
|
32
32
|
'cancelOrder': true,
|
|
33
33
|
'createOrder': true,
|
|
34
34
|
'createReduceOnlyOrder': false,
|
|
35
|
+
'createStopLimitOrder': false,
|
|
36
|
+
'createStopMarketOrder': false,
|
|
37
|
+
'createStopOrder': false,
|
|
35
38
|
'fetchBalance': true,
|
|
36
39
|
'fetchBorrowRate': false,
|
|
37
40
|
'fetchBorrowRateHistories': false,
|
|
@@ -364,12 +367,17 @@ class bl3p extends bl3p$1 {
|
|
|
364
367
|
* @method
|
|
365
368
|
* @name bl3p#createOrder
|
|
366
369
|
* @description create a trade order
|
|
370
|
+
* @see https://github.com/BitonicNL/bl3p-api/blob/master/examples/nodejs/example.md#21---create-an-order
|
|
367
371
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
368
372
|
* @param {string} type 'market' or 'limit'
|
|
369
373
|
* @param {string} side 'buy' or 'sell'
|
|
370
374
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
371
375
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
372
376
|
* @param {object} [params] extra parameters specific to the bl3p api endpoint
|
|
377
|
+
*
|
|
378
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
379
|
+
* @param {int} [params.amount_funds] maximal EUR amount to spend (*1e5)
|
|
380
|
+
* @param {string} [params.fee_currency] 'EUR' or 'BTC'
|
|
373
381
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
374
382
|
*/
|
|
375
383
|
const market = this.market(symbol);
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -3721,12 +3721,12 @@ class bybit extends bybit$1 {
|
|
|
3721
3721
|
}
|
|
3722
3722
|
else if (isStopLoss || isTakeProfit) {
|
|
3723
3723
|
if (isStopLoss) {
|
|
3724
|
-
const
|
|
3725
|
-
request['stopLoss'] = this.priceToPrecision(symbol,
|
|
3724
|
+
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
3725
|
+
request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
|
|
3726
3726
|
}
|
|
3727
3727
|
if (isTakeProfit) {
|
|
3728
|
-
const
|
|
3729
|
-
request['takeProfit'] = this.priceToPrecision(symbol,
|
|
3728
|
+
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
3729
|
+
request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
3730
3730
|
}
|
|
3731
3731
|
}
|
|
3732
3732
|
if (market['spot']) {
|
|
@@ -3835,12 +3835,12 @@ class bybit extends bybit$1 {
|
|
|
3835
3835
|
}
|
|
3836
3836
|
else if (isStopLoss || isTakeProfit) {
|
|
3837
3837
|
if (isStopLoss) {
|
|
3838
|
-
const
|
|
3839
|
-
request['stopLoss'] = this.priceToPrecision(symbol,
|
|
3838
|
+
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
3839
|
+
request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
|
|
3840
3840
|
}
|
|
3841
3841
|
if (isTakeProfit) {
|
|
3842
|
-
const
|
|
3843
|
-
request['takeProfit'] = this.priceToPrecision(symbol,
|
|
3842
|
+
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
3843
|
+
request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
3844
3844
|
}
|
|
3845
3845
|
}
|
|
3846
3846
|
else {
|
|
@@ -4021,12 +4021,12 @@ class bybit extends bybit$1 {
|
|
|
4021
4021
|
}
|
|
4022
4022
|
if (isStopLoss || isTakeProfit) {
|
|
4023
4023
|
if (isStopLoss) {
|
|
4024
|
-
const
|
|
4025
|
-
request['stopLoss'] = this.priceToPrecision(symbol,
|
|
4024
|
+
const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
4025
|
+
request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
|
|
4026
4026
|
}
|
|
4027
4027
|
if (isTakeProfit) {
|
|
4028
|
-
const
|
|
4029
|
-
request['takeProfit'] = this.priceToPrecision(symbol,
|
|
4028
|
+
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
4029
|
+
request['takeProfit'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
4032
|
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
@@ -5996,12 +5996,10 @@ class bybit extends bybit$1 {
|
|
|
5996
5996
|
await this.loadMarkets();
|
|
5997
5997
|
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
5998
5998
|
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
5999
|
+
let market = undefined;
|
|
5999
6000
|
let response = undefined;
|
|
6000
|
-
if (
|
|
6001
|
+
if (isUnifiedAccount) {
|
|
6001
6002
|
if (marginMode === 'isolated') {
|
|
6002
|
-
if (!isUnifiedAccount) {
|
|
6003
|
-
throw new errors.NotSupported(this.id + ' setMarginMode() Normal Account not support ISOLATED_MARGIN');
|
|
6004
|
-
}
|
|
6005
6003
|
marginMode = 'ISOLATED_MARGIN';
|
|
6006
6004
|
}
|
|
6007
6005
|
else if (marginMode === 'cross') {
|
|
@@ -6019,44 +6017,70 @@ class bybit extends bybit$1 {
|
|
|
6019
6017
|
response = await this.privatePostV5AccountSetMarginMode(this.extend(request, params));
|
|
6020
6018
|
}
|
|
6021
6019
|
else {
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6020
|
+
if (symbol === undefined) {
|
|
6021
|
+
throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol parameter for non unified account');
|
|
6022
|
+
}
|
|
6023
|
+
market = this.market(symbol);
|
|
6024
|
+
const isUsdcSettled = market['settle'] === 'USDC';
|
|
6025
|
+
if (isUsdcSettled) {
|
|
6026
|
+
if (marginMode === 'cross') {
|
|
6027
|
+
marginMode = 'REGULAR_MARGIN';
|
|
6028
6028
|
}
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
throw new errors.NotSupported(this.id + ' setMarginMode() with symbol only support USDT perpetual / inverse contract');
|
|
6029
|
+
else if (marginMode === 'portfolio') {
|
|
6030
|
+
marginMode = 'PORTFOLIO_MARGIN';
|
|
6032
6031
|
}
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
}
|
|
6041
|
-
else if (marginMode === 'isolated') {
|
|
6042
|
-
tradeMode = 1;
|
|
6032
|
+
else {
|
|
6033
|
+
throw new errors.NotSupported(this.id + ' setMarginMode() for usdc market marginMode must be either [cross, portfolio]');
|
|
6034
|
+
}
|
|
6035
|
+
const request = {
|
|
6036
|
+
'setMarginMode': marginMode,
|
|
6037
|
+
};
|
|
6038
|
+
response = await this.privatePostV5AccountSetMarginMode(this.extend(request, params));
|
|
6043
6039
|
}
|
|
6044
6040
|
else {
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6041
|
+
let type = undefined;
|
|
6042
|
+
[type, params] = this.getBybitType('setPositionMode', market, params);
|
|
6043
|
+
let tradeMode = undefined;
|
|
6044
|
+
if (marginMode === 'cross') {
|
|
6045
|
+
tradeMode = 0;
|
|
6046
|
+
}
|
|
6047
|
+
else if (marginMode === 'isolated') {
|
|
6048
|
+
tradeMode = 1;
|
|
6049
|
+
}
|
|
6050
|
+
else {
|
|
6051
|
+
throw new errors.NotSupported(this.id + ' setMarginMode() with symbol marginMode must be either [isolated, cross]');
|
|
6052
|
+
}
|
|
6053
|
+
let sellLeverage = undefined;
|
|
6054
|
+
let buyLeverage = undefined;
|
|
6055
|
+
const leverage = this.safeString(params, 'leverage');
|
|
6056
|
+
if (leverage === undefined) {
|
|
6057
|
+
sellLeverage = this.safeString2(params, 'sell_leverage', 'sellLeverage');
|
|
6058
|
+
buyLeverage = this.safeString2(params, 'buy_leverage', 'buyLeverage');
|
|
6059
|
+
if (sellLeverage === undefined && buyLeverage === undefined) {
|
|
6060
|
+
throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a leverage parameter or sell_leverage and buy_leverage parameters');
|
|
6061
|
+
}
|
|
6062
|
+
if (buyLeverage === undefined) {
|
|
6063
|
+
buyLeverage = sellLeverage;
|
|
6064
|
+
}
|
|
6065
|
+
if (sellLeverage === undefined) {
|
|
6066
|
+
sellLeverage = buyLeverage;
|
|
6067
|
+
}
|
|
6068
|
+
params = this.omit(params, ['buy_leverage', 'sell_leverage', 'sellLeverage', 'buyLeverage']);
|
|
6069
|
+
}
|
|
6070
|
+
else {
|
|
6071
|
+
sellLeverage = leverage;
|
|
6072
|
+
buyLeverage = leverage;
|
|
6073
|
+
params = this.omit(params, 'leverage');
|
|
6074
|
+
}
|
|
6075
|
+
const request = {
|
|
6076
|
+
'category': type,
|
|
6077
|
+
'symbol': market['id'],
|
|
6078
|
+
'tradeMode': tradeMode,
|
|
6079
|
+
'buyLeverage': buyLeverage,
|
|
6080
|
+
'sellLeverage': sellLeverage,
|
|
6081
|
+
};
|
|
6082
|
+
response = await this.privatePostV5PositionSwitchIsolated(this.extend(request, params));
|
|
6051
6083
|
}
|
|
6052
|
-
const request = {
|
|
6053
|
-
'category': type,
|
|
6054
|
-
'symbol': market['id'],
|
|
6055
|
-
'tradeMode': tradeMode,
|
|
6056
|
-
'buyLeverage': leverage,
|
|
6057
|
-
'sellLeverage': leverage,
|
|
6058
|
-
};
|
|
6059
|
-
response = await this.privatePostV5PositionSwitchIsolated(this.extend(request, params));
|
|
6060
6084
|
}
|
|
6061
6085
|
return response;
|
|
6062
6086
|
}
|
package/dist/cjs/src/gemini.js
CHANGED
|
@@ -221,6 +221,7 @@ class gemini extends gemini$1 {
|
|
|
221
221
|
'InsufficientFunds': errors.InsufficientFunds,
|
|
222
222
|
'InvalidJson': errors.BadRequest,
|
|
223
223
|
'InvalidNonce': errors.InvalidNonce,
|
|
224
|
+
'InvalidApiKey': errors.AuthenticationError,
|
|
224
225
|
'InvalidOrderType': errors.InvalidOrder,
|
|
225
226
|
'InvalidPrice': errors.InvalidOrder,
|
|
226
227
|
'InvalidQuantity': errors.InvalidOrder,
|
|
@@ -502,8 +502,8 @@ class binance extends binance$1 {
|
|
|
502
502
|
for (let i = 0; i < symbols.length; i++) {
|
|
503
503
|
const symbol = symbols[i];
|
|
504
504
|
const market = this.market(symbol);
|
|
505
|
-
const
|
|
506
|
-
subParams.push(
|
|
505
|
+
const currentMessageHash = market['lowercaseId'] + '@' + name;
|
|
506
|
+
subParams.push(currentMessageHash);
|
|
507
507
|
}
|
|
508
508
|
const messageHash = 'multipleTrades::' + symbols.join(',');
|
|
509
509
|
const query = this.omit(params, 'type');
|
|
@@ -821,10 +821,10 @@ class binance extends binance$1 {
|
|
|
821
821
|
const hashes = [];
|
|
822
822
|
for (let i = 0; i < symbolsAndTimeframes.length; i++) {
|
|
823
823
|
const data = symbolsAndTimeframes[i];
|
|
824
|
-
const
|
|
825
|
-
const
|
|
826
|
-
const interval = this.safeString(this.timeframes,
|
|
827
|
-
const market = this.market(
|
|
824
|
+
const symbolString = data[0];
|
|
825
|
+
const timeframeString = data[1];
|
|
826
|
+
const interval = this.safeString(this.timeframes, timeframeString, timeframeString);
|
|
827
|
+
const market = this.market(symbolString);
|
|
828
828
|
let marketId = market['lowercaseId'];
|
|
829
829
|
if (name === 'indexPriceKline') {
|
|
830
830
|
// weird behavior for index price kline we can't use the perp suffix
|
|
@@ -832,7 +832,7 @@ class binance extends binance$1 {
|
|
|
832
832
|
}
|
|
833
833
|
const topic = marketId + '@' + name + '_' + interval;
|
|
834
834
|
subParams.push(topic);
|
|
835
|
-
hashes.push(
|
|
835
|
+
hashes.push(symbolString + '#' + timeframeString);
|
|
836
836
|
}
|
|
837
837
|
const messageHash = 'multipleOHLCV::' + hashes.join(',');
|
|
838
838
|
const url = this.urls['api']['ws'][type] + '/' + this.stream(type, messageHash);
|
|
@@ -361,17 +361,17 @@ class bybit extends bybit$1 {
|
|
|
361
361
|
let firstSymbol = undefined;
|
|
362
362
|
for (let i = 0; i < symbolsAndTimeframes.length; i++) {
|
|
363
363
|
const data = symbolsAndTimeframes[i];
|
|
364
|
-
let
|
|
365
|
-
const
|
|
366
|
-
const market = this.market(
|
|
367
|
-
|
|
364
|
+
let symbolString = this.safeString(data, 0);
|
|
365
|
+
const timeframeString = this.safeString(data, 1);
|
|
366
|
+
const market = this.market(symbolString);
|
|
367
|
+
symbolString = market['symbol'];
|
|
368
368
|
if (i === 0) {
|
|
369
369
|
firstSymbol = market['symbol'];
|
|
370
370
|
}
|
|
371
|
-
const timeframeId = this.safeString(this.timeframes,
|
|
371
|
+
const timeframeId = this.safeString(this.timeframes, timeframeString, timeframeString);
|
|
372
372
|
const topic = 'kline.' + timeframeId + '.' + market['id'];
|
|
373
373
|
topics.push(topic);
|
|
374
|
-
hashes.push(
|
|
374
|
+
hashes.push(symbolString + '#' + timeframeString);
|
|
375
375
|
}
|
|
376
376
|
const messageHash = 'multipleOHLCV::' + hashes.join(',');
|
|
377
377
|
const url = this.getUrlByMarketType(firstSymbol, false, params);
|
|
@@ -918,8 +918,8 @@ class bybit extends bybit$1 {
|
|
|
918
918
|
}
|
|
919
919
|
const keys = Object.keys(symbols);
|
|
920
920
|
for (let i = 0; i < keys.length; i++) {
|
|
921
|
-
const
|
|
922
|
-
client.resolve(trades,
|
|
921
|
+
const currentMessageHash = 'myTrades:' + keys[i];
|
|
922
|
+
client.resolve(trades, currentMessageHash);
|
|
923
923
|
}
|
|
924
924
|
// non-symbol specific
|
|
925
925
|
const messageHash = 'myTrades';
|
|
@@ -1051,25 +1051,26 @@ class bybit extends bybit$1 {
|
|
|
1051
1051
|
const first = this.safeValue(rawOrders, 0, {});
|
|
1052
1052
|
const category = this.safeString(first, 'category');
|
|
1053
1053
|
const isSpot = category === 'spot';
|
|
1054
|
-
|
|
1055
|
-
if (isSpot) {
|
|
1056
|
-
parser = 'parseWsSpotOrder';
|
|
1057
|
-
}
|
|
1058
|
-
else {
|
|
1059
|
-
parser = 'parseContractOrder';
|
|
1054
|
+
if (!isSpot) {
|
|
1060
1055
|
rawOrders = this.safeValue(rawOrders, 'result', rawOrders);
|
|
1061
1056
|
}
|
|
1062
1057
|
const symbols = {};
|
|
1063
1058
|
for (let i = 0; i < rawOrders.length; i++) {
|
|
1064
|
-
|
|
1059
|
+
let parsed = undefined;
|
|
1060
|
+
if (isSpot) {
|
|
1061
|
+
parsed = this.parseWsSpotOrder(rawOrders[i]);
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
parsed = this.parseOrder(rawOrders[i]);
|
|
1065
|
+
}
|
|
1065
1066
|
const symbol = parsed['symbol'];
|
|
1066
1067
|
symbols[symbol] = true;
|
|
1067
1068
|
orders.append(parsed);
|
|
1068
1069
|
}
|
|
1069
1070
|
const symbolsArray = Object.keys(symbols);
|
|
1070
1071
|
for (let i = 0; i < symbolsArray.length; i++) {
|
|
1071
|
-
const
|
|
1072
|
-
client.resolve(orders,
|
|
1072
|
+
const currentMessageHash = 'orders:' + symbolsArray[i];
|
|
1073
|
+
client.resolve(orders, currentMessageHash);
|
|
1073
1074
|
}
|
|
1074
1075
|
const messageHash = 'orders';
|
|
1075
1076
|
client.resolve(orders, messageHash);
|
|
@@ -523,11 +523,11 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
523
523
|
// reason: 'filled'
|
|
524
524
|
// }
|
|
525
525
|
//
|
|
526
|
-
let
|
|
527
|
-
if (
|
|
526
|
+
let currentOrders = this.orders;
|
|
527
|
+
if (currentOrders === undefined) {
|
|
528
528
|
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
529
|
-
|
|
530
|
-
this.orders =
|
|
529
|
+
currentOrders = new Cache.ArrayCacheBySymbolById(limit);
|
|
530
|
+
this.orders = currentOrders;
|
|
531
531
|
}
|
|
532
532
|
const type = this.safeString(message, 'type');
|
|
533
533
|
const marketId = this.safeString(message, 'product_id');
|
|
@@ -564,9 +564,9 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
564
564
|
let totalAmount = 0;
|
|
565
565
|
const trades = previousOrder['trades'];
|
|
566
566
|
for (let i = 0; i < trades.length; i++) {
|
|
567
|
-
const
|
|
568
|
-
totalCost = this.sum(totalCost,
|
|
569
|
-
totalAmount = this.sum(totalAmount,
|
|
567
|
+
const tradeEntry = trades[i];
|
|
568
|
+
totalCost = this.sum(totalCost, tradeEntry['cost']);
|
|
569
|
+
totalAmount = this.sum(totalAmount, tradeEntry['amount']);
|
|
570
570
|
}
|
|
571
571
|
if (totalAmount > 0) {
|
|
572
572
|
previousOrder['average'] = totalCost / totalAmount;
|
|
@@ -694,12 +694,12 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
694
694
|
client.resolve(ticker, messageHash);
|
|
695
695
|
const messageHashes = this.findMessageHashes(client, 'tickers::');
|
|
696
696
|
for (let i = 0; i < messageHashes.length; i++) {
|
|
697
|
-
const
|
|
698
|
-
const parts =
|
|
697
|
+
const currentMessageHash = messageHashes[i];
|
|
698
|
+
const parts = currentMessageHash.split('::');
|
|
699
699
|
const symbolsString = parts[1];
|
|
700
700
|
const symbols = symbolsString.split(',');
|
|
701
701
|
if (this.inArray(symbol, symbols)) {
|
|
702
|
-
client.resolve(ticker,
|
|
702
|
+
client.resolve(ticker, currentMessageHash);
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
}
|
|
@@ -235,15 +235,15 @@ class kucoin extends kucoin$1 {
|
|
|
235
235
|
client.resolve(ticker, 'tickers');
|
|
236
236
|
const messageHashes = this.findMessageHashes(client, 'tickers::');
|
|
237
237
|
for (let i = 0; i < messageHashes.length; i++) {
|
|
238
|
-
const
|
|
239
|
-
const parts =
|
|
238
|
+
const currentMessageHash = messageHashes[i];
|
|
239
|
+
const parts = currentMessageHash.split('::');
|
|
240
240
|
const symbolsString = parts[1];
|
|
241
241
|
const symbols = symbolsString.split(',');
|
|
242
242
|
const tickers = this.filterByArray(this.tickers, 'symbol', symbols);
|
|
243
243
|
const tickersSymbols = Object.keys(tickers);
|
|
244
244
|
const numTickers = tickersSymbols.length;
|
|
245
245
|
if (numTickers > 0) {
|
|
246
|
-
client.resolve(tickers,
|
|
246
|
+
client.resolve(tickers, currentMessageHash);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
}
|