ccxt 4.3.13 → 4.3.15
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/LICENSE.txt +1 -1
- package/README.md +3 -3
- package/dist/cjs/ccxt.js +2 -1
- package/dist/cjs/src/base/Exchange.js +14 -6
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/base/functions/misc.js +2 -2
- package/dist/cjs/src/base/ws/Client.js +2 -1
- package/dist/cjs/src/binance.js +106 -5
- package/dist/cjs/src/bingx.js +1 -0
- package/dist/cjs/src/bybit.js +105 -105
- package/dist/cjs/src/coinbase.js +103 -0
- package/dist/cjs/src/coinex.js +435 -423
- package/dist/cjs/src/cryptocom.js +2 -1
- package/dist/cjs/src/hitbtc.js +1 -0
- package/dist/cjs/src/luno.js +2 -0
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/hitbtc.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +3 -3
- package/dist/cjs/src/pro/poloniex.js +3 -3
- package/dist/cjs/src/pro/woo.js +147 -9
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +3 -3
- package/js/src/abstract/luno.d.ts +2 -0
- package/js/src/alpaca.d.ts +1 -1
- package/js/src/base/Exchange.d.ts +5 -5
- package/js/src/base/Exchange.js +14 -6
- package/js/src/base/errorHierarchy.d.ts +1 -0
- package/js/src/base/errorHierarchy.js +1 -0
- package/js/src/base/errors.d.ts +5 -1
- package/js/src/base/errors.js +8 -2
- package/js/src/base/functions/generic.d.ts +1 -1
- package/js/src/base/functions/misc.d.ts +5 -4
- package/js/src/base/functions/misc.js +2 -2
- package/js/src/base/functions/number.d.ts +5 -5
- package/js/src/base/functions/rsa.d.ts +2 -1
- package/js/src/base/functions/totp.d.ts +1 -1
- package/js/src/base/ws/Client.d.ts +8 -7
- package/js/src/base/ws/Client.js +2 -1
- package/js/src/binance.d.ts +14 -1
- package/js/src/binance.js +107 -6
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bingx.js +1 -0
- package/js/src/bybit.js +105 -105
- package/js/src/coinbase.d.ts +5 -1
- package/js/src/coinbase.js +103 -0
- package/js/src/coinex.js +435 -423
- package/js/src/cryptocom.js +2 -1
- package/js/src/hitbtc.js +1 -0
- package/js/src/luno.js +2 -0
- package/js/src/okx.js +1 -1
- package/js/src/phemex.js +1 -1
- package/js/src/pro/hitbtc.js +1 -1
- package/js/src/pro/independentreserve.js +3 -3
- package/js/src/pro/poloniex.js +3 -3
- package/js/src/pro/woo.d.ts +2 -0
- package/js/src/pro/woo.js +147 -9
- package/js/src/upbit.d.ts +1 -1
- package/js/src/woo.d.ts +1 -1
- package/js/src/zonda.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -1104,7 +1104,7 @@ class bybit extends bybit$1 {
|
|
|
1104
1104
|
return this.milliseconds() - this.options['timeDifference'];
|
|
1105
1105
|
}
|
|
1106
1106
|
addPaginationCursorToResult(response) {
|
|
1107
|
-
const result = this.
|
|
1107
|
+
const result = this.safeDict(response, 'result', {});
|
|
1108
1108
|
const data = this.safeValueN(result, ['list', 'rows', 'data', 'dataList'], []);
|
|
1109
1109
|
const paginationCursor = this.safeString2(result, 'nextPageCursor', 'cursor');
|
|
1110
1110
|
const dataLength = data.length;
|
|
@@ -1124,8 +1124,8 @@ class bybit extends bybit$1 {
|
|
|
1124
1124
|
// The API key of user id must own one of permissions will be allowed to call following API endpoints.
|
|
1125
1125
|
// SUB UID: "Account Transfer"
|
|
1126
1126
|
// MASTER UID: "Account Transfer", "Subaccount Transfer", "Withdrawal"
|
|
1127
|
-
const enableUnifiedMargin = this.
|
|
1128
|
-
const enableUnifiedAccount = this.
|
|
1127
|
+
const enableUnifiedMargin = this.safeBool(this.options, 'enableUnifiedMargin');
|
|
1128
|
+
const enableUnifiedAccount = this.safeBool(this.options, 'enableUnifiedAccount');
|
|
1129
1129
|
if (enableUnifiedMargin === undefined || enableUnifiedAccount === undefined) {
|
|
1130
1130
|
if (this.options['enableDemoTrading']) {
|
|
1131
1131
|
// info endpoint is not available in demo trading
|
|
@@ -1175,7 +1175,7 @@ class bybit extends bybit$1 {
|
|
|
1175
1175
|
// "time": 1676891757649
|
|
1176
1176
|
// }
|
|
1177
1177
|
//
|
|
1178
|
-
const result = this.
|
|
1178
|
+
const result = this.safeDict(response, 'result', {});
|
|
1179
1179
|
this.options['enableUnifiedMargin'] = this.safeInteger(result, 'unified') === 1;
|
|
1180
1180
|
this.options['enableUnifiedAccount'] = this.safeInteger(result, 'uta') === 1;
|
|
1181
1181
|
}
|
|
@@ -1337,15 +1337,15 @@ class bybit extends bybit$1 {
|
|
|
1337
1337
|
// "time": 1672194582264
|
|
1338
1338
|
// }
|
|
1339
1339
|
//
|
|
1340
|
-
const data = this.
|
|
1341
|
-
const rows = this.
|
|
1340
|
+
const data = this.safeDict(response, 'result', {});
|
|
1341
|
+
const rows = this.safeList(data, 'rows', []);
|
|
1342
1342
|
const result = {};
|
|
1343
1343
|
for (let i = 0; i < rows.length; i++) {
|
|
1344
1344
|
const currency = rows[i];
|
|
1345
1345
|
const currencyId = this.safeString(currency, 'coin');
|
|
1346
1346
|
const code = this.safeCurrencyCode(currencyId);
|
|
1347
1347
|
const name = this.safeString(currency, 'name');
|
|
1348
|
-
const chains = this.
|
|
1348
|
+
const chains = this.safeList(currency, 'chains', []);
|
|
1349
1349
|
const networks = {};
|
|
1350
1350
|
let minPrecision = undefined;
|
|
1351
1351
|
let minWithdrawFeeString = undefined;
|
|
@@ -1438,7 +1438,7 @@ class bybit extends bybit$1 {
|
|
|
1438
1438
|
await this.loadTimeDifference();
|
|
1439
1439
|
}
|
|
1440
1440
|
const promisesUnresolved = [];
|
|
1441
|
-
const fetchMarkets = this.
|
|
1441
|
+
const fetchMarkets = this.safeList(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']);
|
|
1442
1442
|
for (let i = 0; i < fetchMarkets.length; i++) {
|
|
1443
1443
|
const marketType = fetchMarkets[i];
|
|
1444
1444
|
if (marketType === 'spot') {
|
|
@@ -1460,12 +1460,12 @@ class bybit extends bybit$1 {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
}
|
|
1462
1462
|
const promises = await Promise.all(promisesUnresolved);
|
|
1463
|
-
const spotMarkets = this.
|
|
1464
|
-
const linearMarkets = this.
|
|
1465
|
-
const inverseMarkets = this.
|
|
1466
|
-
const btcOptionMarkets = this.
|
|
1467
|
-
const ethOptionMarkets = this.
|
|
1468
|
-
const solOptionMarkets = this.
|
|
1463
|
+
const spotMarkets = this.safeList(promises, 0, []);
|
|
1464
|
+
const linearMarkets = this.safeList(promises, 1, []);
|
|
1465
|
+
const inverseMarkets = this.safeList(promises, 2, []);
|
|
1466
|
+
const btcOptionMarkets = this.safeList(promises, 3, []);
|
|
1467
|
+
const ethOptionMarkets = this.safeList(promises, 4, []);
|
|
1468
|
+
const solOptionMarkets = this.safeList(promises, 5, []);
|
|
1469
1469
|
const futureMarkets = this.arrayConcat(linearMarkets, inverseMarkets);
|
|
1470
1470
|
let optionMarkets = this.arrayConcat(btcOptionMarkets, ethOptionMarkets);
|
|
1471
1471
|
optionMarkets = this.arrayConcat(optionMarkets, solOptionMarkets);
|
|
@@ -1508,8 +1508,8 @@ class bybit extends bybit$1 {
|
|
|
1508
1508
|
// "time": 1672712468011
|
|
1509
1509
|
// }
|
|
1510
1510
|
//
|
|
1511
|
-
const responseResult = this.
|
|
1512
|
-
const markets = this.
|
|
1511
|
+
const responseResult = this.safeDict(response, 'result', {});
|
|
1512
|
+
const markets = this.safeList(responseResult, 'list', []);
|
|
1513
1513
|
const result = [];
|
|
1514
1514
|
const takerFee = this.parseNumber('0.001');
|
|
1515
1515
|
const makerFee = this.parseNumber('0.001');
|
|
@@ -1523,8 +1523,8 @@ class bybit extends bybit$1 {
|
|
|
1523
1523
|
const symbol = base + '/' + quote;
|
|
1524
1524
|
const status = this.safeString(market, 'status');
|
|
1525
1525
|
const active = (status === 'Trading');
|
|
1526
|
-
const lotSizeFilter = this.
|
|
1527
|
-
const priceFilter = this.
|
|
1526
|
+
const lotSizeFilter = this.safeDict(market, 'lotSizeFilter');
|
|
1527
|
+
const priceFilter = this.safeDict(market, 'priceFilter');
|
|
1528
1528
|
const quotePrecision = this.safeNumber(lotSizeFilter, 'quotePrecision');
|
|
1529
1529
|
result.push({
|
|
1530
1530
|
'id': id,
|
|
@@ -1584,15 +1584,15 @@ class bybit extends bybit$1 {
|
|
|
1584
1584
|
params = this.extend(params);
|
|
1585
1585
|
params['limit'] = 1000; // minimize number of requests
|
|
1586
1586
|
const response = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1587
|
-
const data = this.
|
|
1588
|
-
let markets = this.
|
|
1587
|
+
const data = this.safeDict(response, 'result', {});
|
|
1588
|
+
let markets = this.safeList(data, 'list', []);
|
|
1589
1589
|
let paginationCursor = this.safeString(data, 'nextPageCursor');
|
|
1590
1590
|
if (paginationCursor !== undefined) {
|
|
1591
1591
|
while (paginationCursor !== undefined) {
|
|
1592
1592
|
params['cursor'] = paginationCursor;
|
|
1593
1593
|
const responseInner = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1594
|
-
const dataNew = this.
|
|
1595
|
-
const rawMarkets = this.
|
|
1594
|
+
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1595
|
+
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1596
1596
|
const rawMarketsLength = rawMarkets.length;
|
|
1597
1597
|
if (rawMarketsLength === 0) {
|
|
1598
1598
|
break;
|
|
@@ -1674,9 +1674,9 @@ class bybit extends bybit$1 {
|
|
|
1674
1674
|
settle = this.safeCurrencyCode(settleId);
|
|
1675
1675
|
}
|
|
1676
1676
|
let symbol = base + '/' + quote;
|
|
1677
|
-
const lotSizeFilter = this.
|
|
1678
|
-
const priceFilter = this.
|
|
1679
|
-
const leverage = this.
|
|
1677
|
+
const lotSizeFilter = this.safeDict(market, 'lotSizeFilter', {});
|
|
1678
|
+
const priceFilter = this.safeDict(market, 'priceFilter', {});
|
|
1679
|
+
const leverage = this.safeDict(market, 'leverageFilter', {});
|
|
1680
1680
|
const status = this.safeString(market, 'status');
|
|
1681
1681
|
const swap = linearPerpetual || inversePerpetual;
|
|
1682
1682
|
const future = inverseFutures || linearFutures;
|
|
@@ -1760,8 +1760,8 @@ class bybit extends bybit$1 {
|
|
|
1760
1760
|
'category': 'option',
|
|
1761
1761
|
};
|
|
1762
1762
|
const response = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1763
|
-
const data = this.
|
|
1764
|
-
let markets = this.
|
|
1763
|
+
const data = this.safeDict(response, 'result', {});
|
|
1764
|
+
let markets = this.safeList(data, 'list', []);
|
|
1765
1765
|
if (this.options['loadAllOptions']) {
|
|
1766
1766
|
request['limit'] = 1000;
|
|
1767
1767
|
let paginationCursor = this.safeString(data, 'nextPageCursor');
|
|
@@ -1769,8 +1769,8 @@ class bybit extends bybit$1 {
|
|
|
1769
1769
|
while (paginationCursor !== undefined) {
|
|
1770
1770
|
request['cursor'] = paginationCursor;
|
|
1771
1771
|
const responseInner = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1772
|
-
const dataNew = this.
|
|
1773
|
-
const rawMarkets = this.
|
|
1772
|
+
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1773
|
+
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1774
1774
|
const rawMarketsLength = rawMarkets.length;
|
|
1775
1775
|
if (rawMarketsLength === 0) {
|
|
1776
1776
|
break;
|
|
@@ -1825,8 +1825,8 @@ class bybit extends bybit$1 {
|
|
|
1825
1825
|
const base = this.safeCurrencyCode(baseId);
|
|
1826
1826
|
const quote = this.safeCurrencyCode(quoteId);
|
|
1827
1827
|
const settle = this.safeCurrencyCode(settleId);
|
|
1828
|
-
const lotSizeFilter = this.
|
|
1829
|
-
const priceFilter = this.
|
|
1828
|
+
const lotSizeFilter = this.safeDict(market, 'lotSizeFilter', {});
|
|
1829
|
+
const priceFilter = this.safeDict(market, 'priceFilter', {});
|
|
1830
1830
|
const status = this.safeString(market, 'status');
|
|
1831
1831
|
const expiry = this.safeInteger(market, 'deliveryTime');
|
|
1832
1832
|
const splitId = id.split('-');
|
|
@@ -2079,8 +2079,8 @@ class bybit extends bybit$1 {
|
|
|
2079
2079
|
// "time": 1672376496682
|
|
2080
2080
|
// }
|
|
2081
2081
|
//
|
|
2082
|
-
const result = this.
|
|
2083
|
-
const tickers = this.
|
|
2082
|
+
const result = this.safeDict(response, 'result', {});
|
|
2083
|
+
const tickers = this.safeList(result, 'list', []);
|
|
2084
2084
|
const rawTicker = this.safeDict(tickers, 0);
|
|
2085
2085
|
return this.parseTicker(rawTicker, market);
|
|
2086
2086
|
}
|
|
@@ -2186,7 +2186,7 @@ class bybit extends bybit$1 {
|
|
|
2186
2186
|
// "time": 1672376496682
|
|
2187
2187
|
// }
|
|
2188
2188
|
//
|
|
2189
|
-
const result = this.
|
|
2189
|
+
const result = this.safeDict(response, 'result', {});
|
|
2190
2190
|
const tickerList = this.safeList(result, 'list', []);
|
|
2191
2191
|
return this.parseTickers(tickerList, parsedSymbols);
|
|
2192
2192
|
}
|
|
@@ -2325,7 +2325,7 @@ class bybit extends bybit$1 {
|
|
|
2325
2325
|
// "time": 1672025956592
|
|
2326
2326
|
// }
|
|
2327
2327
|
//
|
|
2328
|
-
const result = this.
|
|
2328
|
+
const result = this.safeDict(response, 'result', {});
|
|
2329
2329
|
const ohlcvs = this.safeList(result, 'list', []);
|
|
2330
2330
|
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
2331
2331
|
}
|
|
@@ -2541,8 +2541,8 @@ class bybit extends bybit$1 {
|
|
|
2541
2541
|
// }
|
|
2542
2542
|
//
|
|
2543
2543
|
const rates = [];
|
|
2544
|
-
const result = this.
|
|
2545
|
-
const resultList = this.
|
|
2544
|
+
const result = this.safeDict(response, 'result');
|
|
2545
|
+
const resultList = this.safeList(result, 'list');
|
|
2546
2546
|
for (let i = 0; i < resultList.length; i++) {
|
|
2547
2547
|
const entry = resultList[i];
|
|
2548
2548
|
const timestamp = this.safeInteger(entry, 'fundingRateTimestamp');
|
|
@@ -2676,7 +2676,7 @@ class bybit extends bybit$1 {
|
|
|
2676
2676
|
side = isBuyer ? 'buy' : 'sell';
|
|
2677
2677
|
}
|
|
2678
2678
|
}
|
|
2679
|
-
const isMaker = this.
|
|
2679
|
+
const isMaker = this.safeBool(trade, 'isMaker');
|
|
2680
2680
|
let takerOrMaker = undefined;
|
|
2681
2681
|
if (isMaker !== undefined) {
|
|
2682
2682
|
takerOrMaker = isMaker ? 'maker' : 'taker';
|
|
@@ -2802,7 +2802,7 @@ class bybit extends bybit$1 {
|
|
|
2802
2802
|
// "time": 1672053054358
|
|
2803
2803
|
// }
|
|
2804
2804
|
//
|
|
2805
|
-
const result = this.
|
|
2805
|
+
const result = this.safeDict(response, 'result', {});
|
|
2806
2806
|
const trades = this.safeList(result, 'list', []);
|
|
2807
2807
|
return this.parseTrades(trades, market, since, limit);
|
|
2808
2808
|
}
|
|
@@ -2872,7 +2872,7 @@ class bybit extends bybit$1 {
|
|
|
2872
2872
|
// "time": 1672765737734
|
|
2873
2873
|
// }
|
|
2874
2874
|
//
|
|
2875
|
-
const result = this.
|
|
2875
|
+
const result = this.safeDict(response, 'result', {});
|
|
2876
2876
|
const timestamp = this.safeInteger(result, 'ts');
|
|
2877
2877
|
return this.parseOrderBook(result, symbol, timestamp, 'b', 'a');
|
|
2878
2878
|
}
|
|
@@ -2985,7 +2985,7 @@ class bybit extends bybit$1 {
|
|
|
2985
2985
|
'timestamp': timestamp,
|
|
2986
2986
|
'datetime': this.iso8601(timestamp),
|
|
2987
2987
|
};
|
|
2988
|
-
const responseResult = this.
|
|
2988
|
+
const responseResult = this.safeDict(response, 'result', {});
|
|
2989
2989
|
const currencyList = this.safeValueN(responseResult, ['loanAccountList', 'list', 'balance']);
|
|
2990
2990
|
if (currencyList === undefined) {
|
|
2991
2991
|
// usdc wallet
|
|
@@ -3000,7 +3000,7 @@ class bybit extends bybit$1 {
|
|
|
3000
3000
|
const entry = currencyList[i];
|
|
3001
3001
|
const accountType = this.safeString(entry, 'accountType');
|
|
3002
3002
|
if (accountType === 'UNIFIED' || accountType === 'CONTRACT' || accountType === 'SPOT') {
|
|
3003
|
-
const coins = this.
|
|
3003
|
+
const coins = this.safeList(entry, 'coin');
|
|
3004
3004
|
for (let j = 0; j < coins.length; j++) {
|
|
3005
3005
|
const account = this.account();
|
|
3006
3006
|
const coinEntry = coins[j];
|
|
@@ -3065,7 +3065,7 @@ class bybit extends bybit$1 {
|
|
|
3065
3065
|
type = 'contract';
|
|
3066
3066
|
}
|
|
3067
3067
|
}
|
|
3068
|
-
const accountTypes = this.
|
|
3068
|
+
const accountTypes = this.safeDict(this.options, 'accountsByType', {});
|
|
3069
3069
|
const unifiedType = this.safeStringUpper(accountTypes, type, type);
|
|
3070
3070
|
let marginMode = undefined;
|
|
3071
3071
|
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
@@ -3393,7 +3393,7 @@ class bybit extends bybit$1 {
|
|
|
3393
3393
|
const rawTimeInForce = this.safeString(order, 'timeInForce');
|
|
3394
3394
|
const timeInForce = this.parseTimeInForce(rawTimeInForce);
|
|
3395
3395
|
const stopPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
|
|
3396
|
-
const reduceOnly = this.
|
|
3396
|
+
const reduceOnly = this.safeBool(order, 'reduceOnly');
|
|
3397
3397
|
let takeProfitPrice = this.omitZero(this.safeString(order, 'takeProfit'));
|
|
3398
3398
|
let stopLossPrice = this.omitZero(this.safeString(order, 'stopLoss'));
|
|
3399
3399
|
const triggerDirection = this.safeString(order, 'triggerDirection');
|
|
@@ -3433,7 +3433,7 @@ class bybit extends bybit$1 {
|
|
|
3433
3433
|
'type': type,
|
|
3434
3434
|
'timeInForce': timeInForce,
|
|
3435
3435
|
'postOnly': undefined,
|
|
3436
|
-
'reduceOnly': this.
|
|
3436
|
+
'reduceOnly': this.safeBool(order, 'reduceOnly'),
|
|
3437
3437
|
'side': side,
|
|
3438
3438
|
'price': price,
|
|
3439
3439
|
'stopPrice': stopPrice,
|
|
@@ -3534,7 +3534,7 @@ class bybit extends bybit$1 {
|
|
|
3534
3534
|
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3535
3535
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3536
3536
|
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
|
|
3537
|
-
const options = this.
|
|
3537
|
+
const options = this.safeDict(this.options, 'createOrder', {});
|
|
3538
3538
|
const defaultMethod = this.safeString(options, 'method', 'privatePostV5OrderCreate');
|
|
3539
3539
|
let response = undefined;
|
|
3540
3540
|
if (isTrailingAmountOrder || (defaultMethod === 'privatePostV5PositionTradingStop')) {
|
|
@@ -3833,10 +3833,10 @@ class bybit extends bybit$1 {
|
|
|
3833
3833
|
'request': ordersRequests,
|
|
3834
3834
|
};
|
|
3835
3835
|
const response = await this.privatePostV5OrderCreateBatch(this.extend(request, params));
|
|
3836
|
-
const result = this.
|
|
3837
|
-
const data = this.
|
|
3838
|
-
const retInfo = this.
|
|
3839
|
-
const codes = this.
|
|
3836
|
+
const result = this.safeDict(response, 'result', {});
|
|
3837
|
+
const data = this.safeList(result, 'list', []);
|
|
3838
|
+
const retInfo = this.safeDict(response, 'retExtInfo', {});
|
|
3839
|
+
const codes = this.safeList(retInfo, 'list', []);
|
|
3840
3840
|
// extend the error with the unsuccessful orders
|
|
3841
3841
|
for (let i = 0; i < codes.length; i++) {
|
|
3842
3842
|
const code = codes[i];
|
|
@@ -4030,7 +4030,7 @@ class bybit extends bybit$1 {
|
|
|
4030
4030
|
response = await this.privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder(this.extend(request, params));
|
|
4031
4031
|
}
|
|
4032
4032
|
else {
|
|
4033
|
-
const isStop = this.
|
|
4033
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4034
4034
|
const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
|
|
4035
4035
|
const stopLossPrice = this.safeValue(params, 'stopLossPrice');
|
|
4036
4036
|
const isStopLossOrder = stopLossPrice !== undefined;
|
|
@@ -4197,7 +4197,7 @@ class bybit extends bybit$1 {
|
|
|
4197
4197
|
// "time": 1672217093461
|
|
4198
4198
|
// }
|
|
4199
4199
|
//
|
|
4200
|
-
const result = this.
|
|
4200
|
+
const result = this.safeDict(response, 'result', {});
|
|
4201
4201
|
return this.safeOrder({
|
|
4202
4202
|
'info': response,
|
|
4203
4203
|
'id': this.safeString(result, 'orderId'),
|
|
@@ -4214,7 +4214,7 @@ class bybit extends bybit$1 {
|
|
|
4214
4214
|
// 'orderLinkId': 'string', // one of order_id, stop_order_id or order_link_id is required
|
|
4215
4215
|
// 'orderId': id,
|
|
4216
4216
|
};
|
|
4217
|
-
const isStop = this.
|
|
4217
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4218
4218
|
params = this.omit(params, ['stop', 'trigger']);
|
|
4219
4219
|
if (id !== undefined) { // The user can also use argument params["order_link_id"]
|
|
4220
4220
|
request['orderId'] = id;
|
|
@@ -4495,7 +4495,7 @@ class bybit extends bybit$1 {
|
|
|
4495
4495
|
response = await this.privatePostOptionUsdcOpenapiPrivateV1CancelAll(this.extend(request, params));
|
|
4496
4496
|
}
|
|
4497
4497
|
else {
|
|
4498
|
-
const isStop = this.
|
|
4498
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4499
4499
|
if (isStop) {
|
|
4500
4500
|
request['orderFilter'] = 'StopOrder';
|
|
4501
4501
|
}
|
|
@@ -4569,7 +4569,7 @@ class bybit extends bybit$1 {
|
|
|
4569
4569
|
request['settleCoin'] = this.safeString(params, 'settleCoin', defaultSettle);
|
|
4570
4570
|
}
|
|
4571
4571
|
}
|
|
4572
|
-
const isStop = this.
|
|
4572
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4573
4573
|
params = this.omit(params, ['stop', 'trigger']);
|
|
4574
4574
|
if (isStop) {
|
|
4575
4575
|
request['orderFilter'] = 'StopOrder';
|
|
@@ -4603,8 +4603,8 @@ class bybit extends bybit$1 {
|
|
|
4603
4603
|
// "time": 1676962409398
|
|
4604
4604
|
// }
|
|
4605
4605
|
//
|
|
4606
|
-
const result = this.
|
|
4607
|
-
const orders = this.
|
|
4606
|
+
const result = this.safeDict(response, 'result', {});
|
|
4607
|
+
const orders = this.safeList(result, 'list');
|
|
4608
4608
|
if (!Array.isArray(orders)) {
|
|
4609
4609
|
return response;
|
|
4610
4610
|
}
|
|
@@ -4637,7 +4637,7 @@ class bybit extends bybit$1 {
|
|
|
4637
4637
|
else {
|
|
4638
4638
|
request['category'] = 'OPTION';
|
|
4639
4639
|
}
|
|
4640
|
-
const isStop = this.
|
|
4640
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4641
4641
|
params = this.omit(params, ['stop', 'trigger']);
|
|
4642
4642
|
if (isStop) {
|
|
4643
4643
|
request['orderFilter'] = 'StopOrder';
|
|
@@ -4693,7 +4693,7 @@ class bybit extends bybit$1 {
|
|
|
4693
4693
|
// "retMsg": "Success."
|
|
4694
4694
|
// }
|
|
4695
4695
|
//
|
|
4696
|
-
const result = this.
|
|
4696
|
+
const result = this.safeDict(response, 'result', {});
|
|
4697
4697
|
const data = this.safeList(result, 'dataList', []);
|
|
4698
4698
|
return this.parseOrders(data, market, since, limit);
|
|
4699
4699
|
}
|
|
@@ -5121,8 +5121,8 @@ class bybit extends bybit$1 {
|
|
|
5121
5121
|
[type, params] = this.handleMarketTypeAndParams('fetchUsdcOpenOrders', market, params);
|
|
5122
5122
|
request['category'] = (type === 'swap') ? 'perpetual' : 'option';
|
|
5123
5123
|
const response = await this.privatePostOptionUsdcOpenapiPrivateV1QueryActiveOrders(this.extend(request, params));
|
|
5124
|
-
const result = this.
|
|
5125
|
-
const orders = this.
|
|
5124
|
+
const result = this.safeDict(response, 'result', {});
|
|
5125
|
+
const orders = this.safeList(result, 'dataList', []);
|
|
5126
5126
|
//
|
|
5127
5127
|
// {
|
|
5128
5128
|
// "retCode": 0,
|
|
@@ -5195,7 +5195,7 @@ class bybit extends bybit$1 {
|
|
|
5195
5195
|
return await this.fetchUsdcOpenOrders(symbol, since, limit, params);
|
|
5196
5196
|
}
|
|
5197
5197
|
request['category'] = type;
|
|
5198
|
-
const isStop = this.
|
|
5198
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
5199
5199
|
params = this.omit(params, ['stop', 'trigger']);
|
|
5200
5200
|
if (isStop) {
|
|
5201
5201
|
request['orderFilter'] = 'StopOrder';
|
|
@@ -5321,7 +5321,7 @@ class bybit extends bybit$1 {
|
|
|
5321
5321
|
// "retMsg": "Success."
|
|
5322
5322
|
// }
|
|
5323
5323
|
//
|
|
5324
|
-
const result = this.
|
|
5324
|
+
const result = this.safeDict(response, 'result', {});
|
|
5325
5325
|
const dataList = this.safeList(result, 'dataList', []);
|
|
5326
5326
|
return this.parseTrades(dataList, market, since, limit);
|
|
5327
5327
|
}
|
|
@@ -5472,8 +5472,8 @@ class bybit extends bybit$1 {
|
|
|
5472
5472
|
// "time": 1672192792860
|
|
5473
5473
|
// }
|
|
5474
5474
|
//
|
|
5475
|
-
const result = this.
|
|
5476
|
-
const chains = this.
|
|
5475
|
+
const result = this.safeDict(response, 'result', {});
|
|
5476
|
+
const chains = this.safeList(result, 'chains', []);
|
|
5477
5477
|
const coin = this.safeString(result, 'coin');
|
|
5478
5478
|
currency = this.currency(coin);
|
|
5479
5479
|
const parsed = this.parseDepositAddresses(chains, [currency['code']], false, {
|
|
@@ -5521,8 +5521,8 @@ class bybit extends bybit$1 {
|
|
|
5521
5521
|
// "time": 1672192792860
|
|
5522
5522
|
// }
|
|
5523
5523
|
//
|
|
5524
|
-
const result = this.
|
|
5525
|
-
const chains = this.
|
|
5524
|
+
const result = this.safeDict(response, 'result', {});
|
|
5525
|
+
const chains = this.safeList(result, 'chains', []);
|
|
5526
5526
|
const chainsIndexedById = this.indexBy(chains, 'chain');
|
|
5527
5527
|
const selectedNetworkId = this.selectNetworkIdFromRawNetworks(code, networkCode, chainsIndexedById);
|
|
5528
5528
|
const addressObject = this.safeDict(chainsIndexedById, selectedNetworkId, {});
|
|
@@ -6230,14 +6230,14 @@ class bybit extends bybit$1 {
|
|
|
6230
6230
|
// "retMsg": "Success."
|
|
6231
6231
|
// }
|
|
6232
6232
|
//
|
|
6233
|
-
const result = this.
|
|
6234
|
-
const positions = this.
|
|
6233
|
+
const result = this.safeDict(response, 'result', {});
|
|
6234
|
+
const positions = this.safeList(result, 'dataList', []);
|
|
6235
6235
|
const results = [];
|
|
6236
6236
|
for (let i = 0; i < positions.length; i++) {
|
|
6237
6237
|
let rawPosition = positions[i];
|
|
6238
6238
|
if (('data' in rawPosition) && ('is_valid' in rawPosition)) {
|
|
6239
6239
|
// futures only
|
|
6240
|
-
rawPosition = this.
|
|
6240
|
+
rawPosition = this.safeDict(rawPosition, 'data');
|
|
6241
6241
|
}
|
|
6242
6242
|
results.push(this.parsePosition(rawPosition, market));
|
|
6243
6243
|
}
|
|
@@ -6350,7 +6350,7 @@ class bybit extends bybit$1 {
|
|
|
6350
6350
|
let rawPosition = positions[i];
|
|
6351
6351
|
if (('data' in rawPosition) && ('is_valid' in rawPosition)) {
|
|
6352
6352
|
// futures only
|
|
6353
|
-
rawPosition = this.
|
|
6353
|
+
rawPosition = this.safeDict(rawPosition, 'data');
|
|
6354
6354
|
}
|
|
6355
6355
|
results.push(this.parsePosition(rawPosition));
|
|
6356
6356
|
}
|
|
@@ -6752,20 +6752,20 @@ class bybit extends bybit$1 {
|
|
|
6752
6752
|
const isUsdcSettled = market['settle'] === 'USDC';
|
|
6753
6753
|
// engage in leverage setting
|
|
6754
6754
|
// we reuse the code here instead of having two methods
|
|
6755
|
-
|
|
6755
|
+
const leverageString = this.numberToString(leverage);
|
|
6756
6756
|
const request = {
|
|
6757
6757
|
'symbol': market['id'],
|
|
6758
|
-
'buyLeverage':
|
|
6759
|
-
'sellLeverage':
|
|
6758
|
+
'buyLeverage': leverageString,
|
|
6759
|
+
'sellLeverage': leverageString,
|
|
6760
6760
|
};
|
|
6761
6761
|
let response = undefined;
|
|
6762
6762
|
if (isUsdcSettled && !isUnifiedAccount) {
|
|
6763
|
-
request['leverage'] =
|
|
6763
|
+
request['leverage'] = leverageString;
|
|
6764
6764
|
response = await this.privatePostPerpetualUsdcOpenapiPrivateV1PositionLeverageSave(this.extend(request, params));
|
|
6765
6765
|
}
|
|
6766
6766
|
else {
|
|
6767
|
-
request['buyLeverage'] =
|
|
6768
|
-
request['sellLeverage'] =
|
|
6767
|
+
request['buyLeverage'] = leverageString;
|
|
6768
|
+
request['sellLeverage'] = leverageString;
|
|
6769
6769
|
if (market['linear']) {
|
|
6770
6770
|
request['category'] = 'linear';
|
|
6771
6771
|
}
|
|
@@ -6837,7 +6837,7 @@ class bybit extends bybit$1 {
|
|
|
6837
6837
|
let market = this.market(symbol);
|
|
6838
6838
|
const subType = market['linear'] ? 'linear' : 'inverse';
|
|
6839
6839
|
const category = this.safeString(params, 'category', subType);
|
|
6840
|
-
const intervals = this.
|
|
6840
|
+
const intervals = this.safeDict(this.options, 'intervals');
|
|
6841
6841
|
const interval = this.safeString(intervals, timeframe); // 5min,15min,30min,1h,4h,1d
|
|
6842
6842
|
if (interval === undefined) {
|
|
6843
6843
|
throw new errors.BadRequest(this.id + ' fetchOpenInterestHistory() cannot use the ' + timeframe + ' timeframe');
|
|
@@ -6882,7 +6882,7 @@ class bybit extends bybit$1 {
|
|
|
6882
6882
|
// "time": 1672053548579
|
|
6883
6883
|
// }
|
|
6884
6884
|
//
|
|
6885
|
-
const result = this.
|
|
6885
|
+
const result = this.safeDict(response, 'result', {});
|
|
6886
6886
|
const data = this.addPaginationCursorToResult(response);
|
|
6887
6887
|
const id = this.safeString(result, 'symbol');
|
|
6888
6888
|
market = this.safeMarket(id, market, undefined, 'contract');
|
|
@@ -6906,7 +6906,7 @@ class bybit extends bybit$1 {
|
|
|
6906
6906
|
throw new errors.BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
|
|
6907
6907
|
}
|
|
6908
6908
|
const timeframe = this.safeString(params, 'interval', '1h');
|
|
6909
|
-
const intervals = this.
|
|
6909
|
+
const intervals = this.safeDict(this.options, 'intervals');
|
|
6910
6910
|
const interval = this.safeString(intervals, timeframe); // 5min,15min,30min,1h,4h,1d
|
|
6911
6911
|
if (interval === undefined) {
|
|
6912
6912
|
throw new errors.BadRequest(this.id + ' fetchOpenInterest() cannot use the ' + timeframe + ' timeframe');
|
|
@@ -6942,7 +6942,7 @@ class bybit extends bybit$1 {
|
|
|
6942
6942
|
// "time": 1672053548579
|
|
6943
6943
|
// }
|
|
6944
6944
|
//
|
|
6945
|
-
const result = this.
|
|
6945
|
+
const result = this.safeDict(response, 'result', {});
|
|
6946
6946
|
const id = this.safeString(result, 'symbol');
|
|
6947
6947
|
market = this.safeMarket(id, market, undefined, 'contract');
|
|
6948
6948
|
const data = this.addPaginationCursorToResult(response);
|
|
@@ -7029,7 +7029,7 @@ class bybit extends bybit$1 {
|
|
|
7029
7029
|
// }
|
|
7030
7030
|
//
|
|
7031
7031
|
const timestamp = this.safeInteger(response, 'time');
|
|
7032
|
-
const data = this.
|
|
7032
|
+
const data = this.safeDict(response, 'result', {});
|
|
7033
7033
|
data['timestamp'] = timestamp;
|
|
7034
7034
|
return this.parseBorrowRate(data, currency);
|
|
7035
7035
|
}
|
|
@@ -7095,8 +7095,8 @@ class bybit extends bybit$1 {
|
|
|
7095
7095
|
// }
|
|
7096
7096
|
// }
|
|
7097
7097
|
//
|
|
7098
|
-
const data = this.
|
|
7099
|
-
const rows = this.
|
|
7098
|
+
const data = this.safeDict(response, 'result', {});
|
|
7099
|
+
const rows = this.safeList(data, 'loanAccountList', []);
|
|
7100
7100
|
const interest = this.parseBorrowInterests(rows, undefined);
|
|
7101
7101
|
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
7102
7102
|
}
|
|
@@ -7139,7 +7139,7 @@ class bybit extends bybit$1 {
|
|
|
7139
7139
|
*/
|
|
7140
7140
|
await this.loadMarkets();
|
|
7141
7141
|
const transferId = this.safeString(params, 'transferId', this.uuid());
|
|
7142
|
-
const accountTypes = this.
|
|
7142
|
+
const accountTypes = this.safeDict(this.options, 'accountsByType', {});
|
|
7143
7143
|
const fromId = this.safeString(accountTypes, fromAccount, fromAccount);
|
|
7144
7144
|
const toId = this.safeString(accountTypes, toAccount, toAccount);
|
|
7145
7145
|
const currency = this.currency(code);
|
|
@@ -7164,7 +7164,7 @@ class bybit extends bybit$1 {
|
|
|
7164
7164
|
// }
|
|
7165
7165
|
//
|
|
7166
7166
|
const timestamp = this.safeInteger(response, 'time');
|
|
7167
|
-
const transfer = this.
|
|
7167
|
+
const transfer = this.safeDict(response, 'result', {});
|
|
7168
7168
|
const statusRaw = this.safeStringN(response, ['retCode', 'retMsg']);
|
|
7169
7169
|
const status = this.parseTransferStatus(statusRaw);
|
|
7170
7170
|
return this.extend(this.parseTransfer(transfer, currency), {
|
|
@@ -7264,7 +7264,7 @@ class bybit extends bybit$1 {
|
|
|
7264
7264
|
// "time": 1662617848970
|
|
7265
7265
|
// }
|
|
7266
7266
|
//
|
|
7267
|
-
const result = this.
|
|
7267
|
+
const result = this.safeDict(response, 'result', {});
|
|
7268
7268
|
const transaction = this.parseMarginLoan(result, currency);
|
|
7269
7269
|
return this.extend(transaction, {
|
|
7270
7270
|
'symbol': undefined,
|
|
@@ -7300,7 +7300,7 @@ class bybit extends bybit$1 {
|
|
|
7300
7300
|
// "time": 1662618298452
|
|
7301
7301
|
// }
|
|
7302
7302
|
//
|
|
7303
|
-
const result = this.
|
|
7303
|
+
const result = this.safeDict(response, 'result', {});
|
|
7304
7304
|
const transaction = this.parseMarginLoan(result, currency);
|
|
7305
7305
|
return this.extend(transaction, {
|
|
7306
7306
|
'symbol': undefined,
|
|
@@ -7363,7 +7363,7 @@ class bybit extends bybit$1 {
|
|
|
7363
7363
|
const timestamp = this.safeInteger(transfer, 'timestamp');
|
|
7364
7364
|
const fromAccountId = this.safeString(transfer, 'fromAccountType');
|
|
7365
7365
|
const toAccountId = this.safeString(transfer, 'toAccountType');
|
|
7366
|
-
const accountIds = this.
|
|
7366
|
+
const accountIds = this.safeDict(this.options, 'accountsById', {});
|
|
7367
7367
|
const fromAccount = this.safeString(accountIds, fromAccountId, fromAccountId);
|
|
7368
7368
|
const toAccount = this.safeString(accountIds, toAccountId, toAccountId);
|
|
7369
7369
|
return {
|
|
@@ -7414,8 +7414,8 @@ class bybit extends bybit$1 {
|
|
|
7414
7414
|
// "time": 1672054488010
|
|
7415
7415
|
// }
|
|
7416
7416
|
//
|
|
7417
|
-
const result = this.
|
|
7418
|
-
const tiers = this.
|
|
7417
|
+
const result = this.safeDict(response, 'result');
|
|
7418
|
+
const tiers = this.safeList(result, 'list');
|
|
7419
7419
|
return this.parseMarketLeverageTiers(tiers, market);
|
|
7420
7420
|
}
|
|
7421
7421
|
async fetchMarketLeverageTiers(symbol, params = {}) {
|
|
@@ -7504,9 +7504,9 @@ class bybit extends bybit$1 {
|
|
|
7504
7504
|
// "time": 1676360412576
|
|
7505
7505
|
// }
|
|
7506
7506
|
//
|
|
7507
|
-
const result = this.
|
|
7508
|
-
const fees = this.
|
|
7509
|
-
const first = this.
|
|
7507
|
+
const result = this.safeDict(response, 'result', {});
|
|
7508
|
+
const fees = this.safeList(result, 'list', []);
|
|
7509
|
+
const first = this.safeDict(fees, 0, {});
|
|
7510
7510
|
return this.parseTradingFee(first, market);
|
|
7511
7511
|
}
|
|
7512
7512
|
async fetchTradingFees(params = {}) {
|
|
@@ -7543,8 +7543,8 @@ class bybit extends bybit$1 {
|
|
|
7543
7543
|
// "time": 1676360412576
|
|
7544
7544
|
// }
|
|
7545
7545
|
//
|
|
7546
|
-
let fees = this.
|
|
7547
|
-
fees = this.
|
|
7546
|
+
let fees = this.safeDict(response, 'result', {});
|
|
7547
|
+
fees = this.safeList(fees, 'list', []);
|
|
7548
7548
|
const result = {};
|
|
7549
7549
|
for (let i = 0; i < fees.length; i++) {
|
|
7550
7550
|
const fee = this.parseTradingFee(fees[i]);
|
|
@@ -7574,7 +7574,7 @@ class bybit extends bybit$1 {
|
|
|
7574
7574
|
// ]
|
|
7575
7575
|
// }
|
|
7576
7576
|
//
|
|
7577
|
-
const chains = this.
|
|
7577
|
+
const chains = this.safeList(fee, 'chains', []);
|
|
7578
7578
|
const chainsLength = chains.length;
|
|
7579
7579
|
const result = {
|
|
7580
7580
|
'info': fee,
|
|
@@ -7649,7 +7649,7 @@ class bybit extends bybit$1 {
|
|
|
7649
7649
|
// "time": 1672194582264
|
|
7650
7650
|
// }
|
|
7651
7651
|
//
|
|
7652
|
-
const data = this.
|
|
7652
|
+
const data = this.safeDict(response, 'result', {});
|
|
7653
7653
|
const rows = this.safeList(data, 'rows', []);
|
|
7654
7654
|
return this.parseDepositWithdrawFees(rows, codes, 'coin');
|
|
7655
7655
|
}
|
|
@@ -7703,8 +7703,8 @@ class bybit extends bybit$1 {
|
|
|
7703
7703
|
// "time": 1689043527231
|
|
7704
7704
|
// }
|
|
7705
7705
|
//
|
|
7706
|
-
const result = this.
|
|
7707
|
-
const data = this.
|
|
7706
|
+
const result = this.safeDict(response, 'result', {});
|
|
7707
|
+
const data = this.safeList(result, 'list', []);
|
|
7708
7708
|
const settlements = this.parseSettlements(data, market);
|
|
7709
7709
|
const sorted = this.sortBy(settlements, 'timestamp');
|
|
7710
7710
|
return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
|
|
@@ -7764,8 +7764,8 @@ class bybit extends bybit$1 {
|
|
|
7764
7764
|
// "time": 1689043527231
|
|
7765
7765
|
// }
|
|
7766
7766
|
//
|
|
7767
|
-
const result = this.
|
|
7768
|
-
const data = this.
|
|
7767
|
+
const result = this.safeDict(response, 'result', {});
|
|
7768
|
+
const data = this.safeList(result, 'list', []);
|
|
7769
7769
|
const settlements = this.parseSettlements(data, market);
|
|
7770
7770
|
const sorted = this.sortBy(settlements, 'timestamp');
|
|
7771
7771
|
return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
|
|
@@ -7868,7 +7868,7 @@ class bybit extends bybit$1 {
|
|
|
7868
7868
|
// ]
|
|
7869
7869
|
// }
|
|
7870
7870
|
//
|
|
7871
|
-
const volatility = this.
|
|
7871
|
+
const volatility = this.safeList(response, 'result', []);
|
|
7872
7872
|
return this.parseVolatilityHistory(volatility);
|
|
7873
7873
|
}
|
|
7874
7874
|
parseVolatilityHistory(volatility) {
|
|
@@ -7950,8 +7950,8 @@ class bybit extends bybit$1 {
|
|
|
7950
7950
|
// }
|
|
7951
7951
|
//
|
|
7952
7952
|
const timestamp = this.safeInteger(response, 'time');
|
|
7953
|
-
const result = this.
|
|
7954
|
-
const data = this.
|
|
7953
|
+
const result = this.safeDict(response, 'result', {});
|
|
7954
|
+
const data = this.safeList(result, 'list', []);
|
|
7955
7955
|
const greeks = this.parseGreeks(data[0], market);
|
|
7956
7956
|
return this.extend(greeks, {
|
|
7957
7957
|
'timestamp': timestamp,
|