ccxt 4.1.48 → 4.1.50

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 (43) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.js +1134 -216
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +76 -0
  7. package/dist/cjs/src/bybit.js +121 -0
  8. package/dist/cjs/src/coinex.js +67 -18
  9. package/dist/cjs/src/cryptocom.js +1 -0
  10. package/dist/cjs/src/delta.js +149 -0
  11. package/dist/cjs/src/deribit.js +132 -0
  12. package/dist/cjs/src/gate.js +102 -4
  13. package/dist/cjs/src/htx.js +313 -135
  14. package/dist/cjs/src/mexc.js +21 -21
  15. package/dist/cjs/src/okx.js +108 -0
  16. package/js/ccxt.d.ts +3 -3
  17. package/js/ccxt.js +1 -1
  18. package/js/src/abstract/htx.d.ts +1 -1
  19. package/js/src/abstract/huobi.d.ts +1 -1
  20. package/js/src/abstract/huobi.js +3 -3
  21. package/js/src/abstract/huobipro.d.ts +1 -1
  22. package/js/src/base/Exchange.d.ts +4 -2
  23. package/js/src/base/Exchange.js +6 -0
  24. package/js/src/base/types.d.ts +21 -0
  25. package/js/src/binance.d.ts +23 -1
  26. package/js/src/binance.js +76 -0
  27. package/js/src/bybit.d.ts +23 -1
  28. package/js/src/bybit.js +121 -0
  29. package/js/src/coinex.js +67 -18
  30. package/js/src/cryptocom.js +1 -0
  31. package/js/src/delta.d.ts +23 -1
  32. package/js/src/delta.js +149 -0
  33. package/js/src/deribit.d.ts +23 -1
  34. package/js/src/deribit.js +132 -0
  35. package/js/src/gate.d.ts +23 -1
  36. package/js/src/gate.js +102 -4
  37. package/js/src/htx.d.ts +4 -3
  38. package/js/src/htx.js +313 -135
  39. package/js/src/mexc.js +21 -21
  40. package/js/src/okx.d.ts +23 -1
  41. package/js/src/okx.js +108 -0
  42. package/package.json +1 -1
  43. package/skip-tests.json +2 -0
@@ -10193,6 +10193,9 @@ class Exchange {
10193
10193
  async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
10194
10194
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOHLCVWs() is not supported yet');
10195
10195
  }
10196
+ async fetchGreeks(symbol, params = {}) {
10197
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchGreeks() is not supported yet');
10198
+ }
10196
10199
  async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
10197
10200
  /**
10198
10201
  * @method
@@ -11353,6 +11356,9 @@ class Exchange {
11353
11356
  const symbol = this.safeString(market, 'symbol');
11354
11357
  return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
11355
11358
  }
11359
+ parseGreeks(greeks, market = undefined) {
11360
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseGreeks () is not supported yet');
11361
+ }
11356
11362
  }
11357
11363
 
11358
11364
 
@@ -16582,6 +16588,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16582
16588
  'fetchFundingRate': true,
16583
16589
  'fetchFundingRateHistory': true,
16584
16590
  'fetchFundingRates': true,
16591
+ 'fetchGreeks': true,
16585
16592
  'fetchIndexOHLCV': true,
16586
16593
  'fetchL3OrderBook': false,
16587
16594
  'fetchLastPrices': true,
@@ -26055,6 +26062,81 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26055
26062
  'datetime': this.iso8601(timestamp),
26056
26063
  });
26057
26064
  }
26065
+ async fetchGreeks(symbol, params = {}) {
26066
+ /**
26067
+ * @method
26068
+ * @name binance#fetchGreeks
26069
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
26070
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#option-mark-price
26071
+ * @param {string} symbol unified symbol of the market to fetch greeks for
26072
+ * @param {object} [params] extra parameters specific to the binance api endpoint
26073
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
26074
+ */
26075
+ await this.loadMarkets();
26076
+ const market = this.market(symbol);
26077
+ const request = {
26078
+ 'symbol': market['id'],
26079
+ };
26080
+ const response = await this.eapiPublicGetMark(this.extend(request, params));
26081
+ //
26082
+ // [
26083
+ // {
26084
+ // "symbol": "BTC-231229-40000-C",
26085
+ // "markPrice": "2012",
26086
+ // "bidIV": "0.60236275",
26087
+ // "askIV": "0.62267244",
26088
+ // "markIV": "0.6125176",
26089
+ // "delta": "0.39111646",
26090
+ // "theta": "-32.13948531",
26091
+ // "gamma": "0.00004656",
26092
+ // "vega": "51.70062218",
26093
+ // "highPriceLimit": "6474",
26094
+ // "lowPriceLimit": "5"
26095
+ // }
26096
+ // ]
26097
+ //
26098
+ return this.parseGreeks(response[0], market);
26099
+ }
26100
+ parseGreeks(greeks, market = undefined) {
26101
+ //
26102
+ // {
26103
+ // "symbol": "BTC-231229-40000-C",
26104
+ // "markPrice": "2012",
26105
+ // "bidIV": "0.60236275",
26106
+ // "askIV": "0.62267244",
26107
+ // "markIV": "0.6125176",
26108
+ // "delta": "0.39111646",
26109
+ // "theta": "-32.13948531",
26110
+ // "gamma": "0.00004656",
26111
+ // "vega": "51.70062218",
26112
+ // "highPriceLimit": "6474",
26113
+ // "lowPriceLimit": "5"
26114
+ // }
26115
+ //
26116
+ const marketId = this.safeString(greeks, 'symbol');
26117
+ const symbol = this.safeSymbol(marketId, market);
26118
+ return {
26119
+ 'symbol': symbol,
26120
+ 'timestamp': undefined,
26121
+ 'datetime': undefined,
26122
+ 'delta': this.safeNumber(greeks, 'delta'),
26123
+ 'gamma': this.safeNumber(greeks, 'gamma'),
26124
+ 'theta': this.safeNumber(greeks, 'theta'),
26125
+ 'vega': this.safeNumber(greeks, 'vega'),
26126
+ 'rho': undefined,
26127
+ 'bidSize': undefined,
26128
+ 'askSize': undefined,
26129
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bidIV'),
26130
+ 'askImpliedVolatility': this.safeNumber(greeks, 'askIV'),
26131
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markIV'),
26132
+ 'bidPrice': undefined,
26133
+ 'askPrice': undefined,
26134
+ 'markPrice': this.safeNumber(greeks, 'markPrice'),
26135
+ 'lastPrice': undefined,
26136
+ 'underlyingPrice': undefined,
26137
+ 'info': greeks,
26138
+ };
26139
+ }
26058
26140
  }
26059
26141
 
26060
26142
 
@@ -74707,6 +74789,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
74707
74789
  'fetchFundingRate': true,
74708
74790
  'fetchFundingRateHistory': true,
74709
74791
  'fetchFundingRates': true,
74792
+ 'fetchGreeks': true,
74710
74793
  'fetchIndexOHLCV': true,
74711
74794
  'fetchLedger': true,
74712
74795
  'fetchMarketLeverageTiers': true,
@@ -81916,6 +81999,126 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81916
81999
  }
81917
82000
  return result;
81918
82001
  }
82002
+ async fetchGreeks(symbol, params = {}) {
82003
+ /**
82004
+ * @method
82005
+ * @name bybit#fetchGreeks
82006
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
82007
+ * @see https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers
82008
+ * @param {string} symbol unified symbol of the market to fetch greeks for
82009
+ * @param {object} [params] extra parameters specific to the bybit api endpoint
82010
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
82011
+ */
82012
+ await this.loadMarkets();
82013
+ const market = this.market(symbol);
82014
+ const request = {
82015
+ 'symbol': market['id'],
82016
+ 'category': 'option',
82017
+ };
82018
+ const response = await this.publicGetV5MarketTickers(this.extend(request, params));
82019
+ //
82020
+ // {
82021
+ // "retCode": 0,
82022
+ // "retMsg": "SUCCESS",
82023
+ // "result": {
82024
+ // "category": "option",
82025
+ // "list": [
82026
+ // {
82027
+ // "symbol": "BTC-26JAN24-39000-C",
82028
+ // "bid1Price": "3205",
82029
+ // "bid1Size": "7.1",
82030
+ // "bid1Iv": "0.5478",
82031
+ // "ask1Price": "3315",
82032
+ // "ask1Size": "1.98",
82033
+ // "ask1Iv": "0.5638",
82034
+ // "lastPrice": "3230",
82035
+ // "highPrice24h": "3255",
82036
+ // "lowPrice24h": "3200",
82037
+ // "markPrice": "3273.02263032",
82038
+ // "indexPrice": "36790.96",
82039
+ // "markIv": "0.5577",
82040
+ // "underlyingPrice": "37649.67254894",
82041
+ // "openInterest": "19.67",
82042
+ // "turnover24h": "170140.33875912",
82043
+ // "volume24h": "4.56",
82044
+ // "totalVolume": "22",
82045
+ // "totalTurnover": "789305",
82046
+ // "delta": "0.49640971",
82047
+ // "gamma": "0.00004131",
82048
+ // "vega": "69.08651675",
82049
+ // "theta": "-24.9443226",
82050
+ // "predictedDeliveryPrice": "0",
82051
+ // "change24h": "0.18532111"
82052
+ // }
82053
+ // ]
82054
+ // },
82055
+ // "retExtInfo": {},
82056
+ // "time": 1699584008326
82057
+ // }
82058
+ //
82059
+ const timestamp = this.safeInteger(response, 'time');
82060
+ const result = this.safeValue(response, 'result', {});
82061
+ const data = this.safeValue(result, 'list', []);
82062
+ const greeks = this.parseGreeks(data[0], market);
82063
+ return this.extend(greeks, {
82064
+ 'timestamp': timestamp,
82065
+ 'datetime': this.iso8601(timestamp),
82066
+ });
82067
+ }
82068
+ parseGreeks(greeks, market = undefined) {
82069
+ //
82070
+ // {
82071
+ // "symbol": "BTC-26JAN24-39000-C",
82072
+ // "bid1Price": "3205",
82073
+ // "bid1Size": "7.1",
82074
+ // "bid1Iv": "0.5478",
82075
+ // "ask1Price": "3315",
82076
+ // "ask1Size": "1.98",
82077
+ // "ask1Iv": "0.5638",
82078
+ // "lastPrice": "3230",
82079
+ // "highPrice24h": "3255",
82080
+ // "lowPrice24h": "3200",
82081
+ // "markPrice": "3273.02263032",
82082
+ // "indexPrice": "36790.96",
82083
+ // "markIv": "0.5577",
82084
+ // "underlyingPrice": "37649.67254894",
82085
+ // "openInterest": "19.67",
82086
+ // "turnover24h": "170140.33875912",
82087
+ // "volume24h": "4.56",
82088
+ // "totalVolume": "22",
82089
+ // "totalTurnover": "789305",
82090
+ // "delta": "0.49640971",
82091
+ // "gamma": "0.00004131",
82092
+ // "vega": "69.08651675",
82093
+ // "theta": "-24.9443226",
82094
+ // "predictedDeliveryPrice": "0",
82095
+ // "change24h": "0.18532111"
82096
+ // }
82097
+ //
82098
+ const marketId = this.safeString(greeks, 'symbol');
82099
+ const symbol = this.safeSymbol(marketId, market);
82100
+ return {
82101
+ 'symbol': symbol,
82102
+ 'timestamp': undefined,
82103
+ 'datetime': undefined,
82104
+ 'delta': this.safeNumber(greeks, 'delta'),
82105
+ 'gamma': this.safeNumber(greeks, 'gamma'),
82106
+ 'theta': this.safeNumber(greeks, 'theta'),
82107
+ 'vega': this.safeNumber(greeks, 'vega'),
82108
+ 'rho': undefined,
82109
+ 'bidSize': this.safeNumber(greeks, 'bid1Size'),
82110
+ 'askSize': this.safeNumber(greeks, 'ask1Size'),
82111
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid1Iv'),
82112
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask1Iv'),
82113
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markIv'),
82114
+ 'bidPrice': this.safeNumber(greeks, 'bid1Price'),
82115
+ 'askPrice': this.safeNumber(greeks, 'ask1Price'),
82116
+ 'markPrice': this.safeNumber(greeks, 'markPrice'),
82117
+ 'lastPrice': this.safeNumber(greeks, 'lastPrice'),
82118
+ 'underlyingPrice': this.safeNumber(greeks, 'underlyingPrice'),
82119
+ 'info': greeks,
82120
+ };
82121
+ }
81919
82122
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
81920
82123
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
81921
82124
  if (api === 'public') {
@@ -89534,8 +89737,8 @@ class coincheck extends _abstract_coincheck_js__WEBPACK_IMPORTED_MODULE_0__/* ["
89534
89737
  /* harmony export */ "Z": () => (/* binding */ coinex)
89535
89738
  /* harmony export */ });
89536
89739
  /* harmony import */ var _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8519);
89537
- /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6689);
89538
- /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2194);
89740
+ /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
89741
+ /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
89539
89742
  /* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9292);
89540
89743
  /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1372);
89541
89744
  /* harmony import */ var _static_dependencies_noble_hashes_md5_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7311);
@@ -89821,6 +90024,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
89821
90024
  },
89822
90025
  },
89823
90026
  'options': {
90027
+ 'brokerId': 'x-167673045',
89824
90028
  'createMarketBuyOrderRequiresPrice': true,
89825
90029
  'defaultType': 'spot',
89826
90030
  'defaultSubType': 'linear',
@@ -89840,6 +90044,26 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
89840
90044
  'ACM': 'Actinium',
89841
90045
  },
89842
90046
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TICK_SIZE */ .sh,
90047
+ 'exceptions': {
90048
+ 'exact': {
90049
+ // https://github.com/coinexcom/coinex_exchange_api/wiki/013error_code
90050
+ '23': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
90051
+ '24': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
90052
+ '25': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
90053
+ '34': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
90054
+ '35': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeNotAvailable,
90055
+ '36': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RequestTimeout,
90056
+ '213': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded,
90057
+ '107': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
90058
+ '600': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
90059
+ '601': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
90060
+ '602': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
90061
+ '606': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
90062
+ },
90063
+ 'broad': {
90064
+ 'ip not allow visit': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
90065
+ },
90066
+ },
89843
90067
  });
89844
90068
  }
89845
90069
  async fetchCurrencies(params = {}) {
@@ -89912,7 +90136,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
89912
90136
  }
89913
90137
  let minFeeString = this.safeString(result[code], 'fee');
89914
90138
  if (feeString !== undefined) {
89915
- minFeeString = (minFeeString === undefined) ? feeString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringMin */ .O.stringMin(feeString, minFeeString);
90139
+ minFeeString = (minFeeString === undefined) ? feeString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMin */ .O.stringMin(feeString, minFeeString);
89916
90140
  }
89917
90141
  let depositAvailable = this.safeValue(result[code], 'deposit');
89918
90142
  depositAvailable = (canDeposit) ? canDeposit : depositAvailable;
@@ -89920,15 +90144,15 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
89920
90144
  withdrawAvailable = (canWithdraw) ? canWithdraw : withdrawAvailable;
89921
90145
  let minDepositString = this.safeString(result[code]['limits']['deposit'], 'min');
89922
90146
  if (minNetworkDepositString !== undefined) {
89923
- minDepositString = (minDepositString === undefined) ? minNetworkDepositString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringMin */ .O.stringMin(minNetworkDepositString, minDepositString);
90147
+ minDepositString = (minDepositString === undefined) ? minNetworkDepositString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMin */ .O.stringMin(minNetworkDepositString, minDepositString);
89924
90148
  }
89925
90149
  let minWithdrawString = this.safeString(result[code]['limits']['withdraw'], 'min');
89926
90150
  if (minNetworkWithdrawString !== undefined) {
89927
- minWithdrawString = (minWithdrawString === undefined) ? minNetworkWithdrawString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringMin */ .O.stringMin(minNetworkWithdrawString, minWithdrawString);
90151
+ minWithdrawString = (minWithdrawString === undefined) ? minNetworkWithdrawString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMin */ .O.stringMin(minNetworkWithdrawString, minWithdrawString);
89928
90152
  }
89929
90153
  let minPrecisionString = this.safeString(result[code], 'precision');
89930
90154
  if (precisionString !== undefined) {
89931
- minPrecisionString = (minPrecisionString === undefined) ? precisionString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringMin */ .O.stringMin(precisionString, minPrecisionString);
90155
+ minPrecisionString = (minPrecisionString === undefined) ? precisionString : _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMin */ .O.stringMin(precisionString, minPrecisionString);
89932
90156
  }
89933
90157
  const networks = this.safeValue(result[code], 'networks', {});
89934
90158
  const network = {
@@ -90834,7 +91058,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90834
91058
  marketId = market['id'];
90835
91059
  }
90836
91060
  else if (marketId === undefined) {
90837
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchMarginBalance() fetching a margin account requires a market parameter or a symbol parameter');
91061
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMarginBalance() fetching a margin account requires a market parameter or a symbol parameter');
90838
91062
  }
90839
91063
  params = this.omit(params, ['symbol', 'market']);
90840
91064
  const request = {
@@ -90890,7 +91114,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90890
91114
  sellAccount['total'] = this.safeString(total, 'sell_type');
90891
91115
  const sellDebt = this.safeString(loan, 'sell_type');
90892
91116
  const sellInterest = this.safeString(interest, 'sell_type');
90893
- sellAccount['debt'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringAdd */ .O.stringAdd(sellDebt, sellInterest);
91117
+ sellAccount['debt'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(sellDebt, sellInterest);
90894
91118
  result[sellCurrencyCode] = sellAccount;
90895
91119
  //
90896
91120
  const buyAccount = this.account();
@@ -90900,7 +91124,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90900
91124
  buyAccount['total'] = this.safeString(total, 'buy_type');
90901
91125
  const buyDebt = this.safeString(loan, 'buy_type');
90902
91126
  const buyInterest = this.safeString(interest, 'buy_type');
90903
- buyAccount['debt'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringAdd */ .O.stringAdd(buyDebt, buyInterest);
91127
+ buyAccount['debt'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(buyDebt, buyInterest);
90904
91128
  result[buyCurrencyCode] = buyAccount;
90905
91129
  //
90906
91130
  return this.safeBalance(result);
@@ -91009,7 +91233,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91009
91233
  account['free'] = this.safeString(balance, 'available');
91010
91234
  const frozen = this.safeString(balance, 'frozen');
91011
91235
  const locked = this.safeString(balance, 'lock');
91012
- account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringAdd */ .O.stringAdd(frozen, locked);
91236
+ account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(frozen, locked);
91013
91237
  result[code] = account;
91014
91238
  }
91015
91239
  return this.safeBalance(result);
@@ -91077,6 +91301,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91077
91301
  // "status": "done",
91078
91302
  // "taker_fee_rate": "0.0005",
91079
91303
  // "type": "sell",
91304
+ // "client_id": "",
91080
91305
  // }
91081
91306
  //
91082
91307
  // Spot and Margin createOrder, cancelOrder, fetchOrder
@@ -91104,6 +91329,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91104
91329
  // "stock_fee":"0",
91105
91330
  // "taker_fee_rate":"0.002",
91106
91331
  // "type":"buy"
91332
+ // "client_id": "",
91107
91333
  // }
91108
91334
  //
91109
91335
  // Swap createOrder, cancelOrder, fetchOrder
@@ -91319,9 +91545,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91319
91545
  else {
91320
91546
  type = rawType;
91321
91547
  }
91548
+ let clientOrderId = this.safeString(order, 'client_id');
91549
+ if (clientOrderId === '') {
91550
+ clientOrderId = undefined;
91551
+ }
91322
91552
  return this.safeOrder({
91323
91553
  'id': this.safeString2(order, 'id', 'order_id'),
91324
- 'clientOrderId': undefined,
91554
+ 'clientOrderId': clientOrderId,
91325
91555
  'datetime': this.iso8601(timestamp),
91326
91556
  'timestamp': timestamp,
91327
91557
  'lastTradeTimestamp': this.safeTimestamp(order, 'update_time'),
@@ -91378,6 +91608,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91378
91608
  await this.loadMarkets();
91379
91609
  const market = this.market(symbol);
91380
91610
  const swap = market['swap'];
91611
+ const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
91381
91612
  const stopPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
91382
91613
  const stopLossPrice = this.safeValue(params, 'stopLossPrice');
91383
91614
  const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
@@ -91389,21 +91620,29 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91389
91620
  const reduceOnly = this.safeValue(params, 'reduceOnly');
91390
91621
  if (reduceOnly) {
91391
91622
  if (market['type'] !== 'swap') {
91392
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only');
91623
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only');
91393
91624
  }
91394
91625
  if (positionId === undefined) {
91395
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders');
91626
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders');
91396
91627
  }
91397
91628
  }
91398
91629
  let method = undefined;
91399
91630
  const request = {
91400
91631
  'market': market['id'],
91401
91632
  };
91633
+ if (clientOrderId === undefined) {
91634
+ const defaultId = 'x-167673045';
91635
+ const brokerId = this.safeString(this.options, 'brokerId', defaultId);
91636
+ request['client_id'] = brokerId + '-' + this.uuid16();
91637
+ }
91638
+ else {
91639
+ request['client_id'] = clientOrderId;
91640
+ }
91402
91641
  if (swap) {
91403
91642
  if (stopLossPrice || takeProfitPrice) {
91404
91643
  request['stop_type'] = this.safeInteger(params, 'stop_type', 1); // 1: triggered by the latest transaction, 2: mark price, 3: index price
91405
91644
  if (positionId === undefined) {
91406
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' createOrder() requires a position_id parameter for stop loss and take profit orders');
91645
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires a position_id parameter for stop loss and take profit orders');
91407
91646
  }
91408
91647
  request['position_id'] = positionId;
91409
91648
  if (stopLossPrice) {
@@ -91479,12 +91718,12 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91479
91718
  if ((type === 'market') && (side === 'buy')) {
91480
91719
  if (this.options['createMarketBuyOrderRequiresPrice']) {
91481
91720
  if (price === undefined) {
91482
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InvalidOrder(this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false to supply the cost in the amount argument (the exchange-specific behaviour)");
91721
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false to supply the cost in the amount argument (the exchange-specific behaviour)");
91483
91722
  }
91484
91723
  else {
91485
91724
  const amountString = this.amountToPrecision(symbol, amount);
91486
91725
  const priceString = this.priceToPrecision(symbol, price);
91487
- const costString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringMul */ .O.stringMul(amountString, priceString);
91726
+ const costString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(amountString, priceString);
91488
91727
  const costNumber = this.parseNumber(costString);
91489
91728
  request['amount'] = this.costToPrecision(symbol, costNumber);
91490
91729
  }
@@ -91512,7 +91751,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91512
91751
  // following options cannot be applied to vanilla market orders (but can be applied to stop-market orders)
91513
91752
  if ((timeInForceRaw !== undefined) || postOnly) {
91514
91753
  if ((postOnly || (timeInForceRaw !== 'IOC')) && ((type === 'limit') && (stopPrice !== undefined))) {
91515
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InvalidOrder(this.id + ' createOrder() only supports the IOC option for stop-limit orders');
91754
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() only supports the IOC option for stop-limit orders');
91516
91755
  }
91517
91756
  if (postOnly) {
91518
91757
  request['option'] = 'MAKER_ONLY';
@@ -91529,7 +91768,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91529
91768
  const defaultType = this.safeString(this.options, 'defaultType');
91530
91769
  if (defaultType === 'margin') {
91531
91770
  if (accountId === undefined) {
91532
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' createOrder() requires an account_id parameter for margin orders');
91771
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder() requires an account_id parameter for margin orders');
91533
91772
  }
91534
91773
  request['account_id'] = accountId;
91535
91774
  }
@@ -91634,7 +91873,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91634
91873
  await this.loadMarkets();
91635
91874
  const market = this.market(symbol);
91636
91875
  if (!market['spot']) {
91637
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' editOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted');
91876
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' editOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted');
91638
91877
  }
91639
91878
  const request = {
91640
91879
  'market': market['id'],
@@ -91713,7 +91952,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91713
91952
  const defaultType = this.safeString(this.options, 'defaultType');
91714
91953
  if (defaultType === 'margin') {
91715
91954
  if (accountId === undefined) {
91716
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' cancelOrder() requires an account_id parameter for margin orders');
91955
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' cancelOrder() requires an account_id parameter for margin orders');
91717
91956
  }
91718
91957
  request['account_id'] = accountId;
91719
91958
  }
@@ -92028,7 +92267,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92028
92267
  let method = undefined;
92029
92268
  if (marketType === 'swap') {
92030
92269
  if (symbol === undefined) {
92031
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchOrdersByStatus() requires a symbol argument for swap markets');
92270
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrdersByStatus() requires a symbol argument for swap markets');
92032
92271
  }
92033
92272
  method = 'perpetualPrivateGetOrder' + this.capitalize(status);
92034
92273
  if (stop) {
@@ -92053,7 +92292,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92053
92292
  const defaultType = this.safeString(this.options, 'defaultType');
92054
92293
  if (defaultType === 'margin') {
92055
92294
  if (accountId === undefined) {
92056
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
92295
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
92057
92296
  }
92058
92297
  request['account_id'] = accountId;
92059
92298
  }
@@ -92293,10 +92532,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92293
92532
  const numOfNetworks = networksKeys.length;
92294
92533
  if (networks !== undefined && numOfNetworks > 1) {
92295
92534
  if (network === undefined) {
92296
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchDepositAddress() ' + code + ' requires a network parameter');
92535
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchDepositAddress() ' + code + ' requires a network parameter');
92297
92536
  }
92298
92537
  if (!(network in networks)) {
92299
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code);
92538
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code);
92300
92539
  }
92301
92540
  }
92302
92541
  if (network !== undefined) {
@@ -92397,7 +92636,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92397
92636
  let type = undefined;
92398
92637
  [type, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
92399
92638
  if (type !== 'spot' && symbol === undefined) {
92400
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument for non-spot markets');
92639
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument for non-spot markets');
92401
92640
  }
92402
92641
  const swap = (type === 'swap');
92403
92642
  let method = undefined;
@@ -92405,7 +92644,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92405
92644
  method = 'perpetualPublicGetMarketUserDeals';
92406
92645
  const side = this.safeInteger(params, 'side');
92407
92646
  if (side === undefined) {
92408
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a side parameter for swap markets');
92647
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a side parameter for swap markets');
92409
92648
  }
92410
92649
  if (since !== undefined) {
92411
92650
  request['start_time'] = since;
@@ -92421,7 +92660,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92421
92660
  const defaultType = this.safeString(this.options, 'defaultType');
92422
92661
  if (defaultType === 'margin') {
92423
92662
  if (accountId === undefined) {
92424
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
92663
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
92425
92664
  }
92426
92665
  request['account_id'] = accountId;
92427
92666
  params = this.omit(params, 'account_id');
@@ -92522,7 +92761,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92522
92761
  if (Array.isArray(symbols)) {
92523
92762
  const symbolsLength = symbols.length;
92524
92763
  if (symbolsLength > 1) {
92525
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' fetchPositions() symbols argument cannot contain more than 1 symbol');
92764
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchPositions() symbols argument cannot contain more than 1 symbol');
92526
92765
  }
92527
92766
  symbol = symbols[0];
92528
92767
  }
@@ -92791,12 +93030,12 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92791
93030
  this.checkRequiredSymbol('setMarginMode', symbol);
92792
93031
  marginMode = marginMode.toLowerCase();
92793
93032
  if (marginMode !== 'isolated' && marginMode !== 'cross') {
92794
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' setMarginMode() marginMode argument should be isolated or cross');
93033
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setMarginMode() marginMode argument should be isolated or cross');
92795
93034
  }
92796
93035
  await this.loadMarkets();
92797
93036
  const market = this.market(symbol);
92798
93037
  if (market['type'] !== 'swap') {
92799
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadSymbol(this.id + ' setMarginMode() supports swap contracts only');
93038
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' setMarginMode() supports swap contracts only');
92800
93039
  }
92801
93040
  let defaultPositionType = undefined;
92802
93041
  if (marginMode === 'isolated') {
@@ -92809,13 +93048,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92809
93048
  const maxLeverage = this.safeInteger(market['limits']['leverage'], 'max', 100);
92810
93049
  const positionType = this.safeInteger(params, 'position_type', defaultPositionType);
92811
93050
  if (leverage === undefined) {
92812
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' setMarginMode() requires a leverage parameter');
93051
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' setMarginMode() requires a leverage parameter');
92813
93052
  }
92814
93053
  if (positionType === undefined) {
92815
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' setMarginMode() requires a position_type parameter that will transfer margin to the specified trading pair');
93054
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' setMarginMode() requires a position_type parameter that will transfer margin to the specified trading pair');
92816
93055
  }
92817
93056
  if ((leverage < 3) || (leverage > maxLeverage)) {
92818
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' setMarginMode() leverage should be between 3 and ' + maxLeverage.toString() + ' for ' + symbol);
93057
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setMarginMode() leverage should be between 3 and ' + maxLeverage.toString() + ' for ' + symbol);
92819
93058
  }
92820
93059
  const request = {
92821
93060
  'market': market['id'],
@@ -92840,7 +93079,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92840
93079
  await this.loadMarkets();
92841
93080
  const market = this.market(symbol);
92842
93081
  if (!market['swap']) {
92843
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadSymbol(this.id + ' setLeverage() supports swap contracts only');
93082
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' setLeverage() supports swap contracts only');
92844
93083
  }
92845
93084
  let marginMode = undefined;
92846
93085
  [marginMode, params] = this.handleMarginModeAndParams('setLeverage', params, 'cross');
@@ -92854,7 +93093,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
92854
93093
  const minLeverage = this.safeInteger(market['limits']['leverage'], 'min', 1);
92855
93094
  const maxLeverage = this.safeInteger(market['limits']['leverage'], 'max', 100);
92856
93095
  if ((leverage < minLeverage) || (leverage > maxLeverage)) {
92857
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' setLeverage() leverage should be between ' + minLeverage.toString() + ' and ' + maxLeverage.toString() + ' for ' + symbol);
93096
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setLeverage() leverage should be between ' + minLeverage.toString() + ' and ' + maxLeverage.toString() + ' for ' + symbol);
92858
93097
  }
92859
93098
  const request = {
92860
93099
  'market': market['id'],
@@ -93136,7 +93375,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93136
93375
  await this.loadMarkets();
93137
93376
  const market = this.market(symbol);
93138
93377
  if (!market['swap']) {
93139
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
93378
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
93140
93379
  }
93141
93380
  const request = {
93142
93381
  'market': market['id'],
@@ -93248,7 +93487,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93248
93487
  const symbol = this.safeValue(symbols, 0);
93249
93488
  market = this.market(symbol);
93250
93489
  if (!market['swap']) {
93251
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.BadSymbol(this.id + ' fetchFundingRates() supports swap contracts only');
93490
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchFundingRates() supports swap contracts only');
93252
93491
  }
93253
93492
  }
93254
93493
  const response = await this.perpetualPublicGetMarketTickerAll(params);
@@ -94074,7 +94313,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
94074
94313
  const timestamp = this.safeTimestamp(info, 'expire_time');
94075
94314
  const unflatAmount = this.safeString(info, 'unflat_amount');
94076
94315
  const loanAmount = this.safeString(info, 'loan_amount');
94077
- let interest = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringSub */ .O.stringSub(unflatAmount, loanAmount);
94316
+ let interest = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(unflatAmount, loanAmount);
94078
94317
  if (unflatAmount === '0') {
94079
94318
  interest = undefined;
94080
94319
  }
@@ -94300,6 +94539,32 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
94300
94539
  let url = this.urls['api'][api] + '/' + this.version + '/' + path;
94301
94540
  let query = this.omit(params, this.extractParams(path));
94302
94541
  const nonce = this.nonce().toString();
94542
+ if (method === 'POST') {
94543
+ const parts = path.split('/');
94544
+ const firstPart = this.safeString(parts, 0, '');
94545
+ const numParts = parts.length;
94546
+ const lastPart = this.safeString(parts, numParts - 1, '');
94547
+ const lastWords = lastPart.split('_');
94548
+ const numWords = lastWords.length;
94549
+ const lastWord = this.safeString(lastWords, numWords - 1, '');
94550
+ if ((firstPart === 'order') && (lastWord === 'limit' || lastWord === 'market')) {
94551
+ // inject in implicit API calls
94552
+ // POST /order/limit - Place limit orders
94553
+ // POST /order/market - Place market orders
94554
+ // POST /order/stop/limit - Place stop limit orders
94555
+ // POST /order/stop/market - Place stop market orders
94556
+ // POST /perpetual/v1/order/put_limit - Place limit orders
94557
+ // POST /perpetual/v1/order/put_market - Place market orders
94558
+ // POST /perpetual/v1/order/put_stop_limit - Place stop limit orders
94559
+ // POST /perpetual/v1/order/put_stop_market - Place stop market orders
94560
+ const clientOrderId = this.safeString(params, 'client_id');
94561
+ if (clientOrderId === undefined) {
94562
+ const defaultId = 'x-167673045';
94563
+ const brokerId = this.safeValue(this.options, 'brokerId', defaultId);
94564
+ query['client_id'] = brokerId + '_' + this.uuid16();
94565
+ }
94566
+ }
94567
+ }
94303
94568
  if (api === 'perpetualPrivate' || url === 'https://api.coinex.com/perpetual/v1/market/user_deals') {
94304
94569
  this.checkRequiredCredentials();
94305
94570
  query = this.extend({
@@ -94356,23 +94621,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
94356
94621
  const data = this.safeValue(response, 'data');
94357
94622
  const message = this.safeString(response, 'message');
94358
94623
  if ((code !== '0') || ((message !== 'Success') && (message !== 'Succeeded') && (message !== 'Ok') && !data)) {
94359
- const responseCodes = {
94360
- // https://github.com/coinexcom/coinex_exchange_api/wiki/013error_code
94361
- '23': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.PermissionDenied,
94362
- '24': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.AuthenticationError,
94363
- '25': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.AuthenticationError,
94364
- '34': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.AuthenticationError,
94365
- '35': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeNotAvailable,
94366
- '36': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.RequestTimeout,
94367
- '213': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.RateLimitExceeded,
94368
- '107': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InsufficientFunds,
94369
- '600': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.OrderNotFound,
94370
- '601': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InvalidOrder,
94371
- '602': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InvalidOrder,
94372
- '606': _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.InvalidOrder,
94373
- };
94374
- const ErrorClass = this.safeValue(responseCodes, code, _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError);
94375
- throw new ErrorClass(response['message']);
94624
+ const feedback = this.id + ' ' + message;
94625
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
94626
+ this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
94627
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(feedback);
94376
94628
  }
94377
94629
  return undefined;
94378
94630
  }
@@ -102226,6 +102478,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
102226
102478
  'fetchFundingRate': false,
102227
102479
  'fetchFundingRateHistory': true,
102228
102480
  'fetchFundingRates': false,
102481
+ 'fetchGreeks': false,
102229
102482
  'fetchIndexOHLCV': false,
102230
102483
  'fetchLedger': true,
102231
102484
  'fetchLeverage': false,
@@ -107513,6 +107766,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
107513
107766
  'fetchFundingRate': true,
107514
107767
  'fetchFundingRateHistory': false,
107515
107768
  'fetchFundingRates': true,
107769
+ 'fetchGreeks': true,
107516
107770
  'fetchIndexOHLCV': true,
107517
107771
  'fetchLedger': true,
107518
107772
  'fetchLeverage': true,
@@ -110489,6 +110743,154 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
110489
110743
  }
110490
110744
  return result;
110491
110745
  }
110746
+ async fetchGreeks(symbol, params = {}) {
110747
+ /**
110748
+ * @method
110749
+ * @name delta#fetchGreeks
110750
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
110751
+ * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
110752
+ * @param {string} symbol unified symbol of the market to fetch greeks for
110753
+ * @param {object} [params] extra parameters specific to the delta api endpoint
110754
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
110755
+ */
110756
+ await this.loadMarkets();
110757
+ const market = this.market(symbol);
110758
+ const request = {
110759
+ 'symbol': market['id'],
110760
+ };
110761
+ const response = await this.publicGetTickersSymbol(this.extend(request, params));
110762
+ //
110763
+ // {
110764
+ // "result": {
110765
+ // "close": 6793.0,
110766
+ // "contract_type": "call_options",
110767
+ // "greeks": {
110768
+ // "delta": "0.94739174",
110769
+ // "gamma": "0.00002206",
110770
+ // "rho": "11.00890725",
110771
+ // "spot": "36839.58124652",
110772
+ // "theta": "-18.18365310",
110773
+ // "vega": "7.85209698"
110774
+ // },
110775
+ // "high": 7556.0,
110776
+ // "low": 6793.0,
110777
+ // "mark_price": "6955.70698909",
110778
+ // "mark_vol": "0.66916863",
110779
+ // "oi": "1.8980",
110780
+ // "oi_change_usd_6h": "110.4600",
110781
+ // "oi_contracts": "1898",
110782
+ // "oi_value": "1.8980",
110783
+ // "oi_value_symbol": "BTC",
110784
+ // "oi_value_usd": "69940.7319",
110785
+ // "open": 7.2e3,
110786
+ // "price_band": {
110787
+ // "lower_limit": "5533.89814767",
110788
+ // "upper_limit": "11691.37688371"
110789
+ // },
110790
+ // "product_id": 129508,
110791
+ // "quotes": {
110792
+ // "ask_iv": "0.90180438",
110793
+ // "ask_size": "1898",
110794
+ // "best_ask": "7210",
110795
+ // "best_bid": "6913",
110796
+ // "bid_iv": "0.60881706",
110797
+ // "bid_size": "3163",
110798
+ // "impact_mid_price": null,
110799
+ // "mark_iv": "0.66973549"
110800
+ // },
110801
+ // "size": 5,
110802
+ // "spot_price": "36839.58153868",
110803
+ // "strike_price": "30000",
110804
+ // "symbol": "C-BTC-30000-241123",
110805
+ // "timestamp": 1699584998504530,
110806
+ // "turnover": 184.41206804,
110807
+ // "turnover_symbol": "USDT",
110808
+ // "turnover_usd": 184.41206804,
110809
+ // "volume": 0.005
110810
+ // },
110811
+ // "success": true
110812
+ // }
110813
+ //
110814
+ const result = this.safeValue(response, 'result', {});
110815
+ return this.parseGreeks(result, market);
110816
+ }
110817
+ parseGreeks(greeks, market = undefined) {
110818
+ //
110819
+ // {
110820
+ // "close": 6793.0,
110821
+ // "contract_type": "call_options",
110822
+ // "greeks": {
110823
+ // "delta": "0.94739174",
110824
+ // "gamma": "0.00002206",
110825
+ // "rho": "11.00890725",
110826
+ // "spot": "36839.58124652",
110827
+ // "theta": "-18.18365310",
110828
+ // "vega": "7.85209698"
110829
+ // },
110830
+ // "high": 7556.0,
110831
+ // "low": 6793.0,
110832
+ // "mark_price": "6955.70698909",
110833
+ // "mark_vol": "0.66916863",
110834
+ // "oi": "1.8980",
110835
+ // "oi_change_usd_6h": "110.4600",
110836
+ // "oi_contracts": "1898",
110837
+ // "oi_value": "1.8980",
110838
+ // "oi_value_symbol": "BTC",
110839
+ // "oi_value_usd": "69940.7319",
110840
+ // "open": 7.2e3,
110841
+ // "price_band": {
110842
+ // "lower_limit": "5533.89814767",
110843
+ // "upper_limit": "11691.37688371"
110844
+ // },
110845
+ // "product_id": 129508,
110846
+ // "quotes": {
110847
+ // "ask_iv": "0.90180438",
110848
+ // "ask_size": "1898",
110849
+ // "best_ask": "7210",
110850
+ // "best_bid": "6913",
110851
+ // "bid_iv": "0.60881706",
110852
+ // "bid_size": "3163",
110853
+ // "impact_mid_price": null,
110854
+ // "mark_iv": "0.66973549"
110855
+ // },
110856
+ // "size": 5,
110857
+ // "spot_price": "36839.58153868",
110858
+ // "strike_price": "30000",
110859
+ // "symbol": "C-BTC-30000-241123",
110860
+ // "timestamp": 1699584998504530,
110861
+ // "turnover": 184.41206804,
110862
+ // "turnover_symbol": "USDT",
110863
+ // "turnover_usd": 184.41206804,
110864
+ // "volume": 0.005
110865
+ // }
110866
+ //
110867
+ const timestamp = this.safeIntegerProduct(greeks, 'timestamp', 0.001);
110868
+ const marketId = this.safeString(greeks, 'symbol');
110869
+ const symbol = this.safeSymbol(marketId, market);
110870
+ const stats = this.safeValue(greeks, 'greeks', {});
110871
+ const quotes = this.safeValue(greeks, 'quotes', {});
110872
+ return {
110873
+ 'symbol': symbol,
110874
+ 'timestamp': timestamp,
110875
+ 'datetime': this.iso8601(timestamp),
110876
+ 'delta': this.safeNumber(stats, 'delta'),
110877
+ 'gamma': this.safeNumber(stats, 'gamma'),
110878
+ 'theta': this.safeNumber(stats, 'theta'),
110879
+ 'vega': this.safeNumber(stats, 'vega'),
110880
+ 'rho': this.safeNumber(stats, 'rho'),
110881
+ 'bidSize': this.safeNumber(quotes, 'bid_size'),
110882
+ 'askSize': this.safeNumber(quotes, 'ask_size'),
110883
+ 'bidImpliedVolatility': this.safeNumber(quotes, 'bid_iv'),
110884
+ 'askImpliedVolatility': this.safeNumber(quotes, 'ask_iv'),
110885
+ 'markImpliedVolatility': this.safeNumber(quotes, 'mark_iv'),
110886
+ 'bidPrice': this.safeNumber(quotes, 'best_bid'),
110887
+ 'askPrice': this.safeNumber(quotes, 'best_ask'),
110888
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
110889
+ 'lastPrice': undefined,
110890
+ 'underlyingPrice': this.safeNumber(greeks, 'spot_price'),
110891
+ 'info': greeks,
110892
+ };
110893
+ }
110492
110894
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
110493
110895
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
110494
110896
  let url = this.urls['api'][api] + requestPath;
@@ -110612,6 +111014,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
110612
111014
  'fetchDepositWithdrawFees': true,
110613
111015
  'fetchFundingRate': true,
110614
111016
  'fetchFundingRateHistory': true,
111017
+ 'fetchGreeks': true,
110615
111018
  'fetchIndexOHLCV': false,
110616
111019
  'fetchLeverageTiers': false,
110617
111020
  'fetchLiquidations': true,
@@ -113635,6 +114038,137 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
113635
114038
  'datetime': this.iso8601(timestamp),
113636
114039
  });
113637
114040
  }
114041
+ async fetchGreeks(symbol, params = {}) {
114042
+ /**
114043
+ * @method
114044
+ * @name deribit#fetchGreeks
114045
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
114046
+ * @see https://docs.deribit.com/#public-ticker
114047
+ * @param {string} symbol unified symbol of the market to fetch greeks for
114048
+ * @param {object} [params] extra parameters specific to the deribit api endpoint
114049
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
114050
+ */
114051
+ await this.loadMarkets();
114052
+ const market = this.market(symbol);
114053
+ const request = {
114054
+ 'instrument_name': market['id'],
114055
+ };
114056
+ const response = await this.publicGetTicker(this.extend(request, params));
114057
+ //
114058
+ // {
114059
+ // "jsonrpc": "2.0",
114060
+ // "result": {
114061
+ // "estimated_delivery_price": 36552.72,
114062
+ // "best_bid_amount": 0.2,
114063
+ // "best_ask_amount": 9.1,
114064
+ // "interest_rate": 0.0,
114065
+ // "best_bid_price": 0.214,
114066
+ // "best_ask_price": 0.219,
114067
+ // "open_interest": 368.8,
114068
+ // "settlement_price": 0.22103022,
114069
+ // "last_price": 0.215,
114070
+ // "bid_iv": 60.51,
114071
+ // "ask_iv": 61.88,
114072
+ // "mark_iv": 61.27,
114073
+ // "underlying_index": "BTC-27SEP24",
114074
+ // "underlying_price": 38992.71,
114075
+ // "min_price": 0.1515,
114076
+ // "max_price": 0.326,
114077
+ // "mark_price": 0.2168,
114078
+ // "instrument_name": "BTC-27SEP24-40000-C",
114079
+ // "index_price": 36552.72,
114080
+ // "greeks": {
114081
+ // "rho": 130.63998,
114082
+ // "theta": -13.48784,
114083
+ // "vega": 141.90146,
114084
+ // "gamma": 0.00002,
114085
+ // "delta": 0.59621
114086
+ // },
114087
+ // "stats": {
114088
+ // "volume_usd": 100453.9,
114089
+ // "volume": 12.0,
114090
+ // "price_change": -2.2727,
114091
+ // "low": 0.2065,
114092
+ // "high": 0.238
114093
+ // },
114094
+ // "state": "open",
114095
+ // "timestamp": 1699578548021
114096
+ // },
114097
+ // "usIn": 1699578548308414,
114098
+ // "usOut": 1699578548308606,
114099
+ // "usDiff": 192,
114100
+ // "testnet": false
114101
+ // }
114102
+ //
114103
+ const result = this.safeValue(response, 'result', {});
114104
+ return this.parseGreeks(result, market);
114105
+ }
114106
+ parseGreeks(greeks, market = undefined) {
114107
+ //
114108
+ // {
114109
+ // "estimated_delivery_price": 36552.72,
114110
+ // "best_bid_amount": 0.2,
114111
+ // "best_ask_amount": 9.1,
114112
+ // "interest_rate": 0.0,
114113
+ // "best_bid_price": 0.214,
114114
+ // "best_ask_price": 0.219,
114115
+ // "open_interest": 368.8,
114116
+ // "settlement_price": 0.22103022,
114117
+ // "last_price": 0.215,
114118
+ // "bid_iv": 60.51,
114119
+ // "ask_iv": 61.88,
114120
+ // "mark_iv": 61.27,
114121
+ // "underlying_index": "BTC-27SEP24",
114122
+ // "underlying_price": 38992.71,
114123
+ // "min_price": 0.1515,
114124
+ // "max_price": 0.326,
114125
+ // "mark_price": 0.2168,
114126
+ // "instrument_name": "BTC-27SEP24-40000-C",
114127
+ // "index_price": 36552.72,
114128
+ // "greeks": {
114129
+ // "rho": 130.63998,
114130
+ // "theta": -13.48784,
114131
+ // "vega": 141.90146,
114132
+ // "gamma": 0.00002,
114133
+ // "delta": 0.59621
114134
+ // },
114135
+ // "stats": {
114136
+ // "volume_usd": 100453.9,
114137
+ // "volume": 12.0,
114138
+ // "price_change": -2.2727,
114139
+ // "low": 0.2065,
114140
+ // "high": 0.238
114141
+ // },
114142
+ // "state": "open",
114143
+ // "timestamp": 1699578548021
114144
+ // }
114145
+ //
114146
+ const timestamp = this.safeInteger(greeks, 'timestamp');
114147
+ const marketId = this.safeString(greeks, 'instrument_name');
114148
+ const symbol = this.safeSymbol(marketId, market);
114149
+ const stats = this.safeValue(greeks, 'greeks', {});
114150
+ return {
114151
+ 'symbol': symbol,
114152
+ 'timestamp': timestamp,
114153
+ 'datetime': this.iso8601(timestamp),
114154
+ 'delta': this.safeNumber(stats, 'delta'),
114155
+ 'gamma': this.safeNumber(stats, 'gamma'),
114156
+ 'theta': this.safeNumber(stats, 'theta'),
114157
+ 'vega': this.safeNumber(stats, 'vega'),
114158
+ 'rho': this.safeNumber(stats, 'rho'),
114159
+ 'bidSize': this.safeNumber(greeks, 'best_bid_amount'),
114160
+ 'askSize': this.safeNumber(greeks, 'best_ask_amount'),
114161
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
114162
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
114163
+ 'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
114164
+ 'bidPrice': this.safeNumber(greeks, 'best_bid_price'),
114165
+ 'askPrice': this.safeNumber(greeks, 'best_ask_price'),
114166
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
114167
+ 'lastPrice': this.safeNumber(greeks, 'last_price'),
114168
+ 'underlyingPrice': this.safeNumber(greeks, 'underlying_price'),
114169
+ 'info': greeks,
114170
+ };
114171
+ }
113638
114172
  nonce() {
113639
114173
  return this.milliseconds();
113640
114174
  }
@@ -120732,6 +121266,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
120732
121266
  'fetchFundingRate': true,
120733
121267
  'fetchFundingRateHistory': true,
120734
121268
  'fetchFundingRates': true,
121269
+ 'fetchGreeks': true,
120735
121270
  'fetchIndexOHLCV': true,
120736
121271
  'fetchLedger': true,
120737
121272
  'fetchLeverage': false,
@@ -124705,6 +125240,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124705
125240
  * @name gate#editOrder
124706
125241
  * @description edit a trade order, gate currently only supports the modification of the price or amount fields
124707
125242
  * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order
125243
+ * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order-2
124708
125244
  * @param {string} id order id
124709
125245
  * @param {string} symbol unified symbol of the market to create an order in
124710
125246
  * @param {string} type 'market' or 'limit'
@@ -124716,9 +125252,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124716
125252
  */
124717
125253
  await this.loadMarkets();
124718
125254
  const market = this.market(symbol);
124719
- if (!market['spot']) {
124720
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' editOrder() supports only spot markets');
124721
- }
124722
125255
  const [marketType, query] = this.handleMarketTypeAndParams('editOrder', market, params);
124723
125256
  const account = this.convertTypeToAccount(marketType);
124724
125257
  const isLimitOrder = (type === 'limit');
@@ -124739,7 +125272,14 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124739
125272
  if (price !== undefined) {
124740
125273
  request['price'] = this.priceToPrecision(symbol, price);
124741
125274
  }
124742
- const response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
125275
+ let response = undefined;
125276
+ if (market['spot']) {
125277
+ response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
125278
+ }
125279
+ else {
125280
+ request['settle'] = market['settleId'];
125281
+ response = await this.privateFuturesPutSettleOrdersOrderId(this.extend(request, query));
125282
+ }
124743
125283
  //
124744
125284
  // {
124745
125285
  // "id": "243233276443",
@@ -127298,6 +127838,98 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
127298
127838
  'datetime': this.iso8601(timestamp),
127299
127839
  });
127300
127840
  }
127841
+ async fetchGreeks(symbol, params = {}) {
127842
+ /**
127843
+ * @method
127844
+ * @name gate#fetchGreeks
127845
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
127846
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-tickers-of-options-contracts
127847
+ * @param {string} symbol unified symbol of the market to fetch greeks for
127848
+ * @param {object} [params] extra parameters specific to the gate api endpoint
127849
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
127850
+ */
127851
+ await this.loadMarkets();
127852
+ const market = this.market(symbol);
127853
+ const request = {
127854
+ 'underlying': market['info']['underlying'],
127855
+ };
127856
+ const response = await this.publicOptionsGetTickers(this.extend(request, params));
127857
+ //
127858
+ // [
127859
+ // {
127860
+ // "vega": "1.78992",
127861
+ // "leverage": "6.2096777055417",
127862
+ // "ask_iv": "0.6245",
127863
+ // "delta": "-0.69397",
127864
+ // "last_price": "0",
127865
+ // "theta": "-2.5723",
127866
+ // "bid1_price": "222.9",
127867
+ // "mark_iv": "0.5909",
127868
+ // "name": "ETH_USDT-20231201-2300-P",
127869
+ // "bid_iv": "0.5065",
127870
+ // "ask1_price": "243.6",
127871
+ // "mark_price": "236.57",
127872
+ // "position_size": 0,
127873
+ // "bid1_size": 368,
127874
+ // "ask1_size": -335,
127875
+ // "gamma": "0.00116"
127876
+ // },
127877
+ // ]
127878
+ //
127879
+ const marketId = market['id'];
127880
+ for (let i = 0; i < response.length; i++) {
127881
+ const entry = response[i];
127882
+ const entryMarketId = this.safeString(entry, 'name');
127883
+ if (entryMarketId === marketId) {
127884
+ return this.parseGreeks(entry, market);
127885
+ }
127886
+ }
127887
+ }
127888
+ parseGreeks(greeks, market = undefined) {
127889
+ //
127890
+ // {
127891
+ // "vega": "1.78992",
127892
+ // "leverage": "6.2096777055417",
127893
+ // "ask_iv": "0.6245",
127894
+ // "delta": "-0.69397",
127895
+ // "last_price": "0",
127896
+ // "theta": "-2.5723",
127897
+ // "bid1_price": "222.9",
127898
+ // "mark_iv": "0.5909",
127899
+ // "name": "ETH_USDT-20231201-2300-P",
127900
+ // "bid_iv": "0.5065",
127901
+ // "ask1_price": "243.6",
127902
+ // "mark_price": "236.57",
127903
+ // "position_size": 0,
127904
+ // "bid1_size": 368,
127905
+ // "ask1_size": -335,
127906
+ // "gamma": "0.00116"
127907
+ // }
127908
+ //
127909
+ const marketId = this.safeString(greeks, 'name');
127910
+ const symbol = this.safeSymbol(marketId, market);
127911
+ return {
127912
+ 'symbol': symbol,
127913
+ 'timestamp': undefined,
127914
+ 'datetime': undefined,
127915
+ 'delta': this.safeNumber(greeks, 'delta'),
127916
+ 'gamma': this.safeNumber(greeks, 'gamma'),
127917
+ 'theta': this.safeNumber(greeks, 'theta'),
127918
+ 'vega': this.safeNumber(greeks, 'vega'),
127919
+ 'rho': undefined,
127920
+ 'bidSize': this.safeNumber(greeks, 'bid1_size'),
127921
+ 'askSize': this.safeNumber(greeks, 'ask1_size'),
127922
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
127923
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
127924
+ 'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
127925
+ 'bidPrice': this.safeNumber(greeks, 'bid1_price'),
127926
+ 'askPrice': this.safeNumber(greeks, 'ask1_price'),
127927
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
127928
+ 'lastPrice': this.safeNumber(greeks, 'last_price'),
127929
+ 'underlyingPrice': this.parseNumber(market['info']['underlying_price']),
127930
+ 'info': greeks,
127931
+ };
127932
+ }
127301
127933
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
127302
127934
  if (response === undefined) {
127303
127935
  return undefined;
@@ -134519,6 +135151,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
134519
135151
  'cancelOrders': true,
134520
135152
  'createDepositAddress': undefined,
134521
135153
  'createOrder': true,
135154
+ 'createOrders': true,
134522
135155
  'createReduceOnlyOrder': false,
134523
135156
  'createStopLimitOrder': true,
134524
135157
  'createStopMarketOrder': true,
@@ -135113,7 +135746,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
135113
135746
  // Future Trade Interface
135114
135747
  'api/v1/contract-cancel-after': 1,
135115
135748
  'api/v1/contract_order': 1,
135116
- 'v1/contract_batchorder': 1,
135749
+ 'api/v1/contract_batchorder': 1,
135117
135750
  'api/v1/contract_cancel': 1,
135118
135751
  'api/v1/contract_cancelall': 1,
135119
135752
  'api/v1/contract_switch_lever_rate': 1,
@@ -139186,7 +139819,41 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139186
139819
  // "trade_partition": "USDT"
139187
139820
  // }
139188
139821
  //
139189
- const id = this.safeString2(order, 'id', 'order_id_str');
139822
+ // spot: createOrders
139823
+ //
139824
+ // [
139825
+ // {
139826
+ // "order-id": 936847569789079,
139827
+ // "client-order-id": "AA03022abc3a55e82c-0087-4fc2-beac-112fdebb1ee9"
139828
+ // },
139829
+ // {
139830
+ // "client-order-id": "AA03022abcdb3baefb-3cfa-4891-8009-082b3d46ca82",
139831
+ // "err-code": "account-frozen-balance-insufficient-error",
139832
+ // "err-msg": "trade account balance is not enough, left: `89`"
139833
+ // }
139834
+ // ]
139835
+ //
139836
+ // swap and future: createOrders
139837
+ //
139838
+ // [
139839
+ // {
139840
+ // "index": 2,
139841
+ // "err_code": 1047,
139842
+ // "err_msg": "Insufficient margin available."
139843
+ // },
139844
+ // {
139845
+ // "order_id": 1172923090632953857,
139846
+ // "index": 1,
139847
+ // "order_id_str": "1172923090632953857"
139848
+ // }
139849
+ // ]
139850
+ //
139851
+ const rejectedCreateOrders = this.safeString2(order, 'err_code', 'err-code');
139852
+ let status = this.parseOrderStatus(this.safeString2(order, 'state', 'status'));
139853
+ if (rejectedCreateOrders !== undefined) {
139854
+ status = 'rejected';
139855
+ }
139856
+ const id = this.safeStringN(order, ['id', 'order_id_str', 'order-id']);
139190
139857
  let side = this.safeString(order, 'direction');
139191
139858
  let type = this.safeString(order, 'order_price_type');
139192
139859
  if ('type' in order) {
@@ -139194,7 +139861,6 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139194
139861
  side = orderType[0];
139195
139862
  type = orderType[1];
139196
139863
  }
139197
- const status = this.parseOrderStatus(this.safeString2(order, 'state', 'status'));
139198
139864
  const marketId = this.safeString2(order, 'contract_code', 'symbol');
139199
139865
  market = this.safeMarket(marketId, market);
139200
139866
  const timestamp = this.safeIntegerN(order, ['created_at', 'created-at', 'create_date']);
@@ -139237,7 +139903,10 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139237
139903
  const average = this.safeString(order, 'trade_avg_price');
139238
139904
  const trades = this.safeValue(order, 'trades');
139239
139905
  const reduceOnlyInteger = this.safeInteger(order, 'reduce_only');
139240
- const reduceOnly = (reduceOnlyInteger === 0) ? false : true;
139906
+ let reduceOnly = undefined;
139907
+ if (reduceOnlyInteger !== undefined) {
139908
+ reduceOnly = (reduceOnlyInteger === 0) ? false : true;
139909
+ }
139241
139910
  return this.safeOrder({
139242
139911
  'info': order,
139243
139912
  'id': id,
@@ -139264,61 +139933,20 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139264
139933
  'trades': trades,
139265
139934
  }, market);
139266
139935
  }
139267
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
139936
+ async createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
139268
139937
  /**
139269
139938
  * @method
139270
- * @name huobi#createOrder
139271
- * @description create a trade order
139272
- * @see https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order // spot, margin
139273
- * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order // coin-m swap
139274
- * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order // coin-m swap trigger
139275
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order // usdt-m swap cross
139276
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order // usdt-m swap cross trigger
139277
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order // usdt-m swap isolated
139278
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order // usdt-m swap isolated trigger
139279
- * @see https://huobiapi.github.io/docs/dm/v1/en/#place-an-order // coin-m futures
139280
- * @see https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order // coin-m futures contract trigger
139281
- * @param {string} symbol unified symbol of the market to create an order in
139282
- * @param {string} type 'market' or 'limit'
139283
- * @param {string} side 'buy' or 'sell'
139284
- * @param {float} amount how much of currency you want to trade in units of base currency
139285
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
139286
- * @param {object} [params] extra parameters specific to the huobi api endpoint
139287
- * @param {float} [params.stopPrice] the price a trigger order is triggered at
139288
- * @param {string} [params.triggerType] *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
139289
- * @param {float} [params.stopLossPrice] *contract only* the price a stop-loss order is triggered at
139290
- * @param {float} [params.takeProfitPrice] *contract only* the price a take-profit order is triggered at
139291
- * @param {string} [params.operator] *spot and margin only* gte or lte, trigger price condition
139292
- * @param {string} [params.offset] *contract only* 'open', 'close', or 'both', required in hedge mode
139293
- * @param {bool} [params.postOnly] *contract only* true or false
139294
- * @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
139295
- * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
139296
- * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
139297
- */
139298
- await this.loadMarkets();
139299
- const market = this.market(symbol);
139300
- const [marketType, query] = this.handleMarketTypeAndParams('createOrder', market, params);
139301
- if (marketType === 'spot') {
139302
- return await this.createSpotOrder(symbol, type, side, amount, price, query);
139303
- }
139304
- else {
139305
- return await this.createContractOrder(symbol, type, side, amount, price, query);
139306
- }
139307
- }
139308
- async createSpotOrder(symbol, type, side, amount, price = undefined, params = {}) {
139309
- /**
139310
139939
  * @ignore
139311
- * @method
139312
- * @name huobi#createSpotOrder
139313
- * @description create a spot trade order
139314
- * @see https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order
139940
+ * @name htx#createSpotOrderRequest
139941
+ * @description helper function to build request
139315
139942
  * @param {string} symbol unified symbol of the market to create an order in
139316
139943
  * @param {string} type 'market' or 'limit'
139317
139944
  * @param {string} side 'buy' or 'sell'
139318
- * @param {float} amount how much of currency you want to trade in units of base currency
139945
+ * @param {float} amount how much you want to trade in units of the base currency
139319
139946
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
139320
- * @param {object} params extra parameters specific to the huobi api endpoint
139321
- * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
139947
+ * @param {object} [params] extra parameters specific to the htx api endpoint
139948
+ * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
139949
+ * @returns {object} request to be sent to the exchange
139322
139950
  */
139323
139951
  await this.loadMarkets();
139324
139952
  await this.loadAccounts();
@@ -139420,52 +140048,22 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139420
140048
  request['price'] = this.priceToPrecision(symbol, price);
139421
140049
  }
139422
140050
  params = this.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
139423
- const response = await this.spotPrivatePostV1OrderOrdersPlace(this.extend(request, params));
139424
- //
139425
- // spot
139426
- //
139427
- // {"status":"ok","data":"438398393065481"}
139428
- //
139429
- const id = this.safeString(response, 'data');
139430
- return this.safeOrder({
139431
- 'info': response,
139432
- 'id': id,
139433
- 'timestamp': undefined,
139434
- 'datetime': undefined,
139435
- 'lastTradeTimestamp': undefined,
139436
- 'status': undefined,
139437
- 'symbol': undefined,
139438
- 'type': type,
139439
- 'side': side,
139440
- 'price': price,
139441
- 'amount': amount,
139442
- 'filled': undefined,
139443
- 'remaining': undefined,
139444
- 'cost': undefined,
139445
- 'trades': undefined,
139446
- 'fee': undefined,
139447
- 'clientOrderId': undefined,
139448
- 'average': undefined,
139449
- }, market);
140051
+ return this.extend(request, params);
139450
140052
  }
139451
- async createContractOrder(symbol, type, side, amount, price = undefined, params = {}) {
140053
+ createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
139452
140054
  /**
139453
- * @ignore
139454
140055
  * @method
139455
- * @name huobi#createContractOrder
139456
- * @description create a contract trade order
139457
- * @see https://huobiapi.github.io/docs/dm/v1/en/#place-an-order
139458
- * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order
139459
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order
139460
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order
140056
+ * @ignore
140057
+ * @name htx#createContractOrderRequest
140058
+ * @description helper function to build request
139461
140059
  * @param {string} symbol unified symbol of the market to create an order in
139462
140060
  * @param {string} type 'market' or 'limit'
139463
140061
  * @param {string} side 'buy' or 'sell'
139464
- * @param {float} amount how much of currency you want to trade in units of base currency
140062
+ * @param {float} amount how much you want to trade in units of the base currency
139465
140063
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
139466
- * @param {object} params extra parameters specific to the huobi api endpoint
140064
+ * @param {object} [params] extra parameters specific to the htx api endpoint
139467
140065
  * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
139468
- * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
140066
+ * @returns {object} request to be sent to the exchange
139469
140067
  */
139470
140068
  const market = this.market(symbol);
139471
140069
  const request = {
@@ -139537,63 +140135,117 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139537
140135
  request['lever_rate'] = leverRate;
139538
140136
  request['order_price_type'] = type;
139539
140137
  }
139540
- params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
139541
140138
  const broker = this.safeValue(this.options, 'broker', {});
139542
140139
  const brokerId = this.safeString(broker, 'id');
139543
140140
  request['channel_code'] = brokerId;
140141
+ params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
140142
+ return this.extend(request, params);
140143
+ }
140144
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
140145
+ /**
140146
+ * @method
140147
+ * @name huobi#createOrder
140148
+ * @description create a trade order
140149
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order // spot, margin
140150
+ * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order // coin-m swap
140151
+ * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order // coin-m swap trigger
140152
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order // usdt-m swap cross
140153
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order // usdt-m swap cross trigger
140154
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order // usdt-m swap isolated
140155
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order // usdt-m swap isolated trigger
140156
+ * @see https://huobiapi.github.io/docs/dm/v1/en/#place-an-order // coin-m futures
140157
+ * @see https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order // coin-m futures contract trigger
140158
+ * @param {string} symbol unified symbol of the market to create an order in
140159
+ * @param {string} type 'market' or 'limit'
140160
+ * @param {string} side 'buy' or 'sell'
140161
+ * @param {float} amount how much you want to trade in units of the base currency
140162
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
140163
+ * @param {object} [params] extra parameters specific to the huobi api endpoint
140164
+ * @param {float} [params.stopPrice] the price a trigger order is triggered at
140165
+ * @param {string} [params.triggerType] *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
140166
+ * @param {float} [params.stopLossPrice] *contract only* the price a stop-loss order is triggered at
140167
+ * @param {float} [params.takeProfitPrice] *contract only* the price a take-profit order is triggered at
140168
+ * @param {string} [params.operator] *spot and margin only* gte or lte, trigger price condition
140169
+ * @param {string} [params.offset] *contract only* 'open', 'close', or 'both', required in hedge mode
140170
+ * @param {bool} [params.postOnly] *contract only* true or false
140171
+ * @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
140172
+ * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
140173
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
140174
+ */
140175
+ await this.loadMarkets();
140176
+ const market = this.market(symbol);
140177
+ const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
140178
+ const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
140179
+ const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
140180
+ const isStop = triggerPrice !== undefined;
140181
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
140182
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
139544
140183
  let response = undefined;
139545
- if (market['linear']) {
139546
- let marginMode = undefined;
139547
- [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
139548
- marginMode = (marginMode === undefined) ? 'cross' : marginMode;
139549
- if (marginMode === 'isolated') {
139550
- if (isStop) {
139551
- response = await this.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(this.extend(request, params));
139552
- }
139553
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139554
- response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(this.extend(request, params));
139555
- }
139556
- else {
139557
- response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(this.extend(request, params));
139558
- }
139559
- }
139560
- else if (marginMode === 'cross') {
139561
- if (isStop) {
139562
- response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(this.extend(request, params));
139563
- }
139564
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139565
- response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(this.extend(request, params));
139566
- }
139567
- else {
139568
- response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(this.extend(request, params));
139569
- }
139570
- }
140184
+ if (market['spot']) {
140185
+ const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
140186
+ response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
139571
140187
  }
139572
- else if (market['inverse']) {
139573
- if (market['swap']) {
139574
- if (isStop) {
139575
- response = await this.contractPrivatePostSwapApiV1SwapTriggerOrder(this.extend(request, params));
139576
- }
139577
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139578
- response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(this.extend(request, params));
140188
+ else {
140189
+ const contractRequest = this.createContractOrderRequest(symbol, type, side, amount, price, params);
140190
+ if (market['linear']) {
140191
+ let marginMode = undefined;
140192
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
140193
+ marginMode = (marginMode === undefined) ? 'cross' : marginMode;
140194
+ if (marginMode === 'isolated') {
140195
+ if (isStop) {
140196
+ response = await this.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(contractRequest);
140197
+ }
140198
+ else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
140199
+ response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest);
140200
+ }
140201
+ else {
140202
+ response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest);
140203
+ }
139579
140204
  }
139580
- else {
139581
- response = await this.contractPrivatePostSwapApiV1SwapOrder(this.extend(request, params));
140205
+ else if (marginMode === 'cross') {
140206
+ if (isStop) {
140207
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(contractRequest);
140208
+ }
140209
+ else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
140210
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest);
140211
+ }
140212
+ else {
140213
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(contractRequest);
140214
+ }
139582
140215
  }
139583
140216
  }
139584
- else if (market['future']) {
139585
- if (isStop) {
139586
- response = await this.contractPrivatePostApiV1ContractTriggerOrder(this.extend(request, params));
139587
- }
139588
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139589
- response = await this.contractPrivatePostApiV1ContractTpslOrder(this.extend(request, params));
140217
+ else if (market['inverse']) {
140218
+ if (market['swap']) {
140219
+ if (isStop) {
140220
+ response = await this.contractPrivatePostSwapApiV1SwapTriggerOrder(contractRequest);
140221
+ }
140222
+ else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
140223
+ response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest);
140224
+ }
140225
+ else {
140226
+ response = await this.contractPrivatePostSwapApiV1SwapOrder(contractRequest);
140227
+ }
139590
140228
  }
139591
- else {
139592
- response = await this.contractPrivatePostApiV1ContractOrder(this.extend(request, params));
140229
+ else if (market['future']) {
140230
+ if (isStop) {
140231
+ response = await this.contractPrivatePostApiV1ContractTriggerOrder(contractRequest);
140232
+ }
140233
+ else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
140234
+ response = await this.contractPrivatePostApiV1ContractTpslOrder(contractRequest);
140235
+ }
140236
+ else {
140237
+ response = await this.contractPrivatePostApiV1ContractOrder(contractRequest);
140238
+ }
139593
140239
  }
139594
140240
  }
139595
140241
  }
139596
140242
  //
140243
+ // spot
140244
+ //
140245
+ // {"status":"ok","data":"438398393065481"}
140246
+ //
140247
+ // swap and future
140248
+ //
139597
140249
  // {
139598
140250
  // "status": "ok",
139599
140251
  // "data": {
@@ -139619,7 +140271,29 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139619
140271
  //
139620
140272
  let data = undefined;
139621
140273
  let result = undefined;
139622
- if (isStopLossTriggerOrder) {
140274
+ if (market['spot']) {
140275
+ return this.safeOrder({
140276
+ 'info': response,
140277
+ 'id': this.safeString(response, 'data'),
140278
+ 'timestamp': undefined,
140279
+ 'datetime': undefined,
140280
+ 'lastTradeTimestamp': undefined,
140281
+ 'status': undefined,
140282
+ 'symbol': undefined,
140283
+ 'type': type,
140284
+ 'side': side,
140285
+ 'price': price,
140286
+ 'amount': amount,
140287
+ 'filled': undefined,
140288
+ 'remaining': undefined,
140289
+ 'cost': undefined,
140290
+ 'trades': undefined,
140291
+ 'fee': undefined,
140292
+ 'clientOrderId': undefined,
140293
+ 'average': undefined,
140294
+ }, market);
140295
+ }
140296
+ else if (isStopLossTriggerOrder) {
139623
140297
  data = this.safeValue(response, 'data', {});
139624
140298
  result = this.safeValue(data, 'sl_order', {});
139625
140299
  }
@@ -139632,6 +140306,142 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139632
140306
  }
139633
140307
  return this.parseOrder(result, market);
139634
140308
  }
140309
+ async createOrders(orders, params = {}) {
140310
+ /**
140311
+ * @method
140312
+ * @name htx#createOrders
140313
+ * @description create a list of trade orders
140314
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#place-a-batch-of-orders
140315
+ * @see https://huobiapi.github.io/docs/dm/v1/en/#place-a-batch-of-orders
140316
+ * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
140317
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
140318
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-a-batch-of-orders
140319
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
140320
+ * @param {object} [params] extra parameters specific to the htx api endpoint
140321
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
140322
+ */
140323
+ await this.loadMarkets();
140324
+ const ordersRequests = [];
140325
+ let symbol = undefined;
140326
+ let market = undefined;
140327
+ let marginMode = undefined;
140328
+ for (let i = 0; i < orders.length; i++) {
140329
+ const rawOrder = orders[i];
140330
+ const marketId = this.safeString(rawOrder, 'symbol');
140331
+ if (symbol === undefined) {
140332
+ symbol = marketId;
140333
+ }
140334
+ else {
140335
+ if (symbol !== marketId) {
140336
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
140337
+ }
140338
+ }
140339
+ const type = this.safeString(rawOrder, 'type');
140340
+ const side = this.safeString(rawOrder, 'side');
140341
+ const amount = this.safeValue(rawOrder, 'amount');
140342
+ const price = this.safeValue(rawOrder, 'price');
140343
+ const orderParams = this.safeValue(rawOrder, 'params', {});
140344
+ const marginResult = this.handleMarginModeAndParams('createOrders', orderParams);
140345
+ const currentMarginMode = marginResult[0];
140346
+ if (currentMarginMode !== undefined) {
140347
+ if (marginMode === undefined) {
140348
+ marginMode = currentMarginMode;
140349
+ }
140350
+ else {
140351
+ if (marginMode !== currentMarginMode) {
140352
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' createOrders() requires all orders to have the same margin mode (isolated or cross)');
140353
+ }
140354
+ }
140355
+ }
140356
+ market = this.market(symbol);
140357
+ let orderRequest = undefined;
140358
+ if (market['spot']) {
140359
+ orderRequest = await this.createSpotOrderRequest(marketId, type, side, amount, price, orderParams);
140360
+ }
140361
+ else {
140362
+ orderRequest = this.createContractOrderRequest(marketId, type, side, amount, price, orderParams);
140363
+ }
140364
+ orderRequest = this.omit(orderRequest, 'marginMode');
140365
+ ordersRequests.push(orderRequest);
140366
+ }
140367
+ const request = {};
140368
+ let response = undefined;
140369
+ if (market['spot']) {
140370
+ response = await this.privatePostOrderBatchOrders(ordersRequests);
140371
+ }
140372
+ else {
140373
+ request['orders_data'] = ordersRequests;
140374
+ if (market['linear']) {
140375
+ marginMode = (marginMode === undefined) ? 'cross' : marginMode;
140376
+ if (marginMode === 'isolated') {
140377
+ response = await this.contractPrivatePostLinearSwapApiV1SwapBatchorder(request);
140378
+ }
140379
+ else if (marginMode === 'cross') {
140380
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossBatchorder(request);
140381
+ }
140382
+ }
140383
+ else if (market['inverse']) {
140384
+ if (market['swap']) {
140385
+ response = await this.contractPrivatePostSwapApiV1SwapBatchorder(request);
140386
+ }
140387
+ else if (market['future']) {
140388
+ response = await this.contractPrivatePostApiV1ContractBatchorder(request);
140389
+ }
140390
+ }
140391
+ }
140392
+ //
140393
+ // spot
140394
+ //
140395
+ // {
140396
+ // "status": "ok",
140397
+ // "data": [
140398
+ // {
140399
+ // "order-id": 936847569789079,
140400
+ // "client-order-id": "AA03022abc3a55e82c-0087-4fc2-beac-112fdebb1ee9"
140401
+ // },
140402
+ // {
140403
+ // "client-order-id": "AA03022abcdb3baefb-3cfa-4891-8009-082b3d46ca82",
140404
+ // "err-code": "account-frozen-balance-insufficient-error",
140405
+ // "err-msg": "trade account balance is not enough, left: `89`"
140406
+ // }
140407
+ // ]
140408
+ // }
140409
+ //
140410
+ // swap and future
140411
+ //
140412
+ // {
140413
+ // "status": "ok",
140414
+ // "data": {
140415
+ // "errors": [
140416
+ // {
140417
+ // "index": 2,
140418
+ // "err_code": 1047,
140419
+ // "err_msg": "Insufficient margin available."
140420
+ // }
140421
+ // ],
140422
+ // "success": [
140423
+ // {
140424
+ // "order_id": 1172923090632953857,
140425
+ // "index": 1,
140426
+ // "order_id_str": "1172923090632953857"
140427
+ // }
140428
+ // ]
140429
+ // },
140430
+ // "ts": 1699688256671
140431
+ // }
140432
+ //
140433
+ let result = undefined;
140434
+ if (market['spot']) {
140435
+ result = this.safeValue(response, 'data', []);
140436
+ }
140437
+ else {
140438
+ const data = this.safeValue(response, 'data', {});
140439
+ const success = this.safeValue(data, 'success', []);
140440
+ const errors = this.safeValue(data, 'errors', []);
140441
+ result = this.arrayConcat(success, errors);
140442
+ }
140443
+ return this.parseOrders(result, market);
140444
+ }
139635
140445
  async cancelOrder(id, symbol = undefined, params = {}) {
139636
140446
  /**
139637
140447
  * @method
@@ -171125,8 +171935,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
171125
171935
  },
171126
171936
  'www': 'https://www.mexc.com/',
171127
171937
  'doc': [
171128
- 'https://mxcdevelop.github.io/apidocs/spot_v3_en/',
171129
- 'https://mxcdevelop.github.io/APIDoc/', // v1 & v2 : soon to be deprecated
171938
+ 'https://mexcdevelop.github.io/apidocs/spot_v3_en/',
171939
+ 'https://mexcdevelop.github.io/APIDoc/', // v1 & v2 : soon to be deprecated
171130
171940
  ],
171131
171941
  'fees': [
171132
171942
  'https://www.mexc.com/fee',
@@ -171878,7 +172688,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
171878
172688
  * @method
171879
172689
  * @name mexc3#fetchCurrencies
171880
172690
  * @description fetches all available currencies on an exchange
171881
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
172691
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
171882
172692
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
171883
172693
  * @returns {object} an associative dictionary of currencies
171884
172694
  */
@@ -172278,8 +173088,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
172278
173088
  /**
172279
173089
  * @method
172280
173090
  * @name mexc3#fetchOrderBook
172281
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#order-book
172282
- * @see https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
173091
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
173092
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
172283
173093
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
172284
173094
  * @param {string} symbol unified symbol of the market to fetch the order book for
172285
173095
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -174527,9 +175337,9 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
174527
175337
  * @method
174528
175338
  * @name mexc3#fetchBalance
174529
175339
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
174530
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#account-information
174531
- * @see https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
174532
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
175340
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
175341
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
175342
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
174533
175343
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
174534
175344
  * @param {string} [params.symbols] // required for margin, market id's separated by commas
174535
175345
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
@@ -175226,7 +176036,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175226
176036
  * @method
175227
176037
  * @name mexc3#fetchDepositAddressesByNetwork
175228
176038
  * @description fetch a dictionary of addresses for a currency, indexed by network
175229
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
176039
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
175230
176040
  * @param {string} code unified currency code of the currency for the deposit address
175231
176041
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
175232
176042
  * @returns {object} a dictionary of [address structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure} indexed by the network
@@ -175265,7 +176075,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175265
176075
  /**
175266
176076
  * @method
175267
176077
  * @name mexc3#createDepositAddress
175268
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
176078
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
175269
176079
  * @description create a currency deposit address
175270
176080
  * @param {string} code unified currency code of the currency for the deposit address
175271
176081
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
@@ -175306,7 +176116,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175306
176116
  * @method
175307
176117
  * @name mexc3#fetchDepositAddress
175308
176118
  * @description fetch the deposit address for a currency associated with this account
175309
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
176119
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
175310
176120
  * @param {string} code unified currency code
175311
176121
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
175312
176122
  * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
@@ -175334,7 +176144,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175334
176144
  * @method
175335
176145
  * @name mexc3#fetchDeposits
175336
176146
  * @description fetch all deposits made to an account
175337
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
176147
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
175338
176148
  * @param {string} code unified currency code
175339
176149
  * @param {int} [since] the earliest time in ms to fetch deposits for
175340
176150
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -175394,7 +176204,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175394
176204
  * @method
175395
176205
  * @name mexc3#fetchWithdrawals
175396
176206
  * @description fetch all withdrawals made from an account
175397
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
176207
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
175398
176208
  * @param {string} code unified currency code
175399
176209
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
175400
176210
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -175813,7 +176623,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175813
176623
  * @method
175814
176624
  * @name mexc3#transfer
175815
176625
  * @description transfer currency internally between wallets on the same account
175816
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
176626
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
175817
176627
  * @param {string} code unified currency code
175818
176628
  * @param {float} amount amount to transfer
175819
176629
  * @param {string} fromAccount account to transfer from
@@ -175946,7 +176756,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175946
176756
  * @method
175947
176757
  * @name mexc3#withdraw
175948
176758
  * @description make a withdrawal
175949
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#withdraw
176759
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw
175950
176760
  * @param {string} code unified currency code
175951
176761
  * @param {float} amount the amount to withdraw
175952
176762
  * @param {string} address the address to withdraw to
@@ -175956,7 +176766,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175956
176766
  */
175957
176767
  [tag, params] = this.handleWithdrawTagAndParams(tag, params);
175958
176768
  const networks = this.safeValue(this.options, 'networks', {});
175959
- let network = this.safeStringUpper2(params, 'network', 'chain'); // this line allows the user to specify either ERC20 or ETH
176769
+ let network = this.safeString2(params, 'network', 'chain'); // this line allows the user to specify either ERC20 or ETH
175960
176770
  network = this.safeString(networks, network, network); // handle ETH > ERC-20 alias
175961
176771
  this.checkAddress(address);
175962
176772
  await this.loadMarkets();
@@ -175971,7 +176781,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175971
176781
  }
175972
176782
  if (network !== undefined) {
175973
176783
  request['network'] = network;
175974
- params = this.omit(params, 'network');
176784
+ params = this.omit(params, ['network', 'chain']);
175975
176785
  }
175976
176786
  const response = await this.spotPrivatePostCapitalWithdrawApply(this.extend(request, params));
175977
176787
  //
@@ -176014,7 +176824,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
176014
176824
  * @method
176015
176825
  * @name mexc3#borrowMargin
176016
176826
  * @description create a loan to borrow margin
176017
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#loan
176827
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#loan
176018
176828
  * @param {string} code unified currency code of the currency to borrow
176019
176829
  * @param {float} amount the amount to borrow
176020
176830
  * @param {string} symbol unified market symbol
@@ -176047,7 +176857,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
176047
176857
  * @method
176048
176858
  * @name mexc3#repayMargin
176049
176859
  * @description repay borrowed margin and interest
176050
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#repayment
176860
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#repayment
176051
176861
  * @param {string} code unified currency code of the currency to repay
176052
176862
  * @param {float} amount the amount to repay
176053
176863
  * @param {string} symbol unified market symbol
@@ -176086,7 +176896,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
176086
176896
  * @method
176087
176897
  * @name mexc3#fetchTransactionFees
176088
176898
  * @description fetch deposit and withdrawal fees
176089
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
176899
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
176090
176900
  * @param {string[]|undefined} codes returns fees for all currencies if undefined
176091
176901
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
176092
176902
  * @returns {object[]} a list of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -176184,7 +176994,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
176184
176994
  * @method
176185
176995
  * @name mexc3#fetchDepositWithdrawFees
176186
176996
  * @description fetch deposit and withdrawal fees
176187
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
176997
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
176188
176998
  * @param {string[]|undefined} codes returns fees for all currencies if undefined
176189
176999
  * @param {object} [params] extra parameters specific to the mexc3 api endpoint
176190
177000
  * @returns {object[]} a list of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -184594,6 +185404,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
184594
185404
  'fetchFundingRate': true,
184595
185405
  'fetchFundingRateHistory': true,
184596
185406
  'fetchFundingRates': false,
185407
+ 'fetchGreeks': true,
184597
185408
  'fetchIndexOHLCV': true,
184598
185409
  'fetchL3OrderBook': false,
184599
185410
  'fetchLedger': true,
@@ -191471,6 +192282,113 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191471
192282
  const underlyings = this.safeValue(response, 'data', []);
191472
192283
  return underlyings[0];
191473
192284
  }
192285
+ async fetchGreeks(symbol, params = {}) {
192286
+ /**
192287
+ * @method
192288
+ * @name okx#fetchGreeks
192289
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
192290
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
192291
+ * @param {string} symbol unified symbol of the market to fetch greeks for
192292
+ * @param {object} [params] extra parameters specific to the okx api endpoint
192293
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
192294
+ */
192295
+ await this.loadMarkets();
192296
+ const market = this.market(symbol);
192297
+ const marketId = market['id'];
192298
+ const optionParts = marketId.split('-');
192299
+ const request = {
192300
+ 'uly': market['info']['uly'],
192301
+ 'instFamily': market['info']['instFamily'],
192302
+ 'expTime': this.safeString(optionParts, 2),
192303
+ };
192304
+ const response = await this.publicGetPublicOptSummary(this.extend(request, params));
192305
+ //
192306
+ // {
192307
+ // "code": "0",
192308
+ // "data": [
192309
+ // {
192310
+ // "askVol": "0",
192311
+ // "bidVol": "0",
192312
+ // "delta": "0.5105464486882039",
192313
+ // "deltaBS": "0.7325502184143025",
192314
+ // "fwdPx": "37675.80158694987186",
192315
+ // "gamma": "-0.13183515090501083",
192316
+ // "gammaBS": "0.000024139685826358558",
192317
+ // "instId": "BTC-USD-240329-32000-C",
192318
+ // "instType": "OPTION",
192319
+ // "lever": "4.504428015946619",
192320
+ // "markVol": "0.5916253554539876",
192321
+ // "realVol": "0",
192322
+ // "theta": "-0.0004202992014012855",
192323
+ // "thetaBS": "-18.52354631567909",
192324
+ // "ts": "1699586421976",
192325
+ // "uly": "BTC-USD",
192326
+ // "vega": "0.0020207455080045846",
192327
+ // "vegaBS": "74.44022302387287",
192328
+ // "volLv": "0.5948549730405797"
192329
+ // },
192330
+ // ],
192331
+ // "msg": ""
192332
+ // }
192333
+ //
192334
+ const data = this.safeValue(response, 'data', []);
192335
+ for (let i = 0; i < data.length; i++) {
192336
+ const entry = data[i];
192337
+ const entryMarketId = this.safeString(entry, 'instId');
192338
+ if (entryMarketId === marketId) {
192339
+ return this.parseGreeks(entry, market);
192340
+ }
192341
+ }
192342
+ }
192343
+ parseGreeks(greeks, market = undefined) {
192344
+ //
192345
+ // {
192346
+ // "askVol": "0",
192347
+ // "bidVol": "0",
192348
+ // "delta": "0.5105464486882039",
192349
+ // "deltaBS": "0.7325502184143025",
192350
+ // "fwdPx": "37675.80158694987186",
192351
+ // "gamma": "-0.13183515090501083",
192352
+ // "gammaBS": "0.000024139685826358558",
192353
+ // "instId": "BTC-USD-240329-32000-C",
192354
+ // "instType": "OPTION",
192355
+ // "lever": "4.504428015946619",
192356
+ // "markVol": "0.5916253554539876",
192357
+ // "realVol": "0",
192358
+ // "theta": "-0.0004202992014012855",
192359
+ // "thetaBS": "-18.52354631567909",
192360
+ // "ts": "1699586421976",
192361
+ // "uly": "BTC-USD",
192362
+ // "vega": "0.0020207455080045846",
192363
+ // "vegaBS": "74.44022302387287",
192364
+ // "volLv": "0.5948549730405797"
192365
+ // }
192366
+ //
192367
+ const timestamp = this.safeInteger(greeks, 'ts');
192368
+ const marketId = this.safeString(greeks, 'instId');
192369
+ const symbol = this.safeSymbol(marketId, market);
192370
+ return {
192371
+ 'symbol': symbol,
192372
+ 'timestamp': timestamp,
192373
+ 'datetime': this.iso8601(timestamp),
192374
+ 'delta': this.safeNumber(greeks, 'delta'),
192375
+ 'gamma': this.safeNumber(greeks, 'gamma'),
192376
+ 'theta': this.safeNumber(greeks, 'theta'),
192377
+ 'vega': this.safeNumber(greeks, 'vega'),
192378
+ 'rho': undefined,
192379
+ 'bidSize': undefined,
192380
+ 'askSize': undefined,
192381
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bidVol'),
192382
+ 'askImpliedVolatility': this.safeNumber(greeks, 'askVol'),
192383
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markVol'),
192384
+ 'bidPrice': undefined,
192385
+ 'askPrice': undefined,
192386
+ 'markPrice': undefined,
192387
+ 'lastPrice': undefined,
192388
+ 'underlyingPrice': undefined,
192389
+ 'info': greeks,
192390
+ };
192391
+ }
191474
192392
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
191475
192393
  if (!response) {
191476
192394
  return undefined; // fallback to default error handler
@@ -285736,7 +286654,7 @@ SOFTWARE.
285736
286654
 
285737
286655
  //-----------------------------------------------------------------------------
285738
286656
  // this is updated by vss.js when building
285739
- const version = '4.1.48';
286657
+ const version = '4.1.50';
285740
286658
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
285741
286659
  //-----------------------------------------------------------------------------
285742
286660