ccxt 4.3.13 → 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 +99 -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/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 +99 -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/js/src/bybit.js
CHANGED
|
@@ -1107,7 +1107,7 @@ export default class bybit extends Exchange {
|
|
|
1107
1107
|
return this.milliseconds() - this.options['timeDifference'];
|
|
1108
1108
|
}
|
|
1109
1109
|
addPaginationCursorToResult(response) {
|
|
1110
|
-
const result = this.
|
|
1110
|
+
const result = this.safeDict(response, 'result', {});
|
|
1111
1111
|
const data = this.safeValueN(result, ['list', 'rows', 'data', 'dataList'], []);
|
|
1112
1112
|
const paginationCursor = this.safeString2(result, 'nextPageCursor', 'cursor');
|
|
1113
1113
|
const dataLength = data.length;
|
|
@@ -1127,8 +1127,8 @@ export default class bybit extends Exchange {
|
|
|
1127
1127
|
// The API key of user id must own one of permissions will be allowed to call following API endpoints.
|
|
1128
1128
|
// SUB UID: "Account Transfer"
|
|
1129
1129
|
// MASTER UID: "Account Transfer", "Subaccount Transfer", "Withdrawal"
|
|
1130
|
-
const enableUnifiedMargin = this.
|
|
1131
|
-
const enableUnifiedAccount = this.
|
|
1130
|
+
const enableUnifiedMargin = this.safeBool(this.options, 'enableUnifiedMargin');
|
|
1131
|
+
const enableUnifiedAccount = this.safeBool(this.options, 'enableUnifiedAccount');
|
|
1132
1132
|
if (enableUnifiedMargin === undefined || enableUnifiedAccount === undefined) {
|
|
1133
1133
|
if (this.options['enableDemoTrading']) {
|
|
1134
1134
|
// info endpoint is not available in demo trading
|
|
@@ -1178,7 +1178,7 @@ export default class bybit extends Exchange {
|
|
|
1178
1178
|
// "time": 1676891757649
|
|
1179
1179
|
// }
|
|
1180
1180
|
//
|
|
1181
|
-
const result = this.
|
|
1181
|
+
const result = this.safeDict(response, 'result', {});
|
|
1182
1182
|
this.options['enableUnifiedMargin'] = this.safeInteger(result, 'unified') === 1;
|
|
1183
1183
|
this.options['enableUnifiedAccount'] = this.safeInteger(result, 'uta') === 1;
|
|
1184
1184
|
}
|
|
@@ -1340,15 +1340,15 @@ export default class bybit extends Exchange {
|
|
|
1340
1340
|
// "time": 1672194582264
|
|
1341
1341
|
// }
|
|
1342
1342
|
//
|
|
1343
|
-
const data = this.
|
|
1344
|
-
const rows = this.
|
|
1343
|
+
const data = this.safeDict(response, 'result', {});
|
|
1344
|
+
const rows = this.safeList(data, 'rows', []);
|
|
1345
1345
|
const result = {};
|
|
1346
1346
|
for (let i = 0; i < rows.length; i++) {
|
|
1347
1347
|
const currency = rows[i];
|
|
1348
1348
|
const currencyId = this.safeString(currency, 'coin');
|
|
1349
1349
|
const code = this.safeCurrencyCode(currencyId);
|
|
1350
1350
|
const name = this.safeString(currency, 'name');
|
|
1351
|
-
const chains = this.
|
|
1351
|
+
const chains = this.safeList(currency, 'chains', []);
|
|
1352
1352
|
const networks = {};
|
|
1353
1353
|
let minPrecision = undefined;
|
|
1354
1354
|
let minWithdrawFeeString = undefined;
|
|
@@ -1441,7 +1441,7 @@ export default class bybit extends Exchange {
|
|
|
1441
1441
|
await this.loadTimeDifference();
|
|
1442
1442
|
}
|
|
1443
1443
|
const promisesUnresolved = [];
|
|
1444
|
-
const fetchMarkets = this.
|
|
1444
|
+
const fetchMarkets = this.safeList(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']);
|
|
1445
1445
|
for (let i = 0; i < fetchMarkets.length; i++) {
|
|
1446
1446
|
const marketType = fetchMarkets[i];
|
|
1447
1447
|
if (marketType === 'spot') {
|
|
@@ -1463,12 +1463,12 @@ export default class bybit extends Exchange {
|
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
1465
|
const promises = await Promise.all(promisesUnresolved);
|
|
1466
|
-
const spotMarkets = this.
|
|
1467
|
-
const linearMarkets = this.
|
|
1468
|
-
const inverseMarkets = this.
|
|
1469
|
-
const btcOptionMarkets = this.
|
|
1470
|
-
const ethOptionMarkets = this.
|
|
1471
|
-
const solOptionMarkets = this.
|
|
1466
|
+
const spotMarkets = this.safeList(promises, 0, []);
|
|
1467
|
+
const linearMarkets = this.safeList(promises, 1, []);
|
|
1468
|
+
const inverseMarkets = this.safeList(promises, 2, []);
|
|
1469
|
+
const btcOptionMarkets = this.safeList(promises, 3, []);
|
|
1470
|
+
const ethOptionMarkets = this.safeList(promises, 4, []);
|
|
1471
|
+
const solOptionMarkets = this.safeList(promises, 5, []);
|
|
1472
1472
|
const futureMarkets = this.arrayConcat(linearMarkets, inverseMarkets);
|
|
1473
1473
|
let optionMarkets = this.arrayConcat(btcOptionMarkets, ethOptionMarkets);
|
|
1474
1474
|
optionMarkets = this.arrayConcat(optionMarkets, solOptionMarkets);
|
|
@@ -1511,8 +1511,8 @@ export default class bybit extends Exchange {
|
|
|
1511
1511
|
// "time": 1672712468011
|
|
1512
1512
|
// }
|
|
1513
1513
|
//
|
|
1514
|
-
const responseResult = this.
|
|
1515
|
-
const markets = this.
|
|
1514
|
+
const responseResult = this.safeDict(response, 'result', {});
|
|
1515
|
+
const markets = this.safeList(responseResult, 'list', []);
|
|
1516
1516
|
const result = [];
|
|
1517
1517
|
const takerFee = this.parseNumber('0.001');
|
|
1518
1518
|
const makerFee = this.parseNumber('0.001');
|
|
@@ -1526,8 +1526,8 @@ export default class bybit extends Exchange {
|
|
|
1526
1526
|
const symbol = base + '/' + quote;
|
|
1527
1527
|
const status = this.safeString(market, 'status');
|
|
1528
1528
|
const active = (status === 'Trading');
|
|
1529
|
-
const lotSizeFilter = this.
|
|
1530
|
-
const priceFilter = this.
|
|
1529
|
+
const lotSizeFilter = this.safeDict(market, 'lotSizeFilter');
|
|
1530
|
+
const priceFilter = this.safeDict(market, 'priceFilter');
|
|
1531
1531
|
const quotePrecision = this.safeNumber(lotSizeFilter, 'quotePrecision');
|
|
1532
1532
|
result.push({
|
|
1533
1533
|
'id': id,
|
|
@@ -1587,15 +1587,15 @@ export default class bybit extends Exchange {
|
|
|
1587
1587
|
params = this.extend(params);
|
|
1588
1588
|
params['limit'] = 1000; // minimize number of requests
|
|
1589
1589
|
const response = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1590
|
-
const data = this.
|
|
1591
|
-
let markets = this.
|
|
1590
|
+
const data = this.safeDict(response, 'result', {});
|
|
1591
|
+
let markets = this.safeList(data, 'list', []);
|
|
1592
1592
|
let paginationCursor = this.safeString(data, 'nextPageCursor');
|
|
1593
1593
|
if (paginationCursor !== undefined) {
|
|
1594
1594
|
while (paginationCursor !== undefined) {
|
|
1595
1595
|
params['cursor'] = paginationCursor;
|
|
1596
1596
|
const responseInner = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1597
|
-
const dataNew = this.
|
|
1598
|
-
const rawMarkets = this.
|
|
1597
|
+
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1598
|
+
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1599
1599
|
const rawMarketsLength = rawMarkets.length;
|
|
1600
1600
|
if (rawMarketsLength === 0) {
|
|
1601
1601
|
break;
|
|
@@ -1677,9 +1677,9 @@ export default class bybit extends Exchange {
|
|
|
1677
1677
|
settle = this.safeCurrencyCode(settleId);
|
|
1678
1678
|
}
|
|
1679
1679
|
let symbol = base + '/' + quote;
|
|
1680
|
-
const lotSizeFilter = this.
|
|
1681
|
-
const priceFilter = this.
|
|
1682
|
-
const leverage = this.
|
|
1680
|
+
const lotSizeFilter = this.safeDict(market, 'lotSizeFilter', {});
|
|
1681
|
+
const priceFilter = this.safeDict(market, 'priceFilter', {});
|
|
1682
|
+
const leverage = this.safeDict(market, 'leverageFilter', {});
|
|
1683
1683
|
const status = this.safeString(market, 'status');
|
|
1684
1684
|
const swap = linearPerpetual || inversePerpetual;
|
|
1685
1685
|
const future = inverseFutures || linearFutures;
|
|
@@ -1763,8 +1763,8 @@ export default class bybit extends Exchange {
|
|
|
1763
1763
|
'category': 'option',
|
|
1764
1764
|
};
|
|
1765
1765
|
const response = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1766
|
-
const data = this.
|
|
1767
|
-
let markets = this.
|
|
1766
|
+
const data = this.safeDict(response, 'result', {});
|
|
1767
|
+
let markets = this.safeList(data, 'list', []);
|
|
1768
1768
|
if (this.options['loadAllOptions']) {
|
|
1769
1769
|
request['limit'] = 1000;
|
|
1770
1770
|
let paginationCursor = this.safeString(data, 'nextPageCursor');
|
|
@@ -1772,8 +1772,8 @@ export default class bybit extends Exchange {
|
|
|
1772
1772
|
while (paginationCursor !== undefined) {
|
|
1773
1773
|
request['cursor'] = paginationCursor;
|
|
1774
1774
|
const responseInner = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1775
|
-
const dataNew = this.
|
|
1776
|
-
const rawMarkets = this.
|
|
1775
|
+
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1776
|
+
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1777
1777
|
const rawMarketsLength = rawMarkets.length;
|
|
1778
1778
|
if (rawMarketsLength === 0) {
|
|
1779
1779
|
break;
|
|
@@ -1828,8 +1828,8 @@ export default class bybit extends Exchange {
|
|
|
1828
1828
|
const base = this.safeCurrencyCode(baseId);
|
|
1829
1829
|
const quote = this.safeCurrencyCode(quoteId);
|
|
1830
1830
|
const settle = this.safeCurrencyCode(settleId);
|
|
1831
|
-
const lotSizeFilter = this.
|
|
1832
|
-
const priceFilter = this.
|
|
1831
|
+
const lotSizeFilter = this.safeDict(market, 'lotSizeFilter', {});
|
|
1832
|
+
const priceFilter = this.safeDict(market, 'priceFilter', {});
|
|
1833
1833
|
const status = this.safeString(market, 'status');
|
|
1834
1834
|
const expiry = this.safeInteger(market, 'deliveryTime');
|
|
1835
1835
|
const splitId = id.split('-');
|
|
@@ -2082,8 +2082,8 @@ export default class bybit extends Exchange {
|
|
|
2082
2082
|
// "time": 1672376496682
|
|
2083
2083
|
// }
|
|
2084
2084
|
//
|
|
2085
|
-
const result = this.
|
|
2086
|
-
const tickers = this.
|
|
2085
|
+
const result = this.safeDict(response, 'result', {});
|
|
2086
|
+
const tickers = this.safeList(result, 'list', []);
|
|
2087
2087
|
const rawTicker = this.safeDict(tickers, 0);
|
|
2088
2088
|
return this.parseTicker(rawTicker, market);
|
|
2089
2089
|
}
|
|
@@ -2189,7 +2189,7 @@ export default class bybit extends Exchange {
|
|
|
2189
2189
|
// "time": 1672376496682
|
|
2190
2190
|
// }
|
|
2191
2191
|
//
|
|
2192
|
-
const result = this.
|
|
2192
|
+
const result = this.safeDict(response, 'result', {});
|
|
2193
2193
|
const tickerList = this.safeList(result, 'list', []);
|
|
2194
2194
|
return this.parseTickers(tickerList, parsedSymbols);
|
|
2195
2195
|
}
|
|
@@ -2328,7 +2328,7 @@ export default class bybit extends Exchange {
|
|
|
2328
2328
|
// "time": 1672025956592
|
|
2329
2329
|
// }
|
|
2330
2330
|
//
|
|
2331
|
-
const result = this.
|
|
2331
|
+
const result = this.safeDict(response, 'result', {});
|
|
2332
2332
|
const ohlcvs = this.safeList(result, 'list', []);
|
|
2333
2333
|
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
2334
2334
|
}
|
|
@@ -2544,8 +2544,8 @@ export default class bybit extends Exchange {
|
|
|
2544
2544
|
// }
|
|
2545
2545
|
//
|
|
2546
2546
|
const rates = [];
|
|
2547
|
-
const result = this.
|
|
2548
|
-
const resultList = this.
|
|
2547
|
+
const result = this.safeDict(response, 'result');
|
|
2548
|
+
const resultList = this.safeList(result, 'list');
|
|
2549
2549
|
for (let i = 0; i < resultList.length; i++) {
|
|
2550
2550
|
const entry = resultList[i];
|
|
2551
2551
|
const timestamp = this.safeInteger(entry, 'fundingRateTimestamp');
|
|
@@ -2679,7 +2679,7 @@ export default class bybit extends Exchange {
|
|
|
2679
2679
|
side = isBuyer ? 'buy' : 'sell';
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
const isMaker = this.
|
|
2682
|
+
const isMaker = this.safeBool(trade, 'isMaker');
|
|
2683
2683
|
let takerOrMaker = undefined;
|
|
2684
2684
|
if (isMaker !== undefined) {
|
|
2685
2685
|
takerOrMaker = isMaker ? 'maker' : 'taker';
|
|
@@ -2805,7 +2805,7 @@ export default class bybit extends Exchange {
|
|
|
2805
2805
|
// "time": 1672053054358
|
|
2806
2806
|
// }
|
|
2807
2807
|
//
|
|
2808
|
-
const result = this.
|
|
2808
|
+
const result = this.safeDict(response, 'result', {});
|
|
2809
2809
|
const trades = this.safeList(result, 'list', []);
|
|
2810
2810
|
return this.parseTrades(trades, market, since, limit);
|
|
2811
2811
|
}
|
|
@@ -2875,7 +2875,7 @@ export default class bybit extends Exchange {
|
|
|
2875
2875
|
// "time": 1672765737734
|
|
2876
2876
|
// }
|
|
2877
2877
|
//
|
|
2878
|
-
const result = this.
|
|
2878
|
+
const result = this.safeDict(response, 'result', {});
|
|
2879
2879
|
const timestamp = this.safeInteger(result, 'ts');
|
|
2880
2880
|
return this.parseOrderBook(result, symbol, timestamp, 'b', 'a');
|
|
2881
2881
|
}
|
|
@@ -2988,7 +2988,7 @@ export default class bybit extends Exchange {
|
|
|
2988
2988
|
'timestamp': timestamp,
|
|
2989
2989
|
'datetime': this.iso8601(timestamp),
|
|
2990
2990
|
};
|
|
2991
|
-
const responseResult = this.
|
|
2991
|
+
const responseResult = this.safeDict(response, 'result', {});
|
|
2992
2992
|
const currencyList = this.safeValueN(responseResult, ['loanAccountList', 'list', 'balance']);
|
|
2993
2993
|
if (currencyList === undefined) {
|
|
2994
2994
|
// usdc wallet
|
|
@@ -3003,7 +3003,7 @@ export default class bybit extends Exchange {
|
|
|
3003
3003
|
const entry = currencyList[i];
|
|
3004
3004
|
const accountType = this.safeString(entry, 'accountType');
|
|
3005
3005
|
if (accountType === 'UNIFIED' || accountType === 'CONTRACT' || accountType === 'SPOT') {
|
|
3006
|
-
const coins = this.
|
|
3006
|
+
const coins = this.safeList(entry, 'coin');
|
|
3007
3007
|
for (let j = 0; j < coins.length; j++) {
|
|
3008
3008
|
const account = this.account();
|
|
3009
3009
|
const coinEntry = coins[j];
|
|
@@ -3068,7 +3068,7 @@ export default class bybit extends Exchange {
|
|
|
3068
3068
|
type = 'contract';
|
|
3069
3069
|
}
|
|
3070
3070
|
}
|
|
3071
|
-
const accountTypes = this.
|
|
3071
|
+
const accountTypes = this.safeDict(this.options, 'accountsByType', {});
|
|
3072
3072
|
const unifiedType = this.safeStringUpper(accountTypes, type, type);
|
|
3073
3073
|
let marginMode = undefined;
|
|
3074
3074
|
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
@@ -3396,7 +3396,7 @@ export default class bybit extends Exchange {
|
|
|
3396
3396
|
const rawTimeInForce = this.safeString(order, 'timeInForce');
|
|
3397
3397
|
const timeInForce = this.parseTimeInForce(rawTimeInForce);
|
|
3398
3398
|
const stopPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
|
|
3399
|
-
const reduceOnly = this.
|
|
3399
|
+
const reduceOnly = this.safeBool(order, 'reduceOnly');
|
|
3400
3400
|
let takeProfitPrice = this.omitZero(this.safeString(order, 'takeProfit'));
|
|
3401
3401
|
let stopLossPrice = this.omitZero(this.safeString(order, 'stopLoss'));
|
|
3402
3402
|
const triggerDirection = this.safeString(order, 'triggerDirection');
|
|
@@ -3436,7 +3436,7 @@ export default class bybit extends Exchange {
|
|
|
3436
3436
|
'type': type,
|
|
3437
3437
|
'timeInForce': timeInForce,
|
|
3438
3438
|
'postOnly': undefined,
|
|
3439
|
-
'reduceOnly': this.
|
|
3439
|
+
'reduceOnly': this.safeBool(order, 'reduceOnly'),
|
|
3440
3440
|
'side': side,
|
|
3441
3441
|
'price': price,
|
|
3442
3442
|
'stopPrice': stopPrice,
|
|
@@ -3537,7 +3537,7 @@ export default class bybit extends Exchange {
|
|
|
3537
3537
|
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3538
3538
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3539
3539
|
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
|
|
3540
|
-
const options = this.
|
|
3540
|
+
const options = this.safeDict(this.options, 'createOrder', {});
|
|
3541
3541
|
const defaultMethod = this.safeString(options, 'method', 'privatePostV5OrderCreate');
|
|
3542
3542
|
let response = undefined;
|
|
3543
3543
|
if (isTrailingAmountOrder || (defaultMethod === 'privatePostV5PositionTradingStop')) {
|
|
@@ -3836,10 +3836,10 @@ export default class bybit extends Exchange {
|
|
|
3836
3836
|
'request': ordersRequests,
|
|
3837
3837
|
};
|
|
3838
3838
|
const response = await this.privatePostV5OrderCreateBatch(this.extend(request, params));
|
|
3839
|
-
const result = this.
|
|
3840
|
-
const data = this.
|
|
3841
|
-
const retInfo = this.
|
|
3842
|
-
const codes = this.
|
|
3839
|
+
const result = this.safeDict(response, 'result', {});
|
|
3840
|
+
const data = this.safeList(result, 'list', []);
|
|
3841
|
+
const retInfo = this.safeDict(response, 'retExtInfo', {});
|
|
3842
|
+
const codes = this.safeList(retInfo, 'list', []);
|
|
3843
3843
|
// extend the error with the unsuccessful orders
|
|
3844
3844
|
for (let i = 0; i < codes.length; i++) {
|
|
3845
3845
|
const code = codes[i];
|
|
@@ -4033,7 +4033,7 @@ export default class bybit extends Exchange {
|
|
|
4033
4033
|
response = await this.privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder(this.extend(request, params));
|
|
4034
4034
|
}
|
|
4035
4035
|
else {
|
|
4036
|
-
const isStop = this.
|
|
4036
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4037
4037
|
const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
|
|
4038
4038
|
const stopLossPrice = this.safeValue(params, 'stopLossPrice');
|
|
4039
4039
|
const isStopLossOrder = stopLossPrice !== undefined;
|
|
@@ -4200,7 +4200,7 @@ export default class bybit extends Exchange {
|
|
|
4200
4200
|
// "time": 1672217093461
|
|
4201
4201
|
// }
|
|
4202
4202
|
//
|
|
4203
|
-
const result = this.
|
|
4203
|
+
const result = this.safeDict(response, 'result', {});
|
|
4204
4204
|
return this.safeOrder({
|
|
4205
4205
|
'info': response,
|
|
4206
4206
|
'id': this.safeString(result, 'orderId'),
|
|
@@ -4217,7 +4217,7 @@ export default class bybit extends Exchange {
|
|
|
4217
4217
|
// 'orderLinkId': 'string', // one of order_id, stop_order_id or order_link_id is required
|
|
4218
4218
|
// 'orderId': id,
|
|
4219
4219
|
};
|
|
4220
|
-
const isStop = this.
|
|
4220
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4221
4221
|
params = this.omit(params, ['stop', 'trigger']);
|
|
4222
4222
|
if (id !== undefined) { // The user can also use argument params["order_link_id"]
|
|
4223
4223
|
request['orderId'] = id;
|
|
@@ -4498,7 +4498,7 @@ export default class bybit extends Exchange {
|
|
|
4498
4498
|
response = await this.privatePostOptionUsdcOpenapiPrivateV1CancelAll(this.extend(request, params));
|
|
4499
4499
|
}
|
|
4500
4500
|
else {
|
|
4501
|
-
const isStop = this.
|
|
4501
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4502
4502
|
if (isStop) {
|
|
4503
4503
|
request['orderFilter'] = 'StopOrder';
|
|
4504
4504
|
}
|
|
@@ -4572,7 +4572,7 @@ export default class bybit extends Exchange {
|
|
|
4572
4572
|
request['settleCoin'] = this.safeString(params, 'settleCoin', defaultSettle);
|
|
4573
4573
|
}
|
|
4574
4574
|
}
|
|
4575
|
-
const isStop = this.
|
|
4575
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4576
4576
|
params = this.omit(params, ['stop', 'trigger']);
|
|
4577
4577
|
if (isStop) {
|
|
4578
4578
|
request['orderFilter'] = 'StopOrder';
|
|
@@ -4606,8 +4606,8 @@ export default class bybit extends Exchange {
|
|
|
4606
4606
|
// "time": 1676962409398
|
|
4607
4607
|
// }
|
|
4608
4608
|
//
|
|
4609
|
-
const result = this.
|
|
4610
|
-
const orders = this.
|
|
4609
|
+
const result = this.safeDict(response, 'result', {});
|
|
4610
|
+
const orders = this.safeList(result, 'list');
|
|
4611
4611
|
if (!Array.isArray(orders)) {
|
|
4612
4612
|
return response;
|
|
4613
4613
|
}
|
|
@@ -4640,7 +4640,7 @@ export default class bybit extends Exchange {
|
|
|
4640
4640
|
else {
|
|
4641
4641
|
request['category'] = 'OPTION';
|
|
4642
4642
|
}
|
|
4643
|
-
const isStop = this.
|
|
4643
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
4644
4644
|
params = this.omit(params, ['stop', 'trigger']);
|
|
4645
4645
|
if (isStop) {
|
|
4646
4646
|
request['orderFilter'] = 'StopOrder';
|
|
@@ -4696,7 +4696,7 @@ export default class bybit extends Exchange {
|
|
|
4696
4696
|
// "retMsg": "Success."
|
|
4697
4697
|
// }
|
|
4698
4698
|
//
|
|
4699
|
-
const result = this.
|
|
4699
|
+
const result = this.safeDict(response, 'result', {});
|
|
4700
4700
|
const data = this.safeList(result, 'dataList', []);
|
|
4701
4701
|
return this.parseOrders(data, market, since, limit);
|
|
4702
4702
|
}
|
|
@@ -5124,8 +5124,8 @@ export default class bybit extends Exchange {
|
|
|
5124
5124
|
[type, params] = this.handleMarketTypeAndParams('fetchUsdcOpenOrders', market, params);
|
|
5125
5125
|
request['category'] = (type === 'swap') ? 'perpetual' : 'option';
|
|
5126
5126
|
const response = await this.privatePostOptionUsdcOpenapiPrivateV1QueryActiveOrders(this.extend(request, params));
|
|
5127
|
-
const result = this.
|
|
5128
|
-
const orders = this.
|
|
5127
|
+
const result = this.safeDict(response, 'result', {});
|
|
5128
|
+
const orders = this.safeList(result, 'dataList', []);
|
|
5129
5129
|
//
|
|
5130
5130
|
// {
|
|
5131
5131
|
// "retCode": 0,
|
|
@@ -5198,7 +5198,7 @@ export default class bybit extends Exchange {
|
|
|
5198
5198
|
return await this.fetchUsdcOpenOrders(symbol, since, limit, params);
|
|
5199
5199
|
}
|
|
5200
5200
|
request['category'] = type;
|
|
5201
|
-
const isStop = this.
|
|
5201
|
+
const isStop = this.safeBool2(params, 'stop', 'trigger', false);
|
|
5202
5202
|
params = this.omit(params, ['stop', 'trigger']);
|
|
5203
5203
|
if (isStop) {
|
|
5204
5204
|
request['orderFilter'] = 'StopOrder';
|
|
@@ -5324,7 +5324,7 @@ export default class bybit extends Exchange {
|
|
|
5324
5324
|
// "retMsg": "Success."
|
|
5325
5325
|
// }
|
|
5326
5326
|
//
|
|
5327
|
-
const result = this.
|
|
5327
|
+
const result = this.safeDict(response, 'result', {});
|
|
5328
5328
|
const dataList = this.safeList(result, 'dataList', []);
|
|
5329
5329
|
return this.parseTrades(dataList, market, since, limit);
|
|
5330
5330
|
}
|
|
@@ -5475,8 +5475,8 @@ export default class bybit extends Exchange {
|
|
|
5475
5475
|
// "time": 1672192792860
|
|
5476
5476
|
// }
|
|
5477
5477
|
//
|
|
5478
|
-
const result = this.
|
|
5479
|
-
const chains = this.
|
|
5478
|
+
const result = this.safeDict(response, 'result', {});
|
|
5479
|
+
const chains = this.safeList(result, 'chains', []);
|
|
5480
5480
|
const coin = this.safeString(result, 'coin');
|
|
5481
5481
|
currency = this.currency(coin);
|
|
5482
5482
|
const parsed = this.parseDepositAddresses(chains, [currency['code']], false, {
|
|
@@ -5524,8 +5524,8 @@ export default class bybit extends Exchange {
|
|
|
5524
5524
|
// "time": 1672192792860
|
|
5525
5525
|
// }
|
|
5526
5526
|
//
|
|
5527
|
-
const result = this.
|
|
5528
|
-
const chains = this.
|
|
5527
|
+
const result = this.safeDict(response, 'result', {});
|
|
5528
|
+
const chains = this.safeList(result, 'chains', []);
|
|
5529
5529
|
const chainsIndexedById = this.indexBy(chains, 'chain');
|
|
5530
5530
|
const selectedNetworkId = this.selectNetworkIdFromRawNetworks(code, networkCode, chainsIndexedById);
|
|
5531
5531
|
const addressObject = this.safeDict(chainsIndexedById, selectedNetworkId, {});
|
|
@@ -6233,14 +6233,14 @@ export default class bybit extends Exchange {
|
|
|
6233
6233
|
// "retMsg": "Success."
|
|
6234
6234
|
// }
|
|
6235
6235
|
//
|
|
6236
|
-
const result = this.
|
|
6237
|
-
const positions = this.
|
|
6236
|
+
const result = this.safeDict(response, 'result', {});
|
|
6237
|
+
const positions = this.safeList(result, 'dataList', []);
|
|
6238
6238
|
const results = [];
|
|
6239
6239
|
for (let i = 0; i < positions.length; i++) {
|
|
6240
6240
|
let rawPosition = positions[i];
|
|
6241
6241
|
if (('data' in rawPosition) && ('is_valid' in rawPosition)) {
|
|
6242
6242
|
// futures only
|
|
6243
|
-
rawPosition = this.
|
|
6243
|
+
rawPosition = this.safeDict(rawPosition, 'data');
|
|
6244
6244
|
}
|
|
6245
6245
|
results.push(this.parsePosition(rawPosition, market));
|
|
6246
6246
|
}
|
|
@@ -6353,7 +6353,7 @@ export default class bybit extends Exchange {
|
|
|
6353
6353
|
let rawPosition = positions[i];
|
|
6354
6354
|
if (('data' in rawPosition) && ('is_valid' in rawPosition)) {
|
|
6355
6355
|
// futures only
|
|
6356
|
-
rawPosition = this.
|
|
6356
|
+
rawPosition = this.safeDict(rawPosition, 'data');
|
|
6357
6357
|
}
|
|
6358
6358
|
results.push(this.parsePosition(rawPosition));
|
|
6359
6359
|
}
|
|
@@ -6840,7 +6840,7 @@ export default class bybit extends Exchange {
|
|
|
6840
6840
|
let market = this.market(symbol);
|
|
6841
6841
|
const subType = market['linear'] ? 'linear' : 'inverse';
|
|
6842
6842
|
const category = this.safeString(params, 'category', subType);
|
|
6843
|
-
const intervals = this.
|
|
6843
|
+
const intervals = this.safeDict(this.options, 'intervals');
|
|
6844
6844
|
const interval = this.safeString(intervals, timeframe); // 5min,15min,30min,1h,4h,1d
|
|
6845
6845
|
if (interval === undefined) {
|
|
6846
6846
|
throw new BadRequest(this.id + ' fetchOpenInterestHistory() cannot use the ' + timeframe + ' timeframe');
|
|
@@ -6885,7 +6885,7 @@ export default class bybit extends Exchange {
|
|
|
6885
6885
|
// "time": 1672053548579
|
|
6886
6886
|
// }
|
|
6887
6887
|
//
|
|
6888
|
-
const result = this.
|
|
6888
|
+
const result = this.safeDict(response, 'result', {});
|
|
6889
6889
|
const data = this.addPaginationCursorToResult(response);
|
|
6890
6890
|
const id = this.safeString(result, 'symbol');
|
|
6891
6891
|
market = this.safeMarket(id, market, undefined, 'contract');
|
|
@@ -6909,7 +6909,7 @@ export default class bybit extends Exchange {
|
|
|
6909
6909
|
throw new BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
|
|
6910
6910
|
}
|
|
6911
6911
|
const timeframe = this.safeString(params, 'interval', '1h');
|
|
6912
|
-
const intervals = this.
|
|
6912
|
+
const intervals = this.safeDict(this.options, 'intervals');
|
|
6913
6913
|
const interval = this.safeString(intervals, timeframe); // 5min,15min,30min,1h,4h,1d
|
|
6914
6914
|
if (interval === undefined) {
|
|
6915
6915
|
throw new BadRequest(this.id + ' fetchOpenInterest() cannot use the ' + timeframe + ' timeframe');
|
|
@@ -6945,7 +6945,7 @@ export default class bybit extends Exchange {
|
|
|
6945
6945
|
// "time": 1672053548579
|
|
6946
6946
|
// }
|
|
6947
6947
|
//
|
|
6948
|
-
const result = this.
|
|
6948
|
+
const result = this.safeDict(response, 'result', {});
|
|
6949
6949
|
const id = this.safeString(result, 'symbol');
|
|
6950
6950
|
market = this.safeMarket(id, market, undefined, 'contract');
|
|
6951
6951
|
const data = this.addPaginationCursorToResult(response);
|
|
@@ -7035,7 +7035,7 @@ export default class bybit extends Exchange {
|
|
|
7035
7035
|
// }
|
|
7036
7036
|
//
|
|
7037
7037
|
const timestamp = this.safeInteger(response, 'time');
|
|
7038
|
-
const data = this.
|
|
7038
|
+
const data = this.safeDict(response, 'result', {});
|
|
7039
7039
|
data['timestamp'] = timestamp;
|
|
7040
7040
|
return this.parseBorrowRate(data, currency);
|
|
7041
7041
|
}
|
|
@@ -7101,8 +7101,8 @@ export default class bybit extends Exchange {
|
|
|
7101
7101
|
// }
|
|
7102
7102
|
// }
|
|
7103
7103
|
//
|
|
7104
|
-
const data = this.
|
|
7105
|
-
const rows = this.
|
|
7104
|
+
const data = this.safeDict(response, 'result', {});
|
|
7105
|
+
const rows = this.safeList(data, 'loanAccountList', []);
|
|
7106
7106
|
const interest = this.parseBorrowInterests(rows, undefined);
|
|
7107
7107
|
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
7108
7108
|
}
|
|
@@ -7145,7 +7145,7 @@ export default class bybit extends Exchange {
|
|
|
7145
7145
|
*/
|
|
7146
7146
|
await this.loadMarkets();
|
|
7147
7147
|
const transferId = this.safeString(params, 'transferId', this.uuid());
|
|
7148
|
-
const accountTypes = this.
|
|
7148
|
+
const accountTypes = this.safeDict(this.options, 'accountsByType', {});
|
|
7149
7149
|
const fromId = this.safeString(accountTypes, fromAccount, fromAccount);
|
|
7150
7150
|
const toId = this.safeString(accountTypes, toAccount, toAccount);
|
|
7151
7151
|
const currency = this.currency(code);
|
|
@@ -7170,7 +7170,7 @@ export default class bybit extends Exchange {
|
|
|
7170
7170
|
// }
|
|
7171
7171
|
//
|
|
7172
7172
|
const timestamp = this.safeInteger(response, 'time');
|
|
7173
|
-
const transfer = this.
|
|
7173
|
+
const transfer = this.safeDict(response, 'result', {});
|
|
7174
7174
|
const statusRaw = this.safeStringN(response, ['retCode', 'retMsg']);
|
|
7175
7175
|
const status = this.parseTransferStatus(statusRaw);
|
|
7176
7176
|
return this.extend(this.parseTransfer(transfer, currency), {
|
|
@@ -7270,7 +7270,7 @@ export default class bybit extends Exchange {
|
|
|
7270
7270
|
// "time": 1662617848970
|
|
7271
7271
|
// }
|
|
7272
7272
|
//
|
|
7273
|
-
const result = this.
|
|
7273
|
+
const result = this.safeDict(response, 'result', {});
|
|
7274
7274
|
const transaction = this.parseMarginLoan(result, currency);
|
|
7275
7275
|
return this.extend(transaction, {
|
|
7276
7276
|
'symbol': undefined,
|
|
@@ -7306,7 +7306,7 @@ export default class bybit extends Exchange {
|
|
|
7306
7306
|
// "time": 1662618298452
|
|
7307
7307
|
// }
|
|
7308
7308
|
//
|
|
7309
|
-
const result = this.
|
|
7309
|
+
const result = this.safeDict(response, 'result', {});
|
|
7310
7310
|
const transaction = this.parseMarginLoan(result, currency);
|
|
7311
7311
|
return this.extend(transaction, {
|
|
7312
7312
|
'symbol': undefined,
|
|
@@ -7369,7 +7369,7 @@ export default class bybit extends Exchange {
|
|
|
7369
7369
|
const timestamp = this.safeInteger(transfer, 'timestamp');
|
|
7370
7370
|
const fromAccountId = this.safeString(transfer, 'fromAccountType');
|
|
7371
7371
|
const toAccountId = this.safeString(transfer, 'toAccountType');
|
|
7372
|
-
const accountIds = this.
|
|
7372
|
+
const accountIds = this.safeDict(this.options, 'accountsById', {});
|
|
7373
7373
|
const fromAccount = this.safeString(accountIds, fromAccountId, fromAccountId);
|
|
7374
7374
|
const toAccount = this.safeString(accountIds, toAccountId, toAccountId);
|
|
7375
7375
|
return {
|
|
@@ -7420,8 +7420,8 @@ export default class bybit extends Exchange {
|
|
|
7420
7420
|
// "time": 1672054488010
|
|
7421
7421
|
// }
|
|
7422
7422
|
//
|
|
7423
|
-
const result = this.
|
|
7424
|
-
const tiers = this.
|
|
7423
|
+
const result = this.safeDict(response, 'result');
|
|
7424
|
+
const tiers = this.safeList(result, 'list');
|
|
7425
7425
|
return this.parseMarketLeverageTiers(tiers, market);
|
|
7426
7426
|
}
|
|
7427
7427
|
async fetchMarketLeverageTiers(symbol, params = {}) {
|
|
@@ -7511,9 +7511,9 @@ export default class bybit extends Exchange {
|
|
|
7511
7511
|
// "time": 1676360412576
|
|
7512
7512
|
// }
|
|
7513
7513
|
//
|
|
7514
|
-
const result = this.
|
|
7515
|
-
const fees = this.
|
|
7516
|
-
const first = this.
|
|
7514
|
+
const result = this.safeDict(response, 'result', {});
|
|
7515
|
+
const fees = this.safeList(result, 'list', []);
|
|
7516
|
+
const first = this.safeDict(fees, 0, {});
|
|
7517
7517
|
return this.parseTradingFee(first, market);
|
|
7518
7518
|
}
|
|
7519
7519
|
async fetchTradingFees(params = {}) {
|
|
@@ -7550,8 +7550,8 @@ export default class bybit extends Exchange {
|
|
|
7550
7550
|
// "time": 1676360412576
|
|
7551
7551
|
// }
|
|
7552
7552
|
//
|
|
7553
|
-
let fees = this.
|
|
7554
|
-
fees = this.
|
|
7553
|
+
let fees = this.safeDict(response, 'result', {});
|
|
7554
|
+
fees = this.safeList(fees, 'list', []);
|
|
7555
7555
|
const result = {};
|
|
7556
7556
|
for (let i = 0; i < fees.length; i++) {
|
|
7557
7557
|
const fee = this.parseTradingFee(fees[i]);
|
|
@@ -7581,7 +7581,7 @@ export default class bybit extends Exchange {
|
|
|
7581
7581
|
// ]
|
|
7582
7582
|
// }
|
|
7583
7583
|
//
|
|
7584
|
-
const chains = this.
|
|
7584
|
+
const chains = this.safeList(fee, 'chains', []);
|
|
7585
7585
|
const chainsLength = chains.length;
|
|
7586
7586
|
const result = {
|
|
7587
7587
|
'info': fee,
|
|
@@ -7656,7 +7656,7 @@ export default class bybit extends Exchange {
|
|
|
7656
7656
|
// "time": 1672194582264
|
|
7657
7657
|
// }
|
|
7658
7658
|
//
|
|
7659
|
-
const data = this.
|
|
7659
|
+
const data = this.safeDict(response, 'result', {});
|
|
7660
7660
|
const rows = this.safeList(data, 'rows', []);
|
|
7661
7661
|
return this.parseDepositWithdrawFees(rows, codes, 'coin');
|
|
7662
7662
|
}
|
|
@@ -7710,8 +7710,8 @@ export default class bybit extends Exchange {
|
|
|
7710
7710
|
// "time": 1689043527231
|
|
7711
7711
|
// }
|
|
7712
7712
|
//
|
|
7713
|
-
const result = this.
|
|
7714
|
-
const data = this.
|
|
7713
|
+
const result = this.safeDict(response, 'result', {});
|
|
7714
|
+
const data = this.safeList(result, 'list', []);
|
|
7715
7715
|
const settlements = this.parseSettlements(data, market);
|
|
7716
7716
|
const sorted = this.sortBy(settlements, 'timestamp');
|
|
7717
7717
|
return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
|
|
@@ -7771,8 +7771,8 @@ export default class bybit extends Exchange {
|
|
|
7771
7771
|
// "time": 1689043527231
|
|
7772
7772
|
// }
|
|
7773
7773
|
//
|
|
7774
|
-
const result = this.
|
|
7775
|
-
const data = this.
|
|
7774
|
+
const result = this.safeDict(response, 'result', {});
|
|
7775
|
+
const data = this.safeList(result, 'list', []);
|
|
7776
7776
|
const settlements = this.parseSettlements(data, market);
|
|
7777
7777
|
const sorted = this.sortBy(settlements, 'timestamp');
|
|
7778
7778
|
return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
|
|
@@ -7875,7 +7875,7 @@ export default class bybit extends Exchange {
|
|
|
7875
7875
|
// ]
|
|
7876
7876
|
// }
|
|
7877
7877
|
//
|
|
7878
|
-
const volatility = this.
|
|
7878
|
+
const volatility = this.safeList(response, 'result', []);
|
|
7879
7879
|
return this.parseVolatilityHistory(volatility);
|
|
7880
7880
|
}
|
|
7881
7881
|
parseVolatilityHistory(volatility) {
|
|
@@ -7957,8 +7957,8 @@ export default class bybit extends Exchange {
|
|
|
7957
7957
|
// }
|
|
7958
7958
|
//
|
|
7959
7959
|
const timestamp = this.safeInteger(response, 'time');
|
|
7960
|
-
const result = this.
|
|
7961
|
-
const data = this.
|
|
7960
|
+
const result = this.safeDict(response, 'result', {});
|
|
7961
|
+
const data = this.safeList(result, 'list', []);
|
|
7962
7962
|
const greeks = this.parseGreeks(data[0], market);
|
|
7963
7963
|
return this.extend(greeks, {
|
|
7964
7964
|
'timestamp': timestamp,
|
package/js/src/coinbase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/coinbase.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class coinbase
|
|
5
5
|
* @augments Exchange
|
|
@@ -104,6 +104,10 @@ export default class coinbase extends Exchange {
|
|
|
104
104
|
};
|
|
105
105
|
deposit(code: string, amount: number, id: string, params?: {}): Promise<Transaction>;
|
|
106
106
|
fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
|
|
107
|
+
fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
|
|
108
|
+
createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
|
|
109
|
+
fetchConvertTrade(id: string, code?: Str, params?: {}): Promise<Conversion>;
|
|
110
|
+
parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
|
|
107
111
|
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
108
112
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
109
113
|
fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
|