ccxt 4.1.49 → 4.1.51

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 +3 -3
  2. package/dist/ccxt.browser.js +1040 -153
  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/cryptocom.js +1 -0
  9. package/dist/cjs/src/delta.js +149 -0
  10. package/dist/cjs/src/deribit.js +132 -0
  11. package/dist/cjs/src/gate.js +102 -4
  12. package/dist/cjs/src/htx.js +313 -135
  13. package/dist/cjs/src/kraken.js +7 -10
  14. package/dist/cjs/src/okx.js +108 -0
  15. package/dist/cjs/src/pro/krakenfutures.js +24 -3
  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/huobipro.d.ts +1 -1
  21. package/js/src/abstract/kraken.d.ts +0 -5
  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/cryptocom.js +1 -0
  30. package/js/src/delta.d.ts +23 -1
  31. package/js/src/delta.js +149 -0
  32. package/js/src/deribit.d.ts +23 -1
  33. package/js/src/deribit.js +132 -0
  34. package/js/src/gate.d.ts +23 -1
  35. package/js/src/gate.js +102 -4
  36. package/js/src/htx.d.ts +4 -3
  37. package/js/src/htx.js +313 -135
  38. package/js/src/kraken.js +7 -10
  39. package/js/src/okx.d.ts +23 -1
  40. package/js/src/okx.js +108 -0
  41. package/js/src/pro/krakenfutures.js +24 -3
  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') {
@@ -102275,6 +102478,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
102275
102478
  'fetchFundingRate': false,
102276
102479
  'fetchFundingRateHistory': true,
102277
102480
  'fetchFundingRates': false,
102481
+ 'fetchGreeks': false,
102278
102482
  'fetchIndexOHLCV': false,
102279
102483
  'fetchLedger': true,
102280
102484
  'fetchLeverage': false,
@@ -107562,6 +107766,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
107562
107766
  'fetchFundingRate': true,
107563
107767
  'fetchFundingRateHistory': false,
107564
107768
  'fetchFundingRates': true,
107769
+ 'fetchGreeks': true,
107565
107770
  'fetchIndexOHLCV': true,
107566
107771
  'fetchLedger': true,
107567
107772
  'fetchLeverage': true,
@@ -110538,6 +110743,154 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
110538
110743
  }
110539
110744
  return result;
110540
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
+ }
110541
110894
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
110542
110895
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
110543
110896
  let url = this.urls['api'][api] + requestPath;
@@ -110661,6 +111014,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
110661
111014
  'fetchDepositWithdrawFees': true,
110662
111015
  'fetchFundingRate': true,
110663
111016
  'fetchFundingRateHistory': true,
111017
+ 'fetchGreeks': true,
110664
111018
  'fetchIndexOHLCV': false,
110665
111019
  'fetchLeverageTiers': false,
110666
111020
  'fetchLiquidations': true,
@@ -113684,6 +114038,137 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
113684
114038
  'datetime': this.iso8601(timestamp),
113685
114039
  });
113686
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
+ }
113687
114172
  nonce() {
113688
114173
  return this.milliseconds();
113689
114174
  }
@@ -120781,6 +121266,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
120781
121266
  'fetchFundingRate': true,
120782
121267
  'fetchFundingRateHistory': true,
120783
121268
  'fetchFundingRates': true,
121269
+ 'fetchGreeks': true,
120784
121270
  'fetchIndexOHLCV': true,
120785
121271
  'fetchLedger': true,
120786
121272
  'fetchLeverage': false,
@@ -124754,6 +125240,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124754
125240
  * @name gate#editOrder
124755
125241
  * @description edit a trade order, gate currently only supports the modification of the price or amount fields
124756
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
124757
125244
  * @param {string} id order id
124758
125245
  * @param {string} symbol unified symbol of the market to create an order in
124759
125246
  * @param {string} type 'market' or 'limit'
@@ -124765,9 +125252,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124765
125252
  */
124766
125253
  await this.loadMarkets();
124767
125254
  const market = this.market(symbol);
124768
- if (!market['spot']) {
124769
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' editOrder() supports only spot markets');
124770
- }
124771
125255
  const [marketType, query] = this.handleMarketTypeAndParams('editOrder', market, params);
124772
125256
  const account = this.convertTypeToAccount(marketType);
124773
125257
  const isLimitOrder = (type === 'limit');
@@ -124788,7 +125272,14 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124788
125272
  if (price !== undefined) {
124789
125273
  request['price'] = this.priceToPrecision(symbol, price);
124790
125274
  }
124791
- 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
+ }
124792
125283
  //
124793
125284
  // {
124794
125285
  // "id": "243233276443",
@@ -127347,6 +127838,98 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
127347
127838
  'datetime': this.iso8601(timestamp),
127348
127839
  });
127349
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
+ }
127350
127933
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
127351
127934
  if (response === undefined) {
127352
127935
  return undefined;
@@ -134568,6 +135151,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
134568
135151
  'cancelOrders': true,
134569
135152
  'createDepositAddress': undefined,
134570
135153
  'createOrder': true,
135154
+ 'createOrders': true,
134571
135155
  'createReduceOnlyOrder': false,
134572
135156
  'createStopLimitOrder': true,
134573
135157
  'createStopMarketOrder': true,
@@ -135162,7 +135746,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
135162
135746
  // Future Trade Interface
135163
135747
  'api/v1/contract-cancel-after': 1,
135164
135748
  'api/v1/contract_order': 1,
135165
- 'v1/contract_batchorder': 1,
135749
+ 'api/v1/contract_batchorder': 1,
135166
135750
  'api/v1/contract_cancel': 1,
135167
135751
  'api/v1/contract_cancelall': 1,
135168
135752
  'api/v1/contract_switch_lever_rate': 1,
@@ -139235,7 +139819,41 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139235
139819
  // "trade_partition": "USDT"
139236
139820
  // }
139237
139821
  //
139238
- 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']);
139239
139857
  let side = this.safeString(order, 'direction');
139240
139858
  let type = this.safeString(order, 'order_price_type');
139241
139859
  if ('type' in order) {
@@ -139243,7 +139861,6 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139243
139861
  side = orderType[0];
139244
139862
  type = orderType[1];
139245
139863
  }
139246
- const status = this.parseOrderStatus(this.safeString2(order, 'state', 'status'));
139247
139864
  const marketId = this.safeString2(order, 'contract_code', 'symbol');
139248
139865
  market = this.safeMarket(marketId, market);
139249
139866
  const timestamp = this.safeIntegerN(order, ['created_at', 'created-at', 'create_date']);
@@ -139286,7 +139903,10 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139286
139903
  const average = this.safeString(order, 'trade_avg_price');
139287
139904
  const trades = this.safeValue(order, 'trades');
139288
139905
  const reduceOnlyInteger = this.safeInteger(order, 'reduce_only');
139289
- const reduceOnly = (reduceOnlyInteger === 0) ? false : true;
139906
+ let reduceOnly = undefined;
139907
+ if (reduceOnlyInteger !== undefined) {
139908
+ reduceOnly = (reduceOnlyInteger === 0) ? false : true;
139909
+ }
139290
139910
  return this.safeOrder({
139291
139911
  'info': order,
139292
139912
  'id': id,
@@ -139313,61 +139933,20 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139313
139933
  'trades': trades,
139314
139934
  }, market);
139315
139935
  }
139316
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
139936
+ async createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
139317
139937
  /**
139318
139938
  * @method
139319
- * @name huobi#createOrder
139320
- * @description create a trade order
139321
- * @see https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order // spot, margin
139322
- * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order // coin-m swap
139323
- * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order // coin-m swap trigger
139324
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order // usdt-m swap cross
139325
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order // usdt-m swap cross trigger
139326
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order // usdt-m swap isolated
139327
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order // usdt-m swap isolated trigger
139328
- * @see https://huobiapi.github.io/docs/dm/v1/en/#place-an-order // coin-m futures
139329
- * @see https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order // coin-m futures contract trigger
139330
- * @param {string} symbol unified symbol of the market to create an order in
139331
- * @param {string} type 'market' or 'limit'
139332
- * @param {string} side 'buy' or 'sell'
139333
- * @param {float} amount how much of currency you want to trade in units of base currency
139334
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
139335
- * @param {object} [params] extra parameters specific to the huobi api endpoint
139336
- * @param {float} [params.stopPrice] the price a trigger order is triggered at
139337
- * @param {string} [params.triggerType] *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
139338
- * @param {float} [params.stopLossPrice] *contract only* the price a stop-loss order is triggered at
139339
- * @param {float} [params.takeProfitPrice] *contract only* the price a take-profit order is triggered at
139340
- * @param {string} [params.operator] *spot and margin only* gte or lte, trigger price condition
139341
- * @param {string} [params.offset] *contract only* 'open', 'close', or 'both', required in hedge mode
139342
- * @param {bool} [params.postOnly] *contract only* true or false
139343
- * @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
139344
- * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
139345
- * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
139346
- */
139347
- await this.loadMarkets();
139348
- const market = this.market(symbol);
139349
- const [marketType, query] = this.handleMarketTypeAndParams('createOrder', market, params);
139350
- if (marketType === 'spot') {
139351
- return await this.createSpotOrder(symbol, type, side, amount, price, query);
139352
- }
139353
- else {
139354
- return await this.createContractOrder(symbol, type, side, amount, price, query);
139355
- }
139356
- }
139357
- async createSpotOrder(symbol, type, side, amount, price = undefined, params = {}) {
139358
- /**
139359
139939
  * @ignore
139360
- * @method
139361
- * @name huobi#createSpotOrder
139362
- * @description create a spot trade order
139363
- * @see https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order
139940
+ * @name htx#createSpotOrderRequest
139941
+ * @description helper function to build request
139364
139942
  * @param {string} symbol unified symbol of the market to create an order in
139365
139943
  * @param {string} type 'market' or 'limit'
139366
139944
  * @param {string} side 'buy' or 'sell'
139367
- * @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
139368
139946
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
139369
- * @param {object} params extra parameters specific to the huobi api endpoint
139370
- * @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
139371
139950
  */
139372
139951
  await this.loadMarkets();
139373
139952
  await this.loadAccounts();
@@ -139469,52 +140048,22 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139469
140048
  request['price'] = this.priceToPrecision(symbol, price);
139470
140049
  }
139471
140050
  params = this.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
139472
- const response = await this.spotPrivatePostV1OrderOrdersPlace(this.extend(request, params));
139473
- //
139474
- // spot
139475
- //
139476
- // {"status":"ok","data":"438398393065481"}
139477
- //
139478
- const id = this.safeString(response, 'data');
139479
- return this.safeOrder({
139480
- 'info': response,
139481
- 'id': id,
139482
- 'timestamp': undefined,
139483
- 'datetime': undefined,
139484
- 'lastTradeTimestamp': undefined,
139485
- 'status': undefined,
139486
- 'symbol': undefined,
139487
- 'type': type,
139488
- 'side': side,
139489
- 'price': price,
139490
- 'amount': amount,
139491
- 'filled': undefined,
139492
- 'remaining': undefined,
139493
- 'cost': undefined,
139494
- 'trades': undefined,
139495
- 'fee': undefined,
139496
- 'clientOrderId': undefined,
139497
- 'average': undefined,
139498
- }, market);
140051
+ return this.extend(request, params);
139499
140052
  }
139500
- async createContractOrder(symbol, type, side, amount, price = undefined, params = {}) {
140053
+ createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
139501
140054
  /**
139502
- * @ignore
139503
140055
  * @method
139504
- * @name huobi#createContractOrder
139505
- * @description create a contract trade order
139506
- * @see https://huobiapi.github.io/docs/dm/v1/en/#place-an-order
139507
- * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order
139508
- * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order
139509
- * @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
139510
140059
  * @param {string} symbol unified symbol of the market to create an order in
139511
140060
  * @param {string} type 'market' or 'limit'
139512
140061
  * @param {string} side 'buy' or 'sell'
139513
- * @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
139514
140063
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
139515
- * @param {object} params extra parameters specific to the huobi api endpoint
140064
+ * @param {object} [params] extra parameters specific to the htx api endpoint
139516
140065
  * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
139517
- * @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
139518
140067
  */
139519
140068
  const market = this.market(symbol);
139520
140069
  const request = {
@@ -139586,63 +140135,117 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139586
140135
  request['lever_rate'] = leverRate;
139587
140136
  request['order_price_type'] = type;
139588
140137
  }
139589
- params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
139590
140138
  const broker = this.safeValue(this.options, 'broker', {});
139591
140139
  const brokerId = this.safeString(broker, 'id');
139592
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;
139593
140183
  let response = undefined;
139594
- if (market['linear']) {
139595
- let marginMode = undefined;
139596
- [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
139597
- marginMode = (marginMode === undefined) ? 'cross' : marginMode;
139598
- if (marginMode === 'isolated') {
139599
- if (isStop) {
139600
- response = await this.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(this.extend(request, params));
139601
- }
139602
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139603
- response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(this.extend(request, params));
139604
- }
139605
- else {
139606
- response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(this.extend(request, params));
139607
- }
139608
- }
139609
- else if (marginMode === 'cross') {
139610
- if (isStop) {
139611
- response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(this.extend(request, params));
139612
- }
139613
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139614
- response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(this.extend(request, params));
139615
- }
139616
- else {
139617
- response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(this.extend(request, params));
139618
- }
139619
- }
140184
+ if (market['spot']) {
140185
+ const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
140186
+ response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
139620
140187
  }
139621
- else if (market['inverse']) {
139622
- if (market['swap']) {
139623
- if (isStop) {
139624
- response = await this.contractPrivatePostSwapApiV1SwapTriggerOrder(this.extend(request, params));
139625
- }
139626
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139627
- 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
+ }
139628
140204
  }
139629
- else {
139630
- 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
+ }
139631
140215
  }
139632
140216
  }
139633
- else if (market['future']) {
139634
- if (isStop) {
139635
- response = await this.contractPrivatePostApiV1ContractTriggerOrder(this.extend(request, params));
139636
- }
139637
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
139638
- 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
+ }
139639
140228
  }
139640
- else {
139641
- 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
+ }
139642
140239
  }
139643
140240
  }
139644
140241
  }
139645
140242
  //
140243
+ // spot
140244
+ //
140245
+ // {"status":"ok","data":"438398393065481"}
140246
+ //
140247
+ // swap and future
140248
+ //
139646
140249
  // {
139647
140250
  // "status": "ok",
139648
140251
  // "data": {
@@ -139668,7 +140271,29 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139668
140271
  //
139669
140272
  let data = undefined;
139670
140273
  let result = undefined;
139671
- 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) {
139672
140297
  data = this.safeValue(response, 'data', {});
139673
140298
  result = this.safeValue(data, 'sl_order', {});
139674
140299
  }
@@ -139681,6 +140306,142 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139681
140306
  }
139682
140307
  return this.parseOrder(result, market);
139683
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
+ }
139684
140445
  async cancelOrder(id, symbol = undefined, params = {}) {
139685
140446
  /**
139686
140447
  * @method
@@ -148787,12 +149548,6 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
148787
149548
  'WithdrawInfo': 3,
148788
149549
  'WithdrawStatus': 3,
148789
149550
  'WalletTransfer': 3,
148790
- // staking
148791
- 'Stake': 3,
148792
- 'Unstake': 3,
148793
- 'Staking/Assets': 3,
148794
- 'Staking/Pending': 3,
148795
- 'Staking/Transactions': 3,
148796
149551
  // sub accounts
148797
149552
  'CreateSubaccount': 3,
148798
149553
  'AccountTransfer': 3,
@@ -149086,7 +149841,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149086
149841
  'max': undefined,
149087
149842
  },
149088
149843
  'cost': {
149089
- 'min': undefined,
149844
+ 'min': this.safeNumber(market, 'costmin'),
149090
149845
  'max': undefined,
149091
149846
  },
149092
149847
  },
@@ -149857,7 +150612,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149857
150612
  /**
149858
150613
  * @method
149859
150614
  * @name kraken#createOrder
149860
- * @see https://docs.kraken.com/rest/#tag/User-Trading/operation/addOrder
150615
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
149861
150616
  * @description create a trade order
149862
150617
  * @param {string} symbol unified symbol of the market to create an order in
149863
150618
  * @param {string} type 'market' or 'limit'
@@ -150200,7 +150955,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
150200
150955
  * @method
150201
150956
  * @name kraken#editOrder
150202
150957
  * @description edit a trade order
150203
- * @see https://docs.kraken.com/rest/#tag/User-Trading/operation/editOrder
150958
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/editOrder
150204
150959
  * @param {string} id order id
150205
150960
  * @param {string} symbol unified symbol of the market to create an order in
150206
150961
  * @param {string} type 'market' or 'limit'
@@ -150796,6 +151551,9 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
150796
151551
  const request = {
150797
151552
  'asset': currency['id'],
150798
151553
  };
151554
+ if (since !== undefined) {
151555
+ request['start'] = since;
151556
+ }
150799
151557
  const response = await this.privatePostDepositStatus(this.extend(request, params));
150800
151558
  //
150801
151559
  // { error: [],
@@ -151022,7 +151780,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151022
151780
  const request = {
151023
151781
  'asset': currency['id'],
151024
151782
  'amount': amount,
151025
- // 'address': address, // they don't allow withdrawals to direct addresses
151783
+ 'address': address,
151026
151784
  };
151027
151785
  const response = await this.privatePostWithdraw(this.extend(request, params));
151028
151786
  //
@@ -184643,6 +185401,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
184643
185401
  'fetchFundingRate': true,
184644
185402
  'fetchFundingRateHistory': true,
184645
185403
  'fetchFundingRates': false,
185404
+ 'fetchGreeks': true,
184646
185405
  'fetchIndexOHLCV': true,
184647
185406
  'fetchL3OrderBook': false,
184648
185407
  'fetchLedger': true,
@@ -191520,6 +192279,113 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191520
192279
  const underlyings = this.safeValue(response, 'data', []);
191521
192280
  return underlyings[0];
191522
192281
  }
192282
+ async fetchGreeks(symbol, params = {}) {
192283
+ /**
192284
+ * @method
192285
+ * @name okx#fetchGreeks
192286
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
192287
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
192288
+ * @param {string} symbol unified symbol of the market to fetch greeks for
192289
+ * @param {object} [params] extra parameters specific to the okx api endpoint
192290
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
192291
+ */
192292
+ await this.loadMarkets();
192293
+ const market = this.market(symbol);
192294
+ const marketId = market['id'];
192295
+ const optionParts = marketId.split('-');
192296
+ const request = {
192297
+ 'uly': market['info']['uly'],
192298
+ 'instFamily': market['info']['instFamily'],
192299
+ 'expTime': this.safeString(optionParts, 2),
192300
+ };
192301
+ const response = await this.publicGetPublicOptSummary(this.extend(request, params));
192302
+ //
192303
+ // {
192304
+ // "code": "0",
192305
+ // "data": [
192306
+ // {
192307
+ // "askVol": "0",
192308
+ // "bidVol": "0",
192309
+ // "delta": "0.5105464486882039",
192310
+ // "deltaBS": "0.7325502184143025",
192311
+ // "fwdPx": "37675.80158694987186",
192312
+ // "gamma": "-0.13183515090501083",
192313
+ // "gammaBS": "0.000024139685826358558",
192314
+ // "instId": "BTC-USD-240329-32000-C",
192315
+ // "instType": "OPTION",
192316
+ // "lever": "4.504428015946619",
192317
+ // "markVol": "0.5916253554539876",
192318
+ // "realVol": "0",
192319
+ // "theta": "-0.0004202992014012855",
192320
+ // "thetaBS": "-18.52354631567909",
192321
+ // "ts": "1699586421976",
192322
+ // "uly": "BTC-USD",
192323
+ // "vega": "0.0020207455080045846",
192324
+ // "vegaBS": "74.44022302387287",
192325
+ // "volLv": "0.5948549730405797"
192326
+ // },
192327
+ // ],
192328
+ // "msg": ""
192329
+ // }
192330
+ //
192331
+ const data = this.safeValue(response, 'data', []);
192332
+ for (let i = 0; i < data.length; i++) {
192333
+ const entry = data[i];
192334
+ const entryMarketId = this.safeString(entry, 'instId');
192335
+ if (entryMarketId === marketId) {
192336
+ return this.parseGreeks(entry, market);
192337
+ }
192338
+ }
192339
+ }
192340
+ parseGreeks(greeks, market = undefined) {
192341
+ //
192342
+ // {
192343
+ // "askVol": "0",
192344
+ // "bidVol": "0",
192345
+ // "delta": "0.5105464486882039",
192346
+ // "deltaBS": "0.7325502184143025",
192347
+ // "fwdPx": "37675.80158694987186",
192348
+ // "gamma": "-0.13183515090501083",
192349
+ // "gammaBS": "0.000024139685826358558",
192350
+ // "instId": "BTC-USD-240329-32000-C",
192351
+ // "instType": "OPTION",
192352
+ // "lever": "4.504428015946619",
192353
+ // "markVol": "0.5916253554539876",
192354
+ // "realVol": "0",
192355
+ // "theta": "-0.0004202992014012855",
192356
+ // "thetaBS": "-18.52354631567909",
192357
+ // "ts": "1699586421976",
192358
+ // "uly": "BTC-USD",
192359
+ // "vega": "0.0020207455080045846",
192360
+ // "vegaBS": "74.44022302387287",
192361
+ // "volLv": "0.5948549730405797"
192362
+ // }
192363
+ //
192364
+ const timestamp = this.safeInteger(greeks, 'ts');
192365
+ const marketId = this.safeString(greeks, 'instId');
192366
+ const symbol = this.safeSymbol(marketId, market);
192367
+ return {
192368
+ 'symbol': symbol,
192369
+ 'timestamp': timestamp,
192370
+ 'datetime': this.iso8601(timestamp),
192371
+ 'delta': this.safeNumber(greeks, 'delta'),
192372
+ 'gamma': this.safeNumber(greeks, 'gamma'),
192373
+ 'theta': this.safeNumber(greeks, 'theta'),
192374
+ 'vega': this.safeNumber(greeks, 'vega'),
192375
+ 'rho': undefined,
192376
+ 'bidSize': undefined,
192377
+ 'askSize': undefined,
192378
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bidVol'),
192379
+ 'askImpliedVolatility': this.safeNumber(greeks, 'askVol'),
192380
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markVol'),
192381
+ 'bidPrice': undefined,
192382
+ 'askPrice': undefined,
192383
+ 'markPrice': undefined,
192384
+ 'lastPrice': undefined,
192385
+ 'underlyingPrice': undefined,
192386
+ 'info': greeks,
192387
+ };
192388
+ }
191523
192389
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
191524
192390
  if (!response) {
191525
192391
  return undefined; // fallback to default error handler
@@ -235725,6 +236591,25 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
235725
236591
  // "reason": "cancelled_by_user"
235726
236592
  // }
235727
236593
  //
236594
+ // {
236595
+ // feed: 'open_orders',
236596
+ // order: {
236597
+ // instrument: 'PF_XBTUSD',
236598
+ // time: 1698159920097,
236599
+ // last_update_time: 1699835622988,
236600
+ // qty: 1.1,
236601
+ // filled: 0,
236602
+ // limit_price: 20000,
236603
+ // stop_price: 0,
236604
+ // type: 'limit',
236605
+ // order_id: '0eaf02b0-855d-4451-a3b7-e2b3070c1fa4',
236606
+ // direction: 0,
236607
+ // reduce_only: false
236608
+ // },
236609
+ // is_cancel: false,
236610
+ // reason: 'edited_by_user'
236611
+ // }
236612
+ //
235728
236613
  let orders = this.orders;
235729
236614
  if (orders === undefined) {
235730
236615
  const limit = this.safeInteger(this.options, 'ordersLimit');
@@ -235739,7 +236624,8 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
235739
236624
  const orderId = this.safeString(order, 'order_id');
235740
236625
  const previousOrders = this.safeValue(orders.hashmap, symbol, {});
235741
236626
  const previousOrder = this.safeValue(previousOrders, orderId);
235742
- if (previousOrder === undefined) {
236627
+ const reason = this.safeString(message, 'reason');
236628
+ if ((previousOrder === undefined) || (reason === 'edited_by_user')) {
235743
236629
  const parsed = this.parseWsOrder(order);
235744
236630
  orders.append(parsed);
235745
236631
  client.resolve(orders, messageHash);
@@ -235765,9 +236651,10 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
235765
236651
  }
235766
236652
  previousOrder['cost'] = totalCost;
235767
236653
  if (previousOrder['filled'] !== undefined) {
235768
- previousOrder['filled'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringAdd */ .O.stringAdd(previousOrder['filled'], this.numberToString(trade['amount']));
236654
+ const stringOrderFilled = this.numberToString(previousOrder['filled']);
236655
+ previousOrder['filled'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringAdd */ .O.stringAdd(stringOrderFilled, this.numberToString(trade['amount']));
235769
236656
  if (previousOrder['amount'] !== undefined) {
235770
- previousOrder['remaining'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringSub */ .O.stringSub(previousOrder['amount'], previousOrder['filled']);
236657
+ previousOrder['remaining'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringSub */ .O.stringSub(this.numberToString(previousOrder['amount']), stringOrderFilled);
235771
236658
  }
235772
236659
  }
235773
236660
  if (previousOrder['fee'] === undefined) {
@@ -285785,7 +286672,7 @@ SOFTWARE.
285785
286672
 
285786
286673
  //-----------------------------------------------------------------------------
285787
286674
  // this is updated by vss.js when building
285788
- const version = '4.1.49';
286675
+ const version = '4.1.51';
285789
286676
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
285790
286677
  //-----------------------------------------------------------------------------
285791
286678