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/src/latoken.js
CHANGED
|
@@ -233,6 +233,8 @@ class latoken extends latoken$1 {
|
|
|
233
233
|
'fetchTradingFee': {
|
|
234
234
|
'method': 'fetchPrivateTradingFee', // or 'fetchPublicTradingFee'
|
|
235
235
|
},
|
|
236
|
+
'timeDifference': 0,
|
|
237
|
+
'adjustForTimeDifference': true, // controls the adjustment logic upon instantiation
|
|
236
238
|
},
|
|
237
239
|
'features': {
|
|
238
240
|
'spot': {
|
|
@@ -333,39 +335,6 @@ class latoken extends latoken$1 {
|
|
|
333
335
|
* @returns {object[]} an array of objects representing market data
|
|
334
336
|
*/
|
|
335
337
|
async fetchMarkets(params = {}) {
|
|
336
|
-
const currencies = await this.fetchCurrenciesFromCache(params);
|
|
337
|
-
//
|
|
338
|
-
// [
|
|
339
|
-
// {
|
|
340
|
-
// "id":"1a075819-9e0b-48fc-8784-4dab1d186d6d",
|
|
341
|
-
// "status":"CURRENCY_STATUS_ACTIVE",
|
|
342
|
-
// "type":"CURRENCY_TYPE_ALTERNATIVE", // CURRENCY_TYPE_CRYPTO, CURRENCY_TYPE_IEO
|
|
343
|
-
// "name":"MyCryptoBank",
|
|
344
|
-
// "tag":"MCB",
|
|
345
|
-
// "description":"",
|
|
346
|
-
// "logo":"",
|
|
347
|
-
// "decimals":18,
|
|
348
|
-
// "created":1572912000000,
|
|
349
|
-
// "tier":1,
|
|
350
|
-
// "assetClass":"ASSET_CLASS_UNKNOWN",
|
|
351
|
-
// "minTransferAmount":0
|
|
352
|
-
// },
|
|
353
|
-
// {
|
|
354
|
-
// "id":"db02758e-2507-46a5-a805-7bc60355b3eb",
|
|
355
|
-
// "status":"CURRENCY_STATUS_ACTIVE",
|
|
356
|
-
// "type":"CURRENCY_TYPE_FUTURES_CONTRACT",
|
|
357
|
-
// "name":"BTC USDT Futures Contract",
|
|
358
|
-
// "tag":"BTCUSDT",
|
|
359
|
-
// "description":"",
|
|
360
|
-
// "logo":"",
|
|
361
|
-
// "decimals":8,
|
|
362
|
-
// "created":1589459984395,
|
|
363
|
-
// "tier":1,
|
|
364
|
-
// "assetClass":"ASSET_CLASS_UNKNOWN",
|
|
365
|
-
// "minTransferAmount":0
|
|
366
|
-
// },
|
|
367
|
-
// ]
|
|
368
|
-
//
|
|
369
338
|
const response = await this.publicGetPair(params);
|
|
370
339
|
//
|
|
371
340
|
// [
|
|
@@ -387,9 +356,10 @@ class latoken extends latoken$1 {
|
|
|
387
356
|
// }
|
|
388
357
|
// ]
|
|
389
358
|
//
|
|
390
|
-
if (this.
|
|
359
|
+
if (this.safeBool(this.options, 'adjustForTimeDifference', false)) {
|
|
391
360
|
await this.loadTimeDifference();
|
|
392
361
|
}
|
|
362
|
+
const currencies = this.safeDict(this.options, 'cachedCurrencies', {});
|
|
393
363
|
const currenciesById = this.indexBy(currencies, 'id');
|
|
394
364
|
const result = [];
|
|
395
365
|
for (let i = 0; i < response.length; i++) {
|
|
@@ -398,11 +368,13 @@ class latoken extends latoken$1 {
|
|
|
398
368
|
// the exchange shows them inverted
|
|
399
369
|
const baseId = this.safeString(market, 'baseCurrency');
|
|
400
370
|
const quoteId = this.safeString(market, 'quoteCurrency');
|
|
401
|
-
const baseCurrency = this.
|
|
402
|
-
const quoteCurrency = this.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
371
|
+
const baseCurrency = this.safeDict(currenciesById, baseId);
|
|
372
|
+
const quoteCurrency = this.safeDict(currenciesById, quoteId);
|
|
373
|
+
const baseCurrencyInfo = this.safeDict(baseCurrency, 'info');
|
|
374
|
+
const quoteCurrencyInfo = this.safeDict(quoteCurrency, 'info');
|
|
375
|
+
if (baseCurrencyInfo !== undefined && quoteCurrencyInfo !== undefined) {
|
|
376
|
+
const base = this.safeCurrencyCode(this.safeString(baseCurrencyInfo, 'tag'));
|
|
377
|
+
const quote = this.safeCurrencyCode(this.safeString(quoteCurrencyInfo, 'tag'));
|
|
406
378
|
const lowercaseQuote = quote.toLowerCase();
|
|
407
379
|
const capitalizedQuote = this.capitalize(lowercaseQuote);
|
|
408
380
|
const status = this.safeString(market, 'status');
|
|
@@ -459,22 +431,6 @@ class latoken extends latoken$1 {
|
|
|
459
431
|
}
|
|
460
432
|
return result;
|
|
461
433
|
}
|
|
462
|
-
async fetchCurrenciesFromCache(params = {}) {
|
|
463
|
-
// this method is now redundant
|
|
464
|
-
// currencies are now fetched before markets
|
|
465
|
-
const options = this.safeValue(this.options, 'fetchCurrencies', {});
|
|
466
|
-
const timestamp = this.safeInteger(options, 'timestamp');
|
|
467
|
-
const expires = this.safeInteger(options, 'expires', 1000);
|
|
468
|
-
const now = this.milliseconds();
|
|
469
|
-
if ((timestamp === undefined) || ((now - timestamp) > expires)) {
|
|
470
|
-
const response = await this.publicGetCurrency(params);
|
|
471
|
-
this.options['fetchCurrencies'] = this.extend(options, {
|
|
472
|
-
'response': response,
|
|
473
|
-
'timestamp': now,
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return this.safeValue(this.options['fetchCurrencies'], 'response');
|
|
477
|
-
}
|
|
478
434
|
/**
|
|
479
435
|
* @method
|
|
480
436
|
* @name latoken#fetchCurrencies
|
|
@@ -483,7 +439,7 @@ class latoken extends latoken$1 {
|
|
|
483
439
|
* @returns {object} an associative dictionary of currencies
|
|
484
440
|
*/
|
|
485
441
|
async fetchCurrencies(params = {}) {
|
|
486
|
-
const response = await this.
|
|
442
|
+
const response = await this.publicGetCurrency(params);
|
|
487
443
|
//
|
|
488
444
|
// [
|
|
489
445
|
// {
|
|
@@ -522,29 +478,18 @@ class latoken extends latoken$1 {
|
|
|
522
478
|
const id = this.safeString(currency, 'id');
|
|
523
479
|
const tag = this.safeString(currency, 'tag');
|
|
524
480
|
const code = this.safeCurrencyCode(tag);
|
|
525
|
-
const fee = this.safeNumber(currency, 'fee');
|
|
526
481
|
const currencyType = this.safeString(currency, 'type');
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
type = 'other';
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
// CURRENCY_TYPE_CRYPTO and CURRENCY_TYPE_IEO are all cryptos
|
|
533
|
-
type = 'crypto';
|
|
534
|
-
}
|
|
535
|
-
const status = this.safeString(currency, 'status');
|
|
536
|
-
const active = (status === 'CURRENCY_STATUS_ACTIVE');
|
|
537
|
-
const name = this.safeString(currency, 'name');
|
|
538
|
-
result[code] = {
|
|
482
|
+
const isCrypto = (currencyType === 'CURRENCY_TYPE_CRYPTO' || currencyType === 'CURRENCY_TYPE_IEO');
|
|
483
|
+
result[code] = this.safeCurrencyStructure({
|
|
539
484
|
'id': id,
|
|
540
485
|
'code': code,
|
|
541
486
|
'info': currency,
|
|
542
|
-
'name': name,
|
|
543
|
-
'type':
|
|
544
|
-
'active':
|
|
487
|
+
'name': this.safeString(currency, 'name'),
|
|
488
|
+
'type': isCrypto ? 'crypto' : 'other',
|
|
489
|
+
'active': this.safeString(currency, 'status') === 'CURRENCY_STATUS_ACTIVE',
|
|
545
490
|
'deposit': undefined,
|
|
546
491
|
'withdraw': undefined,
|
|
547
|
-
'fee': fee,
|
|
492
|
+
'fee': this.safeNumber(currency, 'fee'),
|
|
548
493
|
'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
|
|
549
494
|
'limits': {
|
|
550
495
|
'amount': {
|
|
@@ -557,7 +502,7 @@ class latoken extends latoken$1 {
|
|
|
557
502
|
},
|
|
558
503
|
},
|
|
559
504
|
'networks': {},
|
|
560
|
-
};
|
|
505
|
+
});
|
|
561
506
|
}
|
|
562
507
|
return result;
|
|
563
508
|
}
|
package/dist/cjs/src/lbank.js
CHANGED
|
@@ -125,7 +125,7 @@ class lbank extends lbank$1 {
|
|
|
125
125
|
'accuracy': 2.5,
|
|
126
126
|
'usdToCny': 2.5,
|
|
127
127
|
'assetConfigs': 2.5,
|
|
128
|
-
'withdrawConfigs': 2.5,
|
|
128
|
+
'withdrawConfigs': 2.5 * 1.5,
|
|
129
129
|
'timestamp': 2.5,
|
|
130
130
|
'ticker/24hr': 2.5,
|
|
131
131
|
'ticker': 2.5,
|
|
@@ -669,7 +669,7 @@ class lbank extends lbank$1 {
|
|
|
669
669
|
'active': true,
|
|
670
670
|
'contract': true,
|
|
671
671
|
'linear': true,
|
|
672
|
-
'inverse':
|
|
672
|
+
'inverse': false,
|
|
673
673
|
'contractSize': this.safeNumber(market, 'volumeMultiple'),
|
|
674
674
|
'expiry': undefined,
|
|
675
675
|
'expiryDatetime': undefined,
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -55,6 +55,7 @@ class okx extends okx$1 {
|
|
|
55
55
|
'createTriggerOrder': true,
|
|
56
56
|
'editOrder': true,
|
|
57
57
|
'fetchAccounts': true,
|
|
58
|
+
'fetchAllGreeks': true,
|
|
58
59
|
'fetchBalance': true,
|
|
59
60
|
'fetchBidsAsks': undefined,
|
|
60
61
|
'fetchBorrowInterest': true,
|
|
@@ -2600,12 +2601,12 @@ class okx extends okx$1 {
|
|
|
2600
2601
|
// it may be incorrect to use total, free and used for swap accounts
|
|
2601
2602
|
const eq = this.safeString(balance, 'eq');
|
|
2602
2603
|
const availEq = this.safeString(balance, 'availEq');
|
|
2603
|
-
|
|
2604
|
+
account['total'] = eq;
|
|
2605
|
+
if (availEq === undefined) {
|
|
2604
2606
|
account['free'] = this.safeString(balance, 'availBal');
|
|
2605
2607
|
account['used'] = this.safeString(balance, 'frozenBal');
|
|
2606
2608
|
}
|
|
2607
2609
|
else {
|
|
2608
|
-
account['total'] = eq;
|
|
2609
2610
|
account['free'] = availEq;
|
|
2610
2611
|
}
|
|
2611
2612
|
result[code] = account;
|
|
@@ -2877,7 +2878,7 @@ class okx extends okx$1 {
|
|
|
2877
2878
|
}
|
|
2878
2879
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
2879
2880
|
const market = this.market(symbol);
|
|
2880
|
-
|
|
2881
|
+
let request = {
|
|
2881
2882
|
'instId': market['id'],
|
|
2882
2883
|
// 'ccy': currency['id'], // only applicable to cross MARGIN orders in single-currency margin
|
|
2883
2884
|
// 'clOrdId': clientOrderId, // up to 32 characters, must be unique
|
|
@@ -3042,7 +3043,8 @@ class okx extends okx$1 {
|
|
|
3042
3043
|
if (stopLossTriggerPrice === undefined) {
|
|
3043
3044
|
throw new errors.InvalidOrder(this.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"], or params["stopLoss"]["stopPrice"], or params["stopLoss"]["slTriggerPx"] for a stop loss order');
|
|
3044
3045
|
}
|
|
3045
|
-
|
|
3046
|
+
const slTriggerPx = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
3047
|
+
request['slTriggerPx'] = slTriggerPx;
|
|
3046
3048
|
const stopLossLimitPrice = this.safeValueN(stopLoss, ['price', 'stopLossPrice', 'slOrdPx']);
|
|
3047
3049
|
const stopLossOrderType = this.safeString(stopLoss, 'type');
|
|
3048
3050
|
if (stopLossOrderType !== undefined) {
|
|
@@ -3134,6 +3136,14 @@ class okx extends okx$1 {
|
|
|
3134
3136
|
if (twoWayCondition) {
|
|
3135
3137
|
request['ordType'] = 'oco';
|
|
3136
3138
|
}
|
|
3139
|
+
if (side === 'sell') {
|
|
3140
|
+
request = this.omit(request, 'tgtCcy');
|
|
3141
|
+
}
|
|
3142
|
+
if (this.safeString(request, 'tdMode') === 'cash') {
|
|
3143
|
+
// for some reason tdMode = cash throws
|
|
3144
|
+
// {"code":"1","data":[{"algoClOrdId":"","algoId":"","clOrdId":"","sCode":"51000","sMsg":"Parameter tdMode error ","tag":""}],"msg":""}
|
|
3145
|
+
request['tdMode'] = marginMode;
|
|
3146
|
+
}
|
|
3137
3147
|
if (takeProfitPrice !== undefined) {
|
|
3138
3148
|
request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
3139
3149
|
let tpOrdPxReq = '-1';
|
|
@@ -3789,6 +3799,84 @@ class okx extends okx$1 {
|
|
|
3789
3799
|
// "uTime": "1621910749815"
|
|
3790
3800
|
// }
|
|
3791
3801
|
//
|
|
3802
|
+
// watchOrders & fetchClosedOrders
|
|
3803
|
+
//
|
|
3804
|
+
// {
|
|
3805
|
+
// "algoClOrdId": "",
|
|
3806
|
+
// "algoId": "",
|
|
3807
|
+
// "attachAlgoClOrdId": "",
|
|
3808
|
+
// "attachAlgoOrds": [],
|
|
3809
|
+
// "cancelSource": "",
|
|
3810
|
+
// "cancelSourceReason": "", // not present in WS, but present in fetchClosedOrders
|
|
3811
|
+
// "category": "normal",
|
|
3812
|
+
// "ccy": "", // empty in WS, but eg. `USDT` in fetchClosedOrders
|
|
3813
|
+
// "clOrdId": "",
|
|
3814
|
+
// "cTime": "1751705801423",
|
|
3815
|
+
// "feeCcy": "USDT",
|
|
3816
|
+
// "instId": "LINK-USDT-SWAP",
|
|
3817
|
+
// "instType": "SWAP",
|
|
3818
|
+
// "isTpLimit": "false",
|
|
3819
|
+
// "lever": "3",
|
|
3820
|
+
// "linkedAlgoOrd": { "algoId": "" },
|
|
3821
|
+
// "ordId": "2657625147249614848",
|
|
3822
|
+
// "ordType": "limit",
|
|
3823
|
+
// "posSide": "net",
|
|
3824
|
+
// "px": "13.142",
|
|
3825
|
+
// "pxType": "",
|
|
3826
|
+
// "pxUsd": "",
|
|
3827
|
+
// "pxVol": "",
|
|
3828
|
+
// "quickMgnType": "",
|
|
3829
|
+
// "rebate": "0",
|
|
3830
|
+
// "rebateCcy": "USDT",
|
|
3831
|
+
// "reduceOnly": "true",
|
|
3832
|
+
// "side": "sell",
|
|
3833
|
+
// "slOrdPx": "",
|
|
3834
|
+
// "slTriggerPx": "",
|
|
3835
|
+
// "slTriggerPxType": "",
|
|
3836
|
+
// "source": "",
|
|
3837
|
+
// "stpId": "",
|
|
3838
|
+
// "stpMode": "cancel_maker",
|
|
3839
|
+
// "sz": "0.1",
|
|
3840
|
+
// "tag": "",
|
|
3841
|
+
// "tdMode": "isolated",
|
|
3842
|
+
// "tgtCcy": "",
|
|
3843
|
+
// "tpOrdPx": "",
|
|
3844
|
+
// "tpTriggerPx": "",
|
|
3845
|
+
// "tpTriggerPxType": "",
|
|
3846
|
+
// "uTime": "1751705807467",
|
|
3847
|
+
// "reqId": "", // field present only in WS
|
|
3848
|
+
// "msg": "", // field present only in WS
|
|
3849
|
+
// "amendResult": "", // field present only in WS
|
|
3850
|
+
// "amendSource": "", // field present only in WS
|
|
3851
|
+
// "code": "0", // field present only in WS
|
|
3852
|
+
// "fillFwdPx": "", // field present only in WS
|
|
3853
|
+
// "fillMarkVol": "", // field present only in WS
|
|
3854
|
+
// "fillPxUsd": "", // field present only in WS
|
|
3855
|
+
// "fillPxVol": "", // field present only in WS
|
|
3856
|
+
// "lastPx": "13.142", // field present only in WS
|
|
3857
|
+
// "notionalUsd": "1.314515408", // field present only in WS
|
|
3858
|
+
//
|
|
3859
|
+
// #### these below fields are empty on first omit from websocket, because of "creation" event. however, if order is executed, it also immediately sends another update with these fields filled ###
|
|
3860
|
+
//
|
|
3861
|
+
// "pnl": "-0.0001",
|
|
3862
|
+
// "accFillSz": "0.1",
|
|
3863
|
+
// "avgPx": "13.142",
|
|
3864
|
+
// "state": "filled",
|
|
3865
|
+
// "fee": "-0.00026284",
|
|
3866
|
+
// "fillPx": "13.142",
|
|
3867
|
+
// "tradeId": "293429690",
|
|
3868
|
+
// "fillSz": "0.1",
|
|
3869
|
+
// "fillTime": "1751705807467",
|
|
3870
|
+
// "fillNotionalUsd": "1.314515408", // field present only in WS
|
|
3871
|
+
// "fillPnl": "-0.0001", // field present only in WS
|
|
3872
|
+
// "fillFee": "-0.00026284", // field present only in WS
|
|
3873
|
+
// "fillFeeCcy": "USDT", // field present only in WS
|
|
3874
|
+
// "execType": "M", // field present only in WS
|
|
3875
|
+
// "fillMarkPx": "13.141", // field present only in WS
|
|
3876
|
+
// "fillIdxPx": "13.147" // field present only in WS
|
|
3877
|
+
// }
|
|
3878
|
+
//
|
|
3879
|
+
//
|
|
3792
3880
|
// Algo Order fetchOpenOrders, fetchCanceledOrders, fetchClosedOrders
|
|
3793
3881
|
//
|
|
3794
3882
|
// {
|
|
@@ -7943,6 +8031,83 @@ class okx extends okx$1 {
|
|
|
7943
8031
|
}
|
|
7944
8032
|
return undefined;
|
|
7945
8033
|
}
|
|
8034
|
+
/**
|
|
8035
|
+
* @method
|
|
8036
|
+
* @name okx#fetchAllGreeks
|
|
8037
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
8038
|
+
* @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
|
|
8039
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
8040
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8041
|
+
* @param {string} params.uly Underlying, either uly or instFamily is required
|
|
8042
|
+
* @param {string} params.instFamily Instrument family, either uly or instFamily is required
|
|
8043
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
8044
|
+
*/
|
|
8045
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
8046
|
+
await this.loadMarkets();
|
|
8047
|
+
const request = {};
|
|
8048
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
8049
|
+
let symbolsLength = undefined;
|
|
8050
|
+
if (symbols !== undefined) {
|
|
8051
|
+
symbolsLength = symbols.length;
|
|
8052
|
+
}
|
|
8053
|
+
if ((symbols === undefined) || (symbolsLength !== 1)) {
|
|
8054
|
+
const uly = this.safeString(params, 'uly');
|
|
8055
|
+
if (uly !== undefined) {
|
|
8056
|
+
request['uly'] = uly;
|
|
8057
|
+
}
|
|
8058
|
+
const instFamily = this.safeString(params, 'instFamily');
|
|
8059
|
+
if (instFamily !== undefined) {
|
|
8060
|
+
request['instFamily'] = instFamily;
|
|
8061
|
+
}
|
|
8062
|
+
if ((uly === undefined) && (instFamily === undefined)) {
|
|
8063
|
+
throw new errors.BadRequest(this.id + ' fetchAllGreeks() requires either a uly or instFamily parameter');
|
|
8064
|
+
}
|
|
8065
|
+
}
|
|
8066
|
+
let market = undefined;
|
|
8067
|
+
if (symbols !== undefined) {
|
|
8068
|
+
if (symbolsLength === 1) {
|
|
8069
|
+
market = this.market(symbols[0]);
|
|
8070
|
+
const marketId = market['id'];
|
|
8071
|
+
const optionParts = marketId.split('-');
|
|
8072
|
+
request['uly'] = market['info']['uly'];
|
|
8073
|
+
request['instFamily'] = market['info']['instFamily'];
|
|
8074
|
+
request['expTime'] = this.safeString(optionParts, 2);
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
8077
|
+
params = this.omit(params, ['uly', 'instFamily']);
|
|
8078
|
+
const response = await this.publicGetPublicOptSummary(this.extend(request, params));
|
|
8079
|
+
//
|
|
8080
|
+
// {
|
|
8081
|
+
// "code": "0",
|
|
8082
|
+
// "data": [
|
|
8083
|
+
// {
|
|
8084
|
+
// "askVol": "0",
|
|
8085
|
+
// "bidVol": "0",
|
|
8086
|
+
// "delta": "0.5105464486882039",
|
|
8087
|
+
// "deltaBS": "0.7325502184143025",
|
|
8088
|
+
// "fwdPx": "37675.80158694987186",
|
|
8089
|
+
// "gamma": "-0.13183515090501083",
|
|
8090
|
+
// "gammaBS": "0.000024139685826358558",
|
|
8091
|
+
// "instId": "BTC-USD-240329-32000-C",
|
|
8092
|
+
// "instType": "OPTION",
|
|
8093
|
+
// "lever": "4.504428015946619",
|
|
8094
|
+
// "markVol": "0.5916253554539876",
|
|
8095
|
+
// "realVol": "0",
|
|
8096
|
+
// "theta": "-0.0004202992014012855",
|
|
8097
|
+
// "thetaBS": "-18.52354631567909",
|
|
8098
|
+
// "ts": "1699586421976",
|
|
8099
|
+
// "uly": "BTC-USD",
|
|
8100
|
+
// "vega": "0.0020207455080045846",
|
|
8101
|
+
// "vegaBS": "74.44022302387287",
|
|
8102
|
+
// "volLv": "0.5948549730405797"
|
|
8103
|
+
// },
|
|
8104
|
+
// ],
|
|
8105
|
+
// "msg": ""
|
|
8106
|
+
// }
|
|
8107
|
+
//
|
|
8108
|
+
const data = this.safeList(response, 'data', []);
|
|
8109
|
+
return this.parseAllGreeks(data, symbols);
|
|
8110
|
+
}
|
|
7946
8111
|
parseGreeks(greeks, market = undefined) {
|
|
7947
8112
|
//
|
|
7948
8113
|
// {
|
package/dist/cjs/src/paradex.js
CHANGED
|
@@ -54,6 +54,7 @@ class paradex extends paradex$1 {
|
|
|
54
54
|
'createTriggerOrder': true,
|
|
55
55
|
'editOrder': false,
|
|
56
56
|
'fetchAccounts': false,
|
|
57
|
+
'fetchAllGreeks': true,
|
|
57
58
|
'fetchBalance': true,
|
|
58
59
|
'fetchBorrowInterest': false,
|
|
59
60
|
'fetchBorrowRateHistories': false,
|
|
@@ -2410,6 +2411,59 @@ class paradex extends paradex$1 {
|
|
|
2410
2411
|
const greeks = this.safeDict(data, 0, {});
|
|
2411
2412
|
return this.parseGreeks(greeks, market);
|
|
2412
2413
|
}
|
|
2414
|
+
/**
|
|
2415
|
+
* @method
|
|
2416
|
+
* @name paradex#fetchAllGreeks
|
|
2417
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
2418
|
+
* @see https://docs.api.testnet.paradex.trade/#list-available-markets-summary
|
|
2419
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
2420
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2421
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
2422
|
+
*/
|
|
2423
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
2424
|
+
await this.loadMarkets();
|
|
2425
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
2426
|
+
const request = {
|
|
2427
|
+
'market': 'ALL',
|
|
2428
|
+
};
|
|
2429
|
+
const response = await this.publicGetMarketsSummary(this.extend(request, params));
|
|
2430
|
+
//
|
|
2431
|
+
// {
|
|
2432
|
+
// "results": [
|
|
2433
|
+
// {
|
|
2434
|
+
// "symbol": "BTC-USD-114000-P",
|
|
2435
|
+
// "mark_price": "10835.66892602",
|
|
2436
|
+
// "mark_iv": "0.71781855",
|
|
2437
|
+
// "delta": "-0.98726024",
|
|
2438
|
+
// "greeks": {
|
|
2439
|
+
// "delta": "-0.9872602390817709",
|
|
2440
|
+
// "gamma": "0.000004560958862297231",
|
|
2441
|
+
// "vega": "227.11344863639806",
|
|
2442
|
+
// "rho": "-302.0617972461581",
|
|
2443
|
+
// "vanna": "0.06609830491614832",
|
|
2444
|
+
// "volga": "925.9501532805552"
|
|
2445
|
+
// },
|
|
2446
|
+
// "last_traded_price": "10551.5",
|
|
2447
|
+
// "bid": "10794.9",
|
|
2448
|
+
// "bid_iv": "0.05",
|
|
2449
|
+
// "ask": "10887.3",
|
|
2450
|
+
// "ask_iv": "0.8783283",
|
|
2451
|
+
// "last_iv": "0.05",
|
|
2452
|
+
// "volume_24h": "0",
|
|
2453
|
+
// "total_volume": "195240.72672261014",
|
|
2454
|
+
// "created_at": 1747644009995,
|
|
2455
|
+
// "underlying_price": "103164.79162649",
|
|
2456
|
+
// "open_interest": "0",
|
|
2457
|
+
// "funding_rate": "0.000004464241170536191",
|
|
2458
|
+
// "price_change_rate_24h": "0.074915",
|
|
2459
|
+
// "future_funding_rate": "0.0001"
|
|
2460
|
+
// }
|
|
2461
|
+
// ]
|
|
2462
|
+
// }
|
|
2463
|
+
//
|
|
2464
|
+
const results = this.safeList(response, 'results', []);
|
|
2465
|
+
return this.parseAllGreeks(results, symbols);
|
|
2466
|
+
}
|
|
2413
2467
|
parseGreeks(greeks, market = undefined) {
|
|
2414
2468
|
//
|
|
2415
2469
|
// {
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -2760,10 +2760,10 @@ class phemex extends phemex$1 {
|
|
|
2760
2760
|
let triggerDirection = undefined;
|
|
2761
2761
|
[triggerDirection, params] = this.handleParamString(params, 'triggerDirection');
|
|
2762
2762
|
if (triggerDirection === undefined) {
|
|
2763
|
-
throw new errors.ArgumentsRequired(this.id + " createOrder() also requires a 'triggerDirection' parameter with either '
|
|
2763
|
+
throw new errors.ArgumentsRequired(this.id + " createOrder() also requires a 'triggerDirection' parameter with either 'ascending' or 'descending' value");
|
|
2764
2764
|
}
|
|
2765
2765
|
// the flow defined per https://phemex-docs.github.io/#more-order-type-examples
|
|
2766
|
-
if (triggerDirection === 'up') {
|
|
2766
|
+
if (triggerDirection === 'ascending' || triggerDirection === 'up') {
|
|
2767
2767
|
if (side === 'sell') {
|
|
2768
2768
|
request['ordType'] = (type === 'Market') ? 'MarketIfTouched' : 'LimitIfTouched';
|
|
2769
2769
|
}
|
|
@@ -2771,7 +2771,7 @@ class phemex extends phemex$1 {
|
|
|
2771
2771
|
request['ordType'] = (type === 'Market') ? 'Stop' : 'StopLimit';
|
|
2772
2772
|
}
|
|
2773
2773
|
}
|
|
2774
|
-
else if (triggerDirection === 'down') {
|
|
2774
|
+
else if (triggerDirection === 'descending' || triggerDirection === 'down') {
|
|
2775
2775
|
if (side === 'sell') {
|
|
2776
2776
|
request['ordType'] = (type === 'Market') ? 'Stop' : 'StopLimit';
|
|
2777
2777
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var bitstamp$1 = require('../bitstamp.js');
|
|
4
4
|
var errors = require('../base/errors.js');
|
|
5
5
|
var Cache = require('../base/ws/Cache.js');
|
|
6
|
+
var Precise = require('../base/Precise.js');
|
|
6
7
|
|
|
7
8
|
// ----------------------------------------------------------------------------
|
|
8
9
|
// ---------------------------------------------------------------------------
|
|
@@ -306,6 +307,7 @@ class bitstamp extends bitstamp$1 {
|
|
|
306
307
|
// "price_str":"1000.00"
|
|
307
308
|
// },
|
|
308
309
|
// "channel":"private-my_orders_ltcusd-4848701",
|
|
310
|
+
// "event": "order_deleted" // field only present for cancelOrder
|
|
309
311
|
// }
|
|
310
312
|
//
|
|
311
313
|
const channel = this.safeString(message, 'channel');
|
|
@@ -318,29 +320,65 @@ class bitstamp extends bitstamp$1 {
|
|
|
318
320
|
const subscription = this.safeValue(client.subscriptions, channel);
|
|
319
321
|
const symbol = this.safeString(subscription, 'symbol');
|
|
320
322
|
const market = this.market(symbol);
|
|
323
|
+
order['event'] = this.safeString(message, 'event');
|
|
321
324
|
const parsed = this.parseWsOrder(order, market);
|
|
322
325
|
stored.append(parsed);
|
|
323
326
|
client.resolve(this.orders, channel);
|
|
324
327
|
}
|
|
325
328
|
parseWsOrder(order, market = undefined) {
|
|
326
329
|
//
|
|
327
|
-
//
|
|
328
|
-
// "id":"
|
|
329
|
-
// "id_str":"
|
|
330
|
-
// "order_type":
|
|
331
|
-
// "
|
|
332
|
-
// "
|
|
333
|
-
// "
|
|
334
|
-
// "
|
|
335
|
-
// "
|
|
336
|
-
// "
|
|
330
|
+
// {
|
|
331
|
+
// "id": "1894876776091648",
|
|
332
|
+
// "id_str": "1894876776091648",
|
|
333
|
+
// "order_type": 0,
|
|
334
|
+
// "order_subtype": 0,
|
|
335
|
+
// "datetime": "1751451375",
|
|
336
|
+
// "microtimestamp": "1751451375070000",
|
|
337
|
+
// "amount": 1.1,
|
|
338
|
+
// "amount_str": "1.10000000",
|
|
339
|
+
// "amount_traded": "0",
|
|
340
|
+
// "amount_at_create": "1.10000000",
|
|
341
|
+
// "price": 10.23,
|
|
342
|
+
// "price_str": "10.23",
|
|
343
|
+
// "is_liquidation": false,
|
|
344
|
+
// "trade_account_id": 0
|
|
337
345
|
// }
|
|
338
346
|
//
|
|
339
347
|
const id = this.safeString(order, 'id_str');
|
|
340
|
-
const
|
|
348
|
+
const orderTypeRaw = this.safeStringLower(order, 'order_type');
|
|
349
|
+
const side = (orderTypeRaw === '1') ? 'sell' : 'buy';
|
|
350
|
+
const orderSubTypeRaw = this.safeStringLower(order, 'order_subtype'); // https://www.bitstamp.net/websocket/v2/#:~:text=order_subtype
|
|
351
|
+
let orderType = undefined;
|
|
352
|
+
let timeInForce = undefined;
|
|
353
|
+
if (orderSubTypeRaw === '0') {
|
|
354
|
+
orderType = 'limit';
|
|
355
|
+
}
|
|
356
|
+
else if (orderSubTypeRaw === '2') {
|
|
357
|
+
orderType = 'market';
|
|
358
|
+
}
|
|
359
|
+
else if (orderSubTypeRaw === '4') {
|
|
360
|
+
orderType = 'limit';
|
|
361
|
+
timeInForce = 'IOC';
|
|
362
|
+
}
|
|
363
|
+
else if (orderSubTypeRaw === '6') {
|
|
364
|
+
orderType = 'limit';
|
|
365
|
+
timeInForce = 'FOK';
|
|
366
|
+
}
|
|
367
|
+
else if (orderSubTypeRaw === '8') {
|
|
368
|
+
orderType = 'limit';
|
|
369
|
+
timeInForce = 'GTD';
|
|
370
|
+
}
|
|
341
371
|
const price = this.safeString(order, 'price_str');
|
|
342
372
|
const amount = this.safeString(order, 'amount_str');
|
|
343
|
-
const
|
|
373
|
+
const filled = this.safeString(order, 'amount_traded');
|
|
374
|
+
const event = this.safeString(order, 'event');
|
|
375
|
+
let status = undefined;
|
|
376
|
+
if (Precise["default"].stringEq(filled, amount)) {
|
|
377
|
+
status = 'closed';
|
|
378
|
+
}
|
|
379
|
+
else if (event === 'order_deleted') {
|
|
380
|
+
status = 'canceled';
|
|
381
|
+
}
|
|
344
382
|
const timestamp = this.safeTimestamp(order, 'datetime');
|
|
345
383
|
market = this.safeMarket(undefined, market);
|
|
346
384
|
const symbol = market['symbol'];
|
|
@@ -352,8 +390,8 @@ class bitstamp extends bitstamp$1 {
|
|
|
352
390
|
'timestamp': timestamp,
|
|
353
391
|
'datetime': this.iso8601(timestamp),
|
|
354
392
|
'lastTradeTimestamp': undefined,
|
|
355
|
-
'type':
|
|
356
|
-
'timeInForce':
|
|
393
|
+
'type': orderType,
|
|
394
|
+
'timeInForce': timeInForce,
|
|
357
395
|
'postOnly': undefined,
|
|
358
396
|
'side': side,
|
|
359
397
|
'price': price,
|
|
@@ -362,9 +400,9 @@ class bitstamp extends bitstamp$1 {
|
|
|
362
400
|
'amount': amount,
|
|
363
401
|
'cost': undefined,
|
|
364
402
|
'average': undefined,
|
|
365
|
-
'filled':
|
|
403
|
+
'filled': filled,
|
|
366
404
|
'remaining': undefined,
|
|
367
|
-
'status':
|
|
405
|
+
'status': status,
|
|
368
406
|
'fee': undefined,
|
|
369
407
|
'trades': undefined,
|
|
370
408
|
}, market);
|
|
@@ -429,6 +467,7 @@ class bitstamp extends bitstamp$1 {
|
|
|
429
467
|
// "price_str":"1000.00"
|
|
430
468
|
// },
|
|
431
469
|
// "channel":"private-my_orders_ltcusd-4848701",
|
|
470
|
+
// "event": "order_deleted" // field only present for cancelOrder
|
|
432
471
|
// }
|
|
433
472
|
//
|
|
434
473
|
const channel = this.safeString(message, 'channel');
|
|
@@ -2478,7 +2478,8 @@ class bybit extends bybit$1 {
|
|
|
2478
2478
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
2479
2479
|
const unsubHash = messageHashes[j];
|
|
2480
2480
|
const subHash = subMessageHashes[j];
|
|
2481
|
-
|
|
2481
|
+
const usePrefix = (subHash === 'orders') || (subHash === 'myTrades');
|
|
2482
|
+
this.cleanUnsubscription(client, subHash, unsubHash, usePrefix);
|
|
2482
2483
|
}
|
|
2483
2484
|
this.cleanCache(subscription);
|
|
2484
2485
|
}
|
|
@@ -2319,13 +2319,26 @@ class wavesexchange extends wavesexchange$1 {
|
|
|
2319
2319
|
const order1 = this.safeValue(data, 'order1');
|
|
2320
2320
|
const order2 = this.safeValue(data, 'order2');
|
|
2321
2321
|
let order = undefined;
|
|
2322
|
-
//
|
|
2322
|
+
// at first, detect if response is from `fetch_my_trades`
|
|
2323
2323
|
if (this.safeString(order1, 'senderPublicKey') === this.apiKey) {
|
|
2324
2324
|
order = order1;
|
|
2325
2325
|
}
|
|
2326
|
-
else {
|
|
2326
|
+
else if (this.safeString(order2, 'senderPublicKey') === this.apiKey) {
|
|
2327
2327
|
order = order2;
|
|
2328
2328
|
}
|
|
2329
|
+
else {
|
|
2330
|
+
// response is from `fetch_trades`, so find only taker order
|
|
2331
|
+
const date1 = this.safeString(order1, 'timestamp');
|
|
2332
|
+
const date2 = this.safeString(order2, 'timestamp');
|
|
2333
|
+
const ts1 = this.parse8601(date1);
|
|
2334
|
+
const ts2 = this.parse8601(date2);
|
|
2335
|
+
if (ts1 > ts2) {
|
|
2336
|
+
order = order1;
|
|
2337
|
+
}
|
|
2338
|
+
else {
|
|
2339
|
+
order = order2;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2329
2342
|
let symbol = undefined;
|
|
2330
2343
|
const assetPair = this.safeValue(order, 'assetPair');
|
|
2331
2344
|
if (assetPair !== undefined) {
|