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.
Files changed (53) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ascendex.js +9 -8
  5. package/dist/cjs/src/base/Exchange.js +67 -11
  6. package/dist/cjs/src/binance.js +44 -1
  7. package/dist/cjs/src/bitmex.js +3 -3
  8. package/dist/cjs/src/bybit.js +83 -8
  9. package/dist/cjs/src/coinbaseexchange.js +53 -0
  10. package/dist/cjs/src/coincheck.js +47 -4
  11. package/dist/cjs/src/coinex.js +19 -14
  12. package/dist/cjs/src/cryptomus.js +30 -53
  13. package/dist/cjs/src/deribit.js +6 -6
  14. package/dist/cjs/src/exmo.js +66 -61
  15. package/dist/cjs/src/hyperliquid.js +2 -1
  16. package/dist/cjs/src/kucoin.js +13 -15
  17. package/dist/cjs/src/latoken.js +19 -74
  18. package/dist/cjs/src/lbank.js +2 -2
  19. package/dist/cjs/src/okx.js +156 -0
  20. package/dist/cjs/src/paradex.js +54 -0
  21. package/dist/cjs/src/phemex.js +3 -3
  22. package/dist/cjs/src/pro/bitstamp.js +55 -16
  23. package/dist/cjs/src/pro/bybit.js +2 -1
  24. package/js/ccxt.d.ts +1 -1
  25. package/js/ccxt.js +1 -1
  26. package/js/src/ascendex.js +9 -8
  27. package/js/src/base/Exchange.d.ts +3 -1
  28. package/js/src/base/Exchange.js +67 -11
  29. package/js/src/binance.d.ts +10 -0
  30. package/js/src/binance.js +44 -1
  31. package/js/src/bitmex.d.ts +1 -1
  32. package/js/src/bitmex.js +3 -3
  33. package/js/src/bybit.d.ts +12 -1
  34. package/js/src/bybit.js +83 -8
  35. package/js/src/coinbaseexchange.js +53 -0
  36. package/js/src/coincheck.js +48 -5
  37. package/js/src/coinex.js +16 -13
  38. package/js/src/cryptomus.js +30 -53
  39. package/js/src/deribit.js +6 -6
  40. package/js/src/exmo.js +66 -61
  41. package/js/src/hyperliquid.js +2 -1
  42. package/js/src/kucoin.js +13 -15
  43. package/js/src/latoken.d.ts +0 -1
  44. package/js/src/latoken.js +19 -74
  45. package/js/src/lbank.js +2 -2
  46. package/js/src/okx.d.ts +12 -0
  47. package/js/src/okx.js +156 -0
  48. package/js/src/paradex.d.ts +10 -0
  49. package/js/src/paradex.js +54 -0
  50. package/js/src/phemex.js +3 -3
  51. package/js/src/pro/bitstamp.js +55 -16
  52. package/js/src/pro/bybit.js +2 -1
  53. package/package.json +1 -1
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,
@@ -3792,6 +3793,84 @@ export default class okx extends Exchange {
3792
3793
  // "uTime": "1621910749815"
3793
3794
  // }
3794
3795
  //
3796
+ // watchOrders & fetchClosedOrders
3797
+ //
3798
+ // {
3799
+ // "algoClOrdId": "",
3800
+ // "algoId": "",
3801
+ // "attachAlgoClOrdId": "",
3802
+ // "attachAlgoOrds": [],
3803
+ // "cancelSource": "",
3804
+ // "cancelSourceReason": "", // not present in WS, but present in fetchClosedOrders
3805
+ // "category": "normal",
3806
+ // "ccy": "", // empty in WS, but eg. `USDT` in fetchClosedOrders
3807
+ // "clOrdId": "",
3808
+ // "cTime": "1751705801423",
3809
+ // "feeCcy": "USDT",
3810
+ // "instId": "LINK-USDT-SWAP",
3811
+ // "instType": "SWAP",
3812
+ // "isTpLimit": "false",
3813
+ // "lever": "3",
3814
+ // "linkedAlgoOrd": { "algoId": "" },
3815
+ // "ordId": "2657625147249614848",
3816
+ // "ordType": "limit",
3817
+ // "posSide": "net",
3818
+ // "px": "13.142",
3819
+ // "pxType": "",
3820
+ // "pxUsd": "",
3821
+ // "pxVol": "",
3822
+ // "quickMgnType": "",
3823
+ // "rebate": "0",
3824
+ // "rebateCcy": "USDT",
3825
+ // "reduceOnly": "true",
3826
+ // "side": "sell",
3827
+ // "slOrdPx": "",
3828
+ // "slTriggerPx": "",
3829
+ // "slTriggerPxType": "",
3830
+ // "source": "",
3831
+ // "stpId": "",
3832
+ // "stpMode": "cancel_maker",
3833
+ // "sz": "0.1",
3834
+ // "tag": "",
3835
+ // "tdMode": "isolated",
3836
+ // "tgtCcy": "",
3837
+ // "tpOrdPx": "",
3838
+ // "tpTriggerPx": "",
3839
+ // "tpTriggerPxType": "",
3840
+ // "uTime": "1751705807467",
3841
+ // "reqId": "", // field present only in WS
3842
+ // "msg": "", // field present only in WS
3843
+ // "amendResult": "", // field present only in WS
3844
+ // "amendSource": "", // field present only in WS
3845
+ // "code": "0", // field present only in WS
3846
+ // "fillFwdPx": "", // field present only in WS
3847
+ // "fillMarkVol": "", // field present only in WS
3848
+ // "fillPxUsd": "", // field present only in WS
3849
+ // "fillPxVol": "", // field present only in WS
3850
+ // "lastPx": "13.142", // field present only in WS
3851
+ // "notionalUsd": "1.314515408", // field present only in WS
3852
+ //
3853
+ // #### 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 ###
3854
+ //
3855
+ // "pnl": "-0.0001",
3856
+ // "accFillSz": "0.1",
3857
+ // "avgPx": "13.142",
3858
+ // "state": "filled",
3859
+ // "fee": "-0.00026284",
3860
+ // "fillPx": "13.142",
3861
+ // "tradeId": "293429690",
3862
+ // "fillSz": "0.1",
3863
+ // "fillTime": "1751705807467",
3864
+ // "fillNotionalUsd": "1.314515408", // field present only in WS
3865
+ // "fillPnl": "-0.0001", // field present only in WS
3866
+ // "fillFee": "-0.00026284", // field present only in WS
3867
+ // "fillFeeCcy": "USDT", // field present only in WS
3868
+ // "execType": "M", // field present only in WS
3869
+ // "fillMarkPx": "13.141", // field present only in WS
3870
+ // "fillIdxPx": "13.147" // field present only in WS
3871
+ // }
3872
+ //
3873
+ //
3795
3874
  // Algo Order fetchOpenOrders, fetchCanceledOrders, fetchClosedOrders
3796
3875
  //
3797
3876
  // {
@@ -7946,6 +8025,83 @@ export default class okx extends Exchange {
7946
8025
  }
7947
8026
  return undefined;
7948
8027
  }
8028
+ /**
8029
+ * @method
8030
+ * @name okx#fetchAllGreeks
8031
+ * @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
8032
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
8033
+ * @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
8034
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8035
+ * @param {string} params.uly Underlying, either uly or instFamily is required
8036
+ * @param {string} params.instFamily Instrument family, either uly or instFamily is required
8037
+ * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
8038
+ */
8039
+ async fetchAllGreeks(symbols = undefined, params = {}) {
8040
+ await this.loadMarkets();
8041
+ const request = {};
8042
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
8043
+ let symbolsLength = undefined;
8044
+ if (symbols !== undefined) {
8045
+ symbolsLength = symbols.length;
8046
+ }
8047
+ if ((symbols === undefined) || (symbolsLength !== 1)) {
8048
+ const uly = this.safeString(params, 'uly');
8049
+ if (uly !== undefined) {
8050
+ request['uly'] = uly;
8051
+ }
8052
+ const instFamily = this.safeString(params, 'instFamily');
8053
+ if (instFamily !== undefined) {
8054
+ request['instFamily'] = instFamily;
8055
+ }
8056
+ if ((uly === undefined) && (instFamily === undefined)) {
8057
+ throw new BadRequest(this.id + ' fetchAllGreeks() requires either a uly or instFamily parameter');
8058
+ }
8059
+ }
8060
+ let market = undefined;
8061
+ if (symbols !== undefined) {
8062
+ if (symbolsLength === 1) {
8063
+ market = this.market(symbols[0]);
8064
+ const marketId = market['id'];
8065
+ const optionParts = marketId.split('-');
8066
+ request['uly'] = market['info']['uly'];
8067
+ request['instFamily'] = market['info']['instFamily'];
8068
+ request['expTime'] = this.safeString(optionParts, 2);
8069
+ }
8070
+ }
8071
+ params = this.omit(params, ['uly', 'instFamily']);
8072
+ const response = await this.publicGetPublicOptSummary(this.extend(request, params));
8073
+ //
8074
+ // {
8075
+ // "code": "0",
8076
+ // "data": [
8077
+ // {
8078
+ // "askVol": "0",
8079
+ // "bidVol": "0",
8080
+ // "delta": "0.5105464486882039",
8081
+ // "deltaBS": "0.7325502184143025",
8082
+ // "fwdPx": "37675.80158694987186",
8083
+ // "gamma": "-0.13183515090501083",
8084
+ // "gammaBS": "0.000024139685826358558",
8085
+ // "instId": "BTC-USD-240329-32000-C",
8086
+ // "instType": "OPTION",
8087
+ // "lever": "4.504428015946619",
8088
+ // "markVol": "0.5916253554539876",
8089
+ // "realVol": "0",
8090
+ // "theta": "-0.0004202992014012855",
8091
+ // "thetaBS": "-18.52354631567909",
8092
+ // "ts": "1699586421976",
8093
+ // "uly": "BTC-USD",
8094
+ // "vega": "0.0020207455080045846",
8095
+ // "vegaBS": "74.44022302387287",
8096
+ // "volLv": "0.5948549730405797"
8097
+ // },
8098
+ // ],
8099
+ // "msg": ""
8100
+ // }
8101
+ //
8102
+ const data = this.safeList(response, 'data', []);
8103
+ return this.parseAllGreeks(data, symbols);
8104
+ }
7949
8105
  parseGreeks(greeks, market = undefined) {
7950
8106
  //
7951
8107
  // {
@@ -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
@@ -76,6 +76,7 @@ export default class paradex extends Exchange {
76
76
  'fetchFundingRateHistory': false,
77
77
  'fetchFundingRates': false,
78
78
  'fetchGreeks': true,
79
+ 'fetchAllGreeks': true,
79
80
  'fetchIndexOHLCV': false,
80
81
  'fetchIsolatedBorrowRate': false,
81
82
  'fetchIsolatedBorrowRates': 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 'up' or 'down' value");
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
  }
@@ -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":"1463471322288128",
332
- // "id_str":"1463471322288128",
333
- // "order_type":1,
334
- // "datetime":"1646127778",
335
- // "microtimestamp":"1646127777950000",
336
- // "amount":0.05,
337
- // "amount_str":"0.05000000",
338
- // "price":1000,
339
- // "price_str":"1000.00"
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 orderType = this.safeStringLower(order, 'order_type');
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 side = (orderType === '1') ? 'sell' : 'buy';
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': undefined,
359
- 'timeInForce': undefined,
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': undefined,
406
+ 'filled': filled,
369
407
  'remaining': undefined,
370
- 'status': undefined,
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');
@@ -2481,7 +2481,8 @@ export default class bybit extends bybitRest {
2481
2481
  for (let j = 0; j < messageHashes.length; j++) {
2482
2482
  const unsubHash = messageHashes[j];
2483
2483
  const subHash = subMessageHashes[j];
2484
- this.cleanUnsubscription(client, subHash, unsubHash);
2484
+ const usePrefix = (subHash === 'orders') || (subHash === 'myTrades');
2485
+ this.cleanUnsubscription(client, subHash, unsubHash, usePrefix);
2485
2486
  }
2486
2487
  this.cleanCache(subscription);
2487
2488
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.92",
3
+ "version": "4.4.93",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",