ccxt 4.4.92 → 4.4.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +9 -8
- package/dist/cjs/src/base/Exchange.js +118 -33
- package/dist/cjs/src/binance.js +44 -1
- package/dist/cjs/src/bitmex.js +3 -3
- package/dist/cjs/src/bybit.js +85 -10
- package/dist/cjs/src/coinbase.js +3 -1
- package/dist/cjs/src/coinbaseexchange.js +53 -0
- package/dist/cjs/src/coincheck.js +47 -4
- package/dist/cjs/src/coinex.js +19 -14
- package/dist/cjs/src/coinmetro.js +16 -3
- package/dist/cjs/src/cryptomus.js +30 -53
- package/dist/cjs/src/deribit.js +6 -6
- package/dist/cjs/src/exmo.js +66 -61
- package/dist/cjs/src/htx.js +7 -1
- package/dist/cjs/src/hyperliquid.js +134 -33
- package/dist/cjs/src/kucoin.js +13 -15
- package/dist/cjs/src/latoken.js +19 -74
- package/dist/cjs/src/lbank.js +2 -2
- package/dist/cjs/src/okx.js +169 -4
- package/dist/cjs/src/paradex.js +54 -0
- package/dist/cjs/src/phemex.js +3 -3
- package/dist/cjs/src/pro/bitstamp.js +55 -16
- package/dist/cjs/src/pro/bybit.js +2 -1
- package/dist/cjs/src/wavesexchange.js +15 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/ascendex.js +9 -8
- package/js/src/base/Exchange.d.ts +3 -1
- package/js/src/base/Exchange.js +118 -33
- package/js/src/binance.d.ts +10 -0
- package/js/src/binance.js +44 -1
- package/js/src/bitmex.d.ts +1 -1
- package/js/src/bitmex.js +3 -3
- package/js/src/bybit.d.ts +12 -1
- package/js/src/bybit.js +85 -10
- package/js/src/coinbase.js +4 -2
- package/js/src/coinbaseexchange.js +53 -0
- package/js/src/coincheck.js +48 -5
- package/js/src/coinex.js +16 -13
- package/js/src/coinmetro.js +16 -3
- package/js/src/cryptomus.js +30 -53
- package/js/src/deribit.js +6 -6
- package/js/src/exmo.js +66 -61
- package/js/src/htx.js +7 -1
- package/js/src/hyperliquid.d.ts +31 -0
- package/js/src/hyperliquid.js +134 -33
- package/js/src/kucoin.js +13 -15
- package/js/src/latoken.d.ts +0 -1
- package/js/src/latoken.js +19 -74
- package/js/src/lbank.js +2 -2
- package/js/src/okx.d.ts +12 -0
- package/js/src/okx.js +169 -4
- package/js/src/paradex.d.ts +10 -0
- package/js/src/paradex.js +54 -0
- package/js/src/phemex.js +3 -3
- package/js/src/pro/bitstamp.js +55 -16
- package/js/src/pro/bybit.js +2 -1
- package/js/src/wavesexchange.js +15 -2
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -193,7 +193,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
193
193
|
|
|
194
194
|
//-----------------------------------------------------------------------------
|
|
195
195
|
// this is updated by vss.js when building
|
|
196
|
-
const version = '4.4.
|
|
196
|
+
const version = '4.4.94';
|
|
197
197
|
Exchange["default"].ccxtVersion = version;
|
|
198
198
|
const exchanges = {
|
|
199
199
|
'alpaca': alpaca,
|
package/dist/cjs/src/ascendex.js
CHANGED
|
@@ -1438,6 +1438,8 @@ class ascendex extends ascendex$1 {
|
|
|
1438
1438
|
// "timestamp": 1573576916201
|
|
1439
1439
|
// }
|
|
1440
1440
|
//
|
|
1441
|
+
// & linear (fetchClosedOrders)
|
|
1442
|
+
//
|
|
1441
1443
|
// {
|
|
1442
1444
|
// "ac": "FUTURES",
|
|
1443
1445
|
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
@@ -1445,7 +1447,7 @@ class ascendex extends ascendex$1 {
|
|
|
1445
1447
|
// "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
|
|
1446
1448
|
// "seqNum": -1,
|
|
1447
1449
|
// "orderType": "Limit",
|
|
1448
|
-
// "execInst": "NULL_VAL",
|
|
1450
|
+
// "execInst": "NULL_VAL", // NULL_VAL, ReduceOnly , ...
|
|
1449
1451
|
// "side": "Buy",
|
|
1450
1452
|
// "symbol": "BTC-PERP",
|
|
1451
1453
|
// "price": "30000",
|
|
@@ -1534,14 +1536,14 @@ class ascendex extends ascendex$1 {
|
|
|
1534
1536
|
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
1535
1537
|
const marketId = this.safeString(order, 'symbol');
|
|
1536
1538
|
const symbol = this.safeSymbol(marketId, market, '/');
|
|
1537
|
-
let timestamp = this.
|
|
1539
|
+
let timestamp = this.safeIntegerN(order, ['timestamp', 'sendingTime', 'time']);
|
|
1538
1540
|
const lastTradeTimestamp = this.safeInteger(order, 'lastExecTime');
|
|
1539
1541
|
if (timestamp === undefined) {
|
|
1540
1542
|
timestamp = lastTradeTimestamp;
|
|
1541
1543
|
}
|
|
1542
1544
|
const price = this.safeString(order, 'price');
|
|
1543
1545
|
const amount = this.safeString(order, 'orderQty');
|
|
1544
|
-
const average = this.
|
|
1546
|
+
const average = this.safeString2(order, 'avgPx', 'avgFilledPx');
|
|
1545
1547
|
const filled = this.safeStringN(order, ['cumFilledQty', 'cumQty', 'fillQty']);
|
|
1546
1548
|
const id = this.safeString(order, 'orderId');
|
|
1547
1549
|
let clientOrderId = this.safeString(order, 'id');
|
|
@@ -1573,12 +1575,12 @@ class ascendex extends ascendex$1 {
|
|
|
1573
1575
|
}
|
|
1574
1576
|
const triggerPrice = this.omitZero(this.safeString(order, 'stopPrice'));
|
|
1575
1577
|
let reduceOnly = undefined;
|
|
1576
|
-
const execInst = this.
|
|
1577
|
-
if (execInst === '
|
|
1578
|
+
const execInst = this.safeStringLower(order, 'execInst');
|
|
1579
|
+
if (execInst === 'reduceonly') {
|
|
1578
1580
|
reduceOnly = true;
|
|
1579
1581
|
}
|
|
1580
1582
|
let postOnly = undefined;
|
|
1581
|
-
if (execInst === '
|
|
1583
|
+
if (execInst === 'post') {
|
|
1582
1584
|
postOnly = true;
|
|
1583
1585
|
}
|
|
1584
1586
|
return this.safeOrder({
|
|
@@ -2342,8 +2344,7 @@ class ascendex extends ascendex$1 {
|
|
|
2342
2344
|
// }
|
|
2343
2345
|
//
|
|
2344
2346
|
let data = this.safeList(response, 'data', []);
|
|
2345
|
-
|
|
2346
|
-
if (!isArray) {
|
|
2347
|
+
if (!Array.isArray(data)) {
|
|
2347
2348
|
data = this.safeList(data, 'data', []);
|
|
2348
2349
|
}
|
|
2349
2350
|
return this.parseOrders(data, market, since, limit);
|
|
@@ -3514,8 +3514,7 @@ class Exchange {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
safeTicker(ticker, market = undefined) {
|
|
3516
3516
|
let open = this.omitZero(this.safeString(ticker, 'open'));
|
|
3517
|
-
let close = this.omitZero(this.
|
|
3518
|
-
let last = this.omitZero(this.safeString(ticker, 'last'));
|
|
3517
|
+
let close = this.omitZero(this.safeString2(ticker, 'close', 'last'));
|
|
3519
3518
|
let change = this.omitZero(this.safeString(ticker, 'change'));
|
|
3520
3519
|
let percentage = this.omitZero(this.safeString(ticker, 'percentage'));
|
|
3521
3520
|
let average = this.omitZero(this.safeString(ticker, 'average'));
|
|
@@ -3525,17 +3524,55 @@ class Exchange {
|
|
|
3525
3524
|
if (vwap === undefined) {
|
|
3526
3525
|
vwap = Precise["default"].stringDiv(this.omitZero(quoteVolume), baseVolume);
|
|
3527
3526
|
}
|
|
3528
|
-
|
|
3529
|
-
|
|
3527
|
+
// calculate open
|
|
3528
|
+
if (change !== undefined) {
|
|
3529
|
+
if (close === undefined && average !== undefined) {
|
|
3530
|
+
close = Precise["default"].stringAdd(average, Precise["default"].stringDiv(change, '2'));
|
|
3531
|
+
}
|
|
3532
|
+
if (open === undefined && close !== undefined) {
|
|
3533
|
+
open = Precise["default"].stringSub(close, change);
|
|
3534
|
+
}
|
|
3530
3535
|
}
|
|
3531
|
-
else if (
|
|
3532
|
-
|
|
3536
|
+
else if (percentage !== undefined) {
|
|
3537
|
+
if (close === undefined && average !== undefined) {
|
|
3538
|
+
const openAddClose = Precise["default"].stringMul(average, '2');
|
|
3539
|
+
// openAddClose = open * (1 + (100 + percentage)/100)
|
|
3540
|
+
const denominator = Precise["default"].stringAdd('2', Precise["default"].stringDiv(percentage, '100'));
|
|
3541
|
+
const calcOpen = (open !== undefined) ? open : Precise["default"].stringDiv(openAddClose, denominator);
|
|
3542
|
+
close = Precise["default"].stringMul(calcOpen, Precise["default"].stringAdd('1', Precise["default"].stringDiv(percentage, '100')));
|
|
3543
|
+
}
|
|
3544
|
+
if (open === undefined && close !== undefined) {
|
|
3545
|
+
open = Precise["default"].stringDiv(close, Precise["default"].stringAdd('1', Precise["default"].stringDiv(percentage, '100')));
|
|
3546
|
+
}
|
|
3533
3547
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3548
|
+
// change
|
|
3549
|
+
if (change === undefined) {
|
|
3550
|
+
if (close !== undefined && open !== undefined) {
|
|
3551
|
+
change = Precise["default"].stringSub(close, open);
|
|
3537
3552
|
}
|
|
3538
|
-
if (
|
|
3553
|
+
else if (close !== undefined && percentage !== undefined) {
|
|
3554
|
+
change = Precise["default"].stringMul(Precise["default"].stringDiv(percentage, '100'), Precise["default"].stringDiv(close, '100'));
|
|
3555
|
+
}
|
|
3556
|
+
else if (open !== undefined && percentage !== undefined) {
|
|
3557
|
+
change = Precise["default"].stringMul(open, Precise["default"].stringDiv(percentage, '100'));
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
// calculate things according to "open" (similar can be done with "close")
|
|
3561
|
+
if (open !== undefined) {
|
|
3562
|
+
// percentage (using change)
|
|
3563
|
+
if (percentage === undefined && change !== undefined) {
|
|
3564
|
+
percentage = Precise["default"].stringMul(Precise["default"].stringDiv(change, open), '100');
|
|
3565
|
+
}
|
|
3566
|
+
// close (using change)
|
|
3567
|
+
if (close === undefined && change !== undefined) {
|
|
3568
|
+
close = Precise["default"].stringAdd(open, change);
|
|
3569
|
+
}
|
|
3570
|
+
// close (using average)
|
|
3571
|
+
if (close === undefined && average !== undefined) {
|
|
3572
|
+
close = Precise["default"].stringMul(average, '2');
|
|
3573
|
+
}
|
|
3574
|
+
// average
|
|
3575
|
+
if (average === undefined && close !== undefined) {
|
|
3539
3576
|
let precision = 18;
|
|
3540
3577
|
if (market !== undefined && this.isTickPrecision()) {
|
|
3541
3578
|
const marketPrecision = this.safeDict(market, 'precision');
|
|
@@ -3544,20 +3581,12 @@ class Exchange {
|
|
|
3544
3581
|
precision = this.precisionFromString(precisionPrice);
|
|
3545
3582
|
}
|
|
3546
3583
|
}
|
|
3547
|
-
average = Precise["default"].stringDiv(Precise["default"].stringAdd(
|
|
3584
|
+
average = Precise["default"].stringDiv(Precise["default"].stringAdd(open, close), '2', precision);
|
|
3548
3585
|
}
|
|
3549
3586
|
}
|
|
3550
|
-
if ((percentage === undefined) && (change !== undefined) && (open !== undefined) && Precise["default"].stringGt(open, '0')) {
|
|
3551
|
-
percentage = Precise["default"].stringMul(Precise["default"].stringDiv(change, open), '100');
|
|
3552
|
-
}
|
|
3553
|
-
if ((change === undefined) && (percentage !== undefined) && (open !== undefined)) {
|
|
3554
|
-
change = Precise["default"].stringDiv(Precise["default"].stringMul(percentage, open), '100');
|
|
3555
|
-
}
|
|
3556
|
-
if ((open === undefined) && (last !== undefined) && (change !== undefined)) {
|
|
3557
|
-
open = Precise["default"].stringSub(last, change);
|
|
3558
|
-
}
|
|
3559
3587
|
// timestamp and symbol operations don't belong in safeTicker
|
|
3560
3588
|
// they should be done in the derived classes
|
|
3589
|
+
const closeParsed = this.parseNumber(this.omitZero(close));
|
|
3561
3590
|
return this.extend(ticker, {
|
|
3562
3591
|
'bid': this.parseNumber(this.omitZero(this.safeString(ticker, 'bid'))),
|
|
3563
3592
|
'bidVolume': this.safeNumber(ticker, 'bidVolume'),
|
|
@@ -3566,8 +3595,8 @@ class Exchange {
|
|
|
3566
3595
|
'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high'))),
|
|
3567
3596
|
'low': this.parseNumber(this.omitZero(this.safeString(ticker, 'low'))),
|
|
3568
3597
|
'open': this.parseNumber(this.omitZero(open)),
|
|
3569
|
-
'close':
|
|
3570
|
-
'last':
|
|
3598
|
+
'close': closeParsed,
|
|
3599
|
+
'last': closeParsed,
|
|
3571
3600
|
'change': this.parseNumber(change),
|
|
3572
3601
|
'percentage': this.parseNumber(percentage),
|
|
3573
3602
|
'average': this.parseNumber(average),
|
|
@@ -4022,7 +4051,7 @@ class Exchange {
|
|
|
4022
4051
|
return this.filterBySinceLimit(sorted, since, limit, 0, tail);
|
|
4023
4052
|
}
|
|
4024
4053
|
parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
|
|
4025
|
-
// marketIdKey should only be undefined when response is a dictionary
|
|
4054
|
+
// marketIdKey should only be undefined when response is a dictionary.
|
|
4026
4055
|
symbols = this.marketSymbols(symbols);
|
|
4027
4056
|
const tiers = {};
|
|
4028
4057
|
let symbolsLength = 0;
|
|
@@ -5460,6 +5489,9 @@ class Exchange {
|
|
|
5460
5489
|
async fetchGreeks(symbol, params = {}) {
|
|
5461
5490
|
throw new errors.NotSupported(this.id + ' fetchGreeks() is not supported yet');
|
|
5462
5491
|
}
|
|
5492
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
5493
|
+
throw new errors.NotSupported(this.id + ' fetchAllGreeks() is not supported yet');
|
|
5494
|
+
}
|
|
5463
5495
|
async fetchOptionChain(code, params = {}) {
|
|
5464
5496
|
throw new errors.NotSupported(this.id + ' fetchOptionChain() is not supported yet');
|
|
5465
5497
|
}
|
|
@@ -5754,11 +5786,20 @@ class Exchange {
|
|
|
5754
5786
|
if (precisionNumber === 0) {
|
|
5755
5787
|
return '1';
|
|
5756
5788
|
}
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5789
|
+
if (precisionNumber > 0) {
|
|
5790
|
+
let parsedPrecision = '0.';
|
|
5791
|
+
for (let i = 0; i < precisionNumber - 1; i++) {
|
|
5792
|
+
parsedPrecision = parsedPrecision + '0';
|
|
5793
|
+
}
|
|
5794
|
+
return parsedPrecision + '1';
|
|
5795
|
+
}
|
|
5796
|
+
else {
|
|
5797
|
+
let parsedPrecision = '1';
|
|
5798
|
+
for (let i = 0; i < precisionNumber * -1 - 1; i++) {
|
|
5799
|
+
parsedPrecision = parsedPrecision + '0';
|
|
5800
|
+
}
|
|
5801
|
+
return parsedPrecision + '0';
|
|
5760
5802
|
}
|
|
5761
|
-
return parsedPrecision + '1';
|
|
5762
5803
|
}
|
|
5763
5804
|
integerPrecisionToAmount(precision) {
|
|
5764
5805
|
/**
|
|
@@ -6915,6 +6956,31 @@ class Exchange {
|
|
|
6915
6956
|
parseGreeks(greeks, market = undefined) {
|
|
6916
6957
|
throw new errors.NotSupported(this.id + ' parseGreeks () is not supported yet');
|
|
6917
6958
|
}
|
|
6959
|
+
parseAllGreeks(greeks, symbols = undefined, params = {}) {
|
|
6960
|
+
//
|
|
6961
|
+
// the value of greeks is either a dict or a list
|
|
6962
|
+
//
|
|
6963
|
+
const results = [];
|
|
6964
|
+
if (Array.isArray(greeks)) {
|
|
6965
|
+
for (let i = 0; i < greeks.length; i++) {
|
|
6966
|
+
const parsedTicker = this.parseGreeks(greeks[i]);
|
|
6967
|
+
const greek = this.extend(parsedTicker, params);
|
|
6968
|
+
results.push(greek);
|
|
6969
|
+
}
|
|
6970
|
+
}
|
|
6971
|
+
else {
|
|
6972
|
+
const marketIds = Object.keys(greeks);
|
|
6973
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
6974
|
+
const marketId = marketIds[i];
|
|
6975
|
+
const market = this.safeMarket(marketId);
|
|
6976
|
+
const parsed = this.parseGreeks(greeks[marketId], market);
|
|
6977
|
+
const greek = this.extend(parsed, params);
|
|
6978
|
+
results.push(greek);
|
|
6979
|
+
}
|
|
6980
|
+
}
|
|
6981
|
+
symbols = this.marketSymbols(symbols);
|
|
6982
|
+
return this.filterByArray(results, 'symbol', symbols);
|
|
6983
|
+
}
|
|
6918
6984
|
parseOption(chain, currency = undefined, market = undefined) {
|
|
6919
6985
|
throw new errors.NotSupported(this.id + ' parseOption () is not supported yet');
|
|
6920
6986
|
}
|
|
@@ -7153,16 +7219,35 @@ class Exchange {
|
|
|
7153
7219
|
*/
|
|
7154
7220
|
throw new errors.NotSupported(this.id + ' fetchTransfers () is not supported yet');
|
|
7155
7221
|
}
|
|
7156
|
-
cleanUnsubscription(client, subHash, unsubHash) {
|
|
7222
|
+
cleanUnsubscription(client, subHash, unsubHash, subHashIsPrefix = false) {
|
|
7157
7223
|
if (unsubHash in client.subscriptions) {
|
|
7158
7224
|
delete client.subscriptions[unsubHash];
|
|
7159
7225
|
}
|
|
7160
|
-
if (
|
|
7161
|
-
|
|
7226
|
+
if (!subHashIsPrefix) {
|
|
7227
|
+
if (subHash in client.subscriptions) {
|
|
7228
|
+
delete client.subscriptions[subHash];
|
|
7229
|
+
}
|
|
7230
|
+
if (subHash in client.futures) {
|
|
7231
|
+
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
7232
|
+
client.reject(error, subHash);
|
|
7233
|
+
}
|
|
7162
7234
|
}
|
|
7163
|
-
|
|
7164
|
-
const
|
|
7165
|
-
|
|
7235
|
+
else {
|
|
7236
|
+
const clientSubscriptions = Object.keys(client.subscriptions);
|
|
7237
|
+
for (let i = 0; i < clientSubscriptions.length; i++) {
|
|
7238
|
+
const sub = clientSubscriptions[i];
|
|
7239
|
+
if (sub.startsWith(subHash)) {
|
|
7240
|
+
delete client.subscriptions[sub];
|
|
7241
|
+
}
|
|
7242
|
+
}
|
|
7243
|
+
const clientFutures = Object.keys(client.futures);
|
|
7244
|
+
for (let i = 0; i < clientFutures.length; i++) {
|
|
7245
|
+
const future = clientFutures[i];
|
|
7246
|
+
if (future.startsWith(subHash)) {
|
|
7247
|
+
const error = new errors.UnsubscribeError(this.id + ' ' + future);
|
|
7248
|
+
client.reject(error, future);
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7166
7251
|
}
|
|
7167
7252
|
client.resolve(true, unsubHash);
|
|
7168
7253
|
}
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -64,6 +64,7 @@ class binance extends binance$1 {
|
|
|
64
64
|
'editOrder': true,
|
|
65
65
|
'editOrders': true,
|
|
66
66
|
'fetchAccounts': undefined,
|
|
67
|
+
'fetchAllGreeks': true,
|
|
67
68
|
'fetchBalance': true,
|
|
68
69
|
'fetchBidsAsks': true,
|
|
69
70
|
'fetchBorrowInterest': true,
|
|
@@ -11537,6 +11538,7 @@ class binance extends binance$1 {
|
|
|
11537
11538
|
const request = {};
|
|
11538
11539
|
if (symbol !== undefined) {
|
|
11539
11540
|
request['symbol'] = market['id'];
|
|
11541
|
+
symbol = market['symbol'];
|
|
11540
11542
|
}
|
|
11541
11543
|
if (since !== undefined) {
|
|
11542
11544
|
request['startTime'] = since;
|
|
@@ -11567,7 +11569,7 @@ class binance extends binance$1 {
|
|
|
11567
11569
|
//
|
|
11568
11570
|
const settlements = this.parseSettlements(response, market);
|
|
11569
11571
|
const sorted = this.sortBy(settlements, 'timestamp');
|
|
11570
|
-
return this.filterBySymbolSinceLimit(sorted,
|
|
11572
|
+
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
11571
11573
|
}
|
|
11572
11574
|
parseSettlement(settlement, market) {
|
|
11573
11575
|
//
|
|
@@ -13332,6 +13334,47 @@ class binance extends binance$1 {
|
|
|
13332
13334
|
//
|
|
13333
13335
|
return this.parseGreeks(response[0], market);
|
|
13334
13336
|
}
|
|
13337
|
+
/**
|
|
13338
|
+
* @method
|
|
13339
|
+
* @name binance#fetchAllGreeks
|
|
13340
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
13341
|
+
* @see https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price
|
|
13342
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
13343
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
13344
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
13345
|
+
*/
|
|
13346
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
13347
|
+
await this.loadMarkets();
|
|
13348
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
13349
|
+
const request = {};
|
|
13350
|
+
let market = undefined;
|
|
13351
|
+
if (symbols !== undefined) {
|
|
13352
|
+
const symbolsLength = symbols.length;
|
|
13353
|
+
if (symbolsLength === 1) {
|
|
13354
|
+
market = this.market(symbols[0]);
|
|
13355
|
+
request['symbol'] = market['id'];
|
|
13356
|
+
}
|
|
13357
|
+
}
|
|
13358
|
+
const response = await this.eapiPublicGetMark(this.extend(request, params));
|
|
13359
|
+
//
|
|
13360
|
+
// [
|
|
13361
|
+
// {
|
|
13362
|
+
// "symbol": "BTC-231229-40000-C",
|
|
13363
|
+
// "markPrice": "2012",
|
|
13364
|
+
// "bidIV": "0.60236275",
|
|
13365
|
+
// "askIV": "0.62267244",
|
|
13366
|
+
// "markIV": "0.6125176",
|
|
13367
|
+
// "delta": "0.39111646",
|
|
13368
|
+
// "theta": "-32.13948531",
|
|
13369
|
+
// "gamma": "0.00004656",
|
|
13370
|
+
// "vega": "51.70062218",
|
|
13371
|
+
// "highPriceLimit": "6474",
|
|
13372
|
+
// "lowPriceLimit": "5"
|
|
13373
|
+
// }
|
|
13374
|
+
// ]
|
|
13375
|
+
//
|
|
13376
|
+
return this.parseAllGreeks(response, symbols);
|
|
13377
|
+
}
|
|
13335
13378
|
parseGreeks(greeks, market = undefined) {
|
|
13336
13379
|
//
|
|
13337
13380
|
// {
|
package/dist/cjs/src/bitmex.js
CHANGED
|
@@ -1987,7 +1987,7 @@ class bitmex extends bitmex$1 {
|
|
|
1987
1987
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
1988
1988
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1989
1989
|
* @param {object} [params.triggerPrice] the price at which a trigger order is triggered at
|
|
1990
|
-
* @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - '
|
|
1990
|
+
* @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'ascending' or 'descending'
|
|
1991
1991
|
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
1992
1992
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
1993
1993
|
*/
|
|
@@ -2017,7 +2017,7 @@ class bitmex extends bitmex$1 {
|
|
|
2017
2017
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
2018
2018
|
if (isTriggerOrder || isTrailingAmountOrder) {
|
|
2019
2019
|
const triggerDirection = this.safeString(params, 'triggerDirection');
|
|
2020
|
-
const triggerAbove = (triggerDirection === 'above');
|
|
2020
|
+
const triggerAbove = ((triggerDirection === 'ascending') || (triggerDirection === 'above'));
|
|
2021
2021
|
if ((type === 'limit') || (type === 'market')) {
|
|
2022
2022
|
this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
|
|
2023
2023
|
}
|
|
@@ -2074,7 +2074,7 @@ class bitmex extends bitmex$1 {
|
|
|
2074
2074
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
2075
2075
|
if (isTrailingAmountOrder) {
|
|
2076
2076
|
const triggerDirection = this.safeString(params, 'triggerDirection');
|
|
2077
|
-
const triggerAbove = (triggerDirection === 'above');
|
|
2077
|
+
const triggerAbove = ((triggerDirection === 'ascending') || (triggerDirection === 'above'));
|
|
2078
2078
|
if ((type === 'limit') || (type === 'market')) {
|
|
2079
2079
|
this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
|
|
2080
2080
|
}
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -57,6 +57,7 @@ class bybit extends bybit$1 {
|
|
|
57
57
|
'createTriggerOrder': true,
|
|
58
58
|
'editOrder': true,
|
|
59
59
|
'editOrders': true,
|
|
60
|
+
'fetchAllGreeks': true,
|
|
60
61
|
'fetchBalance': true,
|
|
61
62
|
'fetchBidsAsks': 'emulated',
|
|
62
63
|
'fetchBorrowInterest': false,
|
|
@@ -1155,6 +1156,7 @@ class bybit extends bybit$1 {
|
|
|
1155
1156
|
'4h': '4h',
|
|
1156
1157
|
'1d': '1d',
|
|
1157
1158
|
},
|
|
1159
|
+
'useMarkPriceForPositionCollateral': false, // use mark price for position collateral
|
|
1158
1160
|
},
|
|
1159
1161
|
'features': {
|
|
1160
1162
|
'default': {
|
|
@@ -3884,7 +3886,7 @@ class bybit extends bybit$1 {
|
|
|
3884
3886
|
* @param {int} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
|
|
3885
3887
|
* @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
|
|
3886
3888
|
* @param {string} [params.mmp] *option only* market maker protection
|
|
3887
|
-
* @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, '
|
|
3889
|
+
* @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'ascending' or 'descending'
|
|
3888
3890
|
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
3889
3891
|
* @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
|
|
3890
3892
|
* @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
|
|
@@ -3909,7 +3911,7 @@ class bybit extends bybit$1 {
|
|
|
3909
3911
|
const isTakeProfit = takeProfitPrice !== undefined;
|
|
3910
3912
|
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
|
|
3911
3913
|
let defaultMethod = undefined;
|
|
3912
|
-
if (isTrailingAmountOrder || isStopLoss || isTakeProfit) {
|
|
3914
|
+
if ((isTrailingAmountOrder || isStopLoss || isTakeProfit) && !market['spot']) {
|
|
3913
3915
|
defaultMethod = 'privatePostV5PositionTradingStop';
|
|
3914
3916
|
}
|
|
3915
3917
|
else {
|
|
@@ -3990,7 +3992,7 @@ class bybit extends bybit$1 {
|
|
|
3990
3992
|
const isLimit = lowerCaseType === 'limit';
|
|
3991
3993
|
const isBuy = side === 'buy';
|
|
3992
3994
|
let defaultMethod = undefined;
|
|
3993
|
-
if (isTrailingAmountOrder || isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
3995
|
+
if ((isTrailingAmountOrder || isStopLossTriggerOrder || isTakeProfitTriggerOrder) && !market['spot']) {
|
|
3994
3996
|
defaultMethod = 'privatePostV5PositionTradingStop';
|
|
3995
3997
|
}
|
|
3996
3998
|
else {
|
|
@@ -4139,9 +4141,9 @@ class bybit extends bybit$1 {
|
|
|
4139
4141
|
}
|
|
4140
4142
|
else {
|
|
4141
4143
|
if (triggerDirection === undefined) {
|
|
4142
|
-
throw new errors.ArgumentsRequired(this.id + ' stop/trigger orders require a triggerDirection parameter, either "
|
|
4144
|
+
throw new errors.ArgumentsRequired(this.id + ' stop/trigger orders require a triggerDirection parameter, either "ascending" or "descending" to determine the direction of the trigger.');
|
|
4143
4145
|
}
|
|
4144
|
-
const isAsending = ((triggerDirection === 'above') || (triggerDirection === '1'));
|
|
4146
|
+
const isAsending = ((triggerDirection === 'ascending') || (triggerDirection === 'above') || (triggerDirection === '1'));
|
|
4145
4147
|
request['triggerDirection'] = isAsending ? 1 : 2;
|
|
4146
4148
|
}
|
|
4147
4149
|
request['triggerPrice'] = this.getPrice(symbol, triggerPrice);
|
|
@@ -6553,12 +6555,14 @@ class bybit extends bybit$1 {
|
|
|
6553
6555
|
}
|
|
6554
6556
|
let collateralString = this.safeString(position, 'positionBalance');
|
|
6555
6557
|
const entryPrice = this.omitZero(this.safeStringN(position, ['entryPrice', 'avgPrice', 'avgEntryPrice']));
|
|
6558
|
+
const markPrice = this.safeString(position, 'markPrice');
|
|
6556
6559
|
const liquidationPrice = this.omitZero(this.safeString(position, 'liqPrice'));
|
|
6557
6560
|
const leverage = this.safeString(position, 'leverage');
|
|
6558
6561
|
if (liquidationPrice !== undefined) {
|
|
6559
6562
|
if (market['settle'] === 'USDC') {
|
|
6560
6563
|
// (Entry price - Liq price) * Contracts + Maintenance Margin + (unrealised pnl) = Collateral
|
|
6561
|
-
const
|
|
6564
|
+
const price = this.safeBool(this.options, 'useMarkPriceForPositionCollateral', false) ? markPrice : entryPrice;
|
|
6565
|
+
const difference = Precise["default"].stringAbs(Precise["default"].stringSub(price, liquidationPrice));
|
|
6562
6566
|
collateralString = Precise["default"].stringAdd(Precise["default"].stringAdd(Precise["default"].stringMul(difference, size), maintenanceMarginString), unrealisedPnl);
|
|
6563
6567
|
}
|
|
6564
6568
|
else {
|
|
@@ -6614,7 +6618,7 @@ class bybit extends bybit$1 {
|
|
|
6614
6618
|
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
6615
6619
|
'marginRatio': this.parseNumber(marginRatio),
|
|
6616
6620
|
'liquidationPrice': this.parseNumber(liquidationPrice),
|
|
6617
|
-
'markPrice': this.
|
|
6621
|
+
'markPrice': this.parseNumber(markPrice),
|
|
6618
6622
|
'lastPrice': this.safeNumber(position, 'avgExitPrice'),
|
|
6619
6623
|
'collateral': this.parseNumber(collateralString),
|
|
6620
6624
|
'marginMode': marginMode,
|
|
@@ -8030,6 +8034,77 @@ class bybit extends bybit$1 {
|
|
|
8030
8034
|
'datetime': this.iso8601(timestamp),
|
|
8031
8035
|
});
|
|
8032
8036
|
}
|
|
8037
|
+
/**
|
|
8038
|
+
* @method
|
|
8039
|
+
* @name bybit#fetchAllGreeks
|
|
8040
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
8041
|
+
* @see https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers
|
|
8042
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
8043
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8044
|
+
* @param {string} [params.baseCoin] the baseCoin of the symbol, default is BTC
|
|
8045
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
8046
|
+
*/
|
|
8047
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
8048
|
+
await this.loadMarkets();
|
|
8049
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
8050
|
+
const baseCoin = this.safeString(params, 'baseCoin', 'BTC');
|
|
8051
|
+
const request = {
|
|
8052
|
+
'category': 'option',
|
|
8053
|
+
'baseCoin': baseCoin,
|
|
8054
|
+
};
|
|
8055
|
+
let market = undefined;
|
|
8056
|
+
if (symbols !== undefined) {
|
|
8057
|
+
const symbolsLength = symbols.length;
|
|
8058
|
+
if (symbolsLength === 1) {
|
|
8059
|
+
market = this.market(symbols[0]);
|
|
8060
|
+
request['symbol'] = market['id'];
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
const response = await this.publicGetV5MarketTickers(this.extend(request, params));
|
|
8064
|
+
//
|
|
8065
|
+
// {
|
|
8066
|
+
// "retCode": 0,
|
|
8067
|
+
// "retMsg": "SUCCESS",
|
|
8068
|
+
// "result": {
|
|
8069
|
+
// "category": "option",
|
|
8070
|
+
// "list": [
|
|
8071
|
+
// {
|
|
8072
|
+
// "symbol": "BTC-26JAN24-39000-C",
|
|
8073
|
+
// "bid1Price": "3205",
|
|
8074
|
+
// "bid1Size": "7.1",
|
|
8075
|
+
// "bid1Iv": "0.5478",
|
|
8076
|
+
// "ask1Price": "3315",
|
|
8077
|
+
// "ask1Size": "1.98",
|
|
8078
|
+
// "ask1Iv": "0.5638",
|
|
8079
|
+
// "lastPrice": "3230",
|
|
8080
|
+
// "highPrice24h": "3255",
|
|
8081
|
+
// "lowPrice24h": "3200",
|
|
8082
|
+
// "markPrice": "3273.02263032",
|
|
8083
|
+
// "indexPrice": "36790.96",
|
|
8084
|
+
// "markIv": "0.5577",
|
|
8085
|
+
// "underlyingPrice": "37649.67254894",
|
|
8086
|
+
// "openInterest": "19.67",
|
|
8087
|
+
// "turnover24h": "170140.33875912",
|
|
8088
|
+
// "volume24h": "4.56",
|
|
8089
|
+
// "totalVolume": "22",
|
|
8090
|
+
// "totalTurnover": "789305",
|
|
8091
|
+
// "delta": "0.49640971",
|
|
8092
|
+
// "gamma": "0.00004131",
|
|
8093
|
+
// "vega": "69.08651675",
|
|
8094
|
+
// "theta": "-24.9443226",
|
|
8095
|
+
// "predictedDeliveryPrice": "0",
|
|
8096
|
+
// "change24h": "0.18532111"
|
|
8097
|
+
// }
|
|
8098
|
+
// ]
|
|
8099
|
+
// },
|
|
8100
|
+
// "retExtInfo": {},
|
|
8101
|
+
// "time": 1699584008326
|
|
8102
|
+
// }
|
|
8103
|
+
//
|
|
8104
|
+
const result = this.safeDict(response, 'result', {});
|
|
8105
|
+
const data = this.safeList(result, 'list', []);
|
|
8106
|
+
return this.parseAllGreeks(data, symbols);
|
|
8107
|
+
}
|
|
8033
8108
|
parseGreeks(greeks, market = undefined) {
|
|
8034
8109
|
//
|
|
8035
8110
|
// {
|
|
@@ -9175,7 +9250,7 @@ class bybit extends bybit$1 {
|
|
|
9175
9250
|
}
|
|
9176
9251
|
else {
|
|
9177
9252
|
authFull = auth_base + queryEncoded;
|
|
9178
|
-
url += '?' +
|
|
9253
|
+
url += '?' + queryEncoded;
|
|
9179
9254
|
}
|
|
9180
9255
|
let signature = undefined;
|
|
9181
9256
|
if (this.secret.indexOf('PRIVATE KEY') > -1) {
|
|
@@ -9193,7 +9268,7 @@ class bybit extends bybit$1 {
|
|
|
9193
9268
|
'timestamp': timestamp,
|
|
9194
9269
|
});
|
|
9195
9270
|
const sortedQuery = this.keysort(query);
|
|
9196
|
-
const auth = this.rawencode(sortedQuery);
|
|
9271
|
+
const auth = this.rawencode(sortedQuery, true);
|
|
9197
9272
|
let signature = undefined;
|
|
9198
9273
|
if (this.secret.indexOf('PRIVATE KEY') > -1) {
|
|
9199
9274
|
signature = rsa.rsa(auth, this.secret, sha256.sha256);
|
|
@@ -9220,7 +9295,7 @@ class bybit extends bybit$1 {
|
|
|
9220
9295
|
}
|
|
9221
9296
|
}
|
|
9222
9297
|
else {
|
|
9223
|
-
url += '?' + this.rawencode(sortedQuery);
|
|
9298
|
+
url += '?' + this.rawencode(sortedQuery, true);
|
|
9224
9299
|
url += '&sign=' + signature;
|
|
9225
9300
|
}
|
|
9226
9301
|
}
|
package/dist/cjs/src/coinbase.js
CHANGED
|
@@ -322,12 +322,14 @@ class coinbase extends coinbase$1 {
|
|
|
322
322
|
'rate_limit_exceeded': errors.RateLimitExceeded,
|
|
323
323
|
'internal_server_error': errors.ExchangeError,
|
|
324
324
|
'UNSUPPORTED_ORDER_CONFIGURATION': errors.BadRequest,
|
|
325
|
-
'INSUFFICIENT_FUND': errors.
|
|
325
|
+
'INSUFFICIENT_FUND': errors.InsufficientFunds,
|
|
326
326
|
'PERMISSION_DENIED': errors.PermissionDenied,
|
|
327
327
|
'INVALID_ARGUMENT': errors.BadRequest,
|
|
328
328
|
'PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE': errors.InvalidOrder,
|
|
329
|
+
'PREVIEW_INSUFFICIENT_FUND': errors.InsufficientFunds,
|
|
329
330
|
},
|
|
330
331
|
'broad': {
|
|
332
|
+
'Insufficient balance in source account': errors.InsufficientFunds,
|
|
331
333
|
'request timestamp expired': errors.InvalidNonce,
|
|
332
334
|
'order with this orderID was not found': errors.OrderNotFound, // {"error":"unknown","error_details":"order with this orderID was not found","message":"order with this orderID was not found"}
|
|
333
335
|
},
|