ccxt 4.4.18 → 4.4.20
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.min.js +2 -2
- package/dist/cjs/ccxt.js +3 -1
- package/dist/cjs/src/base/Exchange.js +5 -0
- package/dist/cjs/src/binance.js +22 -3
- package/dist/cjs/src/bingx.js +2 -1
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/bybit.js +2 -1
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/htx.js +24 -0
- package/dist/cjs/src/hyperliquid.js +4 -0
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/kucoinfutures.js +63 -0
- package/dist/cjs/src/lbank.js +3 -3
- package/dist/cjs/src/phemex.js +75 -0
- package/dist/cjs/src/pro/coinbaseadvanced.js +17 -0
- package/js/ccxt.d.ts +4 -1
- package/js/ccxt.js +3 -1
- package/js/src/abstract/binance.d.ts +4 -0
- package/js/src/abstract/binancecoinm.d.ts +4 -0
- package/js/src/abstract/binanceus.d.ts +4 -0
- package/js/src/abstract/binanceusdm.d.ts +4 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/base/Exchange.js +5 -0
- package/js/src/base/types.d.ts +1 -0
- package/js/src/binance.js +22 -3
- package/js/src/bingx.js +2 -1
- package/js/src/bitget.js +1 -1
- package/js/src/bybit.js +2 -1
- package/js/src/gate.js +1 -0
- package/js/src/htx.js +24 -0
- package/js/src/hyperliquid.js +4 -0
- package/js/src/kucoin.js +1 -1
- package/js/src/kucoinfutures.d.ts +1 -0
- package/js/src/kucoinfutures.js +63 -0
- package/js/src/lbank.js +3 -3
- package/js/src/phemex.d.ts +2 -0
- package/js/src/phemex.js +75 -0
- package/js/src/pro/coinbaseadvanced.d.ts +4 -0
- package/js/src/pro/coinbaseadvanced.js +18 -0
- package/package.json +1 -1
package/js/src/base/Exchange.js
CHANGED
|
@@ -6148,6 +6148,8 @@ export default class Exchange {
|
|
|
6148
6148
|
let i = 0;
|
|
6149
6149
|
let errors = 0;
|
|
6150
6150
|
let result = [];
|
|
6151
|
+
const timeframe = this.safeString(params, 'timeframe');
|
|
6152
|
+
params = this.omit(params, 'timeframe'); // reading the timeframe from the method arguments to avoid changing the signature
|
|
6151
6153
|
while (i < maxCalls) {
|
|
6152
6154
|
try {
|
|
6153
6155
|
if (cursorValue !== undefined) {
|
|
@@ -6163,6 +6165,9 @@ export default class Exchange {
|
|
|
6163
6165
|
else if (method === 'getLeverageTiersPaginated' || method === 'fetchPositions') {
|
|
6164
6166
|
response = await this[method](symbol, params);
|
|
6165
6167
|
}
|
|
6168
|
+
else if (method === 'fetchOpenInterestHistory') {
|
|
6169
|
+
response = await this[method](symbol, timeframe, since, maxEntriesPerRequest, params);
|
|
6170
|
+
}
|
|
6166
6171
|
else {
|
|
6167
6172
|
response = await this[method](symbol, since, maxEntriesPerRequest, params);
|
|
6168
6173
|
}
|
package/js/src/base/types.d.ts
CHANGED
package/js/src/binance.js
CHANGED
|
@@ -807,6 +807,7 @@ export default class binance extends Exchange {
|
|
|
807
807
|
'constituents': 2,
|
|
808
808
|
'apiTradingStatus': { 'cost': 1, 'noSymbol': 10 },
|
|
809
809
|
'lvtKlines': 1,
|
|
810
|
+
'convert/exchangeInfo': 4,
|
|
810
811
|
},
|
|
811
812
|
},
|
|
812
813
|
'fapiData': {
|
|
@@ -860,6 +861,7 @@ export default class binance extends Exchange {
|
|
|
860
861
|
'feeBurn': 1,
|
|
861
862
|
'symbolConfig': 5,
|
|
862
863
|
'accountConfig': 5,
|
|
864
|
+
'convert/orderStatus': 5,
|
|
863
865
|
},
|
|
864
866
|
'post': {
|
|
865
867
|
'batchOrders': 5,
|
|
@@ -875,6 +877,8 @@ export default class binance extends Exchange {
|
|
|
875
877
|
'apiReferral/customization': 1,
|
|
876
878
|
'apiReferral/userCustomization': 1,
|
|
877
879
|
'feeBurn': 1,
|
|
880
|
+
'convert/getQuote': 200,
|
|
881
|
+
'convert/acceptQuote': 20,
|
|
878
882
|
},
|
|
879
883
|
'put': {
|
|
880
884
|
'listenKey': 1,
|
|
@@ -3202,8 +3206,8 @@ export default class binance extends Exchange {
|
|
|
3202
3206
|
let fees = this.fees;
|
|
3203
3207
|
let linear = undefined;
|
|
3204
3208
|
let inverse = undefined;
|
|
3205
|
-
const strike = this.safeString(market, 'strikePrice');
|
|
3206
3209
|
let symbol = base + '/' + quote;
|
|
3210
|
+
let strike = undefined;
|
|
3207
3211
|
if (contract) {
|
|
3208
3212
|
if (swap) {
|
|
3209
3213
|
symbol = symbol + ':' + settle;
|
|
@@ -3212,6 +3216,7 @@ export default class binance extends Exchange {
|
|
|
3212
3216
|
symbol = symbol + ':' + settle + '-' + this.yymmdd(expiry);
|
|
3213
3217
|
}
|
|
3214
3218
|
else if (option) {
|
|
3219
|
+
strike = this.numberToString(this.parseToNumeric(this.safeString(market, 'strikePrice')));
|
|
3215
3220
|
symbol = symbol + ':' + settle + '-' + this.yymmdd(expiry) + '-' + strike + '-' + this.safeString(optionParts, 3);
|
|
3216
3221
|
}
|
|
3217
3222
|
contractSize = this.safeNumber2(market, 'contractSize', 'unit', this.parseNumber('1'));
|
|
@@ -6285,14 +6290,28 @@ export default class binance extends Exchange {
|
|
|
6285
6290
|
request['quantity'] = this.parseToNumeric(amount);
|
|
6286
6291
|
}
|
|
6287
6292
|
else {
|
|
6288
|
-
|
|
6293
|
+
const marketAmountPrecision = this.safeString(market['precision'], 'amount');
|
|
6294
|
+
const isPrecisionAvailable = (marketAmountPrecision !== undefined);
|
|
6295
|
+
if (isPrecisionAvailable) {
|
|
6296
|
+
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
6297
|
+
}
|
|
6298
|
+
else {
|
|
6299
|
+
request['quantity'] = this.parseToNumeric(amount); // some options don't have the precision available
|
|
6300
|
+
}
|
|
6289
6301
|
}
|
|
6290
6302
|
}
|
|
6291
6303
|
if (priceIsRequired && !isPriceMatch) {
|
|
6292
6304
|
if (price === undefined) {
|
|
6293
6305
|
throw new InvalidOrder(this.id + ' createOrder() requires a price argument for a ' + type + ' order');
|
|
6294
6306
|
}
|
|
6295
|
-
|
|
6307
|
+
const pricePrecision = this.safeString(market['precision'], 'price');
|
|
6308
|
+
const isPricePrecisionAvailable = (pricePrecision !== undefined);
|
|
6309
|
+
if (isPricePrecisionAvailable) {
|
|
6310
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
6311
|
+
}
|
|
6312
|
+
else {
|
|
6313
|
+
request['price'] = this.parseToNumeric(price); // some options don't have the precision available
|
|
6314
|
+
}
|
|
6296
6315
|
}
|
|
6297
6316
|
if (stopPriceIsRequired) {
|
|
6298
6317
|
if (market['contract']) {
|
package/js/src/bingx.js
CHANGED
|
@@ -496,6 +496,7 @@ export default class bingx extends Exchange {
|
|
|
496
496
|
},
|
|
497
497
|
'networks': {
|
|
498
498
|
'ARB': 'ARBITRUM',
|
|
499
|
+
'MATIC': 'POLYGON',
|
|
499
500
|
},
|
|
500
501
|
},
|
|
501
502
|
});
|
|
@@ -775,7 +776,7 @@ export default class bingx extends Exchange {
|
|
|
775
776
|
if ((this.safeString(market, 'apiStateOpen') === 'true') && (this.safeString(market, 'apiStateClose') === 'true')) {
|
|
776
777
|
isActive = true; // swap active
|
|
777
778
|
}
|
|
778
|
-
else if (this.safeBool(market, 'apiStateSell') && this.safeBool(market, 'apiStateBuy') && (this.
|
|
779
|
+
else if (this.safeBool(market, 'apiStateSell') && this.safeBool(market, 'apiStateBuy') && (this.safeString(market, 'status') === '1')) {
|
|
779
780
|
isActive = true; // spot active
|
|
780
781
|
}
|
|
781
782
|
const isInverse = (spot) ? undefined : checkIsInverse;
|
package/js/src/bitget.js
CHANGED
|
@@ -1426,7 +1426,7 @@ export default class bitget extends Exchange {
|
|
|
1426
1426
|
'ARB': 'ArbitrumOne',
|
|
1427
1427
|
'ZKSYNC': 'zkSyncEra',
|
|
1428
1428
|
'STARKNET': 'Starknet',
|
|
1429
|
-
'APT': '
|
|
1429
|
+
'APT': 'Aptos',
|
|
1430
1430
|
'MATIC': 'Polygon',
|
|
1431
1431
|
'VIC': 'VICTION',
|
|
1432
1432
|
'AVAXC': 'C-Chain',
|
package/js/src/bybit.js
CHANGED
|
@@ -7242,7 +7242,8 @@ export default class bybit extends Exchange {
|
|
|
7242
7242
|
const paginate = this.safeBool(params, 'paginate');
|
|
7243
7243
|
if (paginate) {
|
|
7244
7244
|
params = this.omit(params, 'paginate');
|
|
7245
|
-
|
|
7245
|
+
params['timeframe'] = timeframe;
|
|
7246
|
+
return await this.fetchPaginatedCallCursor('fetchOpenInterestHistory', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 200);
|
|
7246
7247
|
}
|
|
7247
7248
|
const market = this.market(symbol);
|
|
7248
7249
|
if (market['spot'] || market['option']) {
|
package/js/src/gate.js
CHANGED
|
@@ -4737,6 +4737,7 @@ export default class gate extends Exchange {
|
|
|
4737
4737
|
* @name gate#fetchOpenOrders
|
|
4738
4738
|
* @description fetch all unfilled currently open orders
|
|
4739
4739
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-open-orders
|
|
4740
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-running-auto-order-list
|
|
4740
4741
|
* @param {string} symbol unified market symbol
|
|
4741
4742
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
4742
4743
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
package/js/src/htx.js
CHANGED
|
@@ -1238,6 +1238,18 @@ export default class htx extends Exchange {
|
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
1240
|
async fetchStatus(params = {}) {
|
|
1241
|
+
/**
|
|
1242
|
+
* @method
|
|
1243
|
+
* @name htx#fetchStatus
|
|
1244
|
+
* @description the latest known information on the availability of the exchange API
|
|
1245
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-system-status
|
|
1246
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-system-status
|
|
1247
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-system-status
|
|
1248
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#get-system-status
|
|
1249
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#query-whether-the-system-is-available // contractPublicGetHeartbeat
|
|
1250
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1251
|
+
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
1252
|
+
*/
|
|
1241
1253
|
await this.loadMarkets();
|
|
1242
1254
|
let marketType = undefined;
|
|
1243
1255
|
[marketType, params] = this.handleMarketTypeAndParams('fetchStatus', undefined, params);
|
|
@@ -1464,6 +1476,8 @@ export default class htx extends Exchange {
|
|
|
1464
1476
|
* @method
|
|
1465
1477
|
* @name htx#fetchTime
|
|
1466
1478
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
1479
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-current-timestamp
|
|
1480
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-current-system-timestamp
|
|
1467
1481
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1468
1482
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
1469
1483
|
*/
|
|
@@ -1514,6 +1528,7 @@ export default class htx extends Exchange {
|
|
|
1514
1528
|
* @method
|
|
1515
1529
|
* @name htx#fetchTradingFee
|
|
1516
1530
|
* @description fetch the trading fees for a market
|
|
1531
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user
|
|
1517
1532
|
* @param {string} symbol unified market symbol
|
|
1518
1533
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1519
1534
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
@@ -1559,6 +1574,15 @@ export default class htx extends Exchange {
|
|
|
1559
1574
|
return result;
|
|
1560
1575
|
}
|
|
1561
1576
|
async fetchTradingLimitsById(id, params = {}) {
|
|
1577
|
+
/**
|
|
1578
|
+
* @ignore
|
|
1579
|
+
* @method
|
|
1580
|
+
* @name htx#fetchTradingLimitsById
|
|
1581
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user
|
|
1582
|
+
* @param {string} id market id
|
|
1583
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1584
|
+
* @returns {object} the limits object of a market structure
|
|
1585
|
+
*/
|
|
1562
1586
|
const request = {
|
|
1563
1587
|
'symbol': id,
|
|
1564
1588
|
};
|
package/js/src/hyperliquid.js
CHANGED
|
@@ -1986,6 +1986,10 @@ export default class hyperliquid extends Exchange {
|
|
|
1986
1986
|
const statuses = {
|
|
1987
1987
|
'triggered': 'open',
|
|
1988
1988
|
'filled': 'closed',
|
|
1989
|
+
'open': 'open',
|
|
1990
|
+
'canceled': 'canceled',
|
|
1991
|
+
'rejected': 'rejected',
|
|
1992
|
+
'marginCanceled': 'canceled',
|
|
1989
1993
|
};
|
|
1990
1994
|
return this.safeString(statuses, status, status);
|
|
1991
1995
|
}
|
package/js/src/kucoin.js
CHANGED
|
@@ -5040,7 +5040,7 @@ export default class kucoin extends Exchange {
|
|
|
5040
5040
|
headers = (headers !== undefined) ? headers : {};
|
|
5041
5041
|
let url = this.urls['api'][api];
|
|
5042
5042
|
if (!this.isEmpty(query)) {
|
|
5043
|
-
if ((method === 'GET') || (method === 'DELETE')) {
|
|
5043
|
+
if (((method === 'GET') || (method === 'DELETE')) && (path !== 'orders/multi-cancel')) {
|
|
5044
5044
|
endpoint += '?' + this.rawencode(query);
|
|
5045
5045
|
}
|
|
5046
5046
|
else {
|
|
@@ -33,6 +33,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
33
33
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
34
34
|
createContractOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
|
|
35
35
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
|
|
36
|
+
cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
|
|
36
37
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
37
38
|
addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
|
|
38
39
|
parseMarginModification(info: any, market?: Market): MarginModification;
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -36,6 +36,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
36
36
|
'addMargin': true,
|
|
37
37
|
'cancelAllOrders': true,
|
|
38
38
|
'cancelOrder': true,
|
|
39
|
+
'cancelOrders': true,
|
|
39
40
|
'closeAllPositions': false,
|
|
40
41
|
'closePosition': true,
|
|
41
42
|
'closePositions': false,
|
|
@@ -207,6 +208,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
207
208
|
'stopOrders': 1,
|
|
208
209
|
'sub/api-key': 1,
|
|
209
210
|
'orders/client-order/{clientOid}': 1,
|
|
211
|
+
'orders/multi-cancel': 20,
|
|
210
212
|
},
|
|
211
213
|
},
|
|
212
214
|
'webExchange': {
|
|
@@ -1665,6 +1667,67 @@ export default class kucoinfutures extends kucoin {
|
|
|
1665
1667
|
//
|
|
1666
1668
|
return this.safeValue(response, 'data');
|
|
1667
1669
|
}
|
|
1670
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
1671
|
+
/**
|
|
1672
|
+
* @method
|
|
1673
|
+
* @name kucoinfutures#cancelOrders
|
|
1674
|
+
* @description cancel multiple orders
|
|
1675
|
+
* @see https://www.kucoin.com/docs/rest/futures-trading/orders/batch-cancel-orders
|
|
1676
|
+
* @param {string[]} ids order ids
|
|
1677
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1678
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1679
|
+
* @param {string[]} [params.clientOrderIds] client order ids
|
|
1680
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1681
|
+
*/
|
|
1682
|
+
await this.loadMarkets();
|
|
1683
|
+
let market = undefined;
|
|
1684
|
+
if (symbol !== undefined) {
|
|
1685
|
+
market = this.market(symbol);
|
|
1686
|
+
}
|
|
1687
|
+
const ordersRequests = [];
|
|
1688
|
+
const clientOrderIds = this.safeList2(params, 'clientOrderIds', 'clientOids', []);
|
|
1689
|
+
params = this.omit(params, ['clientOrderIds', 'clientOids']);
|
|
1690
|
+
let useClientorderId = false;
|
|
1691
|
+
for (let i = 0; i < clientOrderIds.length; i++) {
|
|
1692
|
+
useClientorderId = true;
|
|
1693
|
+
if (symbol === undefined) {
|
|
1694
|
+
throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument when cancelling by clientOrderIds');
|
|
1695
|
+
}
|
|
1696
|
+
ordersRequests.push({
|
|
1697
|
+
'symbol': market['id'],
|
|
1698
|
+
'clientOid': this.safeString(clientOrderIds, i),
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
for (let i = 0; i < ids.length; i++) {
|
|
1702
|
+
ordersRequests.push(ids[i]);
|
|
1703
|
+
}
|
|
1704
|
+
const requestKey = useClientorderId ? 'clientOidsList' : 'orderIdsList';
|
|
1705
|
+
const request = {};
|
|
1706
|
+
request[requestKey] = ordersRequests;
|
|
1707
|
+
const response = await this.futuresPrivateDeleteOrdersMultiCancel(this.extend(request, params));
|
|
1708
|
+
//
|
|
1709
|
+
// {
|
|
1710
|
+
// "code": "200000",
|
|
1711
|
+
// "data":
|
|
1712
|
+
// [
|
|
1713
|
+
// {
|
|
1714
|
+
// "orderId": "80465574458560512",
|
|
1715
|
+
// "clientOid": null,
|
|
1716
|
+
// "code": "200",
|
|
1717
|
+
// "msg": "success"
|
|
1718
|
+
// },
|
|
1719
|
+
// {
|
|
1720
|
+
// "orderId": "80465575289094144",
|
|
1721
|
+
// "clientOid": null,
|
|
1722
|
+
// "code": "200",
|
|
1723
|
+
// "msg": "success"
|
|
1724
|
+
// }
|
|
1725
|
+
// ]
|
|
1726
|
+
// }
|
|
1727
|
+
//
|
|
1728
|
+
const orders = this.safeList(response, 'data', []);
|
|
1729
|
+
return this.parseOrders(orders, market);
|
|
1730
|
+
}
|
|
1668
1731
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1669
1732
|
/**
|
|
1670
1733
|
* @method
|
package/js/src/lbank.js
CHANGED
|
@@ -1010,16 +1010,16 @@ export default class lbank extends Exchange {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
if (since === undefined) {
|
|
1012
1012
|
const duration = this.parseTimeframe(timeframe);
|
|
1013
|
-
since = this.milliseconds() - duration * 1000 * limit;
|
|
1013
|
+
since = this.milliseconds() - (duration * 1000 * limit);
|
|
1014
1014
|
}
|
|
1015
1015
|
const request = {
|
|
1016
1016
|
'symbol': market['id'],
|
|
1017
1017
|
'type': this.safeString(this.timeframes, timeframe, timeframe),
|
|
1018
1018
|
'time': this.parseToInt(since / 1000),
|
|
1019
|
-
'size': limit, // max 2000
|
|
1019
|
+
'size': Math.min(limit + 1, 2000), // max 2000
|
|
1020
1020
|
};
|
|
1021
1021
|
const response = await this.spotPublicGetKline(this.extend(request, params));
|
|
1022
|
-
const ohlcvs = this.
|
|
1022
|
+
const ohlcvs = this.safeList(response, 'data', []);
|
|
1023
1023
|
//
|
|
1024
1024
|
//
|
|
1025
1025
|
// [
|
package/js/src/phemex.d.ts
CHANGED
|
@@ -78,5 +78,7 @@ export default class phemex extends Exchange {
|
|
|
78
78
|
parseTransferStatus(status: Str): Str;
|
|
79
79
|
fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
80
80
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
81
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
82
|
+
parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
|
|
81
83
|
handleErrors(httpCode: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
|
|
82
84
|
}
|
package/js/src/phemex.js
CHANGED
|
@@ -69,6 +69,7 @@ export default class phemex extends Exchange {
|
|
|
69
69
|
'fetchMarkOHLCV': false,
|
|
70
70
|
'fetchMyTrades': true,
|
|
71
71
|
'fetchOHLCV': true,
|
|
72
|
+
'fetchOpenInterest': true,
|
|
72
73
|
'fetchOpenOrders': true,
|
|
73
74
|
'fetchOrder': true,
|
|
74
75
|
'fetchOrderBook': true,
|
|
@@ -4852,6 +4853,80 @@ export default class phemex extends Exchange {
|
|
|
4852
4853
|
const data = this.safeDict(response, 'data', {});
|
|
4853
4854
|
return this.parseTransaction(data, currency);
|
|
4854
4855
|
}
|
|
4856
|
+
async fetchOpenInterest(symbol, params = {}) {
|
|
4857
|
+
/**
|
|
4858
|
+
* @method
|
|
4859
|
+
* @name phemex#fetchOpenInterest
|
|
4860
|
+
* @description retrieves the open interest of a trading pair
|
|
4861
|
+
* @see https://phemex-docs.github.io/#query-24-hours-ticker
|
|
4862
|
+
* @param {string} symbol unified CCXT market symbol
|
|
4863
|
+
* @param {object} [params] exchange specific parameters
|
|
4864
|
+
* @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
4865
|
+
*/
|
|
4866
|
+
await this.loadMarkets();
|
|
4867
|
+
const market = this.market(symbol);
|
|
4868
|
+
if (!market['contract']) {
|
|
4869
|
+
throw new BadRequest(this.id + ' fetchOpenInterest is only supported for contract markets.');
|
|
4870
|
+
}
|
|
4871
|
+
const request = {
|
|
4872
|
+
'symbol': market['id'],
|
|
4873
|
+
};
|
|
4874
|
+
const response = await this.v2GetMdV2Ticker24hr(this.extend(request, params));
|
|
4875
|
+
//
|
|
4876
|
+
// {
|
|
4877
|
+
// error: null,
|
|
4878
|
+
// id: '0',
|
|
4879
|
+
// result: {
|
|
4880
|
+
// closeRp: '67550.1',
|
|
4881
|
+
// fundingRateRr: '0.0001',
|
|
4882
|
+
// highRp: '68400',
|
|
4883
|
+
// indexPriceRp: '67567.15389794',
|
|
4884
|
+
// lowRp: '66096.4',
|
|
4885
|
+
// markPriceRp: '67550.1',
|
|
4886
|
+
// openInterestRv: '1848.1144186',
|
|
4887
|
+
// openRp: '66330',
|
|
4888
|
+
// predFundingRateRr: '0.0001',
|
|
4889
|
+
// symbol: 'BTCUSDT',
|
|
4890
|
+
// timestamp: '1729114315443343001',
|
|
4891
|
+
// turnoverRv: '228863389.3237532',
|
|
4892
|
+
// volumeRq: '3388.5600312'
|
|
4893
|
+
// }
|
|
4894
|
+
// }
|
|
4895
|
+
//
|
|
4896
|
+
const result = this.safeDict(response, 'result');
|
|
4897
|
+
return this.parseOpenInterest(result, market);
|
|
4898
|
+
}
|
|
4899
|
+
parseOpenInterest(interest, market = undefined) {
|
|
4900
|
+
//
|
|
4901
|
+
// {
|
|
4902
|
+
// closeRp: '67550.1',
|
|
4903
|
+
// fundingRateRr: '0.0001',
|
|
4904
|
+
// highRp: '68400',
|
|
4905
|
+
// indexPriceRp: '67567.15389794',
|
|
4906
|
+
// lowRp: '66096.4',
|
|
4907
|
+
// markPriceRp: '67550.1',
|
|
4908
|
+
// openInterestRv: '1848.1144186',
|
|
4909
|
+
// openRp: '66330',
|
|
4910
|
+
// predFundingRateRr: '0.0001',
|
|
4911
|
+
// symbol: 'BTCUSDT',
|
|
4912
|
+
// timestamp: '1729114315443343001',
|
|
4913
|
+
// turnoverRv: '228863389.3237532',
|
|
4914
|
+
// volumeRq: '3388.5600312'
|
|
4915
|
+
// }
|
|
4916
|
+
//
|
|
4917
|
+
const timestamp = this.safeInteger(interest, 'timestamp') / 1000000;
|
|
4918
|
+
const id = this.safeString(interest, 'symbol');
|
|
4919
|
+
return this.safeOpenInterest({
|
|
4920
|
+
'info': interest,
|
|
4921
|
+
'symbol': this.safeSymbol(id, market),
|
|
4922
|
+
'baseVolume': this.safeString(interest, 'volumeRq'),
|
|
4923
|
+
'quoteVolume': undefined,
|
|
4924
|
+
'openInterestAmount': this.safeString(interest, 'openInterestRv'),
|
|
4925
|
+
'openInterestValue': undefined,
|
|
4926
|
+
'timestamp': timestamp,
|
|
4927
|
+
'datetime': this.iso8601(timestamp),
|
|
4928
|
+
}, market);
|
|
4929
|
+
}
|
|
4855
4930
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
4856
4931
|
if (response === undefined) {
|
|
4857
4932
|
return undefined; // fallback to default error handler
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
import coinbase from './coinbase.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
export default class coinbaseadvanced extends coinbase {
|
|
11
|
+
describe() {
|
|
12
|
+
return this.deepExtend(super.describe(), {
|
|
13
|
+
'id': 'coinbaseadvanced',
|
|
14
|
+
'name': 'Coinbase Advanced',
|
|
15
|
+
'alias': true,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
CHANGED