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
@@ -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,
@@ -3789,6 +3790,84 @@ class okx extends okx$1 {
3789
3790
  // "uTime": "1621910749815"
3790
3791
  // }
3791
3792
  //
3793
+ // watchOrders & fetchClosedOrders
3794
+ //
3795
+ // {
3796
+ // "algoClOrdId": "",
3797
+ // "algoId": "",
3798
+ // "attachAlgoClOrdId": "",
3799
+ // "attachAlgoOrds": [],
3800
+ // "cancelSource": "",
3801
+ // "cancelSourceReason": "", // not present in WS, but present in fetchClosedOrders
3802
+ // "category": "normal",
3803
+ // "ccy": "", // empty in WS, but eg. `USDT` in fetchClosedOrders
3804
+ // "clOrdId": "",
3805
+ // "cTime": "1751705801423",
3806
+ // "feeCcy": "USDT",
3807
+ // "instId": "LINK-USDT-SWAP",
3808
+ // "instType": "SWAP",
3809
+ // "isTpLimit": "false",
3810
+ // "lever": "3",
3811
+ // "linkedAlgoOrd": { "algoId": "" },
3812
+ // "ordId": "2657625147249614848",
3813
+ // "ordType": "limit",
3814
+ // "posSide": "net",
3815
+ // "px": "13.142",
3816
+ // "pxType": "",
3817
+ // "pxUsd": "",
3818
+ // "pxVol": "",
3819
+ // "quickMgnType": "",
3820
+ // "rebate": "0",
3821
+ // "rebateCcy": "USDT",
3822
+ // "reduceOnly": "true",
3823
+ // "side": "sell",
3824
+ // "slOrdPx": "",
3825
+ // "slTriggerPx": "",
3826
+ // "slTriggerPxType": "",
3827
+ // "source": "",
3828
+ // "stpId": "",
3829
+ // "stpMode": "cancel_maker",
3830
+ // "sz": "0.1",
3831
+ // "tag": "",
3832
+ // "tdMode": "isolated",
3833
+ // "tgtCcy": "",
3834
+ // "tpOrdPx": "",
3835
+ // "tpTriggerPx": "",
3836
+ // "tpTriggerPxType": "",
3837
+ // "uTime": "1751705807467",
3838
+ // "reqId": "", // field present only in WS
3839
+ // "msg": "", // field present only in WS
3840
+ // "amendResult": "", // field present only in WS
3841
+ // "amendSource": "", // field present only in WS
3842
+ // "code": "0", // field present only in WS
3843
+ // "fillFwdPx": "", // field present only in WS
3844
+ // "fillMarkVol": "", // field present only in WS
3845
+ // "fillPxUsd": "", // field present only in WS
3846
+ // "fillPxVol": "", // field present only in WS
3847
+ // "lastPx": "13.142", // field present only in WS
3848
+ // "notionalUsd": "1.314515408", // field present only in WS
3849
+ //
3850
+ // #### 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 ###
3851
+ //
3852
+ // "pnl": "-0.0001",
3853
+ // "accFillSz": "0.1",
3854
+ // "avgPx": "13.142",
3855
+ // "state": "filled",
3856
+ // "fee": "-0.00026284",
3857
+ // "fillPx": "13.142",
3858
+ // "tradeId": "293429690",
3859
+ // "fillSz": "0.1",
3860
+ // "fillTime": "1751705807467",
3861
+ // "fillNotionalUsd": "1.314515408", // field present only in WS
3862
+ // "fillPnl": "-0.0001", // field present only in WS
3863
+ // "fillFee": "-0.00026284", // field present only in WS
3864
+ // "fillFeeCcy": "USDT", // field present only in WS
3865
+ // "execType": "M", // field present only in WS
3866
+ // "fillMarkPx": "13.141", // field present only in WS
3867
+ // "fillIdxPx": "13.147" // field present only in WS
3868
+ // }
3869
+ //
3870
+ //
3792
3871
  // Algo Order fetchOpenOrders, fetchCanceledOrders, fetchClosedOrders
3793
3872
  //
3794
3873
  // {
@@ -7943,6 +8022,83 @@ class okx extends okx$1 {
7943
8022
  }
7944
8023
  return undefined;
7945
8024
  }
8025
+ /**
8026
+ * @method
8027
+ * @name okx#fetchAllGreeks
8028
+ * @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
8029
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
8030
+ * @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
8031
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8032
+ * @param {string} params.uly Underlying, either uly or instFamily is required
8033
+ * @param {string} params.instFamily Instrument family, either uly or instFamily is required
8034
+ * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
8035
+ */
8036
+ async fetchAllGreeks(symbols = undefined, params = {}) {
8037
+ await this.loadMarkets();
8038
+ const request = {};
8039
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
8040
+ let symbolsLength = undefined;
8041
+ if (symbols !== undefined) {
8042
+ symbolsLength = symbols.length;
8043
+ }
8044
+ if ((symbols === undefined) || (symbolsLength !== 1)) {
8045
+ const uly = this.safeString(params, 'uly');
8046
+ if (uly !== undefined) {
8047
+ request['uly'] = uly;
8048
+ }
8049
+ const instFamily = this.safeString(params, 'instFamily');
8050
+ if (instFamily !== undefined) {
8051
+ request['instFamily'] = instFamily;
8052
+ }
8053
+ if ((uly === undefined) && (instFamily === undefined)) {
8054
+ throw new errors.BadRequest(this.id + ' fetchAllGreeks() requires either a uly or instFamily parameter');
8055
+ }
8056
+ }
8057
+ let market = undefined;
8058
+ if (symbols !== undefined) {
8059
+ if (symbolsLength === 1) {
8060
+ market = this.market(symbols[0]);
8061
+ const marketId = market['id'];
8062
+ const optionParts = marketId.split('-');
8063
+ request['uly'] = market['info']['uly'];
8064
+ request['instFamily'] = market['info']['instFamily'];
8065
+ request['expTime'] = this.safeString(optionParts, 2);
8066
+ }
8067
+ }
8068
+ params = this.omit(params, ['uly', 'instFamily']);
8069
+ const response = await this.publicGetPublicOptSummary(this.extend(request, params));
8070
+ //
8071
+ // {
8072
+ // "code": "0",
8073
+ // "data": [
8074
+ // {
8075
+ // "askVol": "0",
8076
+ // "bidVol": "0",
8077
+ // "delta": "0.5105464486882039",
8078
+ // "deltaBS": "0.7325502184143025",
8079
+ // "fwdPx": "37675.80158694987186",
8080
+ // "gamma": "-0.13183515090501083",
8081
+ // "gammaBS": "0.000024139685826358558",
8082
+ // "instId": "BTC-USD-240329-32000-C",
8083
+ // "instType": "OPTION",
8084
+ // "lever": "4.504428015946619",
8085
+ // "markVol": "0.5916253554539876",
8086
+ // "realVol": "0",
8087
+ // "theta": "-0.0004202992014012855",
8088
+ // "thetaBS": "-18.52354631567909",
8089
+ // "ts": "1699586421976",
8090
+ // "uly": "BTC-USD",
8091
+ // "vega": "0.0020207455080045846",
8092
+ // "vegaBS": "74.44022302387287",
8093
+ // "volLv": "0.5948549730405797"
8094
+ // },
8095
+ // ],
8096
+ // "msg": ""
8097
+ // }
8098
+ //
8099
+ const data = this.safeList(response, 'data', []);
8100
+ return this.parseAllGreeks(data, symbols);
8101
+ }
7946
8102
  parseGreeks(greeks, market = undefined) {
7947
8103
  //
7948
8104
  // {
@@ -73,6 +73,7 @@ class paradex extends paradex$1 {
73
73
  'fetchFundingRateHistory': false,
74
74
  'fetchFundingRates': false,
75
75
  'fetchGreeks': true,
76
+ 'fetchAllGreeks': true,
76
77
  'fetchIndexOHLCV': false,
77
78
  'fetchIsolatedBorrowRate': false,
78
79
  'fetchIsolatedBorrowRates': 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
  // {
@@ -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 'up' or 'down' value");
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":"1463471322288128",
329
- // "id_str":"1463471322288128",
330
- // "order_type":1,
331
- // "datetime":"1646127778",
332
- // "microtimestamp":"1646127777950000",
333
- // "amount":0.05,
334
- // "amount_str":"0.05000000",
335
- // "price":1000,
336
- // "price_str":"1000.00"
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 orderType = this.safeStringLower(order, 'order_type');
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 side = (orderType === '1') ? 'sell' : 'buy';
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': undefined,
356
- 'timeInForce': undefined,
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': undefined,
403
+ 'filled': filled,
366
404
  'remaining': undefined,
367
- 'status': undefined,
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
- this.cleanUnsubscription(client, subHash, unsubHash);
2481
+ const usePrefix = (subHash === 'orders') || (subHash === 'myTrades');
2482
+ this.cleanUnsubscription(client, subHash, unsubHash, usePrefix);
2482
2483
  }
2483
2484
  this.cleanCache(subscription);
2484
2485
  }
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.91";
7
+ declare const version = "4.4.92";
8
8
  import alpaca from './src/alpaca.js';
9
9
  import apex from './src/apex.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.4.91';
41
+ const version = '4.4.92';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import alpaca from './src/alpaca.js';
@@ -1441,6 +1441,8 @@ export default class ascendex extends Exchange {
1441
1441
  // "timestamp": 1573576916201
1442
1442
  // }
1443
1443
  //
1444
+ // & linear (fetchClosedOrders)
1445
+ //
1444
1446
  // {
1445
1447
  // "ac": "FUTURES",
1446
1448
  // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
@@ -1448,7 +1450,7 @@ export default class ascendex extends Exchange {
1448
1450
  // "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
1449
1451
  // "seqNum": -1,
1450
1452
  // "orderType": "Limit",
1451
- // "execInst": "NULL_VAL",
1453
+ // "execInst": "NULL_VAL", // NULL_VAL, ReduceOnly , ...
1452
1454
  // "side": "Buy",
1453
1455
  // "symbol": "BTC-PERP",
1454
1456
  // "price": "30000",
@@ -1537,14 +1539,14 @@ export default class ascendex extends Exchange {
1537
1539
  const status = this.parseOrderStatus(this.safeString(order, 'status'));
1538
1540
  const marketId = this.safeString(order, 'symbol');
1539
1541
  const symbol = this.safeSymbol(marketId, market, '/');
1540
- let timestamp = this.safeInteger2(order, 'timestamp', 'sendingTime');
1542
+ let timestamp = this.safeIntegerN(order, ['timestamp', 'sendingTime', 'time']);
1541
1543
  const lastTradeTimestamp = this.safeInteger(order, 'lastExecTime');
1542
1544
  if (timestamp === undefined) {
1543
1545
  timestamp = lastTradeTimestamp;
1544
1546
  }
1545
1547
  const price = this.safeString(order, 'price');
1546
1548
  const amount = this.safeString(order, 'orderQty');
1547
- const average = this.safeString(order, 'avgPx');
1549
+ const average = this.safeString2(order, 'avgPx', 'avgFilledPx');
1548
1550
  const filled = this.safeStringN(order, ['cumFilledQty', 'cumQty', 'fillQty']);
1549
1551
  const id = this.safeString(order, 'orderId');
1550
1552
  let clientOrderId = this.safeString(order, 'id');
@@ -1576,12 +1578,12 @@ export default class ascendex extends Exchange {
1576
1578
  }
1577
1579
  const triggerPrice = this.omitZero(this.safeString(order, 'stopPrice'));
1578
1580
  let reduceOnly = undefined;
1579
- const execInst = this.safeString(order, 'execInst');
1580
- if (execInst === 'reduceOnly') {
1581
+ const execInst = this.safeStringLower(order, 'execInst');
1582
+ if (execInst === 'reduceonly') {
1581
1583
  reduceOnly = true;
1582
1584
  }
1583
1585
  let postOnly = undefined;
1584
- if (execInst === 'Post') {
1586
+ if (execInst === 'post') {
1585
1587
  postOnly = true;
1586
1588
  }
1587
1589
  return this.safeOrder({
@@ -2345,8 +2347,7 @@ export default class ascendex extends Exchange {
2345
2347
  // }
2346
2348
  //
2347
2349
  let data = this.safeList(response, 'data', []);
2348
- const isArray = Array.isArray(data);
2349
- if (!isArray) {
2350
+ if (!Array.isArray(data)) {
2350
2351
  data = this.safeList(data, 'data', []);
2351
2352
  }
2352
2353
  return this.parseOrders(data, market, since, limit);
@@ -764,6 +764,7 @@ export default class Exchange {
764
764
  fetchMyTradesWs(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
765
765
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
766
766
  fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
767
+ fetchAllGreeks(symbols?: Strings, params?: {}): Promise<Greeks[]>;
767
768
  fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
768
769
  fetchOption(symbol: string, params?: {}): Promise<Option>;
769
770
  fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
@@ -889,6 +890,7 @@ export default class Exchange {
889
890
  parseLiquidation(liquidation: any, market?: Market): Liquidation;
890
891
  parseLiquidations(liquidations: Dict[], market?: Market, since?: Int, limit?: Int): Liquidation[];
891
892
  parseGreeks(greeks: Dict, market?: Market): Greeks;
893
+ parseAllGreeks(greeks: any, symbols?: Strings, params?: {}): Greeks[];
892
894
  parseOption(chain: Dict, currency?: Currency, market?: Market): Option;
893
895
  parseOptionChain(response: object[], currencyKey?: Str, symbolKey?: Str): OptionChain;
894
896
  parseMarginModes(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): MarginModes;
@@ -906,7 +908,7 @@ export default class Exchange {
906
908
  parseMarginModifications(response: object[], symbols?: Strings, symbolKey?: Str, marketType?: MarketType): MarginModification[];
907
909
  fetchTransfer(id: string, code?: Str, params?: {}): Promise<TransferEntry>;
908
910
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
909
- cleanUnsubscription(client: any, subHash: string, unsubHash: string): void;
911
+ cleanUnsubscription(client: any, subHash: string, unsubHash: string, subHashIsPrefix?: boolean): void;
910
912
  cleanCache(subscription: Dict): void;
911
913
  }
912
914
  export { Exchange, };
@@ -4006,7 +4006,7 @@ export default class Exchange {
4006
4006
  return this.filterBySinceLimit(sorted, since, limit, 0, tail);
4007
4007
  }
4008
4008
  parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
4009
- // marketIdKey should only be undefined when response is a dictionary
4009
+ // marketIdKey should only be undefined when response is a dictionary.
4010
4010
  symbols = this.marketSymbols(symbols);
4011
4011
  const tiers = {};
4012
4012
  let symbolsLength = 0;
@@ -5444,6 +5444,9 @@ export default class Exchange {
5444
5444
  async fetchGreeks(symbol, params = {}) {
5445
5445
  throw new NotSupported(this.id + ' fetchGreeks() is not supported yet');
5446
5446
  }
5447
+ async fetchAllGreeks(symbols = undefined, params = {}) {
5448
+ throw new NotSupported(this.id + ' fetchAllGreeks() is not supported yet');
5449
+ }
5447
5450
  async fetchOptionChain(code, params = {}) {
5448
5451
  throw new NotSupported(this.id + ' fetchOptionChain() is not supported yet');
5449
5452
  }
@@ -5738,11 +5741,20 @@ export default class Exchange {
5738
5741
  if (precisionNumber === 0) {
5739
5742
  return '1';
5740
5743
  }
5741
- let parsedPrecision = '0.';
5742
- for (let i = 0; i < precisionNumber - 1; i++) {
5743
- parsedPrecision = parsedPrecision + '0';
5744
+ if (precisionNumber > 0) {
5745
+ let parsedPrecision = '0.';
5746
+ for (let i = 0; i < precisionNumber - 1; i++) {
5747
+ parsedPrecision = parsedPrecision + '0';
5748
+ }
5749
+ return parsedPrecision + '1';
5750
+ }
5751
+ else {
5752
+ let parsedPrecision = '1';
5753
+ for (let i = 0; i < precisionNumber * -1 - 1; i++) {
5754
+ parsedPrecision = parsedPrecision + '0';
5755
+ }
5756
+ return parsedPrecision + '0';
5744
5757
  }
5745
- return parsedPrecision + '1';
5746
5758
  }
5747
5759
  integerPrecisionToAmount(precision) {
5748
5760
  /**
@@ -6899,6 +6911,31 @@ export default class Exchange {
6899
6911
  parseGreeks(greeks, market = undefined) {
6900
6912
  throw new NotSupported(this.id + ' parseGreeks () is not supported yet');
6901
6913
  }
6914
+ parseAllGreeks(greeks, symbols = undefined, params = {}) {
6915
+ //
6916
+ // the value of greeks is either a dict or a list
6917
+ //
6918
+ const results = [];
6919
+ if (Array.isArray(greeks)) {
6920
+ for (let i = 0; i < greeks.length; i++) {
6921
+ const parsedTicker = this.parseGreeks(greeks[i]);
6922
+ const greek = this.extend(parsedTicker, params);
6923
+ results.push(greek);
6924
+ }
6925
+ }
6926
+ else {
6927
+ const marketIds = Object.keys(greeks);
6928
+ for (let i = 0; i < marketIds.length; i++) {
6929
+ const marketId = marketIds[i];
6930
+ const market = this.safeMarket(marketId);
6931
+ const parsed = this.parseGreeks(greeks[marketId], market);
6932
+ const greek = this.extend(parsed, params);
6933
+ results.push(greek);
6934
+ }
6935
+ }
6936
+ symbols = this.marketSymbols(symbols);
6937
+ return this.filterByArray(results, 'symbol', symbols);
6938
+ }
6902
6939
  parseOption(chain, currency = undefined, market = undefined) {
6903
6940
  throw new NotSupported(this.id + ' parseOption () is not supported yet');
6904
6941
  }
@@ -7137,16 +7174,35 @@ export default class Exchange {
7137
7174
  */
7138
7175
  throw new NotSupported(this.id + ' fetchTransfers () is not supported yet');
7139
7176
  }
7140
- cleanUnsubscription(client, subHash, unsubHash) {
7177
+ cleanUnsubscription(client, subHash, unsubHash, subHashIsPrefix = false) {
7141
7178
  if (unsubHash in client.subscriptions) {
7142
7179
  delete client.subscriptions[unsubHash];
7143
7180
  }
7144
- if (subHash in client.subscriptions) {
7145
- delete client.subscriptions[subHash];
7181
+ if (!subHashIsPrefix) {
7182
+ if (subHash in client.subscriptions) {
7183
+ delete client.subscriptions[subHash];
7184
+ }
7185
+ if (subHash in client.futures) {
7186
+ const error = new UnsubscribeError(this.id + ' ' + subHash);
7187
+ client.reject(error, subHash);
7188
+ }
7146
7189
  }
7147
- if (subHash in client.futures) {
7148
- const error = new UnsubscribeError(this.id + ' ' + subHash);
7149
- client.reject(error, subHash);
7190
+ else {
7191
+ const clientSubscriptions = Object.keys(client.subscriptions);
7192
+ for (let i = 0; i < clientSubscriptions.length; i++) {
7193
+ const sub = clientSubscriptions[i];
7194
+ if (sub.startsWith(subHash)) {
7195
+ delete client.subscriptions[sub];
7196
+ }
7197
+ }
7198
+ const clientFutures = Object.keys(client.futures);
7199
+ for (let i = 0; i < clientFutures.length; i++) {
7200
+ const future = clientFutures[i];
7201
+ if (future.startsWith(subHash)) {
7202
+ const error = new UnsubscribeError(this.id + ' ' + future);
7203
+ client.reject(error, future);
7204
+ }
7205
+ }
7150
7206
  }
7151
7207
  client.resolve(true, unsubHash);
7152
7208
  }
@@ -1496,6 +1496,16 @@ export default class binance extends Exchange {
1496
1496
  * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
1497
1497
  */
1498
1498
  fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
1499
+ /**
1500
+ * @method
1501
+ * @name binance#fetchAllGreeks
1502
+ * @description fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
1503
+ * @see https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price
1504
+ * @param {string[]} [symbols] unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
1505
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1506
+ * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
1507
+ */
1508
+ fetchAllGreeks(symbols?: Strings, params?: {}): Promise<Greeks[]>;
1499
1509
  parseGreeks(greeks: Dict, market?: Market): Greeks;
1500
1510
  fetchTradingLimits(symbols?: Strings, params?: {}): Promise<Dict>;
1501
1511
  /**