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/js/src/bybit.d.ts
CHANGED
|
@@ -58,8 +58,9 @@ export default class bybit extends Exchange {
|
|
|
58
58
|
parseOrder(order: any, market?: Market): Order;
|
|
59
59
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
60
60
|
createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
61
|
+
createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
61
62
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
62
|
-
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
63
|
+
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}, isUTA?: boolean): any;
|
|
63
64
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
64
65
|
createUsdcOrder(symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
65
66
|
editUsdcOrder(id: any, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
|
package/js/src/bybit.js
CHANGED
|
@@ -41,7 +41,7 @@ export default class bybit extends Exchange {
|
|
|
41
41
|
'closeAllPositions': false,
|
|
42
42
|
'closePosition': false,
|
|
43
43
|
'createMarketBuyOrderWithCost': true,
|
|
44
|
-
'createMarketSellOrderWithCost':
|
|
44
|
+
'createMarketSellOrderWithCost': true,
|
|
45
45
|
'createOrder': true,
|
|
46
46
|
'createOrders': true,
|
|
47
47
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
@@ -3471,8 +3471,30 @@ export default class bybit extends Exchange {
|
|
|
3471
3471
|
if (!market['spot']) {
|
|
3472
3472
|
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
3473
3473
|
}
|
|
3474
|
-
|
|
3475
|
-
|
|
3474
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, 1, params);
|
|
3475
|
+
}
|
|
3476
|
+
async createMarketSellOrderWithCost(symbol, cost, params = {}) {
|
|
3477
|
+
/**
|
|
3478
|
+
* @method
|
|
3479
|
+
* @name bybit#createMarkeSellOrderWithCost
|
|
3480
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/create-order
|
|
3481
|
+
* @description create a market sell order by providing the symbol and cost
|
|
3482
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3483
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
3484
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3485
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3486
|
+
*/
|
|
3487
|
+
await this.loadMarkets();
|
|
3488
|
+
const types = await this.isUnifiedEnabled();
|
|
3489
|
+
const enableUnifiedAccount = types[1];
|
|
3490
|
+
if (!enableUnifiedAccount) {
|
|
3491
|
+
throw new NotSupported(this.id + ' createMarketSellOrderWithCost() supports UTA accounts only');
|
|
3492
|
+
}
|
|
3493
|
+
const market = this.market(symbol);
|
|
3494
|
+
if (!market['spot']) {
|
|
3495
|
+
throw new NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot orders only');
|
|
3496
|
+
}
|
|
3497
|
+
return await this.createOrder(symbol, 'market', 'sell', cost, 1, params);
|
|
3476
3498
|
}
|
|
3477
3499
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
3478
3500
|
/**
|
|
@@ -3516,7 +3538,7 @@ export default class bybit extends Exchange {
|
|
|
3516
3538
|
}
|
|
3517
3539
|
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3518
3540
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3519
|
-
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
3541
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
|
|
3520
3542
|
let response = undefined;
|
|
3521
3543
|
if (isTrailingAmountOrder) {
|
|
3522
3544
|
response = await this.privatePostV5PositionTradingStop(orderRequest);
|
|
@@ -3539,7 +3561,7 @@ export default class bybit extends Exchange {
|
|
|
3539
3561
|
const order = this.safeValue(response, 'result', {});
|
|
3540
3562
|
return this.parseOrder(order, market);
|
|
3541
3563
|
}
|
|
3542
|
-
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
3564
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}, isUTA = true) {
|
|
3543
3565
|
const market = this.market(symbol);
|
|
3544
3566
|
symbol = market['symbol'];
|
|
3545
3567
|
const lowerCaseType = type.toLowerCase();
|
|
@@ -3583,12 +3605,36 @@ export default class bybit extends Exchange {
|
|
|
3583
3605
|
else if (market['option']) {
|
|
3584
3606
|
request['category'] = 'option';
|
|
3585
3607
|
}
|
|
3586
|
-
|
|
3608
|
+
const cost = this.safeString(params, 'cost');
|
|
3609
|
+
params = this.omit(params, 'cost');
|
|
3610
|
+
// if the cost is inferable, let's keep the old logic and ignore marketUnit, to minimize the impact of the changes
|
|
3611
|
+
const isMarketBuyAndCostInferable = (lowerCaseType === 'market') && (side === 'buy') && ((price !== undefined) || (cost !== undefined));
|
|
3612
|
+
if (market['spot'] && (type === 'market') && isUTA && !isMarketBuyAndCostInferable) {
|
|
3613
|
+
// UTA account can specify the cost of the order on both sides
|
|
3614
|
+
if ((cost !== undefined) || (price !== undefined)) {
|
|
3615
|
+
request['marketUnit'] = 'quoteCoin';
|
|
3616
|
+
let orderCost = undefined;
|
|
3617
|
+
if (cost !== undefined) {
|
|
3618
|
+
orderCost = cost;
|
|
3619
|
+
}
|
|
3620
|
+
else {
|
|
3621
|
+
const amountString = this.numberToString(amount);
|
|
3622
|
+
const priceString = this.numberToString(price);
|
|
3623
|
+
const quoteAmount = Precise.stringMul(amountString, priceString);
|
|
3624
|
+
orderCost = quoteAmount;
|
|
3625
|
+
}
|
|
3626
|
+
request['qty'] = this.costToPrecision(symbol, orderCost);
|
|
3627
|
+
}
|
|
3628
|
+
else {
|
|
3629
|
+
request['marketUnit'] = 'baseCoin';
|
|
3630
|
+
request['qty'] = this.amountToPrecision(symbol, amount);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
else if (market['spot'] && (type === 'market') && (side === 'buy')) {
|
|
3634
|
+
// classic accounts
|
|
3587
3635
|
// for market buy it requires the amount of quote currency to spend
|
|
3588
3636
|
let createMarketBuyOrderRequiresPrice = true;
|
|
3589
3637
|
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
3590
|
-
const cost = this.safeNumber(params, 'cost');
|
|
3591
|
-
params = this.omit(params, 'cost');
|
|
3592
3638
|
if (createMarketBuyOrderRequiresPrice) {
|
|
3593
3639
|
if ((price === undefined) && (cost === undefined)) {
|
|
3594
3640
|
throw new 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');
|
|
@@ -3715,6 +3761,8 @@ export default class bybit extends Exchange {
|
|
|
3715
3761
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3716
3762
|
*/
|
|
3717
3763
|
await this.loadMarkets();
|
|
3764
|
+
const accounts = await this.isUnifiedEnabled();
|
|
3765
|
+
const isUta = accounts[1];
|
|
3718
3766
|
const ordersRequests = [];
|
|
3719
3767
|
const orderSymbols = [];
|
|
3720
3768
|
for (let i = 0; i < orders.length; i++) {
|
|
@@ -3726,7 +3774,7 @@ export default class bybit extends Exchange {
|
|
|
3726
3774
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
3727
3775
|
const price = this.safeValue(rawOrder, 'price');
|
|
3728
3776
|
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
3729
|
-
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
3777
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams, isUta);
|
|
3730
3778
|
ordersRequests.push(orderRequest);
|
|
3731
3779
|
}
|
|
3732
3780
|
const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
|
package/js/src/coinbasepro.js
CHANGED
package/js/src/coinex.d.ts
CHANGED
|
@@ -207,6 +207,7 @@ export default class coinex extends Exchange {
|
|
|
207
207
|
};
|
|
208
208
|
fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<{}>;
|
|
209
209
|
parseDepositWithdrawFees(response: any, codes?: any, currencyIdKey?: any): {};
|
|
210
|
+
handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
|
|
210
211
|
nonce(): number;
|
|
211
212
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
212
213
|
url: string;
|
package/js/src/coinex.js
CHANGED
|
@@ -1580,8 +1580,9 @@ export default class coinex extends Exchange {
|
|
|
1580
1580
|
*/
|
|
1581
1581
|
let marketType = undefined;
|
|
1582
1582
|
[marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1583
|
-
|
|
1584
|
-
|
|
1583
|
+
let marginMode = undefined;
|
|
1584
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
1585
|
+
marketType = (marginMode !== undefined) ? 'margin' : marketType;
|
|
1585
1586
|
params = this.omit(params, 'margin');
|
|
1586
1587
|
if (marketType === 'margin') {
|
|
1587
1588
|
return await this.fetchMarginBalance(params);
|
|
@@ -2111,8 +2112,9 @@ export default class coinex extends Exchange {
|
|
|
2111
2112
|
}
|
|
2112
2113
|
}
|
|
2113
2114
|
const accountId = this.safeInteger(params, 'account_id');
|
|
2114
|
-
|
|
2115
|
-
|
|
2115
|
+
let marginMode = undefined;
|
|
2116
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
2117
|
+
if (marginMode !== undefined) {
|
|
2116
2118
|
if (accountId === undefined) {
|
|
2117
2119
|
throw new BadRequest(this.id + ' createOrder() requires an account_id parameter for margin orders');
|
|
2118
2120
|
}
|
|
@@ -2631,9 +2633,10 @@ export default class coinex extends Exchange {
|
|
|
2631
2633
|
'market': market['id'],
|
|
2632
2634
|
};
|
|
2633
2635
|
const accountId = this.safeInteger(params, 'account_id');
|
|
2634
|
-
|
|
2636
|
+
let marginMode = undefined;
|
|
2637
|
+
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
2635
2638
|
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
2636
|
-
if (
|
|
2639
|
+
if (marginMode !== undefined) {
|
|
2637
2640
|
if (accountId === undefined) {
|
|
2638
2641
|
throw new BadRequest(this.id + ' cancelOrder() requires an account_id parameter for margin orders');
|
|
2639
2642
|
}
|
|
@@ -3005,8 +3008,9 @@ export default class coinex extends Exchange {
|
|
|
3005
3008
|
}
|
|
3006
3009
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
3007
3010
|
const accountId = this.safeInteger(params, 'account_id');
|
|
3008
|
-
|
|
3009
|
-
|
|
3011
|
+
let marginMode = undefined;
|
|
3012
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
|
|
3013
|
+
if (marginMode !== undefined) {
|
|
3010
3014
|
if (accountId === undefined) {
|
|
3011
3015
|
throw new BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
|
|
3012
3016
|
}
|
|
@@ -3409,8 +3413,9 @@ export default class coinex extends Exchange {
|
|
|
3409
3413
|
}
|
|
3410
3414
|
const swap = (type === 'swap');
|
|
3411
3415
|
const accountId = this.safeInteger(params, 'account_id');
|
|
3412
|
-
|
|
3413
|
-
|
|
3416
|
+
let marginMode = undefined;
|
|
3417
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
3418
|
+
if (marginMode !== undefined) {
|
|
3414
3419
|
if (accountId === undefined) {
|
|
3415
3420
|
throw new BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
|
|
3416
3421
|
}
|
|
@@ -4735,9 +4740,10 @@ export default class coinex extends Exchange {
|
|
|
4735
4740
|
request['limit'] = 100;
|
|
4736
4741
|
}
|
|
4737
4742
|
params = this.omit(params, 'page');
|
|
4738
|
-
|
|
4743
|
+
let marginMode = undefined;
|
|
4744
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
|
|
4739
4745
|
let response = undefined;
|
|
4740
|
-
if (
|
|
4746
|
+
if (marginMode !== undefined) {
|
|
4741
4747
|
response = await this.privateGetMarginTransferHistory(this.extend(request, params));
|
|
4742
4748
|
}
|
|
4743
4749
|
else {
|
|
@@ -5318,6 +5324,25 @@ export default class coinex extends Exchange {
|
|
|
5318
5324
|
}
|
|
5319
5325
|
return depositWithdrawFees;
|
|
5320
5326
|
}
|
|
5327
|
+
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
5328
|
+
/**
|
|
5329
|
+
* @ignore
|
|
5330
|
+
* @method
|
|
5331
|
+
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
|
|
5332
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
5333
|
+
* @returns {Array} the marginMode in lowercase
|
|
5334
|
+
*/
|
|
5335
|
+
const defaultType = this.safeString(this.options, 'defaultType');
|
|
5336
|
+
const isMargin = this.safeValue(params, 'margin', false);
|
|
5337
|
+
let marginMode = undefined;
|
|
5338
|
+
[marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
|
|
5339
|
+
if (marginMode === undefined) {
|
|
5340
|
+
if ((defaultType === 'margin') || (isMargin === true)) {
|
|
5341
|
+
marginMode = 'isolated';
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
return [marginMode, params];
|
|
5345
|
+
}
|
|
5321
5346
|
nonce() {
|
|
5322
5347
|
return this.milliseconds();
|
|
5323
5348
|
}
|
package/js/src/deribit.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import Exchange from './abstract/deribit.js';
|
|
2
|
-
import type { Balances, Currency, FundingRateHistory, Greeks, Int, Liquidation, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
|
|
2
|
+
import type { Balances, Currency, FundingRateHistory, Greeks, Int, Liquidation, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, MarketInterface } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class deribit
|
|
5
5
|
* @augments Exchange
|
|
6
6
|
*/
|
|
7
7
|
export default class deribit extends Exchange {
|
|
8
8
|
describe(): any;
|
|
9
|
+
convertExpireDate(date: any): string;
|
|
10
|
+
convertMarketIdExpireDate(date: any): string;
|
|
11
|
+
convertExpireDateToMarketIdDate(date: any): any;
|
|
12
|
+
createExpiredOptionMarket(symbol: any): MarketInterface;
|
|
13
|
+
safeMarket(marketId?: any, market?: any, delimiter?: any, marketType?: any): MarketInterface;
|
|
9
14
|
fetchTime(params?: {}): Promise<number>;
|
|
10
15
|
fetchCurrencies(params?: {}): Promise<{}>;
|
|
11
16
|
codeFromOptions(methodName: any, params?: {}): any;
|
package/js/src/deribit.js
CHANGED
|
@@ -405,6 +405,170 @@ export default class deribit extends Exchange {
|
|
|
405
405
|
},
|
|
406
406
|
});
|
|
407
407
|
}
|
|
408
|
+
convertExpireDate(date) {
|
|
409
|
+
// parse YYMMDD to timestamp
|
|
410
|
+
const year = date.slice(0, 2);
|
|
411
|
+
const month = date.slice(2, 4);
|
|
412
|
+
const day = date.slice(4, 6);
|
|
413
|
+
const reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z';
|
|
414
|
+
return reconstructedDate;
|
|
415
|
+
}
|
|
416
|
+
convertMarketIdExpireDate(date) {
|
|
417
|
+
// parse 19JAN24 to 240119
|
|
418
|
+
const monthMappping = {
|
|
419
|
+
'JAN': '01',
|
|
420
|
+
'FEB': '02',
|
|
421
|
+
'MAR': '03',
|
|
422
|
+
'APR': '04',
|
|
423
|
+
'MAY': '05',
|
|
424
|
+
'JUN': '06',
|
|
425
|
+
'JUL': '07',
|
|
426
|
+
'AUG': '08',
|
|
427
|
+
'SEP': '09',
|
|
428
|
+
'OCT': '10',
|
|
429
|
+
'NOV': '11',
|
|
430
|
+
'DEC': '12',
|
|
431
|
+
};
|
|
432
|
+
const year = date.slice(0, 2);
|
|
433
|
+
const monthName = date.slice(2, 5);
|
|
434
|
+
const month = this.safeString(monthMappping, monthName);
|
|
435
|
+
const day = date.slice(5, 7);
|
|
436
|
+
const reconstructedDate = day + month + year;
|
|
437
|
+
return reconstructedDate;
|
|
438
|
+
}
|
|
439
|
+
convertExpireDateToMarketIdDate(date) {
|
|
440
|
+
// parse 240119 to 19JAN24
|
|
441
|
+
const year = date.slice(0, 2);
|
|
442
|
+
const monthRaw = date.slice(2, 4);
|
|
443
|
+
let month = undefined;
|
|
444
|
+
const day = date.slice(4, 6);
|
|
445
|
+
if (monthRaw === '01') {
|
|
446
|
+
month = 'JAN';
|
|
447
|
+
}
|
|
448
|
+
else if (monthRaw === '02') {
|
|
449
|
+
month = 'FEB';
|
|
450
|
+
}
|
|
451
|
+
else if (monthRaw === '03') {
|
|
452
|
+
month = 'MAR';
|
|
453
|
+
}
|
|
454
|
+
else if (monthRaw === '04') {
|
|
455
|
+
month = 'APR';
|
|
456
|
+
}
|
|
457
|
+
else if (monthRaw === '05') {
|
|
458
|
+
month = 'MAY';
|
|
459
|
+
}
|
|
460
|
+
else if (monthRaw === '06') {
|
|
461
|
+
month = 'JUN';
|
|
462
|
+
}
|
|
463
|
+
else if (monthRaw === '07') {
|
|
464
|
+
month = 'JUL';
|
|
465
|
+
}
|
|
466
|
+
else if (monthRaw === '08') {
|
|
467
|
+
month = 'AUG';
|
|
468
|
+
}
|
|
469
|
+
else if (monthRaw === '09') {
|
|
470
|
+
month = 'SEP';
|
|
471
|
+
}
|
|
472
|
+
else if (monthRaw === '10') {
|
|
473
|
+
month = 'OCT';
|
|
474
|
+
}
|
|
475
|
+
else if (monthRaw === '11') {
|
|
476
|
+
month = 'NOV';
|
|
477
|
+
}
|
|
478
|
+
else if (monthRaw === '12') {
|
|
479
|
+
month = 'DEC';
|
|
480
|
+
}
|
|
481
|
+
const reconstructedDate = day + month + year;
|
|
482
|
+
return reconstructedDate;
|
|
483
|
+
}
|
|
484
|
+
createExpiredOptionMarket(symbol) {
|
|
485
|
+
// support expired option contracts
|
|
486
|
+
let quote = 'USD';
|
|
487
|
+
let settle = undefined;
|
|
488
|
+
const optionParts = symbol.split('-');
|
|
489
|
+
const symbolBase = symbol.split('/');
|
|
490
|
+
let base = undefined;
|
|
491
|
+
let expiry = undefined;
|
|
492
|
+
if (symbol.indexOf('/') > -1) {
|
|
493
|
+
base = this.safeString(symbolBase, 0);
|
|
494
|
+
expiry = this.safeString(optionParts, 1);
|
|
495
|
+
if (symbol.indexOf('USDC') > -1) {
|
|
496
|
+
base = base + '_USDC';
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
base = this.safeString(optionParts, 0);
|
|
501
|
+
expiry = this.convertMarketIdExpireDate(this.safeString(optionParts, 1));
|
|
502
|
+
}
|
|
503
|
+
if (symbol.indexOf('USDC') > -1) {
|
|
504
|
+
quote = 'USDC';
|
|
505
|
+
settle = 'USDC';
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
settle = base;
|
|
509
|
+
}
|
|
510
|
+
let splitBase = base;
|
|
511
|
+
if (base.indexOf('_') > -1) {
|
|
512
|
+
const splitSymbol = base.split('_');
|
|
513
|
+
splitBase = this.safeString(splitSymbol, 0);
|
|
514
|
+
}
|
|
515
|
+
const strike = this.safeString(optionParts, 2);
|
|
516
|
+
const optionType = this.safeString(optionParts, 3);
|
|
517
|
+
const datetime = this.convertExpireDate(expiry);
|
|
518
|
+
const timestamp = this.parse8601(datetime);
|
|
519
|
+
return {
|
|
520
|
+
'id': base + '-' + this.convertExpireDateToMarketIdDate(expiry) + '-' + strike + '-' + optionType,
|
|
521
|
+
'symbol': splitBase + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
|
|
522
|
+
'base': base,
|
|
523
|
+
'quote': quote,
|
|
524
|
+
'settle': settle,
|
|
525
|
+
'baseId': base,
|
|
526
|
+
'quoteId': quote,
|
|
527
|
+
'settleId': settle,
|
|
528
|
+
'active': false,
|
|
529
|
+
'type': 'option',
|
|
530
|
+
'linear': undefined,
|
|
531
|
+
'inverse': undefined,
|
|
532
|
+
'spot': false,
|
|
533
|
+
'swap': false,
|
|
534
|
+
'future': false,
|
|
535
|
+
'option': true,
|
|
536
|
+
'margin': false,
|
|
537
|
+
'contract': true,
|
|
538
|
+
'contractSize': undefined,
|
|
539
|
+
'expiry': timestamp,
|
|
540
|
+
'expiryDatetime': datetime,
|
|
541
|
+
'optionType': (optionType === 'C') ? 'call' : 'put',
|
|
542
|
+
'strike': this.parseNumber(strike),
|
|
543
|
+
'precision': {
|
|
544
|
+
'amount': undefined,
|
|
545
|
+
'price': undefined,
|
|
546
|
+
},
|
|
547
|
+
'limits': {
|
|
548
|
+
'amount': {
|
|
549
|
+
'min': undefined,
|
|
550
|
+
'max': undefined,
|
|
551
|
+
},
|
|
552
|
+
'price': {
|
|
553
|
+
'min': undefined,
|
|
554
|
+
'max': undefined,
|
|
555
|
+
},
|
|
556
|
+
'cost': {
|
|
557
|
+
'min': undefined,
|
|
558
|
+
'max': undefined,
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
'info': undefined,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
|
|
565
|
+
const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')));
|
|
566
|
+
if (isOption && !(marketId in this.markets_by_id)) {
|
|
567
|
+
// handle expired option contracts
|
|
568
|
+
return this.createExpiredOptionMarket(marketId);
|
|
569
|
+
}
|
|
570
|
+
return super.safeMarket(marketId, market, delimiter, marketType);
|
|
571
|
+
}
|
|
408
572
|
async fetchTime(params = {}) {
|
|
409
573
|
/**
|
|
410
574
|
* @method
|
package/js/src/gate.d.ts
CHANGED
|
@@ -220,6 +220,7 @@ export default class gate extends Exchange {
|
|
|
220
220
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
221
221
|
fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<{}>;
|
|
222
222
|
fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
|
|
223
|
+
parseEmulatedLeverageTiers(info: any, market?: any): any[];
|
|
223
224
|
parseMarketLeverageTiers(info: any, market?: Market): any[];
|
|
224
225
|
repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
|
|
225
226
|
id: number;
|
package/js/src/gate.js
CHANGED
|
@@ -532,6 +532,7 @@ export default class gate extends Exchange {
|
|
|
532
532
|
'multi_collateral/currency_quota': 20 / 15,
|
|
533
533
|
'multi_collateral/currencies': 20 / 15,
|
|
534
534
|
'multi_collateral/ltv': 20 / 15,
|
|
535
|
+
'multi_collateral/fixed_rate': 20 / 15,
|
|
535
536
|
},
|
|
536
537
|
'post': {
|
|
537
538
|
'collateral/orders': 20 / 15,
|
|
@@ -5561,7 +5562,7 @@ export default class gate extends Exchange {
|
|
|
5561
5562
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
|
5562
5563
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
|
|
5563
5564
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts-2
|
|
5564
|
-
* @param {string[]
|
|
5565
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
5565
5566
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5566
5567
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
5567
5568
|
*/
|
|
@@ -5706,6 +5707,33 @@ export default class gate extends Exchange {
|
|
|
5706
5707
|
//
|
|
5707
5708
|
return this.parseMarketLeverageTiers(response, market);
|
|
5708
5709
|
}
|
|
5710
|
+
parseEmulatedLeverageTiers(info, market = undefined) {
|
|
5711
|
+
const maintenanceMarginUnit = this.safeString(info, 'maintenance_rate'); // '0.005',
|
|
5712
|
+
const leverageMax = this.safeString(info, 'leverage_max'); // '100',
|
|
5713
|
+
const riskLimitStep = this.safeString(info, 'risk_limit_step'); // '1000000',
|
|
5714
|
+
const riskLimitMax = this.safeString(info, 'risk_limit_max'); // '16000000',
|
|
5715
|
+
const initialMarginUnit = Precise.stringDiv('1', leverageMax);
|
|
5716
|
+
let maintenanceMarginRate = maintenanceMarginUnit;
|
|
5717
|
+
let initialMarginRatio = initialMarginUnit;
|
|
5718
|
+
let floor = '0';
|
|
5719
|
+
const tiers = [];
|
|
5720
|
+
while (Precise.stringLt(floor, riskLimitMax)) {
|
|
5721
|
+
const cap = Precise.stringAdd(floor, riskLimitStep);
|
|
5722
|
+
tiers.push({
|
|
5723
|
+
'tier': this.parseNumber(Precise.stringDiv(cap, riskLimitStep)),
|
|
5724
|
+
'currency': this.safeString(market, 'settle'),
|
|
5725
|
+
'minNotional': this.parseNumber(floor),
|
|
5726
|
+
'maxNotional': this.parseNumber(cap),
|
|
5727
|
+
'maintenanceMarginRate': this.parseNumber(maintenanceMarginRate),
|
|
5728
|
+
'maxLeverage': this.parseNumber(Precise.stringDiv('1', initialMarginRatio)),
|
|
5729
|
+
'info': info,
|
|
5730
|
+
});
|
|
5731
|
+
maintenanceMarginRate = Precise.stringAdd(maintenanceMarginRate, maintenanceMarginUnit);
|
|
5732
|
+
initialMarginRatio = Precise.stringAdd(initialMarginRatio, initialMarginUnit);
|
|
5733
|
+
floor = cap;
|
|
5734
|
+
}
|
|
5735
|
+
return tiers;
|
|
5736
|
+
}
|
|
5709
5737
|
parseMarketLeverageTiers(info, market = undefined) {
|
|
5710
5738
|
//
|
|
5711
5739
|
// [
|
|
@@ -5718,6 +5746,9 @@ export default class gate extends Exchange {
|
|
|
5718
5746
|
// }
|
|
5719
5747
|
// ]
|
|
5720
5748
|
//
|
|
5749
|
+
if (!Array.isArray(info)) {
|
|
5750
|
+
return this.parseEmulatedLeverageTiers(info, market);
|
|
5751
|
+
}
|
|
5721
5752
|
let minNotional = 0;
|
|
5722
5753
|
const tiers = [];
|
|
5723
5754
|
for (let i = 0; i < info.length; i++) {
|
package/js/src/novadax.js
CHANGED
|
@@ -22,9 +22,9 @@ export default class novadax extends Exchange {
|
|
|
22
22
|
'id': 'novadax',
|
|
23
23
|
'name': 'NovaDAX',
|
|
24
24
|
'countries': ['BR'],
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
'rateLimit':
|
|
25
|
+
// 6000 weight per min => 100 weight per second => min weight = 1
|
|
26
|
+
// 100 requests per second => ( 1000ms / 100 ) = 10 ms between requests on average
|
|
27
|
+
'rateLimit': 10,
|
|
28
28
|
'version': 'v1',
|
|
29
29
|
// new metainfo interface
|
|
30
30
|
'has': {
|
|
@@ -122,33 +122,37 @@ export default class novadax extends Exchange {
|
|
|
122
122
|
'api': {
|
|
123
123
|
'public': {
|
|
124
124
|
'get': {
|
|
125
|
-
'common/symbol': 1
|
|
126
|
-
'common/symbols': 1
|
|
127
|
-
'common/timestamp': 1
|
|
128
|
-
'market/tickers':
|
|
129
|
-
'market/ticker': 1
|
|
130
|
-
'market/depth': 1
|
|
131
|
-
'market/trades':
|
|
132
|
-
'market/kline/history':
|
|
125
|
+
'common/symbol': 1,
|
|
126
|
+
'common/symbols': 1,
|
|
127
|
+
'common/timestamp': 1,
|
|
128
|
+
'market/tickers': 5,
|
|
129
|
+
'market/ticker': 1,
|
|
130
|
+
'market/depth': 1,
|
|
131
|
+
'market/trades': 5,
|
|
132
|
+
'market/kline/history': 5,
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
'private': {
|
|
136
136
|
'get': {
|
|
137
|
-
'orders/get':
|
|
138
|
-
'orders/list':
|
|
137
|
+
'orders/get': 1,
|
|
138
|
+
'orders/list': 10,
|
|
139
139
|
'orders/fill': 3,
|
|
140
|
-
'orders/fills':
|
|
141
|
-
'account/getBalance':
|
|
142
|
-
'account/subs':
|
|
143
|
-
'account/subs/balance':
|
|
144
|
-
'account/subs/transfer/record':
|
|
140
|
+
'orders/fills': 10,
|
|
141
|
+
'account/getBalance': 1,
|
|
142
|
+
'account/subs': 1,
|
|
143
|
+
'account/subs/balance': 1,
|
|
144
|
+
'account/subs/transfer/record': 10,
|
|
145
145
|
'wallet/query/deposit-withdraw': 3,
|
|
146
146
|
},
|
|
147
147
|
'post': {
|
|
148
|
-
'orders/create':
|
|
149
|
-
'orders/
|
|
150
|
-
'
|
|
151
|
-
'
|
|
148
|
+
'orders/create': 5,
|
|
149
|
+
'orders/batch-create': 50,
|
|
150
|
+
'orders/cancel': 1,
|
|
151
|
+
'orders/batch-cancel': 10,
|
|
152
|
+
'orders/cancel-by-symbol': 10,
|
|
153
|
+
'account/subs/transfer': 5,
|
|
154
|
+
'wallet/withdraw/coin': 3,
|
|
155
|
+
'account/withdraw/coin': 3, // not found in doc
|
|
152
156
|
},
|
|
153
157
|
},
|
|
154
158
|
},
|
package/js/src/okcoin.js
CHANGED
|
@@ -49,6 +49,9 @@ export default class okcoin extends Exchange {
|
|
|
49
49
|
'fetchCurrencies': true,
|
|
50
50
|
'fetchDepositAddress': true,
|
|
51
51
|
'fetchDeposits': true,
|
|
52
|
+
'fetchFundingHistory': false,
|
|
53
|
+
'fetchFundingRate': false,
|
|
54
|
+
'fetchFundingRateHistory': false,
|
|
52
55
|
'fetchLedger': true,
|
|
53
56
|
'fetchMarkets': true,
|
|
54
57
|
'fetchMyTrades': true,
|
package/js/src/phemex.js
CHANGED
|
@@ -193,6 +193,7 @@ export default class phemex extends Exchange {
|
|
|
193
193
|
'api-data/g-futures/trades': 5,
|
|
194
194
|
'api-data/futures/trading-fees': 5,
|
|
195
195
|
'api-data/g-futures/trading-fees': 5,
|
|
196
|
+
'api-data/futures/v2/tradeAccountDetail': 5,
|
|
196
197
|
'g-orders/activeList': 1,
|
|
197
198
|
'orders/activeList': 1,
|
|
198
199
|
'exchange/order/list': 5,
|
|
@@ -1917,16 +1918,19 @@ export default class phemex extends Exchange {
|
|
|
1917
1918
|
* @method
|
|
1918
1919
|
* @name phemex#fetchBalance
|
|
1919
1920
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1921
|
+
* @see https://phemex-docs.github.io/#query-wallets
|
|
1920
1922
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
|
|
1923
|
+
* @see https://phemex-docs.github.io/#query-trading-account-and-positions
|
|
1921
1924
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1922
1925
|
* @param {string} [params.type] spot or swap
|
|
1926
|
+
* @param {string} [params.code] *swap only* currency code of the balance to query (USD, USDT, etc), default is USDT
|
|
1923
1927
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1924
1928
|
*/
|
|
1925
1929
|
await this.loadMarkets();
|
|
1926
1930
|
let type = undefined;
|
|
1927
1931
|
[type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1928
1932
|
const code = this.safeString(params, 'code');
|
|
1929
|
-
params = this.omit(params, ['
|
|
1933
|
+
params = this.omit(params, ['code']);
|
|
1930
1934
|
let response = undefined;
|
|
1931
1935
|
const request = {};
|
|
1932
1936
|
if ((type !== 'spot') && (type !== 'swap')) {
|
|
@@ -1934,7 +1938,7 @@ export default class phemex extends Exchange {
|
|
|
1934
1938
|
}
|
|
1935
1939
|
if (type === 'swap') {
|
|
1936
1940
|
let settle = undefined;
|
|
1937
|
-
[settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle');
|
|
1941
|
+
[settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle', 'USDT');
|
|
1938
1942
|
if (code !== undefined || settle !== undefined) {
|
|
1939
1943
|
let coin = undefined;
|
|
1940
1944
|
if (code !== undefined) {
|
|
@@ -2770,7 +2774,7 @@ export default class phemex extends Exchange {
|
|
|
2770
2774
|
}
|
|
2771
2775
|
else if (amount !== undefined) {
|
|
2772
2776
|
if (isUSDTSettled) {
|
|
2773
|
-
request['
|
|
2777
|
+
request['orderQtyRq'] = this.amountToPrecision(market['symbol'], amount);
|
|
2774
2778
|
}
|
|
2775
2779
|
else {
|
|
2776
2780
|
request['baseQtyEV'] = this.toEv(amount, market);
|
package/js/src/poloniex.js
CHANGED