ccxt 4.4.92 → 4.4.93
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 +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +9 -8
- package/dist/cjs/src/base/Exchange.js +67 -11
- package/dist/cjs/src/binance.js +44 -1
- package/dist/cjs/src/bitmex.js +3 -3
- package/dist/cjs/src/bybit.js +83 -8
- 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/cryptomus.js +30 -53
- package/dist/cjs/src/deribit.js +6 -6
- package/dist/cjs/src/exmo.js +66 -61
- package/dist/cjs/src/hyperliquid.js +2 -1
- 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 +156 -0
- 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/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 +67 -11
- 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 +83 -8
- package/js/src/coinbaseexchange.js +53 -0
- package/js/src/coincheck.js +48 -5
- package/js/src/coinex.js +16 -13
- package/js/src/cryptomus.js +30 -53
- package/js/src/deribit.js +6 -6
- package/js/src/exmo.js +66 -61
- package/js/src/hyperliquid.js +2 -1
- 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 +156 -0
- 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/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.93';
|
|
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);
|
|
@@ -4022,7 +4022,7 @@ class Exchange {
|
|
|
4022
4022
|
return this.filterBySinceLimit(sorted, since, limit, 0, tail);
|
|
4023
4023
|
}
|
|
4024
4024
|
parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
|
|
4025
|
-
// marketIdKey should only be undefined when response is a dictionary
|
|
4025
|
+
// marketIdKey should only be undefined when response is a dictionary.
|
|
4026
4026
|
symbols = this.marketSymbols(symbols);
|
|
4027
4027
|
const tiers = {};
|
|
4028
4028
|
let symbolsLength = 0;
|
|
@@ -5460,6 +5460,9 @@ class Exchange {
|
|
|
5460
5460
|
async fetchGreeks(symbol, params = {}) {
|
|
5461
5461
|
throw new errors.NotSupported(this.id + ' fetchGreeks() is not supported yet');
|
|
5462
5462
|
}
|
|
5463
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
5464
|
+
throw new errors.NotSupported(this.id + ' fetchAllGreeks() is not supported yet');
|
|
5465
|
+
}
|
|
5463
5466
|
async fetchOptionChain(code, params = {}) {
|
|
5464
5467
|
throw new errors.NotSupported(this.id + ' fetchOptionChain() is not supported yet');
|
|
5465
5468
|
}
|
|
@@ -5754,11 +5757,20 @@ class Exchange {
|
|
|
5754
5757
|
if (precisionNumber === 0) {
|
|
5755
5758
|
return '1';
|
|
5756
5759
|
}
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
+
if (precisionNumber > 0) {
|
|
5761
|
+
let parsedPrecision = '0.';
|
|
5762
|
+
for (let i = 0; i < precisionNumber - 1; i++) {
|
|
5763
|
+
parsedPrecision = parsedPrecision + '0';
|
|
5764
|
+
}
|
|
5765
|
+
return parsedPrecision + '1';
|
|
5766
|
+
}
|
|
5767
|
+
else {
|
|
5768
|
+
let parsedPrecision = '1';
|
|
5769
|
+
for (let i = 0; i < precisionNumber * -1 - 1; i++) {
|
|
5770
|
+
parsedPrecision = parsedPrecision + '0';
|
|
5771
|
+
}
|
|
5772
|
+
return parsedPrecision + '0';
|
|
5760
5773
|
}
|
|
5761
|
-
return parsedPrecision + '1';
|
|
5762
5774
|
}
|
|
5763
5775
|
integerPrecisionToAmount(precision) {
|
|
5764
5776
|
/**
|
|
@@ -6915,6 +6927,31 @@ class Exchange {
|
|
|
6915
6927
|
parseGreeks(greeks, market = undefined) {
|
|
6916
6928
|
throw new errors.NotSupported(this.id + ' parseGreeks () is not supported yet');
|
|
6917
6929
|
}
|
|
6930
|
+
parseAllGreeks(greeks, symbols = undefined, params = {}) {
|
|
6931
|
+
//
|
|
6932
|
+
// the value of greeks is either a dict or a list
|
|
6933
|
+
//
|
|
6934
|
+
const results = [];
|
|
6935
|
+
if (Array.isArray(greeks)) {
|
|
6936
|
+
for (let i = 0; i < greeks.length; i++) {
|
|
6937
|
+
const parsedTicker = this.parseGreeks(greeks[i]);
|
|
6938
|
+
const greek = this.extend(parsedTicker, params);
|
|
6939
|
+
results.push(greek);
|
|
6940
|
+
}
|
|
6941
|
+
}
|
|
6942
|
+
else {
|
|
6943
|
+
const marketIds = Object.keys(greeks);
|
|
6944
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
6945
|
+
const marketId = marketIds[i];
|
|
6946
|
+
const market = this.safeMarket(marketId);
|
|
6947
|
+
const parsed = this.parseGreeks(greeks[marketId], market);
|
|
6948
|
+
const greek = this.extend(parsed, params);
|
|
6949
|
+
results.push(greek);
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
symbols = this.marketSymbols(symbols);
|
|
6953
|
+
return this.filterByArray(results, 'symbol', symbols);
|
|
6954
|
+
}
|
|
6918
6955
|
parseOption(chain, currency = undefined, market = undefined) {
|
|
6919
6956
|
throw new errors.NotSupported(this.id + ' parseOption () is not supported yet');
|
|
6920
6957
|
}
|
|
@@ -7153,16 +7190,35 @@ class Exchange {
|
|
|
7153
7190
|
*/
|
|
7154
7191
|
throw new errors.NotSupported(this.id + ' fetchTransfers () is not supported yet');
|
|
7155
7192
|
}
|
|
7156
|
-
cleanUnsubscription(client, subHash, unsubHash) {
|
|
7193
|
+
cleanUnsubscription(client, subHash, unsubHash, subHashIsPrefix = false) {
|
|
7157
7194
|
if (unsubHash in client.subscriptions) {
|
|
7158
7195
|
delete client.subscriptions[unsubHash];
|
|
7159
7196
|
}
|
|
7160
|
-
if (
|
|
7161
|
-
|
|
7197
|
+
if (!subHashIsPrefix) {
|
|
7198
|
+
if (subHash in client.subscriptions) {
|
|
7199
|
+
delete client.subscriptions[subHash];
|
|
7200
|
+
}
|
|
7201
|
+
if (subHash in client.futures) {
|
|
7202
|
+
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
7203
|
+
client.reject(error, subHash);
|
|
7204
|
+
}
|
|
7162
7205
|
}
|
|
7163
|
-
|
|
7164
|
-
const
|
|
7165
|
-
|
|
7206
|
+
else {
|
|
7207
|
+
const clientSubscriptions = Object.keys(client.subscriptions);
|
|
7208
|
+
for (let i = 0; i < clientSubscriptions.length; i++) {
|
|
7209
|
+
const sub = clientSubscriptions[i];
|
|
7210
|
+
if (sub.startsWith(subHash)) {
|
|
7211
|
+
delete client.subscriptions[sub];
|
|
7212
|
+
}
|
|
7213
|
+
}
|
|
7214
|
+
const clientFutures = Object.keys(client.futures);
|
|
7215
|
+
for (let i = 0; i < clientFutures.length; i++) {
|
|
7216
|
+
const future = clientFutures[i];
|
|
7217
|
+
if (future.startsWith(subHash)) {
|
|
7218
|
+
const error = new errors.UnsubscribeError(this.id + ' ' + future);
|
|
7219
|
+
client.reject(error, future);
|
|
7220
|
+
}
|
|
7221
|
+
}
|
|
7166
7222
|
}
|
|
7167
7223
|
client.resolve(true, unsubHash);
|
|
7168
7224
|
}
|
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
|
|
@@ -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
|
}
|
|
@@ -28,31 +28,73 @@ class coinbaseexchange extends coinbaseexchange$1 {
|
|
|
28
28
|
'swap': false,
|
|
29
29
|
'future': false,
|
|
30
30
|
'option': false,
|
|
31
|
+
'addMargin': false,
|
|
32
|
+
'borrowCrossMargin': false,
|
|
33
|
+
'borrowIsolatedMargin': false,
|
|
34
|
+
'borrowMargin': false,
|
|
31
35
|
'cancelAllOrders': true,
|
|
32
36
|
'cancelOrder': true,
|
|
37
|
+
'closeAllPositions': false,
|
|
38
|
+
'closePosition': false,
|
|
33
39
|
'createDepositAddress': true,
|
|
34
40
|
'createOrder': true,
|
|
41
|
+
'createOrderWithTakeProfitAndStopLoss': false,
|
|
42
|
+
'createOrderWithTakeProfitAndStopLossWs': false,
|
|
43
|
+
'createPostOnlyOrder': false,
|
|
35
44
|
'createReduceOnlyOrder': false,
|
|
36
45
|
'createStopLimitOrder': true,
|
|
37
46
|
'createStopMarketOrder': true,
|
|
38
47
|
'createStopOrder': true,
|
|
39
48
|
'fetchAccounts': true,
|
|
40
49
|
'fetchBalance': true,
|
|
50
|
+
'fetchBorrowInterest': false,
|
|
51
|
+
'fetchBorrowRate': false,
|
|
52
|
+
'fetchBorrowRateHistories': false,
|
|
53
|
+
'fetchBorrowRateHistory': false,
|
|
54
|
+
'fetchBorrowRates': false,
|
|
55
|
+
'fetchBorrowRatesPerSymbol': false,
|
|
41
56
|
'fetchClosedOrders': true,
|
|
57
|
+
'fetchCrossBorrowRate': false,
|
|
58
|
+
'fetchCrossBorrowRates': false,
|
|
42
59
|
'fetchCurrencies': true,
|
|
43
60
|
'fetchDepositAddress': false,
|
|
44
61
|
'fetchDeposits': true,
|
|
45
62
|
'fetchDepositsWithdrawals': true,
|
|
46
63
|
'fetchFundingHistory': false,
|
|
64
|
+
'fetchFundingInterval': false,
|
|
65
|
+
'fetchFundingIntervals': false,
|
|
47
66
|
'fetchFundingRate': false,
|
|
48
67
|
'fetchFundingRateHistory': false,
|
|
49
68
|
'fetchFundingRates': false,
|
|
69
|
+
'fetchGreeks': false,
|
|
70
|
+
'fetchIndexOHLCV': false,
|
|
71
|
+
'fetchIsolatedBorrowRate': false,
|
|
72
|
+
'fetchIsolatedBorrowRates': false,
|
|
73
|
+
'fetchIsolatedPositions': false,
|
|
50
74
|
'fetchLedger': true,
|
|
75
|
+
'fetchLeverage': false,
|
|
76
|
+
'fetchLeverages': false,
|
|
77
|
+
'fetchLeverageTiers': false,
|
|
78
|
+
'fetchLiquidations': false,
|
|
79
|
+
'fetchLongShortRatio': false,
|
|
80
|
+
'fetchLongShortRatioHistory': false,
|
|
81
|
+
'fetchMarginAdjustmentHistory': false,
|
|
51
82
|
'fetchMarginMode': false,
|
|
83
|
+
'fetchMarginModes': false,
|
|
84
|
+
'fetchMarketLeverageTiers': false,
|
|
52
85
|
'fetchMarkets': true,
|
|
86
|
+
'fetchMarkOHLCV': false,
|
|
87
|
+
'fetchMarkPrices': false,
|
|
88
|
+
'fetchMyLiquidations': false,
|
|
89
|
+
'fetchMySettlementHistory': false,
|
|
53
90
|
'fetchMyTrades': true,
|
|
54
91
|
'fetchOHLCV': true,
|
|
92
|
+
'fetchOpenInterest': false,
|
|
93
|
+
'fetchOpenInterestHistory': false,
|
|
94
|
+
'fetchOpenInterests': false,
|
|
55
95
|
'fetchOpenOrders': true,
|
|
96
|
+
'fetchOption': false,
|
|
97
|
+
'fetchOptionChain': false,
|
|
56
98
|
'fetchOrder': true,
|
|
57
99
|
'fetchOrderBook': true,
|
|
58
100
|
'fetchOrders': true,
|
|
@@ -64,6 +106,8 @@ class coinbaseexchange extends coinbaseexchange$1 {
|
|
|
64
106
|
'fetchPositionsForSymbol': false,
|
|
65
107
|
'fetchPositionsHistory': false,
|
|
66
108
|
'fetchPositionsRisk': false,
|
|
109
|
+
'fetchPremiumIndexOHLCV': false,
|
|
110
|
+
'fetchSettlementHistory': false,
|
|
67
111
|
'fetchTicker': true,
|
|
68
112
|
'fetchTickers': true,
|
|
69
113
|
'fetchTime': true,
|
|
@@ -71,7 +115,16 @@ class coinbaseexchange extends coinbaseexchange$1 {
|
|
|
71
115
|
'fetchTradingFee': false,
|
|
72
116
|
'fetchTradingFees': true,
|
|
73
117
|
'fetchTransactions': 'emulated',
|
|
118
|
+
'fetchVolatilityHistory': false,
|
|
74
119
|
'fetchWithdrawals': true,
|
|
120
|
+
'reduceMargin': false,
|
|
121
|
+
'repayCrossMargin': false,
|
|
122
|
+
'repayIsolatedMargin': false,
|
|
123
|
+
'repayMargin': false,
|
|
124
|
+
'setLeverage': false,
|
|
125
|
+
'setMargin': false,
|
|
126
|
+
'setMarginMode': false,
|
|
127
|
+
'setPositionMode': false,
|
|
75
128
|
'withdraw': true,
|
|
76
129
|
},
|
|
77
130
|
'timeframes': {
|
|
@@ -26,30 +26,59 @@ class coincheck extends coincheck$1 {
|
|
|
26
26
|
'future': false,
|
|
27
27
|
'option': false,
|
|
28
28
|
'addMargin': false,
|
|
29
|
+
'borrowCrossMargin': false,
|
|
30
|
+
'borrowIsolatedMargin': false,
|
|
31
|
+
'borrowMargin': false,
|
|
29
32
|
'cancelOrder': true,
|
|
30
33
|
'closeAllPositions': false,
|
|
31
34
|
'closePosition': false,
|
|
32
35
|
'createOrder': true,
|
|
36
|
+
'createOrderWithTakeProfitAndStopLoss': false,
|
|
37
|
+
'createOrderWithTakeProfitAndStopLossWs': false,
|
|
38
|
+
'createPostOnlyOrder': false,
|
|
33
39
|
'createReduceOnlyOrder': false,
|
|
34
40
|
'fetchBalance': true,
|
|
41
|
+
'fetchBorrowInterest': false,
|
|
42
|
+
'fetchBorrowRate': false,
|
|
35
43
|
'fetchBorrowRateHistories': false,
|
|
36
44
|
'fetchBorrowRateHistory': false,
|
|
45
|
+
'fetchBorrowRates': false,
|
|
46
|
+
'fetchBorrowRatesPerSymbol': false,
|
|
37
47
|
'fetchCrossBorrowRate': false,
|
|
38
48
|
'fetchCrossBorrowRates': false,
|
|
39
49
|
'fetchDeposits': true,
|
|
40
50
|
'fetchFundingHistory': false,
|
|
51
|
+
'fetchFundingInterval': false,
|
|
52
|
+
'fetchFundingIntervals': false,
|
|
41
53
|
'fetchFundingRate': false,
|
|
42
54
|
'fetchFundingRateHistory': false,
|
|
43
55
|
'fetchFundingRates': false,
|
|
56
|
+
'fetchGreeks': false,
|
|
44
57
|
'fetchIndexOHLCV': false,
|
|
45
58
|
'fetchIsolatedBorrowRate': false,
|
|
46
59
|
'fetchIsolatedBorrowRates': false,
|
|
60
|
+
'fetchIsolatedPositions': false,
|
|
47
61
|
'fetchLeverage': false,
|
|
62
|
+
'fetchLeverages': false,
|
|
63
|
+
'fetchLeverageTiers': false,
|
|
64
|
+
'fetchLiquidations': false,
|
|
65
|
+
'fetchLongShortRatio': false,
|
|
66
|
+
'fetchLongShortRatioHistory': false,
|
|
67
|
+
'fetchMarginAdjustmentHistory': false,
|
|
48
68
|
'fetchMarginMode': false,
|
|
69
|
+
'fetchMarginModes': false,
|
|
70
|
+
'fetchMarketLeverageTiers': false,
|
|
49
71
|
'fetchMarkOHLCV': false,
|
|
72
|
+
'fetchMarkPrices': false,
|
|
73
|
+
'fetchMyLiquidations': false,
|
|
74
|
+
'fetchMySettlementHistory': false,
|
|
50
75
|
'fetchMyTrades': true,
|
|
76
|
+
'fetchOpenInterest': false,
|
|
51
77
|
'fetchOpenInterestHistory': false,
|
|
78
|
+
'fetchOpenInterests': false,
|
|
52
79
|
'fetchOpenOrders': true,
|
|
80
|
+
'fetchOption': false,
|
|
81
|
+
'fetchOptionChain': false,
|
|
53
82
|
'fetchOrderBook': true,
|
|
54
83
|
'fetchPosition': false,
|
|
55
84
|
'fetchPositionHistory': false,
|
|
@@ -59,13 +88,19 @@ class coincheck extends coincheck$1 {
|
|
|
59
88
|
'fetchPositionsHistory': false,
|
|
60
89
|
'fetchPositionsRisk': false,
|
|
61
90
|
'fetchPremiumIndexOHLCV': false,
|
|
91
|
+
'fetchSettlementHistory': false,
|
|
62
92
|
'fetchTicker': true,
|
|
63
93
|
'fetchTrades': true,
|
|
64
94
|
'fetchTradingFee': false,
|
|
65
95
|
'fetchTradingFees': true,
|
|
96
|
+
'fetchVolatilityHistory': false,
|
|
66
97
|
'fetchWithdrawals': true,
|
|
67
98
|
'reduceMargin': false,
|
|
99
|
+
'repayCrossMargin': false,
|
|
100
|
+
'repayIsolatedMargin': false,
|
|
101
|
+
'repayMargin': false,
|
|
68
102
|
'setLeverage': false,
|
|
103
|
+
'setMargin': false,
|
|
69
104
|
'setMarginMode': false,
|
|
70
105
|
'setPositionMode': false,
|
|
71
106
|
'ws': true,
|
|
@@ -645,10 +680,18 @@ class coincheck extends coincheck$1 {
|
|
|
645
680
|
'pair': market['id'],
|
|
646
681
|
};
|
|
647
682
|
if (type === 'market') {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
683
|
+
request['order_type'] = type + '_' + side;
|
|
684
|
+
if (side === 'sell') {
|
|
685
|
+
request['amount'] = amount;
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
const cost = this.safeNumber(params, 'cost');
|
|
689
|
+
params = this.omit(params, 'cost');
|
|
690
|
+
if (cost !== undefined) {
|
|
691
|
+
throw new errors.ArgumentsRequired(this.id + ' createOrder() : you should use "cost" parameter instead of "amount" argument to create market buy orders');
|
|
692
|
+
}
|
|
693
|
+
request['market_buy_amount'] = cost;
|
|
694
|
+
}
|
|
652
695
|
}
|
|
653
696
|
else {
|
|
654
697
|
request['order_type'] = side;
|