ccxt 4.2.20 → 4.2.22
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 +1405 -274
- package/dist/ccxt.browser.min.js +6 -6
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +37 -4
- package/dist/cjs/src/base/ws/WsClient.js +3 -1
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/binance.js +14 -3
- package/dist/cjs/src/bitget.js +12 -2
- package/dist/cjs/src/bitrue.js +1 -0
- package/dist/cjs/src/bitvavo.js +271 -172
- package/dist/cjs/src/blockchaincom.js +3 -1
- package/dist/cjs/src/bybit.js +57 -9
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/coinex.js +37 -12
- package/dist/cjs/src/deribit.js +164 -0
- package/dist/cjs/src/gate.js +32 -1
- package/dist/cjs/src/novadax.js +26 -22
- package/dist/cjs/src/okcoin.js +3 -0
- package/dist/cjs/src/phemex.js +7 -3
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/bequant.js +6 -1
- package/dist/cjs/src/pro/binance.js +7 -4
- 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/bitopro.js +7 -3
- package/dist/cjs/src/pro/bitrue.js +6 -1
- package/dist/cjs/src/pro/bitvavo.js +668 -22
- package/dist/cjs/src/pro/lbank.js +1 -1
- package/dist/cjs/src/pro/okx.js +13 -3
- 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/abstract/gate.d.ts +1 -0
- package/js/src/abstract/gateio.d.ts +1 -0
- package/js/src/abstract/novadax.d.ts +5 -1
- package/js/src/abstract/phemex.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +12 -1
- package/js/src/base/Exchange.js +37 -4
- package/js/src/base/ws/WsClient.js +3 -2
- package/js/src/bigone.js +1 -0
- package/js/src/binance.js +14 -3
- package/js/src/bitget.js +12 -2
- package/js/src/bitrue.js +1 -0
- package/js/src/bitvavo.d.ts +14 -2
- package/js/src/bitvavo.js +271 -172
- package/js/src/blockchaincom.js +3 -1
- 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 +37 -12
- package/js/src/deribit.d.ts +6 -1
- package/js/src/deribit.js +164 -0
- package/js/src/gate.d.ts +1 -0
- package/js/src/gate.js +32 -1
- package/js/src/novadax.js +26 -22
- package/js/src/okcoin.js +3 -0
- package/js/src/phemex.js +7 -3
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/bequant.js +6 -1
- package/js/src/pro/binance.js +7 -4
- 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/bitopro.js +7 -3
- package/js/src/pro/bitrue.js +6 -1
- package/js/src/pro/bitvavo.d.ts +35 -2
- package/js/src/pro/bitvavo.js +669 -23
- package/js/src/pro/lbank.js +1 -1
- package/js/src/pro/okx.js +13 -3
- 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/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
|
}
|
|
@@ -4732,9 +4737,10 @@ class coinex extends coinex$1 {
|
|
|
4732
4737
|
request['limit'] = 100;
|
|
4733
4738
|
}
|
|
4734
4739
|
params = this.omit(params, 'page');
|
|
4735
|
-
|
|
4740
|
+
let marginMode = undefined;
|
|
4741
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
|
|
4736
4742
|
let response = undefined;
|
|
4737
|
-
if (
|
|
4743
|
+
if (marginMode !== undefined) {
|
|
4738
4744
|
response = await this.privateGetMarginTransferHistory(this.extend(request, params));
|
|
4739
4745
|
}
|
|
4740
4746
|
else {
|
|
@@ -5315,6 +5321,25 @@ class coinex extends coinex$1 {
|
|
|
5315
5321
|
}
|
|
5316
5322
|
return depositWithdrawFees;
|
|
5317
5323
|
}
|
|
5324
|
+
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
5325
|
+
/**
|
|
5326
|
+
* @ignore
|
|
5327
|
+
* @method
|
|
5328
|
+
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
|
|
5329
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
5330
|
+
* @returns {Array} the marginMode in lowercase
|
|
5331
|
+
*/
|
|
5332
|
+
const defaultType = this.safeString(this.options, 'defaultType');
|
|
5333
|
+
const isMargin = this.safeValue(params, 'margin', false);
|
|
5334
|
+
let marginMode = undefined;
|
|
5335
|
+
[marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
|
|
5336
|
+
if (marginMode === undefined) {
|
|
5337
|
+
if ((defaultType === 'margin') || (isMargin === true)) {
|
|
5338
|
+
marginMode = 'isolated';
|
|
5339
|
+
}
|
|
5340
|
+
}
|
|
5341
|
+
return [marginMode, params];
|
|
5342
|
+
}
|
|
5318
5343
|
nonce() {
|
|
5319
5344
|
return this.milliseconds();
|
|
5320
5345
|
}
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -402,6 +402,170 @@ class deribit extends deribit$1 {
|
|
|
402
402
|
},
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
+
convertExpireDate(date) {
|
|
406
|
+
// parse YYMMDD to timestamp
|
|
407
|
+
const year = date.slice(0, 2);
|
|
408
|
+
const month = date.slice(2, 4);
|
|
409
|
+
const day = date.slice(4, 6);
|
|
410
|
+
const reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z';
|
|
411
|
+
return reconstructedDate;
|
|
412
|
+
}
|
|
413
|
+
convertMarketIdExpireDate(date) {
|
|
414
|
+
// parse 19JAN24 to 240119
|
|
415
|
+
const monthMappping = {
|
|
416
|
+
'JAN': '01',
|
|
417
|
+
'FEB': '02',
|
|
418
|
+
'MAR': '03',
|
|
419
|
+
'APR': '04',
|
|
420
|
+
'MAY': '05',
|
|
421
|
+
'JUN': '06',
|
|
422
|
+
'JUL': '07',
|
|
423
|
+
'AUG': '08',
|
|
424
|
+
'SEP': '09',
|
|
425
|
+
'OCT': '10',
|
|
426
|
+
'NOV': '11',
|
|
427
|
+
'DEC': '12',
|
|
428
|
+
};
|
|
429
|
+
const year = date.slice(0, 2);
|
|
430
|
+
const monthName = date.slice(2, 5);
|
|
431
|
+
const month = this.safeString(monthMappping, monthName);
|
|
432
|
+
const day = date.slice(5, 7);
|
|
433
|
+
const reconstructedDate = day + month + year;
|
|
434
|
+
return reconstructedDate;
|
|
435
|
+
}
|
|
436
|
+
convertExpireDateToMarketIdDate(date) {
|
|
437
|
+
// parse 240119 to 19JAN24
|
|
438
|
+
const year = date.slice(0, 2);
|
|
439
|
+
const monthRaw = date.slice(2, 4);
|
|
440
|
+
let month = undefined;
|
|
441
|
+
const day = date.slice(4, 6);
|
|
442
|
+
if (monthRaw === '01') {
|
|
443
|
+
month = 'JAN';
|
|
444
|
+
}
|
|
445
|
+
else if (monthRaw === '02') {
|
|
446
|
+
month = 'FEB';
|
|
447
|
+
}
|
|
448
|
+
else if (monthRaw === '03') {
|
|
449
|
+
month = 'MAR';
|
|
450
|
+
}
|
|
451
|
+
else if (monthRaw === '04') {
|
|
452
|
+
month = 'APR';
|
|
453
|
+
}
|
|
454
|
+
else if (monthRaw === '05') {
|
|
455
|
+
month = 'MAY';
|
|
456
|
+
}
|
|
457
|
+
else if (monthRaw === '06') {
|
|
458
|
+
month = 'JUN';
|
|
459
|
+
}
|
|
460
|
+
else if (monthRaw === '07') {
|
|
461
|
+
month = 'JUL';
|
|
462
|
+
}
|
|
463
|
+
else if (monthRaw === '08') {
|
|
464
|
+
month = 'AUG';
|
|
465
|
+
}
|
|
466
|
+
else if (monthRaw === '09') {
|
|
467
|
+
month = 'SEP';
|
|
468
|
+
}
|
|
469
|
+
else if (monthRaw === '10') {
|
|
470
|
+
month = 'OCT';
|
|
471
|
+
}
|
|
472
|
+
else if (monthRaw === '11') {
|
|
473
|
+
month = 'NOV';
|
|
474
|
+
}
|
|
475
|
+
else if (monthRaw === '12') {
|
|
476
|
+
month = 'DEC';
|
|
477
|
+
}
|
|
478
|
+
const reconstructedDate = day + month + year;
|
|
479
|
+
return reconstructedDate;
|
|
480
|
+
}
|
|
481
|
+
createExpiredOptionMarket(symbol) {
|
|
482
|
+
// support expired option contracts
|
|
483
|
+
let quote = 'USD';
|
|
484
|
+
let settle = undefined;
|
|
485
|
+
const optionParts = symbol.split('-');
|
|
486
|
+
const symbolBase = symbol.split('/');
|
|
487
|
+
let base = undefined;
|
|
488
|
+
let expiry = undefined;
|
|
489
|
+
if (symbol.indexOf('/') > -1) {
|
|
490
|
+
base = this.safeString(symbolBase, 0);
|
|
491
|
+
expiry = this.safeString(optionParts, 1);
|
|
492
|
+
if (symbol.indexOf('USDC') > -1) {
|
|
493
|
+
base = base + '_USDC';
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
base = this.safeString(optionParts, 0);
|
|
498
|
+
expiry = this.convertMarketIdExpireDate(this.safeString(optionParts, 1));
|
|
499
|
+
}
|
|
500
|
+
if (symbol.indexOf('USDC') > -1) {
|
|
501
|
+
quote = 'USDC';
|
|
502
|
+
settle = 'USDC';
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
settle = base;
|
|
506
|
+
}
|
|
507
|
+
let splitBase = base;
|
|
508
|
+
if (base.indexOf('_') > -1) {
|
|
509
|
+
const splitSymbol = base.split('_');
|
|
510
|
+
splitBase = this.safeString(splitSymbol, 0);
|
|
511
|
+
}
|
|
512
|
+
const strike = this.safeString(optionParts, 2);
|
|
513
|
+
const optionType = this.safeString(optionParts, 3);
|
|
514
|
+
const datetime = this.convertExpireDate(expiry);
|
|
515
|
+
const timestamp = this.parse8601(datetime);
|
|
516
|
+
return {
|
|
517
|
+
'id': base + '-' + this.convertExpireDateToMarketIdDate(expiry) + '-' + strike + '-' + optionType,
|
|
518
|
+
'symbol': splitBase + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
|
|
519
|
+
'base': base,
|
|
520
|
+
'quote': quote,
|
|
521
|
+
'settle': settle,
|
|
522
|
+
'baseId': base,
|
|
523
|
+
'quoteId': quote,
|
|
524
|
+
'settleId': settle,
|
|
525
|
+
'active': false,
|
|
526
|
+
'type': 'option',
|
|
527
|
+
'linear': undefined,
|
|
528
|
+
'inverse': undefined,
|
|
529
|
+
'spot': false,
|
|
530
|
+
'swap': false,
|
|
531
|
+
'future': false,
|
|
532
|
+
'option': true,
|
|
533
|
+
'margin': false,
|
|
534
|
+
'contract': true,
|
|
535
|
+
'contractSize': undefined,
|
|
536
|
+
'expiry': timestamp,
|
|
537
|
+
'expiryDatetime': datetime,
|
|
538
|
+
'optionType': (optionType === 'C') ? 'call' : 'put',
|
|
539
|
+
'strike': this.parseNumber(strike),
|
|
540
|
+
'precision': {
|
|
541
|
+
'amount': undefined,
|
|
542
|
+
'price': undefined,
|
|
543
|
+
},
|
|
544
|
+
'limits': {
|
|
545
|
+
'amount': {
|
|
546
|
+
'min': undefined,
|
|
547
|
+
'max': undefined,
|
|
548
|
+
},
|
|
549
|
+
'price': {
|
|
550
|
+
'min': undefined,
|
|
551
|
+
'max': undefined,
|
|
552
|
+
},
|
|
553
|
+
'cost': {
|
|
554
|
+
'min': undefined,
|
|
555
|
+
'max': undefined,
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
'info': undefined,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
|
|
562
|
+
const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')));
|
|
563
|
+
if (isOption && !(marketId in this.markets_by_id)) {
|
|
564
|
+
// handle expired option contracts
|
|
565
|
+
return this.createExpiredOptionMarket(marketId);
|
|
566
|
+
}
|
|
567
|
+
return super.safeMarket(marketId, market, delimiter, marketType);
|
|
568
|
+
}
|
|
405
569
|
async fetchTime(params = {}) {
|
|
406
570
|
/**
|
|
407
571
|
* @method
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -529,6 +529,7 @@ class gate extends gate$1 {
|
|
|
529
529
|
'multi_collateral/currency_quota': 20 / 15,
|
|
530
530
|
'multi_collateral/currencies': 20 / 15,
|
|
531
531
|
'multi_collateral/ltv': 20 / 15,
|
|
532
|
+
'multi_collateral/fixed_rate': 20 / 15,
|
|
532
533
|
},
|
|
533
534
|
'post': {
|
|
534
535
|
'collateral/orders': 20 / 15,
|
|
@@ -5558,7 +5559,7 @@ class gate extends gate$1 {
|
|
|
5558
5559
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
|
5559
5560
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
|
|
5560
5561
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts-2
|
|
5561
|
-
* @param {string[]
|
|
5562
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
5562
5563
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5563
5564
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
5564
5565
|
*/
|
|
@@ -5703,6 +5704,33 @@ class gate extends gate$1 {
|
|
|
5703
5704
|
//
|
|
5704
5705
|
return this.parseMarketLeverageTiers(response, market);
|
|
5705
5706
|
}
|
|
5707
|
+
parseEmulatedLeverageTiers(info, market = undefined) {
|
|
5708
|
+
const maintenanceMarginUnit = this.safeString(info, 'maintenance_rate'); // '0.005',
|
|
5709
|
+
const leverageMax = this.safeString(info, 'leverage_max'); // '100',
|
|
5710
|
+
const riskLimitStep = this.safeString(info, 'risk_limit_step'); // '1000000',
|
|
5711
|
+
const riskLimitMax = this.safeString(info, 'risk_limit_max'); // '16000000',
|
|
5712
|
+
const initialMarginUnit = Precise["default"].stringDiv('1', leverageMax);
|
|
5713
|
+
let maintenanceMarginRate = maintenanceMarginUnit;
|
|
5714
|
+
let initialMarginRatio = initialMarginUnit;
|
|
5715
|
+
let floor = '0';
|
|
5716
|
+
const tiers = [];
|
|
5717
|
+
while (Precise["default"].stringLt(floor, riskLimitMax)) {
|
|
5718
|
+
const cap = Precise["default"].stringAdd(floor, riskLimitStep);
|
|
5719
|
+
tiers.push({
|
|
5720
|
+
'tier': this.parseNumber(Precise["default"].stringDiv(cap, riskLimitStep)),
|
|
5721
|
+
'currency': this.safeString(market, 'settle'),
|
|
5722
|
+
'minNotional': this.parseNumber(floor),
|
|
5723
|
+
'maxNotional': this.parseNumber(cap),
|
|
5724
|
+
'maintenanceMarginRate': this.parseNumber(maintenanceMarginRate),
|
|
5725
|
+
'maxLeverage': this.parseNumber(Precise["default"].stringDiv('1', initialMarginRatio)),
|
|
5726
|
+
'info': info,
|
|
5727
|
+
});
|
|
5728
|
+
maintenanceMarginRate = Precise["default"].stringAdd(maintenanceMarginRate, maintenanceMarginUnit);
|
|
5729
|
+
initialMarginRatio = Precise["default"].stringAdd(initialMarginRatio, initialMarginUnit);
|
|
5730
|
+
floor = cap;
|
|
5731
|
+
}
|
|
5732
|
+
return tiers;
|
|
5733
|
+
}
|
|
5706
5734
|
parseMarketLeverageTiers(info, market = undefined) {
|
|
5707
5735
|
//
|
|
5708
5736
|
// [
|
|
@@ -5715,6 +5743,9 @@ class gate extends gate$1 {
|
|
|
5715
5743
|
// }
|
|
5716
5744
|
// ]
|
|
5717
5745
|
//
|
|
5746
|
+
if (!Array.isArray(info)) {
|
|
5747
|
+
return this.parseEmulatedLeverageTiers(info, market);
|
|
5748
|
+
}
|
|
5718
5749
|
let minNotional = 0;
|
|
5719
5750
|
const tiers = [];
|
|
5720
5751
|
for (let i = 0; i < info.length; i++) {
|
package/dist/cjs/src/novadax.js
CHANGED
|
@@ -19,9 +19,9 @@ class novadax extends novadax$1 {
|
|
|
19
19
|
'id': 'novadax',
|
|
20
20
|
'name': 'NovaDAX',
|
|
21
21
|
'countries': ['BR'],
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
'rateLimit':
|
|
22
|
+
// 6000 weight per min => 100 weight per second => min weight = 1
|
|
23
|
+
// 100 requests per second => ( 1000ms / 100 ) = 10 ms between requests on average
|
|
24
|
+
'rateLimit': 10,
|
|
25
25
|
'version': 'v1',
|
|
26
26
|
// new metainfo interface
|
|
27
27
|
'has': {
|
|
@@ -119,33 +119,37 @@ class novadax extends novadax$1 {
|
|
|
119
119
|
'api': {
|
|
120
120
|
'public': {
|
|
121
121
|
'get': {
|
|
122
|
-
'common/symbol': 1
|
|
123
|
-
'common/symbols': 1
|
|
124
|
-
'common/timestamp': 1
|
|
125
|
-
'market/tickers':
|
|
126
|
-
'market/ticker': 1
|
|
127
|
-
'market/depth': 1
|
|
128
|
-
'market/trades':
|
|
129
|
-
'market/kline/history':
|
|
122
|
+
'common/symbol': 1,
|
|
123
|
+
'common/symbols': 1,
|
|
124
|
+
'common/timestamp': 1,
|
|
125
|
+
'market/tickers': 5,
|
|
126
|
+
'market/ticker': 1,
|
|
127
|
+
'market/depth': 1,
|
|
128
|
+
'market/trades': 5,
|
|
129
|
+
'market/kline/history': 5,
|
|
130
130
|
},
|
|
131
131
|
},
|
|
132
132
|
'private': {
|
|
133
133
|
'get': {
|
|
134
|
-
'orders/get':
|
|
135
|
-
'orders/list':
|
|
134
|
+
'orders/get': 1,
|
|
135
|
+
'orders/list': 10,
|
|
136
136
|
'orders/fill': 3,
|
|
137
|
-
'orders/fills':
|
|
138
|
-
'account/getBalance':
|
|
139
|
-
'account/subs':
|
|
140
|
-
'account/subs/balance':
|
|
141
|
-
'account/subs/transfer/record':
|
|
137
|
+
'orders/fills': 10,
|
|
138
|
+
'account/getBalance': 1,
|
|
139
|
+
'account/subs': 1,
|
|
140
|
+
'account/subs/balance': 1,
|
|
141
|
+
'account/subs/transfer/record': 10,
|
|
142
142
|
'wallet/query/deposit-withdraw': 3,
|
|
143
143
|
},
|
|
144
144
|
'post': {
|
|
145
|
-
'orders/create':
|
|
146
|
-
'orders/
|
|
147
|
-
'
|
|
148
|
-
'
|
|
145
|
+
'orders/create': 5,
|
|
146
|
+
'orders/batch-create': 50,
|
|
147
|
+
'orders/cancel': 1,
|
|
148
|
+
'orders/batch-cancel': 10,
|
|
149
|
+
'orders/cancel-by-symbol': 10,
|
|
150
|
+
'account/subs/transfer': 5,
|
|
151
|
+
'wallet/withdraw/coin': 3,
|
|
152
|
+
'account/withdraw/coin': 3, // not found in doc
|
|
149
153
|
},
|
|
150
154
|
},
|
|
151
155
|
},
|
package/dist/cjs/src/okcoin.js
CHANGED
|
@@ -46,6 +46,9 @@ class okcoin extends okcoin$1 {
|
|
|
46
46
|
'fetchCurrencies': true,
|
|
47
47
|
'fetchDepositAddress': true,
|
|
48
48
|
'fetchDeposits': true,
|
|
49
|
+
'fetchFundingHistory': false,
|
|
50
|
+
'fetchFundingRate': false,
|
|
51
|
+
'fetchFundingRateHistory': false,
|
|
49
52
|
'fetchLedger': true,
|
|
50
53
|
'fetchMarkets': true,
|
|
51
54
|
'fetchMyTrades': true,
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -190,6 +190,7 @@ class phemex extends phemex$1 {
|
|
|
190
190
|
'api-data/g-futures/trades': 5,
|
|
191
191
|
'api-data/futures/trading-fees': 5,
|
|
192
192
|
'api-data/g-futures/trading-fees': 5,
|
|
193
|
+
'api-data/futures/v2/tradeAccountDetail': 5,
|
|
193
194
|
'g-orders/activeList': 1,
|
|
194
195
|
'orders/activeList': 1,
|
|
195
196
|
'exchange/order/list': 5,
|
|
@@ -1914,16 +1915,19 @@ class phemex extends phemex$1 {
|
|
|
1914
1915
|
* @method
|
|
1915
1916
|
* @name phemex#fetchBalance
|
|
1916
1917
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1918
|
+
* @see https://phemex-docs.github.io/#query-wallets
|
|
1917
1919
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
|
|
1920
|
+
* @see https://phemex-docs.github.io/#query-trading-account-and-positions
|
|
1918
1921
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1919
1922
|
* @param {string} [params.type] spot or swap
|
|
1923
|
+
* @param {string} [params.code] *swap only* currency code of the balance to query (USD, USDT, etc), default is USDT
|
|
1920
1924
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1921
1925
|
*/
|
|
1922
1926
|
await this.loadMarkets();
|
|
1923
1927
|
let type = undefined;
|
|
1924
1928
|
[type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1925
1929
|
const code = this.safeString(params, 'code');
|
|
1926
|
-
params = this.omit(params, ['
|
|
1930
|
+
params = this.omit(params, ['code']);
|
|
1927
1931
|
let response = undefined;
|
|
1928
1932
|
const request = {};
|
|
1929
1933
|
if ((type !== 'spot') && (type !== 'swap')) {
|
|
@@ -1931,7 +1935,7 @@ class phemex extends phemex$1 {
|
|
|
1931
1935
|
}
|
|
1932
1936
|
if (type === 'swap') {
|
|
1933
1937
|
let settle = undefined;
|
|
1934
|
-
[settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle');
|
|
1938
|
+
[settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle', 'USDT');
|
|
1935
1939
|
if (code !== undefined || settle !== undefined) {
|
|
1936
1940
|
let coin = undefined;
|
|
1937
1941
|
if (code !== undefined) {
|
|
@@ -2767,7 +2771,7 @@ class phemex extends phemex$1 {
|
|
|
2767
2771
|
}
|
|
2768
2772
|
else if (amount !== undefined) {
|
|
2769
2773
|
if (isUSDTSettled) {
|
|
2770
|
-
request['
|
|
2774
|
+
request['orderQtyRq'] = this.amountToPrecision(market['symbol'], amount);
|
|
2771
2775
|
}
|
|
2772
2776
|
else {
|
|
2773
2777
|
request['baseQtyEV'] = this.toEv(amount, market);
|
package/dist/cjs/src/poloniex.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var hitbtc = require('./hitbtc.js');
|
|
4
|
+
var bequant$1 = require('../bequant.js');
|
|
4
5
|
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
class bequant extends hitbtc {
|
|
8
9
|
describe() {
|
|
9
|
-
|
|
10
|
+
// eslint-disable-next-line new-cap
|
|
11
|
+
const restInstance = new bequant$1();
|
|
12
|
+
const restDescribe = restInstance.describe();
|
|
13
|
+
const extended = this.deepExtend(super.describe(), restDescribe);
|
|
14
|
+
return this.deepExtend(extended, {
|
|
10
15
|
'id': 'bequant',
|
|
11
16
|
'name': 'Bequant',
|
|
12
17
|
'countries': ['MT'],
|
|
@@ -44,7 +44,7 @@ class binance extends binance$1 {
|
|
|
44
44
|
'ws': {
|
|
45
45
|
'spot': 'wss://testnet.binance.vision/ws',
|
|
46
46
|
'margin': 'wss://testnet.binance.vision/ws',
|
|
47
|
-
'future': 'wss://
|
|
47
|
+
'future': 'wss://fstream.binancefuture.com/ws',
|
|
48
48
|
'delivery': 'wss://dstream.binancefuture.com/ws',
|
|
49
49
|
'ws': 'wss://testnet.binance.vision/ws-api/v3',
|
|
50
50
|
},
|
|
@@ -1977,12 +1977,13 @@ class binance extends binance$1 {
|
|
|
1977
1977
|
/**
|
|
1978
1978
|
* @method
|
|
1979
1979
|
* @name binance#watchOrders
|
|
1980
|
-
* @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
|
|
1981
1980
|
* @description watches information on multiple orders made by the user
|
|
1982
|
-
* @
|
|
1981
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
|
|
1982
|
+
* @param {string} symbol unified market symbol of the market the orders were made in
|
|
1983
1983
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1984
1984
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1985
1985
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1986
|
+
* @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
|
|
1986
1987
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1987
1988
|
*/
|
|
1988
1989
|
await this.loadMarkets();
|
|
@@ -2005,8 +2006,10 @@ class binance extends binance$1 {
|
|
|
2005
2006
|
}
|
|
2006
2007
|
params = this.extend(params, { 'type': type, 'symbol': symbol }); // needed inside authenticate for isolated margin
|
|
2007
2008
|
await this.authenticate(params);
|
|
2009
|
+
let marginMode = undefined;
|
|
2010
|
+
[marginMode, params] = this.handleMarginModeAndParams('watchOrders', params);
|
|
2008
2011
|
let urlType = type;
|
|
2009
|
-
if (type === 'margin') {
|
|
2012
|
+
if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
|
|
2010
2013
|
urlType = 'spot'; // spot-margin shares the same stream as regular spot
|
|
2011
2014
|
}
|
|
2012
2015
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|