ccxt 4.2.71 → 4.2.72
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 +195 -16
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +149 -2
- package/dist/cjs/src/pro/bingx.js +29 -6
- package/dist/cjs/src/pro/hitbtc.js +16 -7
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/ascendex.d.ts +5 -1
- package/js/src/ascendex.js +149 -2
- package/js/src/base/Exchange.d.ts +56 -56
- package/js/src/base/types.d.ts +10 -0
- package/js/src/binance.d.ts +1 -1
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitrue.d.ts +3 -3
- package/js/src/cex.d.ts +1 -1
- package/js/src/gate.d.ts +1 -1
- package/js/src/htx.d.ts +1 -1
- package/js/src/idex.d.ts +1 -1
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/poloniexfutures.d.ts +2 -2
- package/js/src/pro/bingx.d.ts +1 -0
- package/js/src/pro/bingx.js +29 -6
- package/js/src/pro/bitvavo.d.ts +8 -8
- package/js/src/pro/bybit.d.ts +1 -1
- package/js/src/pro/cex.d.ts +5 -5
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/hitbtc.js +16 -7
- package/js/src/pro/poloniex.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -210,13 +210,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
210
210
|
|
|
211
211
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
212
212
|
|
|
213
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
214
|
-
* unpkg: https://unpkg.com/ccxt@4.2.
|
|
213
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.72/dist/ccxt.browser.js
|
|
214
|
+
* unpkg: https://unpkg.com/ccxt@4.2.72/dist/ccxt.browser.js
|
|
215
215
|
|
|
216
216
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
217
217
|
|
|
218
218
|
```HTML
|
|
219
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
219
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.72/dist/ccxt.browser.js"></script>
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -3713,9 +3713,11 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
3713
3713
|
'fetchFundingRateHistory': false,
|
|
3714
3714
|
'fetchFundingRates': true,
|
|
3715
3715
|
'fetchIndexOHLCV': false,
|
|
3716
|
-
'fetchLeverage':
|
|
3716
|
+
'fetchLeverage': 'emulated',
|
|
3717
|
+
'fetchLeverages': true,
|
|
3717
3718
|
'fetchLeverageTiers': true,
|
|
3718
|
-
'fetchMarginMode':
|
|
3719
|
+
'fetchMarginMode': 'emulated',
|
|
3720
|
+
'fetchMarginModes': true,
|
|
3719
3721
|
'fetchMarketLeverageTiers': 'emulated',
|
|
3720
3722
|
'fetchMarkets': true,
|
|
3721
3723
|
'fetchMarkOHLCV': false,
|
|
@@ -6931,6 +6933,151 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
6931
6933
|
'amount': this.safeNumber(income, 'paymentInUSDT'),
|
|
6932
6934
|
};
|
|
6933
6935
|
}
|
|
6936
|
+
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
6937
|
+
/**
|
|
6938
|
+
* @method
|
|
6939
|
+
* @name ascendex#fetchMarginMode
|
|
6940
|
+
* @description fetches the set margin mode of the user
|
|
6941
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
|
|
6942
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
6943
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6944
|
+
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
6945
|
+
*/
|
|
6946
|
+
await this.loadMarkets();
|
|
6947
|
+
await this.loadAccounts();
|
|
6948
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
6949
|
+
const accountGroup = this.safeString(account, 'id');
|
|
6950
|
+
const request = {
|
|
6951
|
+
'account-group': accountGroup,
|
|
6952
|
+
};
|
|
6953
|
+
const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
|
|
6954
|
+
//
|
|
6955
|
+
// {
|
|
6956
|
+
// "code": 0,
|
|
6957
|
+
// "data": {
|
|
6958
|
+
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
6959
|
+
// "ac": "FUTURES",
|
|
6960
|
+
// "collaterals": [
|
|
6961
|
+
// {
|
|
6962
|
+
// "asset": "USDT",
|
|
6963
|
+
// "balance": "44.570287262",
|
|
6964
|
+
// "referencePrice": "1",
|
|
6965
|
+
// "discountFactor": "1"
|
|
6966
|
+
// }
|
|
6967
|
+
// ],
|
|
6968
|
+
// "contracts": [
|
|
6969
|
+
// {
|
|
6970
|
+
// "symbol": "BTC-PERP",
|
|
6971
|
+
// "side": "LONG",
|
|
6972
|
+
// "position": "0.0001",
|
|
6973
|
+
// "referenceCost": "-3.12277254",
|
|
6974
|
+
// "unrealizedPnl": "-0.001700233",
|
|
6975
|
+
// "realizedPnl": "0",
|
|
6976
|
+
// "avgOpenPrice": "31209",
|
|
6977
|
+
// "marginType": "isolated",
|
|
6978
|
+
// "isolatedMargin": "1.654972977",
|
|
6979
|
+
// "leverage": "2",
|
|
6980
|
+
// "takeProfitPrice": "0",
|
|
6981
|
+
// "takeProfitTrigger": "market",
|
|
6982
|
+
// "stopLossPrice": "0",
|
|
6983
|
+
// "stopLossTrigger": "market",
|
|
6984
|
+
// "buyOpenOrderNotional": "0",
|
|
6985
|
+
// "sellOpenOrderNotional": "0",
|
|
6986
|
+
// "markPrice": "31210.723063672",
|
|
6987
|
+
// "indexPrice": "31223.148857925"
|
|
6988
|
+
// },
|
|
6989
|
+
// ]
|
|
6990
|
+
// }
|
|
6991
|
+
// }
|
|
6992
|
+
//
|
|
6993
|
+
const data = this.safeDict(response, 'data', {});
|
|
6994
|
+
const marginModes = this.safeList(data, 'contracts', []);
|
|
6995
|
+
return this.parseMarginModes(marginModes, symbols, 'symbol');
|
|
6996
|
+
}
|
|
6997
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
6998
|
+
const marketId = this.safeString(marginMode, 'symbol');
|
|
6999
|
+
const marginType = this.safeString(marginMode, 'marginType');
|
|
7000
|
+
const margin = (marginType === 'crossed') ? 'cross' : 'isolated';
|
|
7001
|
+
return {
|
|
7002
|
+
'info': marginMode,
|
|
7003
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
7004
|
+
'marginMode': margin,
|
|
7005
|
+
};
|
|
7006
|
+
}
|
|
7007
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
7008
|
+
/**
|
|
7009
|
+
* @method
|
|
7010
|
+
* @name ascendex#fetchLeverages
|
|
7011
|
+
* @description fetch the set leverage for all contract markets
|
|
7012
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
|
|
7013
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
7014
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7015
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
7016
|
+
*/
|
|
7017
|
+
await this.loadMarkets();
|
|
7018
|
+
await this.loadAccounts();
|
|
7019
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
7020
|
+
const accountGroup = this.safeString(account, 'id');
|
|
7021
|
+
const request = {
|
|
7022
|
+
'account-group': accountGroup,
|
|
7023
|
+
};
|
|
7024
|
+
const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
|
|
7025
|
+
//
|
|
7026
|
+
// {
|
|
7027
|
+
// "code": 0,
|
|
7028
|
+
// "data": {
|
|
7029
|
+
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
7030
|
+
// "ac": "FUTURES",
|
|
7031
|
+
// "collaterals": [
|
|
7032
|
+
// {
|
|
7033
|
+
// "asset": "USDT",
|
|
7034
|
+
// "balance": "44.570287262",
|
|
7035
|
+
// "referencePrice": "1",
|
|
7036
|
+
// "discountFactor": "1"
|
|
7037
|
+
// }
|
|
7038
|
+
// ],
|
|
7039
|
+
// "contracts": [
|
|
7040
|
+
// {
|
|
7041
|
+
// "symbol": "BTC-PERP",
|
|
7042
|
+
// "side": "LONG",
|
|
7043
|
+
// "position": "0.0001",
|
|
7044
|
+
// "referenceCost": "-3.12277254",
|
|
7045
|
+
// "unrealizedPnl": "-0.001700233",
|
|
7046
|
+
// "realizedPnl": "0",
|
|
7047
|
+
// "avgOpenPrice": "31209",
|
|
7048
|
+
// "marginType": "isolated",
|
|
7049
|
+
// "isolatedMargin": "1.654972977",
|
|
7050
|
+
// "leverage": "2",
|
|
7051
|
+
// "takeProfitPrice": "0",
|
|
7052
|
+
// "takeProfitTrigger": "market",
|
|
7053
|
+
// "stopLossPrice": "0",
|
|
7054
|
+
// "stopLossTrigger": "market",
|
|
7055
|
+
// "buyOpenOrderNotional": "0",
|
|
7056
|
+
// "sellOpenOrderNotional": "0",
|
|
7057
|
+
// "markPrice": "31210.723063672",
|
|
7058
|
+
// "indexPrice": "31223.148857925"
|
|
7059
|
+
// },
|
|
7060
|
+
// ]
|
|
7061
|
+
// }
|
|
7062
|
+
// }
|
|
7063
|
+
//
|
|
7064
|
+
const data = this.safeDict(response, 'data', {});
|
|
7065
|
+
const leverages = this.safeList(data, 'contracts', []);
|
|
7066
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
7067
|
+
}
|
|
7068
|
+
parseLeverage(leverage, market = undefined) {
|
|
7069
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
7070
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
7071
|
+
const marginType = this.safeString(leverage, 'marginType');
|
|
7072
|
+
const marginMode = (marginType === 'crossed') ? 'cross' : 'isolated';
|
|
7073
|
+
return {
|
|
7074
|
+
'info': leverage,
|
|
7075
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
7076
|
+
'marginMode': marginMode,
|
|
7077
|
+
'longLeverage': leverageValue,
|
|
7078
|
+
'shortLeverage': leverageValue,
|
|
7079
|
+
};
|
|
7080
|
+
}
|
|
6934
7081
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
6935
7082
|
const version = api[0];
|
|
6936
7083
|
const access = api[1];
|
|
@@ -227796,21 +227943,44 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
227796
227943
|
}
|
|
227797
227944
|
return true;
|
|
227798
227945
|
}
|
|
227799
|
-
async
|
|
227800
|
-
const time = this.milliseconds();
|
|
227946
|
+
async keepAliveListenKey(params = {}) {
|
|
227801
227947
|
const listenKey = this.safeString(this.options, 'listenKey');
|
|
227802
227948
|
if (listenKey === undefined) {
|
|
227803
|
-
|
|
227804
|
-
|
|
227805
|
-
|
|
227949
|
+
// A network error happened: we can't renew a listen key that does not exist.
|
|
227950
|
+
return;
|
|
227951
|
+
}
|
|
227952
|
+
try {
|
|
227953
|
+
await this.userAuthPrivatePutUserDataStream({ 'listenKey': listenKey }); // extend the expiry
|
|
227954
|
+
}
|
|
227955
|
+
catch (error) {
|
|
227956
|
+
const types = ['spot', 'swap'];
|
|
227957
|
+
for (let i = 0; i < types.length; i++) {
|
|
227958
|
+
const type = types[i];
|
|
227959
|
+
const url = this.urls['api']['ws'][type] + '?listenKey=' + listenKey;
|
|
227960
|
+
const client = this.client(url);
|
|
227961
|
+
const messageHashes = Object.keys(client.futures);
|
|
227962
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
227963
|
+
const messageHash = messageHashes[j];
|
|
227964
|
+
client.reject(error, messageHash);
|
|
227965
|
+
}
|
|
227966
|
+
}
|
|
227967
|
+
this.options['listenKey'] = undefined;
|
|
227968
|
+
this.options['lastAuthenticatedTime'] = 0;
|
|
227806
227969
|
return;
|
|
227807
227970
|
}
|
|
227971
|
+
// whether or not to schedule another listenKey keepAlive request
|
|
227972
|
+
const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000);
|
|
227973
|
+
this.delay(listenKeyRefreshRate, this.keepAliveListenKey, params);
|
|
227974
|
+
}
|
|
227975
|
+
async authenticate(params = {}) {
|
|
227976
|
+
const time = this.milliseconds();
|
|
227808
227977
|
const lastAuthenticatedTime = this.safeInteger(this.options, 'lastAuthenticatedTime', 0);
|
|
227809
227978
|
const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000); // 1 hour
|
|
227810
227979
|
if (time - lastAuthenticatedTime > listenKeyRefreshRate) {
|
|
227811
|
-
const response = await this.
|
|
227980
|
+
const response = await this.userAuthPrivatePostUserDataStream();
|
|
227812
227981
|
this.options['listenKey'] = this.safeString(response, 'listenKey');
|
|
227813
227982
|
this.options['lastAuthenticatedTime'] = time;
|
|
227983
|
+
this.delay(listenKeyRefreshRate, this.keepAliveListenKey, params);
|
|
227814
227984
|
}
|
|
227815
227985
|
}
|
|
227816
227986
|
async pong(client, message) {
|
|
@@ -251134,7 +251304,10 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
251134
251304
|
// }
|
|
251135
251305
|
// }
|
|
251136
251306
|
//
|
|
251137
|
-
const
|
|
251307
|
+
const snapshot = this.safeDict(message, 'snapshot');
|
|
251308
|
+
const update = this.safeDict(message, 'update');
|
|
251309
|
+
const data = snapshot ? snapshot : update;
|
|
251310
|
+
const type = snapshot ? 'snapshot' : 'update';
|
|
251138
251311
|
const marketIds = Object.keys(data);
|
|
251139
251312
|
for (let i = 0; i < marketIds.length; i++) {
|
|
251140
251313
|
const marketId = marketIds[i];
|
|
@@ -251143,17 +251316,23 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
251143
251316
|
const item = data[marketId];
|
|
251144
251317
|
const messageHash = 'orderbooks::' + symbol;
|
|
251145
251318
|
if (!(symbol in this.orderbooks)) {
|
|
251146
|
-
const subscription = this.
|
|
251319
|
+
const subscription = this.safeDict(client.subscriptions, messageHash, {});
|
|
251147
251320
|
const limit = this.safeInteger(subscription, 'limit');
|
|
251148
251321
|
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
251149
251322
|
}
|
|
251323
|
+
const orderbook = this.orderbooks[symbol];
|
|
251150
251324
|
const timestamp = this.safeInteger(item, 't');
|
|
251151
251325
|
const nonce = this.safeInteger(item, 's');
|
|
251152
|
-
|
|
251153
|
-
|
|
251154
|
-
|
|
251155
|
-
|
|
251156
|
-
|
|
251326
|
+
if (type === 'snapshot') {
|
|
251327
|
+
const parsedSnapshot = this.parseOrderBook(item, symbol, timestamp, 'b', 'a');
|
|
251328
|
+
orderbook.reset(parsedSnapshot);
|
|
251329
|
+
}
|
|
251330
|
+
else {
|
|
251331
|
+
const asks = this.safeList(item, 'a', []);
|
|
251332
|
+
const bids = this.safeList(item, 'b', []);
|
|
251333
|
+
this.handleDeltas(orderbook['asks'], asks);
|
|
251334
|
+
this.handleDeltas(orderbook['bids'], bids);
|
|
251335
|
+
}
|
|
251157
251336
|
orderbook['timestamp'] = timestamp;
|
|
251158
251337
|
orderbook['datetime'] = this.iso8601(timestamp);
|
|
251159
251338
|
orderbook['nonce'] = nonce;
|
|
@@ -317879,7 +318058,7 @@ SOFTWARE.
|
|
|
317879
318058
|
|
|
317880
318059
|
//-----------------------------------------------------------------------------
|
|
317881
318060
|
// this is updated by vss.js when building
|
|
317882
|
-
const version = '4.2.
|
|
318061
|
+
const version = '4.2.72';
|
|
317883
318062
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
317884
318063
|
//-----------------------------------------------------------------------------
|
|
317885
318064
|
|