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/js/src/latoken.js
CHANGED
|
@@ -236,6 +236,8 @@ export default class latoken extends Exchange {
|
|
|
236
236
|
'fetchTradingFee': {
|
|
237
237
|
'method': 'fetchPrivateTradingFee', // or 'fetchPublicTradingFee'
|
|
238
238
|
},
|
|
239
|
+
'timeDifference': 0,
|
|
240
|
+
'adjustForTimeDifference': true, // controls the adjustment logic upon instantiation
|
|
239
241
|
},
|
|
240
242
|
'features': {
|
|
241
243
|
'spot': {
|
|
@@ -336,39 +338,6 @@ export default class latoken extends Exchange {
|
|
|
336
338
|
* @returns {object[]} an array of objects representing market data
|
|
337
339
|
*/
|
|
338
340
|
async fetchMarkets(params = {}) {
|
|
339
|
-
const currencies = await this.fetchCurrenciesFromCache(params);
|
|
340
|
-
//
|
|
341
|
-
// [
|
|
342
|
-
// {
|
|
343
|
-
// "id":"1a075819-9e0b-48fc-8784-4dab1d186d6d",
|
|
344
|
-
// "status":"CURRENCY_STATUS_ACTIVE",
|
|
345
|
-
// "type":"CURRENCY_TYPE_ALTERNATIVE", // CURRENCY_TYPE_CRYPTO, CURRENCY_TYPE_IEO
|
|
346
|
-
// "name":"MyCryptoBank",
|
|
347
|
-
// "tag":"MCB",
|
|
348
|
-
// "description":"",
|
|
349
|
-
// "logo":"",
|
|
350
|
-
// "decimals":18,
|
|
351
|
-
// "created":1572912000000,
|
|
352
|
-
// "tier":1,
|
|
353
|
-
// "assetClass":"ASSET_CLASS_UNKNOWN",
|
|
354
|
-
// "minTransferAmount":0
|
|
355
|
-
// },
|
|
356
|
-
// {
|
|
357
|
-
// "id":"db02758e-2507-46a5-a805-7bc60355b3eb",
|
|
358
|
-
// "status":"CURRENCY_STATUS_ACTIVE",
|
|
359
|
-
// "type":"CURRENCY_TYPE_FUTURES_CONTRACT",
|
|
360
|
-
// "name":"BTC USDT Futures Contract",
|
|
361
|
-
// "tag":"BTCUSDT",
|
|
362
|
-
// "description":"",
|
|
363
|
-
// "logo":"",
|
|
364
|
-
// "decimals":8,
|
|
365
|
-
// "created":1589459984395,
|
|
366
|
-
// "tier":1,
|
|
367
|
-
// "assetClass":"ASSET_CLASS_UNKNOWN",
|
|
368
|
-
// "minTransferAmount":0
|
|
369
|
-
// },
|
|
370
|
-
// ]
|
|
371
|
-
//
|
|
372
341
|
const response = await this.publicGetPair(params);
|
|
373
342
|
//
|
|
374
343
|
// [
|
|
@@ -390,9 +359,10 @@ export default class latoken extends Exchange {
|
|
|
390
359
|
// }
|
|
391
360
|
// ]
|
|
392
361
|
//
|
|
393
|
-
if (this.
|
|
362
|
+
if (this.safeBool(this.options, 'adjustForTimeDifference', false)) {
|
|
394
363
|
await this.loadTimeDifference();
|
|
395
364
|
}
|
|
365
|
+
const currencies = this.safeDict(this.options, 'cachedCurrencies', {});
|
|
396
366
|
const currenciesById = this.indexBy(currencies, 'id');
|
|
397
367
|
const result = [];
|
|
398
368
|
for (let i = 0; i < response.length; i++) {
|
|
@@ -401,11 +371,13 @@ export default class latoken extends Exchange {
|
|
|
401
371
|
// the exchange shows them inverted
|
|
402
372
|
const baseId = this.safeString(market, 'baseCurrency');
|
|
403
373
|
const quoteId = this.safeString(market, 'quoteCurrency');
|
|
404
|
-
const baseCurrency = this.
|
|
405
|
-
const quoteCurrency = this.
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
374
|
+
const baseCurrency = this.safeDict(currenciesById, baseId);
|
|
375
|
+
const quoteCurrency = this.safeDict(currenciesById, quoteId);
|
|
376
|
+
const baseCurrencyInfo = this.safeDict(baseCurrency, 'info');
|
|
377
|
+
const quoteCurrencyInfo = this.safeDict(quoteCurrency, 'info');
|
|
378
|
+
if (baseCurrencyInfo !== undefined && quoteCurrencyInfo !== undefined) {
|
|
379
|
+
const base = this.safeCurrencyCode(this.safeString(baseCurrencyInfo, 'tag'));
|
|
380
|
+
const quote = this.safeCurrencyCode(this.safeString(quoteCurrencyInfo, 'tag'));
|
|
409
381
|
const lowercaseQuote = quote.toLowerCase();
|
|
410
382
|
const capitalizedQuote = this.capitalize(lowercaseQuote);
|
|
411
383
|
const status = this.safeString(market, 'status');
|
|
@@ -462,22 +434,6 @@ export default class latoken extends Exchange {
|
|
|
462
434
|
}
|
|
463
435
|
return result;
|
|
464
436
|
}
|
|
465
|
-
async fetchCurrenciesFromCache(params = {}) {
|
|
466
|
-
// this method is now redundant
|
|
467
|
-
// currencies are now fetched before markets
|
|
468
|
-
const options = this.safeValue(this.options, 'fetchCurrencies', {});
|
|
469
|
-
const timestamp = this.safeInteger(options, 'timestamp');
|
|
470
|
-
const expires = this.safeInteger(options, 'expires', 1000);
|
|
471
|
-
const now = this.milliseconds();
|
|
472
|
-
if ((timestamp === undefined) || ((now - timestamp) > expires)) {
|
|
473
|
-
const response = await this.publicGetCurrency(params);
|
|
474
|
-
this.options['fetchCurrencies'] = this.extend(options, {
|
|
475
|
-
'response': response,
|
|
476
|
-
'timestamp': now,
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
return this.safeValue(this.options['fetchCurrencies'], 'response');
|
|
480
|
-
}
|
|
481
437
|
/**
|
|
482
438
|
* @method
|
|
483
439
|
* @name latoken#fetchCurrencies
|
|
@@ -486,7 +442,7 @@ export default class latoken extends Exchange {
|
|
|
486
442
|
* @returns {object} an associative dictionary of currencies
|
|
487
443
|
*/
|
|
488
444
|
async fetchCurrencies(params = {}) {
|
|
489
|
-
const response = await this.
|
|
445
|
+
const response = await this.publicGetCurrency(params);
|
|
490
446
|
//
|
|
491
447
|
// [
|
|
492
448
|
// {
|
|
@@ -525,29 +481,18 @@ export default class latoken extends Exchange {
|
|
|
525
481
|
const id = this.safeString(currency, 'id');
|
|
526
482
|
const tag = this.safeString(currency, 'tag');
|
|
527
483
|
const code = this.safeCurrencyCode(tag);
|
|
528
|
-
const fee = this.safeNumber(currency, 'fee');
|
|
529
484
|
const currencyType = this.safeString(currency, 'type');
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
type = 'other';
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
// CURRENCY_TYPE_CRYPTO and CURRENCY_TYPE_IEO are all cryptos
|
|
536
|
-
type = 'crypto';
|
|
537
|
-
}
|
|
538
|
-
const status = this.safeString(currency, 'status');
|
|
539
|
-
const active = (status === 'CURRENCY_STATUS_ACTIVE');
|
|
540
|
-
const name = this.safeString(currency, 'name');
|
|
541
|
-
result[code] = {
|
|
485
|
+
const isCrypto = (currencyType === 'CURRENCY_TYPE_CRYPTO' || currencyType === 'CURRENCY_TYPE_IEO');
|
|
486
|
+
result[code] = this.safeCurrencyStructure({
|
|
542
487
|
'id': id,
|
|
543
488
|
'code': code,
|
|
544
489
|
'info': currency,
|
|
545
|
-
'name': name,
|
|
546
|
-
'type':
|
|
547
|
-
'active':
|
|
490
|
+
'name': this.safeString(currency, 'name'),
|
|
491
|
+
'type': isCrypto ? 'crypto' : 'other',
|
|
492
|
+
'active': this.safeString(currency, 'status') === 'CURRENCY_STATUS_ACTIVE',
|
|
548
493
|
'deposit': undefined,
|
|
549
494
|
'withdraw': undefined,
|
|
550
|
-
'fee': fee,
|
|
495
|
+
'fee': this.safeNumber(currency, 'fee'),
|
|
551
496
|
'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
|
|
552
497
|
'limits': {
|
|
553
498
|
'amount': {
|
|
@@ -560,7 +505,7 @@ export default class latoken extends Exchange {
|
|
|
560
505
|
},
|
|
561
506
|
},
|
|
562
507
|
'networks': {},
|
|
563
|
-
};
|
|
508
|
+
});
|
|
564
509
|
}
|
|
565
510
|
return result;
|
|
566
511
|
}
|
package/js/src/lbank.js
CHANGED
|
@@ -128,7 +128,7 @@ export default class lbank extends Exchange {
|
|
|
128
128
|
'accuracy': 2.5,
|
|
129
129
|
'usdToCny': 2.5,
|
|
130
130
|
'assetConfigs': 2.5,
|
|
131
|
-
'withdrawConfigs': 2.5,
|
|
131
|
+
'withdrawConfigs': 2.5 * 1.5,
|
|
132
132
|
'timestamp': 2.5,
|
|
133
133
|
'ticker/24hr': 2.5,
|
|
134
134
|
'ticker': 2.5,
|
|
@@ -672,7 +672,7 @@ export default class lbank extends Exchange {
|
|
|
672
672
|
'active': true,
|
|
673
673
|
'contract': true,
|
|
674
674
|
'linear': true,
|
|
675
|
-
'inverse':
|
|
675
|
+
'inverse': false,
|
|
676
676
|
'contractSize': this.safeNumber(market, 'volumeMultiple'),
|
|
677
677
|
'expiry': undefined,
|
|
678
678
|
'expiryDatetime': undefined,
|
package/js/src/okx.d.ts
CHANGED
|
@@ -959,6 +959,18 @@ export default class okx extends Exchange {
|
|
|
959
959
|
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
960
960
|
*/
|
|
961
961
|
fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
|
|
962
|
+
/**
|
|
963
|
+
* @method
|
|
964
|
+
* @name okx#fetchAllGreeks
|
|
965
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
966
|
+
* @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
|
|
967
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
968
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
969
|
+
* @param {string} params.uly Underlying, either uly or instFamily is required
|
|
970
|
+
* @param {string} params.instFamily Instrument family, either uly or instFamily is required
|
|
971
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
972
|
+
*/
|
|
973
|
+
fetchAllGreeks(symbols?: Strings, params?: {}): Promise<Greeks[]>;
|
|
962
974
|
parseGreeks(greeks: Dict, market?: Market): Greeks;
|
|
963
975
|
/**
|
|
964
976
|
* @method
|
package/js/src/okx.js
CHANGED
|
@@ -58,6 +58,7 @@ export default class okx extends Exchange {
|
|
|
58
58
|
'createTriggerOrder': true,
|
|
59
59
|
'editOrder': true,
|
|
60
60
|
'fetchAccounts': true,
|
|
61
|
+
'fetchAllGreeks': true,
|
|
61
62
|
'fetchBalance': true,
|
|
62
63
|
'fetchBidsAsks': undefined,
|
|
63
64
|
'fetchBorrowInterest': true,
|
|
@@ -2603,12 +2604,12 @@ export default class okx extends Exchange {
|
|
|
2603
2604
|
// it may be incorrect to use total, free and used for swap accounts
|
|
2604
2605
|
const eq = this.safeString(balance, 'eq');
|
|
2605
2606
|
const availEq = this.safeString(balance, 'availEq');
|
|
2606
|
-
|
|
2607
|
+
account['total'] = eq;
|
|
2608
|
+
if (availEq === undefined) {
|
|
2607
2609
|
account['free'] = this.safeString(balance, 'availBal');
|
|
2608
2610
|
account['used'] = this.safeString(balance, 'frozenBal');
|
|
2609
2611
|
}
|
|
2610
2612
|
else {
|
|
2611
|
-
account['total'] = eq;
|
|
2612
2613
|
account['free'] = availEq;
|
|
2613
2614
|
}
|
|
2614
2615
|
result[code] = account;
|
|
@@ -2880,7 +2881,7 @@ export default class okx extends Exchange {
|
|
|
2880
2881
|
}
|
|
2881
2882
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
2882
2883
|
const market = this.market(symbol);
|
|
2883
|
-
|
|
2884
|
+
let request = {
|
|
2884
2885
|
'instId': market['id'],
|
|
2885
2886
|
// 'ccy': currency['id'], // only applicable to cross MARGIN orders in single-currency margin
|
|
2886
2887
|
// 'clOrdId': clientOrderId, // up to 32 characters, must be unique
|
|
@@ -3045,7 +3046,8 @@ export default class okx extends Exchange {
|
|
|
3045
3046
|
if (stopLossTriggerPrice === undefined) {
|
|
3046
3047
|
throw new 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');
|
|
3047
3048
|
}
|
|
3048
|
-
|
|
3049
|
+
const slTriggerPx = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
3050
|
+
request['slTriggerPx'] = slTriggerPx;
|
|
3049
3051
|
const stopLossLimitPrice = this.safeValueN(stopLoss, ['price', 'stopLossPrice', 'slOrdPx']);
|
|
3050
3052
|
const stopLossOrderType = this.safeString(stopLoss, 'type');
|
|
3051
3053
|
if (stopLossOrderType !== undefined) {
|
|
@@ -3137,6 +3139,14 @@ export default class okx extends Exchange {
|
|
|
3137
3139
|
if (twoWayCondition) {
|
|
3138
3140
|
request['ordType'] = 'oco';
|
|
3139
3141
|
}
|
|
3142
|
+
if (side === 'sell') {
|
|
3143
|
+
request = this.omit(request, 'tgtCcy');
|
|
3144
|
+
}
|
|
3145
|
+
if (this.safeString(request, 'tdMode') === 'cash') {
|
|
3146
|
+
// for some reason tdMode = cash throws
|
|
3147
|
+
// {"code":"1","data":[{"algoClOrdId":"","algoId":"","clOrdId":"","sCode":"51000","sMsg":"Parameter tdMode error ","tag":""}],"msg":""}
|
|
3148
|
+
request['tdMode'] = marginMode;
|
|
3149
|
+
}
|
|
3140
3150
|
if (takeProfitPrice !== undefined) {
|
|
3141
3151
|
request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
3142
3152
|
let tpOrdPxReq = '-1';
|
|
@@ -3792,6 +3802,84 @@ export default class okx extends Exchange {
|
|
|
3792
3802
|
// "uTime": "1621910749815"
|
|
3793
3803
|
// }
|
|
3794
3804
|
//
|
|
3805
|
+
// watchOrders & fetchClosedOrders
|
|
3806
|
+
//
|
|
3807
|
+
// {
|
|
3808
|
+
// "algoClOrdId": "",
|
|
3809
|
+
// "algoId": "",
|
|
3810
|
+
// "attachAlgoClOrdId": "",
|
|
3811
|
+
// "attachAlgoOrds": [],
|
|
3812
|
+
// "cancelSource": "",
|
|
3813
|
+
// "cancelSourceReason": "", // not present in WS, but present in fetchClosedOrders
|
|
3814
|
+
// "category": "normal",
|
|
3815
|
+
// "ccy": "", // empty in WS, but eg. `USDT` in fetchClosedOrders
|
|
3816
|
+
// "clOrdId": "",
|
|
3817
|
+
// "cTime": "1751705801423",
|
|
3818
|
+
// "feeCcy": "USDT",
|
|
3819
|
+
// "instId": "LINK-USDT-SWAP",
|
|
3820
|
+
// "instType": "SWAP",
|
|
3821
|
+
// "isTpLimit": "false",
|
|
3822
|
+
// "lever": "3",
|
|
3823
|
+
// "linkedAlgoOrd": { "algoId": "" },
|
|
3824
|
+
// "ordId": "2657625147249614848",
|
|
3825
|
+
// "ordType": "limit",
|
|
3826
|
+
// "posSide": "net",
|
|
3827
|
+
// "px": "13.142",
|
|
3828
|
+
// "pxType": "",
|
|
3829
|
+
// "pxUsd": "",
|
|
3830
|
+
// "pxVol": "",
|
|
3831
|
+
// "quickMgnType": "",
|
|
3832
|
+
// "rebate": "0",
|
|
3833
|
+
// "rebateCcy": "USDT",
|
|
3834
|
+
// "reduceOnly": "true",
|
|
3835
|
+
// "side": "sell",
|
|
3836
|
+
// "slOrdPx": "",
|
|
3837
|
+
// "slTriggerPx": "",
|
|
3838
|
+
// "slTriggerPxType": "",
|
|
3839
|
+
// "source": "",
|
|
3840
|
+
// "stpId": "",
|
|
3841
|
+
// "stpMode": "cancel_maker",
|
|
3842
|
+
// "sz": "0.1",
|
|
3843
|
+
// "tag": "",
|
|
3844
|
+
// "tdMode": "isolated",
|
|
3845
|
+
// "tgtCcy": "",
|
|
3846
|
+
// "tpOrdPx": "",
|
|
3847
|
+
// "tpTriggerPx": "",
|
|
3848
|
+
// "tpTriggerPxType": "",
|
|
3849
|
+
// "uTime": "1751705807467",
|
|
3850
|
+
// "reqId": "", // field present only in WS
|
|
3851
|
+
// "msg": "", // field present only in WS
|
|
3852
|
+
// "amendResult": "", // field present only in WS
|
|
3853
|
+
// "amendSource": "", // field present only in WS
|
|
3854
|
+
// "code": "0", // field present only in WS
|
|
3855
|
+
// "fillFwdPx": "", // field present only in WS
|
|
3856
|
+
// "fillMarkVol": "", // field present only in WS
|
|
3857
|
+
// "fillPxUsd": "", // field present only in WS
|
|
3858
|
+
// "fillPxVol": "", // field present only in WS
|
|
3859
|
+
// "lastPx": "13.142", // field present only in WS
|
|
3860
|
+
// "notionalUsd": "1.314515408", // field present only in WS
|
|
3861
|
+
//
|
|
3862
|
+
// #### 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 ###
|
|
3863
|
+
//
|
|
3864
|
+
// "pnl": "-0.0001",
|
|
3865
|
+
// "accFillSz": "0.1",
|
|
3866
|
+
// "avgPx": "13.142",
|
|
3867
|
+
// "state": "filled",
|
|
3868
|
+
// "fee": "-0.00026284",
|
|
3869
|
+
// "fillPx": "13.142",
|
|
3870
|
+
// "tradeId": "293429690",
|
|
3871
|
+
// "fillSz": "0.1",
|
|
3872
|
+
// "fillTime": "1751705807467",
|
|
3873
|
+
// "fillNotionalUsd": "1.314515408", // field present only in WS
|
|
3874
|
+
// "fillPnl": "-0.0001", // field present only in WS
|
|
3875
|
+
// "fillFee": "-0.00026284", // field present only in WS
|
|
3876
|
+
// "fillFeeCcy": "USDT", // field present only in WS
|
|
3877
|
+
// "execType": "M", // field present only in WS
|
|
3878
|
+
// "fillMarkPx": "13.141", // field present only in WS
|
|
3879
|
+
// "fillIdxPx": "13.147" // field present only in WS
|
|
3880
|
+
// }
|
|
3881
|
+
//
|
|
3882
|
+
//
|
|
3795
3883
|
// Algo Order fetchOpenOrders, fetchCanceledOrders, fetchClosedOrders
|
|
3796
3884
|
//
|
|
3797
3885
|
// {
|
|
@@ -7946,6 +8034,83 @@ export default class okx extends Exchange {
|
|
|
7946
8034
|
}
|
|
7947
8035
|
return undefined;
|
|
7948
8036
|
}
|
|
8037
|
+
/**
|
|
8038
|
+
* @method
|
|
8039
|
+
* @name okx#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://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
|
|
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.uly Underlying, either uly or instFamily is required
|
|
8045
|
+
* @param {string} params.instFamily Instrument family, either uly or instFamily is required
|
|
8046
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
8047
|
+
*/
|
|
8048
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
8049
|
+
await this.loadMarkets();
|
|
8050
|
+
const request = {};
|
|
8051
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
8052
|
+
let symbolsLength = undefined;
|
|
8053
|
+
if (symbols !== undefined) {
|
|
8054
|
+
symbolsLength = symbols.length;
|
|
8055
|
+
}
|
|
8056
|
+
if ((symbols === undefined) || (symbolsLength !== 1)) {
|
|
8057
|
+
const uly = this.safeString(params, 'uly');
|
|
8058
|
+
if (uly !== undefined) {
|
|
8059
|
+
request['uly'] = uly;
|
|
8060
|
+
}
|
|
8061
|
+
const instFamily = this.safeString(params, 'instFamily');
|
|
8062
|
+
if (instFamily !== undefined) {
|
|
8063
|
+
request['instFamily'] = instFamily;
|
|
8064
|
+
}
|
|
8065
|
+
if ((uly === undefined) && (instFamily === undefined)) {
|
|
8066
|
+
throw new BadRequest(this.id + ' fetchAllGreeks() requires either a uly or instFamily parameter');
|
|
8067
|
+
}
|
|
8068
|
+
}
|
|
8069
|
+
let market = undefined;
|
|
8070
|
+
if (symbols !== undefined) {
|
|
8071
|
+
if (symbolsLength === 1) {
|
|
8072
|
+
market = this.market(symbols[0]);
|
|
8073
|
+
const marketId = market['id'];
|
|
8074
|
+
const optionParts = marketId.split('-');
|
|
8075
|
+
request['uly'] = market['info']['uly'];
|
|
8076
|
+
request['instFamily'] = market['info']['instFamily'];
|
|
8077
|
+
request['expTime'] = this.safeString(optionParts, 2);
|
|
8078
|
+
}
|
|
8079
|
+
}
|
|
8080
|
+
params = this.omit(params, ['uly', 'instFamily']);
|
|
8081
|
+
const response = await this.publicGetPublicOptSummary(this.extend(request, params));
|
|
8082
|
+
//
|
|
8083
|
+
// {
|
|
8084
|
+
// "code": "0",
|
|
8085
|
+
// "data": [
|
|
8086
|
+
// {
|
|
8087
|
+
// "askVol": "0",
|
|
8088
|
+
// "bidVol": "0",
|
|
8089
|
+
// "delta": "0.5105464486882039",
|
|
8090
|
+
// "deltaBS": "0.7325502184143025",
|
|
8091
|
+
// "fwdPx": "37675.80158694987186",
|
|
8092
|
+
// "gamma": "-0.13183515090501083",
|
|
8093
|
+
// "gammaBS": "0.000024139685826358558",
|
|
8094
|
+
// "instId": "BTC-USD-240329-32000-C",
|
|
8095
|
+
// "instType": "OPTION",
|
|
8096
|
+
// "lever": "4.504428015946619",
|
|
8097
|
+
// "markVol": "0.5916253554539876",
|
|
8098
|
+
// "realVol": "0",
|
|
8099
|
+
// "theta": "-0.0004202992014012855",
|
|
8100
|
+
// "thetaBS": "-18.52354631567909",
|
|
8101
|
+
// "ts": "1699586421976",
|
|
8102
|
+
// "uly": "BTC-USD",
|
|
8103
|
+
// "vega": "0.0020207455080045846",
|
|
8104
|
+
// "vegaBS": "74.44022302387287",
|
|
8105
|
+
// "volLv": "0.5948549730405797"
|
|
8106
|
+
// },
|
|
8107
|
+
// ],
|
|
8108
|
+
// "msg": ""
|
|
8109
|
+
// }
|
|
8110
|
+
//
|
|
8111
|
+
const data = this.safeList(response, 'data', []);
|
|
8112
|
+
return this.parseAllGreeks(data, symbols);
|
|
8113
|
+
}
|
|
7949
8114
|
parseGreeks(greeks, market = undefined) {
|
|
7950
8115
|
//
|
|
7951
8116
|
// {
|
package/js/src/paradex.d.ts
CHANGED
|
@@ -368,6 +368,16 @@ export default class paradex extends Exchange {
|
|
|
368
368
|
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
369
369
|
*/
|
|
370
370
|
fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
|
|
371
|
+
/**
|
|
372
|
+
* @method
|
|
373
|
+
* @name paradex#fetchAllGreeks
|
|
374
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
375
|
+
* @see https://docs.api.testnet.paradex.trade/#list-available-markets-summary
|
|
376
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
377
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
378
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
379
|
+
*/
|
|
380
|
+
fetchAllGreeks(symbols?: Strings, params?: {}): Promise<Greeks[]>;
|
|
371
381
|
parseGreeks(greeks: Dict, market?: Market): Greeks;
|
|
372
382
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
373
383
|
url: string;
|
package/js/src/paradex.js
CHANGED
|
@@ -57,6 +57,7 @@ export default class paradex extends Exchange {
|
|
|
57
57
|
'createTriggerOrder': true,
|
|
58
58
|
'editOrder': false,
|
|
59
59
|
'fetchAccounts': false,
|
|
60
|
+
'fetchAllGreeks': true,
|
|
60
61
|
'fetchBalance': true,
|
|
61
62
|
'fetchBorrowInterest': false,
|
|
62
63
|
'fetchBorrowRateHistories': false,
|
|
@@ -2413,6 +2414,59 @@ export default class paradex extends Exchange {
|
|
|
2413
2414
|
const greeks = this.safeDict(data, 0, {});
|
|
2414
2415
|
return this.parseGreeks(greeks, market);
|
|
2415
2416
|
}
|
|
2417
|
+
/**
|
|
2418
|
+
* @method
|
|
2419
|
+
* @name paradex#fetchAllGreeks
|
|
2420
|
+
* @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
2421
|
+
* @see https://docs.api.testnet.paradex.trade/#list-available-markets-summary
|
|
2422
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
|
2423
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2424
|
+
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
|
|
2425
|
+
*/
|
|
2426
|
+
async fetchAllGreeks(symbols = undefined, params = {}) {
|
|
2427
|
+
await this.loadMarkets();
|
|
2428
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
2429
|
+
const request = {
|
|
2430
|
+
'market': 'ALL',
|
|
2431
|
+
};
|
|
2432
|
+
const response = await this.publicGetMarketsSummary(this.extend(request, params));
|
|
2433
|
+
//
|
|
2434
|
+
// {
|
|
2435
|
+
// "results": [
|
|
2436
|
+
// {
|
|
2437
|
+
// "symbol": "BTC-USD-114000-P",
|
|
2438
|
+
// "mark_price": "10835.66892602",
|
|
2439
|
+
// "mark_iv": "0.71781855",
|
|
2440
|
+
// "delta": "-0.98726024",
|
|
2441
|
+
// "greeks": {
|
|
2442
|
+
// "delta": "-0.9872602390817709",
|
|
2443
|
+
// "gamma": "0.000004560958862297231",
|
|
2444
|
+
// "vega": "227.11344863639806",
|
|
2445
|
+
// "rho": "-302.0617972461581",
|
|
2446
|
+
// "vanna": "0.06609830491614832",
|
|
2447
|
+
// "volga": "925.9501532805552"
|
|
2448
|
+
// },
|
|
2449
|
+
// "last_traded_price": "10551.5",
|
|
2450
|
+
// "bid": "10794.9",
|
|
2451
|
+
// "bid_iv": "0.05",
|
|
2452
|
+
// "ask": "10887.3",
|
|
2453
|
+
// "ask_iv": "0.8783283",
|
|
2454
|
+
// "last_iv": "0.05",
|
|
2455
|
+
// "volume_24h": "0",
|
|
2456
|
+
// "total_volume": "195240.72672261014",
|
|
2457
|
+
// "created_at": 1747644009995,
|
|
2458
|
+
// "underlying_price": "103164.79162649",
|
|
2459
|
+
// "open_interest": "0",
|
|
2460
|
+
// "funding_rate": "0.000004464241170536191",
|
|
2461
|
+
// "price_change_rate_24h": "0.074915",
|
|
2462
|
+
// "future_funding_rate": "0.0001"
|
|
2463
|
+
// }
|
|
2464
|
+
// ]
|
|
2465
|
+
// }
|
|
2466
|
+
//
|
|
2467
|
+
const results = this.safeList(response, 'results', []);
|
|
2468
|
+
return this.parseAllGreeks(results, symbols);
|
|
2469
|
+
}
|
|
2416
2470
|
parseGreeks(greeks, market = undefined) {
|
|
2417
2471
|
//
|
|
2418
2472
|
// {
|
package/js/src/phemex.js
CHANGED
|
@@ -2763,10 +2763,10 @@ export default class phemex extends Exchange {
|
|
|
2763
2763
|
let triggerDirection = undefined;
|
|
2764
2764
|
[triggerDirection, params] = this.handleParamString(params, 'triggerDirection');
|
|
2765
2765
|
if (triggerDirection === undefined) {
|
|
2766
|
-
throw new ArgumentsRequired(this.id + " createOrder() also requires a 'triggerDirection' parameter with either '
|
|
2766
|
+
throw new ArgumentsRequired(this.id + " createOrder() also requires a 'triggerDirection' parameter with either 'ascending' or 'descending' value");
|
|
2767
2767
|
}
|
|
2768
2768
|
// the flow defined per https://phemex-docs.github.io/#more-order-type-examples
|
|
2769
|
-
if (triggerDirection === 'up') {
|
|
2769
|
+
if (triggerDirection === 'ascending' || triggerDirection === 'up') {
|
|
2770
2770
|
if (side === 'sell') {
|
|
2771
2771
|
request['ordType'] = (type === 'Market') ? 'MarketIfTouched' : 'LimitIfTouched';
|
|
2772
2772
|
}
|
|
@@ -2774,7 +2774,7 @@ export default class phemex extends Exchange {
|
|
|
2774
2774
|
request['ordType'] = (type === 'Market') ? 'Stop' : 'StopLimit';
|
|
2775
2775
|
}
|
|
2776
2776
|
}
|
|
2777
|
-
else if (triggerDirection === 'down') {
|
|
2777
|
+
else if (triggerDirection === 'descending' || triggerDirection === 'down') {
|
|
2778
2778
|
if (side === 'sell') {
|
|
2779
2779
|
request['ordType'] = (type === 'Market') ? 'Stop' : 'StopLimit';
|
|
2780
2780
|
}
|
package/js/src/pro/bitstamp.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import bitstampRest from '../bitstamp.js';
|
|
9
9
|
import { ArgumentsRequired, AuthenticationError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
|
|
11
|
+
import { Precise } from '../base/Precise.js';
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
export default class bitstamp extends bitstampRest {
|
|
13
14
|
describe() {
|
|
@@ -309,6 +310,7 @@ export default class bitstamp extends bitstampRest {
|
|
|
309
310
|
// "price_str":"1000.00"
|
|
310
311
|
// },
|
|
311
312
|
// "channel":"private-my_orders_ltcusd-4848701",
|
|
313
|
+
// "event": "order_deleted" // field only present for cancelOrder
|
|
312
314
|
// }
|
|
313
315
|
//
|
|
314
316
|
const channel = this.safeString(message, 'channel');
|
|
@@ -321,29 +323,65 @@ export default class bitstamp extends bitstampRest {
|
|
|
321
323
|
const subscription = this.safeValue(client.subscriptions, channel);
|
|
322
324
|
const symbol = this.safeString(subscription, 'symbol');
|
|
323
325
|
const market = this.market(symbol);
|
|
326
|
+
order['event'] = this.safeString(message, 'event');
|
|
324
327
|
const parsed = this.parseWsOrder(order, market);
|
|
325
328
|
stored.append(parsed);
|
|
326
329
|
client.resolve(this.orders, channel);
|
|
327
330
|
}
|
|
328
331
|
parseWsOrder(order, market = undefined) {
|
|
329
332
|
//
|
|
330
|
-
//
|
|
331
|
-
// "id":"
|
|
332
|
-
// "id_str":"
|
|
333
|
-
// "order_type":
|
|
334
|
-
// "
|
|
335
|
-
// "
|
|
336
|
-
// "
|
|
337
|
-
// "
|
|
338
|
-
// "
|
|
339
|
-
// "
|
|
333
|
+
// {
|
|
334
|
+
// "id": "1894876776091648",
|
|
335
|
+
// "id_str": "1894876776091648",
|
|
336
|
+
// "order_type": 0,
|
|
337
|
+
// "order_subtype": 0,
|
|
338
|
+
// "datetime": "1751451375",
|
|
339
|
+
// "microtimestamp": "1751451375070000",
|
|
340
|
+
// "amount": 1.1,
|
|
341
|
+
// "amount_str": "1.10000000",
|
|
342
|
+
// "amount_traded": "0",
|
|
343
|
+
// "amount_at_create": "1.10000000",
|
|
344
|
+
// "price": 10.23,
|
|
345
|
+
// "price_str": "10.23",
|
|
346
|
+
// "is_liquidation": false,
|
|
347
|
+
// "trade_account_id": 0
|
|
340
348
|
// }
|
|
341
349
|
//
|
|
342
350
|
const id = this.safeString(order, 'id_str');
|
|
343
|
-
const
|
|
351
|
+
const orderTypeRaw = this.safeStringLower(order, 'order_type');
|
|
352
|
+
const side = (orderTypeRaw === '1') ? 'sell' : 'buy';
|
|
353
|
+
const orderSubTypeRaw = this.safeStringLower(order, 'order_subtype'); // https://www.bitstamp.net/websocket/v2/#:~:text=order_subtype
|
|
354
|
+
let orderType = undefined;
|
|
355
|
+
let timeInForce = undefined;
|
|
356
|
+
if (orderSubTypeRaw === '0') {
|
|
357
|
+
orderType = 'limit';
|
|
358
|
+
}
|
|
359
|
+
else if (orderSubTypeRaw === '2') {
|
|
360
|
+
orderType = 'market';
|
|
361
|
+
}
|
|
362
|
+
else if (orderSubTypeRaw === '4') {
|
|
363
|
+
orderType = 'limit';
|
|
364
|
+
timeInForce = 'IOC';
|
|
365
|
+
}
|
|
366
|
+
else if (orderSubTypeRaw === '6') {
|
|
367
|
+
orderType = 'limit';
|
|
368
|
+
timeInForce = 'FOK';
|
|
369
|
+
}
|
|
370
|
+
else if (orderSubTypeRaw === '8') {
|
|
371
|
+
orderType = 'limit';
|
|
372
|
+
timeInForce = 'GTD';
|
|
373
|
+
}
|
|
344
374
|
const price = this.safeString(order, 'price_str');
|
|
345
375
|
const amount = this.safeString(order, 'amount_str');
|
|
346
|
-
const
|
|
376
|
+
const filled = this.safeString(order, 'amount_traded');
|
|
377
|
+
const event = this.safeString(order, 'event');
|
|
378
|
+
let status = undefined;
|
|
379
|
+
if (Precise.stringEq(filled, amount)) {
|
|
380
|
+
status = 'closed';
|
|
381
|
+
}
|
|
382
|
+
else if (event === 'order_deleted') {
|
|
383
|
+
status = 'canceled';
|
|
384
|
+
}
|
|
347
385
|
const timestamp = this.safeTimestamp(order, 'datetime');
|
|
348
386
|
market = this.safeMarket(undefined, market);
|
|
349
387
|
const symbol = market['symbol'];
|
|
@@ -355,8 +393,8 @@ export default class bitstamp extends bitstampRest {
|
|
|
355
393
|
'timestamp': timestamp,
|
|
356
394
|
'datetime': this.iso8601(timestamp),
|
|
357
395
|
'lastTradeTimestamp': undefined,
|
|
358
|
-
'type':
|
|
359
|
-
'timeInForce':
|
|
396
|
+
'type': orderType,
|
|
397
|
+
'timeInForce': timeInForce,
|
|
360
398
|
'postOnly': undefined,
|
|
361
399
|
'side': side,
|
|
362
400
|
'price': price,
|
|
@@ -365,9 +403,9 @@ export default class bitstamp extends bitstampRest {
|
|
|
365
403
|
'amount': amount,
|
|
366
404
|
'cost': undefined,
|
|
367
405
|
'average': undefined,
|
|
368
|
-
'filled':
|
|
406
|
+
'filled': filled,
|
|
369
407
|
'remaining': undefined,
|
|
370
|
-
'status':
|
|
408
|
+
'status': status,
|
|
371
409
|
'fee': undefined,
|
|
372
410
|
'trades': undefined,
|
|
373
411
|
}, market);
|
|
@@ -432,6 +470,7 @@ export default class bitstamp extends bitstampRest {
|
|
|
432
470
|
// "price_str":"1000.00"
|
|
433
471
|
// },
|
|
434
472
|
// "channel":"private-my_orders_ltcusd-4848701",
|
|
473
|
+
// "event": "order_deleted" // field only present for cancelOrder
|
|
435
474
|
// }
|
|
436
475
|
//
|
|
437
476
|
const channel = this.safeString(message, 'channel');
|