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