ccxt 4.2.34 → 4.2.35
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 +108 -24
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +13 -5
- package/dist/cjs/src/binance.js +54 -11
- package/dist/cjs/src/bitfinex2.js +12 -1
- package/dist/cjs/src/krakenfutures.js +25 -3
- package/dist/cjs/src/pro/binance.js +3 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +0 -1
- package/js/src/base/Exchange.js +13 -5
- package/js/src/binance.js +54 -11
- package/js/src/bitfinex2.js +12 -1
- package/js/src/krakenfutures.js +25 -3
- package/js/src/pro/binance.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
209
209
|
|
|
210
210
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
211
211
|
|
|
212
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
213
|
-
* unpkg: https://unpkg.com/ccxt@4.2.
|
|
212
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.35/dist/ccxt.browser.js
|
|
213
|
+
* unpkg: https://unpkg.com/ccxt@4.2.35/dist/ccxt.browser.js
|
|
214
214
|
|
|
215
215
|
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.
|
|
216
216
|
|
|
217
217
|
```HTML
|
|
218
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
218
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.35/dist/ccxt.browser.js"></script>
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -8080,9 +8080,9 @@ class Exchange {
|
|
|
8080
8080
|
}
|
|
8081
8081
|
handleMessage(client, message) { } // stub to override
|
|
8082
8082
|
// ping (client) {} // stub to override
|
|
8083
|
-
ping(client) {
|
|
8084
|
-
|
|
8085
|
-
}
|
|
8083
|
+
// ping (client) {
|
|
8084
|
+
// return undefined;
|
|
8085
|
+
// }
|
|
8086
8086
|
client(url) {
|
|
8087
8087
|
this.clients = this.clients || {};
|
|
8088
8088
|
if (!this.clients[url]) {
|
|
@@ -8464,6 +8464,9 @@ class Exchange {
|
|
|
8464
8464
|
* @returns {object | undefined}
|
|
8465
8465
|
*/
|
|
8466
8466
|
const value = this.safeValueN(dictionaryOrList, keys, defaultValue);
|
|
8467
|
+
if (value === undefined) {
|
|
8468
|
+
return defaultValue;
|
|
8469
|
+
}
|
|
8467
8470
|
if (typeof value === 'object') {
|
|
8468
8471
|
return value;
|
|
8469
8472
|
}
|
|
@@ -8495,6 +8498,9 @@ class Exchange {
|
|
|
8495
8498
|
* @returns {Array | undefined}
|
|
8496
8499
|
*/
|
|
8497
8500
|
const value = this.safeValueN(dictionaryOrList, keys, defaultValue);
|
|
8501
|
+
if (value === undefined) {
|
|
8502
|
+
return defaultValue;
|
|
8503
|
+
}
|
|
8498
8504
|
if (Array.isArray(value)) {
|
|
8499
8505
|
return value;
|
|
8500
8506
|
}
|
|
@@ -12294,7 +12300,8 @@ class Exchange {
|
|
|
12294
12300
|
errors = 0;
|
|
12295
12301
|
const responseLength = response.length;
|
|
12296
12302
|
if (this.verbose) {
|
|
12297
|
-
const
|
|
12303
|
+
const iteration = (i + 1).toString();
|
|
12304
|
+
const cursorMessage = 'Cursor pagination call ' + iteration + ' method ' + method + ' response length ' + responseLength.toString() + ' cursor ' + cursorValue;
|
|
12298
12305
|
this.log(cursorMessage);
|
|
12299
12306
|
}
|
|
12300
12307
|
if (responseLength === 0) {
|
|
@@ -12339,7 +12346,8 @@ class Exchange {
|
|
|
12339
12346
|
errors = 0;
|
|
12340
12347
|
const responseLength = response.length;
|
|
12341
12348
|
if (this.verbose) {
|
|
12342
|
-
const
|
|
12349
|
+
const iteration = (i + 1).toString();
|
|
12350
|
+
const incrementalMessage = 'Incremental pagination call ' + iteration + ' method ' + method + ' response length ' + responseLength.toString();
|
|
12343
12351
|
this.log(incrementalMessage);
|
|
12344
12352
|
}
|
|
12345
12353
|
if (responseLength === 0) {
|
|
@@ -21088,9 +21096,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21088
21096
|
let timestamp = undefined;
|
|
21089
21097
|
const isolated = marginMode === 'isolated';
|
|
21090
21098
|
const cross = (type === 'margin') || (marginMode === 'cross');
|
|
21091
|
-
if (
|
|
21099
|
+
if (type === 'papi') {
|
|
21100
|
+
for (let i = 0; i < response.length; i++) {
|
|
21101
|
+
const entry = response[i];
|
|
21102
|
+
const account = this.account();
|
|
21103
|
+
const currencyId = this.safeString(entry, 'asset');
|
|
21104
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
21105
|
+
const borrowed = this.safeString(entry, 'crossMarginBorrowed');
|
|
21106
|
+
const interest = this.safeString(entry, 'crossMarginInterest');
|
|
21107
|
+
account['free'] = this.safeString(entry, 'crossMarginFree');
|
|
21108
|
+
account['used'] = this.safeString(entry, 'crossMarginLocked');
|
|
21109
|
+
account['total'] = this.safeString(entry, 'crossMarginAsset');
|
|
21110
|
+
account['debt'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(borrowed, interest);
|
|
21111
|
+
result[code] = account;
|
|
21112
|
+
}
|
|
21113
|
+
}
|
|
21114
|
+
else if (!isolated && ((type === 'spot') || cross)) {
|
|
21092
21115
|
timestamp = this.safeInteger(response, 'updateTime');
|
|
21093
|
-
const balances = this.
|
|
21116
|
+
const balances = this.safeList2(response, 'balances', 'userAssets', []);
|
|
21094
21117
|
for (let i = 0; i < balances.length; i++) {
|
|
21095
21118
|
const balance = balances[i];
|
|
21096
21119
|
const currencyId = this.safeString(balance, 'asset');
|
|
@@ -21107,13 +21130,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21107
21130
|
}
|
|
21108
21131
|
}
|
|
21109
21132
|
else if (isolated) {
|
|
21110
|
-
const assets = this.
|
|
21133
|
+
const assets = this.safeList(response, 'assets');
|
|
21111
21134
|
for (let i = 0; i < assets.length; i++) {
|
|
21112
21135
|
const asset = assets[i];
|
|
21113
|
-
const marketId = this.
|
|
21136
|
+
const marketId = this.safeString(asset, 'symbol');
|
|
21114
21137
|
const symbol = this.safeSymbol(marketId, undefined, undefined, 'spot');
|
|
21115
|
-
const base = this.
|
|
21116
|
-
const quote = this.
|
|
21138
|
+
const base = this.safeDict(asset, 'baseAsset', {});
|
|
21139
|
+
const quote = this.safeDict(asset, 'quoteAsset', {});
|
|
21117
21140
|
const baseCode = this.safeCurrencyCode(this.safeString(base, 'asset'));
|
|
21118
21141
|
const quoteCode = this.safeCurrencyCode(this.safeString(quote, 'asset'));
|
|
21119
21142
|
const subResult = {};
|
|
@@ -21123,7 +21146,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21123
21146
|
}
|
|
21124
21147
|
}
|
|
21125
21148
|
else if (type === 'savings') {
|
|
21126
|
-
const positionAmountVos = this.
|
|
21149
|
+
const positionAmountVos = this.safeList(response, 'positionAmountVos', []);
|
|
21127
21150
|
for (let i = 0; i < positionAmountVos.length; i++) {
|
|
21128
21151
|
const entry = positionAmountVos[i];
|
|
21129
21152
|
const currencyId = this.safeString(entry, 'asset');
|
|
@@ -21152,7 +21175,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21152
21175
|
else {
|
|
21153
21176
|
let balances = response;
|
|
21154
21177
|
if (!Array.isArray(response)) {
|
|
21155
|
-
balances = this.
|
|
21178
|
+
balances = this.safeList(response, 'assets', []);
|
|
21156
21179
|
}
|
|
21157
21180
|
for (let i = 0; i < balances.length; i++) {
|
|
21158
21181
|
const balance = balances[i];
|
|
@@ -21182,10 +21205,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21182
21205
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data // swap
|
|
21183
21206
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data // future
|
|
21184
21207
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#option-account-information-trade // option
|
|
21208
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#account-balance-user_data // portfolio margin
|
|
21185
21209
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
21186
|
-
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot'
|
|
21210
|
+
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi'
|
|
21187
21211
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
|
|
21188
21212
|
* @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
|
|
21213
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
|
|
21189
21214
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
21190
21215
|
*/
|
|
21191
21216
|
await this.loadMarkets();
|
|
@@ -21193,13 +21218,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21193
21218
|
let type = this.safeString(params, 'type', defaultType);
|
|
21194
21219
|
let subType = undefined;
|
|
21195
21220
|
[subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
|
|
21221
|
+
let isPortfolioMargin = undefined;
|
|
21222
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchBalance', 'papi', 'portfolioMargin', false);
|
|
21196
21223
|
let marginMode = undefined;
|
|
21197
21224
|
let query = undefined;
|
|
21198
21225
|
[marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
21199
21226
|
query = this.omit(query, 'type');
|
|
21200
21227
|
let response = undefined;
|
|
21201
21228
|
const request = {};
|
|
21202
|
-
if (
|
|
21229
|
+
if (isPortfolioMargin || (type === 'papi')) {
|
|
21230
|
+
type = 'papi';
|
|
21231
|
+
response = await this.papiGetBalance(this.extend(request, query));
|
|
21232
|
+
}
|
|
21233
|
+
else if (this.isLinear(type, subType)) {
|
|
21203
21234
|
type = 'linear';
|
|
21204
21235
|
response = await this.fapiPrivateV2GetAccount(this.extend(request, query));
|
|
21205
21236
|
}
|
|
@@ -21208,7 +21239,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21208
21239
|
response = await this.dapiPrivateGetAccount(this.extend(request, query));
|
|
21209
21240
|
}
|
|
21210
21241
|
else if (marginMode === 'isolated') {
|
|
21211
|
-
const paramSymbols = this.
|
|
21242
|
+
const paramSymbols = this.safeList(params, 'symbols');
|
|
21212
21243
|
query = this.omit(query, 'symbols');
|
|
21213
21244
|
if (paramSymbols !== undefined) {
|
|
21214
21245
|
let symbols = '';
|
|
@@ -21424,6 +21455,26 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21424
21455
|
// }
|
|
21425
21456
|
// ]
|
|
21426
21457
|
//
|
|
21458
|
+
// portfolio margin
|
|
21459
|
+
//
|
|
21460
|
+
// [
|
|
21461
|
+
// {
|
|
21462
|
+
// "asset": "USDT",
|
|
21463
|
+
// "totalWalletBalance": "66.9923261",
|
|
21464
|
+
// "crossMarginAsset": "35.9697141",
|
|
21465
|
+
// "crossMarginBorrowed": "0.0",
|
|
21466
|
+
// "crossMarginFree": "35.9697141",
|
|
21467
|
+
// "crossMarginInterest": "0.0",
|
|
21468
|
+
// "crossMarginLocked": "0.0",
|
|
21469
|
+
// "umWalletBalance": "31.022612",
|
|
21470
|
+
// "umUnrealizedPNL": "0.0",
|
|
21471
|
+
// "cmWalletBalance": "0.0",
|
|
21472
|
+
// "cmUnrealizedPNL": "0.0",
|
|
21473
|
+
// "updateTime": 0,
|
|
21474
|
+
// "negativeBalance": "0.0"
|
|
21475
|
+
// },
|
|
21476
|
+
// ]
|
|
21477
|
+
//
|
|
21427
21478
|
return this.parseBalanceCustom(response, type, marginMode);
|
|
21428
21479
|
}
|
|
21429
21480
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
@@ -37690,11 +37741,13 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37690
37741
|
'has': {
|
|
37691
37742
|
'CORS': undefined,
|
|
37692
37743
|
'spot': true,
|
|
37693
|
-
'margin':
|
|
37744
|
+
'margin': true,
|
|
37694
37745
|
'swap': true,
|
|
37695
37746
|
'future': undefined,
|
|
37696
37747
|
'option': undefined,
|
|
37697
37748
|
'addMargin': false,
|
|
37749
|
+
'borrowCrossMargin': false,
|
|
37750
|
+
'borrowIsolatedMargin': false,
|
|
37698
37751
|
'cancelAllOrders': true,
|
|
37699
37752
|
'cancelOrder': true,
|
|
37700
37753
|
'cancelOrders': true,
|
|
@@ -37711,8 +37764,13 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37711
37764
|
'createTriggerOrder': true,
|
|
37712
37765
|
'editOrder': true,
|
|
37713
37766
|
'fetchBalance': true,
|
|
37767
|
+
'fetchBorrowInterest': false,
|
|
37768
|
+
'fetchBorrowRateHistories': false,
|
|
37769
|
+
'fetchBorrowRateHistory': false,
|
|
37714
37770
|
'fetchClosedOrder': true,
|
|
37715
37771
|
'fetchClosedOrders': true,
|
|
37772
|
+
'fetchCrossBorrowRate': false,
|
|
37773
|
+
'fetchCrossBorrowRates': false,
|
|
37716
37774
|
'fetchCurrencies': true,
|
|
37717
37775
|
'fetchDepositAddress': true,
|
|
37718
37776
|
'fetchDepositsWithdrawals': true,
|
|
@@ -37721,6 +37779,8 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37721
37779
|
'fetchFundingRateHistory': true,
|
|
37722
37780
|
'fetchFundingRates': true,
|
|
37723
37781
|
'fetchIndexOHLCV': false,
|
|
37782
|
+
'fetchIsolatedBorrowRate': false,
|
|
37783
|
+
'fetchIsolatedBorrowRates': false,
|
|
37724
37784
|
'fetchLedger': true,
|
|
37725
37785
|
'fetchLeverage': false,
|
|
37726
37786
|
'fetchLeverageTiers': false,
|
|
@@ -37748,6 +37808,8 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
37748
37808
|
'fetchTransactionFees': undefined,
|
|
37749
37809
|
'fetchTransactions': 'emulated',
|
|
37750
37810
|
'reduceMargin': false,
|
|
37811
|
+
'repayCrossMargin': false,
|
|
37812
|
+
'repayIsolatedMargin': false,
|
|
37751
37813
|
'setLeverage': false,
|
|
37752
37814
|
'setMargin': true,
|
|
37753
37815
|
'setMarginMode': false,
|
|
@@ -159955,10 +160017,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
159955
160017
|
},
|
|
159956
160018
|
'fees': {
|
|
159957
160019
|
'trading': {
|
|
159958
|
-
'tierBased':
|
|
160020
|
+
'tierBased': true,
|
|
159959
160021
|
'percentage': true,
|
|
159960
|
-
'
|
|
159961
|
-
'
|
|
160022
|
+
'taker': this.parseNumber('0.0005'),
|
|
160023
|
+
'maker': this.parseNumber('0.0002'),
|
|
160024
|
+
'tiers': {
|
|
160025
|
+
'taker': [
|
|
160026
|
+
[this.parseNumber('0'), this.parseNumber('0.0005')],
|
|
160027
|
+
[this.parseNumber('100000'), this.parseNumber('0.0004')],
|
|
160028
|
+
[this.parseNumber('1000000'), this.parseNumber('0.0003')],
|
|
160029
|
+
[this.parseNumber('5000000'), this.parseNumber('0.00025')],
|
|
160030
|
+
[this.parseNumber('10000000'), this.parseNumber('0.0002')],
|
|
160031
|
+
[this.parseNumber('20000000'), this.parseNumber('0.00015')],
|
|
160032
|
+
[this.parseNumber('50000000'), this.parseNumber('0.000125')],
|
|
160033
|
+
[this.parseNumber('100000000'), this.parseNumber('0.0001')],
|
|
160034
|
+
],
|
|
160035
|
+
'maker': [
|
|
160036
|
+
[this.parseNumber('0'), this.parseNumber('0.0002')],
|
|
160037
|
+
[this.parseNumber('100000'), this.parseNumber('0.0015')],
|
|
160038
|
+
[this.parseNumber('1000000'), this.parseNumber('0.000125')],
|
|
160039
|
+
[this.parseNumber('5000000'), this.parseNumber('0.0001')],
|
|
160040
|
+
[this.parseNumber('10000000'), this.parseNumber('0.000075')],
|
|
160041
|
+
[this.parseNumber('20000000'), this.parseNumber('0.00005')],
|
|
160042
|
+
[this.parseNumber('50000000'), this.parseNumber('0.000025')],
|
|
160043
|
+
[this.parseNumber('100000000'), this.parseNumber('0')],
|
|
160044
|
+
],
|
|
160045
|
+
},
|
|
159962
160046
|
},
|
|
159963
160047
|
},
|
|
159964
160048
|
'exceptions': {
|
|
@@ -217112,7 +217196,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
217112
217196
|
return this.safePosition({
|
|
217113
217197
|
'info': position,
|
|
217114
217198
|
'id': undefined,
|
|
217115
|
-
'symbol': this.safeSymbol(marketId, undefined, undefined, '
|
|
217199
|
+
'symbol': this.safeSymbol(marketId, undefined, undefined, 'contract'),
|
|
217116
217200
|
'notional': undefined,
|
|
217117
217201
|
'marginMode': this.safeString(position, 'mt'),
|
|
217118
217202
|
'liquidationPrice': undefined,
|
|
@@ -217266,9 +217350,9 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
217266
217350
|
const messageHash = 'myTrades';
|
|
217267
217351
|
const executionType = this.safeString(message, 'x');
|
|
217268
217352
|
if (executionType === 'TRADE') {
|
|
217269
|
-
const trade = this.
|
|
217353
|
+
const trade = this.parseWsTrade(message);
|
|
217270
217354
|
const orderId = this.safeString(trade, 'order');
|
|
217271
|
-
let tradeFee = this.safeValue(trade, 'fee');
|
|
217355
|
+
let tradeFee = this.safeValue(trade, 'fee', {});
|
|
217272
217356
|
tradeFee = this.extend({}, tradeFee);
|
|
217273
217357
|
const symbol = this.safeString(trade, 'symbol');
|
|
217274
217358
|
if (orderId !== undefined && tradeFee !== undefined && symbol !== undefined) {
|
|
@@ -301317,7 +301401,7 @@ SOFTWARE.
|
|
|
301317
301401
|
|
|
301318
301402
|
//-----------------------------------------------------------------------------
|
|
301319
301403
|
// this is updated by vss.js when building
|
|
301320
|
-
const version = '4.2.
|
|
301404
|
+
const version = '4.2.35';
|
|
301321
301405
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
301322
301406
|
//-----------------------------------------------------------------------------
|
|
301323
301407
|
|