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
package/js/src/delta.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/delta.js';
2
- import { Balances, Int, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade } from './base/types.js';
2
+ import { Balances, Greeks, Int, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade } from './base/types.js';
3
3
  /**
4
4
  * @class delta
5
5
  * @extends Exchange
@@ -208,6 +208,28 @@ export default class delta extends Exchange {
208
208
  datetime: string;
209
209
  };
210
210
  parseSettlements(settlements: any, market: any): any[];
211
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
212
+ parseGreeks(greeks: any, market?: any): {
213
+ symbol: any;
214
+ timestamp: number;
215
+ datetime: string;
216
+ delta: number;
217
+ gamma: number;
218
+ theta: number;
219
+ vega: number;
220
+ rho: number;
221
+ bidSize: number;
222
+ askSize: number;
223
+ bidImpliedVolatility: number;
224
+ askImpliedVolatility: number;
225
+ markImpliedVolatility: number;
226
+ bidPrice: number;
227
+ askPrice: number;
228
+ markPrice: number;
229
+ lastPrice: any;
230
+ underlyingPrice: number;
231
+ info: any;
232
+ };
211
233
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
212
234
  url: string;
213
235
  method: string;
package/js/src/delta.js CHANGED
@@ -47,6 +47,7 @@ export default class delta extends Exchange {
47
47
  'fetchFundingRate': true,
48
48
  'fetchFundingRateHistory': false,
49
49
  'fetchFundingRates': true,
50
+ 'fetchGreeks': true,
50
51
  'fetchIndexOHLCV': true,
51
52
  'fetchLedger': true,
52
53
  'fetchLeverage': true,
@@ -3023,6 +3024,154 @@ export default class delta extends Exchange {
3023
3024
  }
3024
3025
  return result;
3025
3026
  }
3027
+ async fetchGreeks(symbol, params = {}) {
3028
+ /**
3029
+ * @method
3030
+ * @name delta#fetchGreeks
3031
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
3032
+ * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
3033
+ * @param {string} symbol unified symbol of the market to fetch greeks for
3034
+ * @param {object} [params] extra parameters specific to the delta api endpoint
3035
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
3036
+ */
3037
+ await this.loadMarkets();
3038
+ const market = this.market(symbol);
3039
+ const request = {
3040
+ 'symbol': market['id'],
3041
+ };
3042
+ const response = await this.publicGetTickersSymbol(this.extend(request, params));
3043
+ //
3044
+ // {
3045
+ // "result": {
3046
+ // "close": 6793.0,
3047
+ // "contract_type": "call_options",
3048
+ // "greeks": {
3049
+ // "delta": "0.94739174",
3050
+ // "gamma": "0.00002206",
3051
+ // "rho": "11.00890725",
3052
+ // "spot": "36839.58124652",
3053
+ // "theta": "-18.18365310",
3054
+ // "vega": "7.85209698"
3055
+ // },
3056
+ // "high": 7556.0,
3057
+ // "low": 6793.0,
3058
+ // "mark_price": "6955.70698909",
3059
+ // "mark_vol": "0.66916863",
3060
+ // "oi": "1.8980",
3061
+ // "oi_change_usd_6h": "110.4600",
3062
+ // "oi_contracts": "1898",
3063
+ // "oi_value": "1.8980",
3064
+ // "oi_value_symbol": "BTC",
3065
+ // "oi_value_usd": "69940.7319",
3066
+ // "open": 7.2e3,
3067
+ // "price_band": {
3068
+ // "lower_limit": "5533.89814767",
3069
+ // "upper_limit": "11691.37688371"
3070
+ // },
3071
+ // "product_id": 129508,
3072
+ // "quotes": {
3073
+ // "ask_iv": "0.90180438",
3074
+ // "ask_size": "1898",
3075
+ // "best_ask": "7210",
3076
+ // "best_bid": "6913",
3077
+ // "bid_iv": "0.60881706",
3078
+ // "bid_size": "3163",
3079
+ // "impact_mid_price": null,
3080
+ // "mark_iv": "0.66973549"
3081
+ // },
3082
+ // "size": 5,
3083
+ // "spot_price": "36839.58153868",
3084
+ // "strike_price": "30000",
3085
+ // "symbol": "C-BTC-30000-241123",
3086
+ // "timestamp": 1699584998504530,
3087
+ // "turnover": 184.41206804,
3088
+ // "turnover_symbol": "USDT",
3089
+ // "turnover_usd": 184.41206804,
3090
+ // "volume": 0.005
3091
+ // },
3092
+ // "success": true
3093
+ // }
3094
+ //
3095
+ const result = this.safeValue(response, 'result', {});
3096
+ return this.parseGreeks(result, market);
3097
+ }
3098
+ parseGreeks(greeks, market = undefined) {
3099
+ //
3100
+ // {
3101
+ // "close": 6793.0,
3102
+ // "contract_type": "call_options",
3103
+ // "greeks": {
3104
+ // "delta": "0.94739174",
3105
+ // "gamma": "0.00002206",
3106
+ // "rho": "11.00890725",
3107
+ // "spot": "36839.58124652",
3108
+ // "theta": "-18.18365310",
3109
+ // "vega": "7.85209698"
3110
+ // },
3111
+ // "high": 7556.0,
3112
+ // "low": 6793.0,
3113
+ // "mark_price": "6955.70698909",
3114
+ // "mark_vol": "0.66916863",
3115
+ // "oi": "1.8980",
3116
+ // "oi_change_usd_6h": "110.4600",
3117
+ // "oi_contracts": "1898",
3118
+ // "oi_value": "1.8980",
3119
+ // "oi_value_symbol": "BTC",
3120
+ // "oi_value_usd": "69940.7319",
3121
+ // "open": 7.2e3,
3122
+ // "price_band": {
3123
+ // "lower_limit": "5533.89814767",
3124
+ // "upper_limit": "11691.37688371"
3125
+ // },
3126
+ // "product_id": 129508,
3127
+ // "quotes": {
3128
+ // "ask_iv": "0.90180438",
3129
+ // "ask_size": "1898",
3130
+ // "best_ask": "7210",
3131
+ // "best_bid": "6913",
3132
+ // "bid_iv": "0.60881706",
3133
+ // "bid_size": "3163",
3134
+ // "impact_mid_price": null,
3135
+ // "mark_iv": "0.66973549"
3136
+ // },
3137
+ // "size": 5,
3138
+ // "spot_price": "36839.58153868",
3139
+ // "strike_price": "30000",
3140
+ // "symbol": "C-BTC-30000-241123",
3141
+ // "timestamp": 1699584998504530,
3142
+ // "turnover": 184.41206804,
3143
+ // "turnover_symbol": "USDT",
3144
+ // "turnover_usd": 184.41206804,
3145
+ // "volume": 0.005
3146
+ // }
3147
+ //
3148
+ const timestamp = this.safeIntegerProduct(greeks, 'timestamp', 0.001);
3149
+ const marketId = this.safeString(greeks, 'symbol');
3150
+ const symbol = this.safeSymbol(marketId, market);
3151
+ const stats = this.safeValue(greeks, 'greeks', {});
3152
+ const quotes = this.safeValue(greeks, 'quotes', {});
3153
+ return {
3154
+ 'symbol': symbol,
3155
+ 'timestamp': timestamp,
3156
+ 'datetime': this.iso8601(timestamp),
3157
+ 'delta': this.safeNumber(stats, 'delta'),
3158
+ 'gamma': this.safeNumber(stats, 'gamma'),
3159
+ 'theta': this.safeNumber(stats, 'theta'),
3160
+ 'vega': this.safeNumber(stats, 'vega'),
3161
+ 'rho': this.safeNumber(stats, 'rho'),
3162
+ 'bidSize': this.safeNumber(quotes, 'bid_size'),
3163
+ 'askSize': this.safeNumber(quotes, 'ask_size'),
3164
+ 'bidImpliedVolatility': this.safeNumber(quotes, 'bid_iv'),
3165
+ 'askImpliedVolatility': this.safeNumber(quotes, 'ask_iv'),
3166
+ 'markImpliedVolatility': this.safeNumber(quotes, 'mark_iv'),
3167
+ 'bidPrice': this.safeNumber(quotes, 'best_bid'),
3168
+ 'askPrice': this.safeNumber(quotes, 'best_ask'),
3169
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
3170
+ 'lastPrice': undefined,
3171
+ 'underlyingPrice': this.safeNumber(greeks, 'spot_price'),
3172
+ 'info': greeks,
3173
+ };
3174
+ }
3026
3175
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3027
3176
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
3028
3177
  let url = this.urls['api'][api] + requestPath;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/deribit.js';
2
- import { Balances, FundingRateHistory, Int, Liquidation, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction } from './base/types.js';
2
+ import { Balances, FundingRateHistory, Greeks, Int, Liquidation, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class deribit
5
5
  * @extends Exchange
@@ -150,6 +150,28 @@ export default class deribit extends Exchange {
150
150
  addPaginationCursorToResult(cursor: any, data: any): any;
151
151
  fetchMyLiquidations(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
152
152
  parseLiquidation(liquidation: any, market?: any): Liquidation;
153
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
154
+ parseGreeks(greeks: any, market?: any): {
155
+ symbol: any;
156
+ timestamp: number;
157
+ datetime: string;
158
+ delta: number;
159
+ gamma: number;
160
+ theta: number;
161
+ vega: number;
162
+ rho: number;
163
+ bidSize: number;
164
+ askSize: number;
165
+ bidImpliedVolatility: number;
166
+ askImpliedVolatility: number;
167
+ markImpliedVolatility: number;
168
+ bidPrice: number;
169
+ askPrice: number;
170
+ markPrice: number;
171
+ lastPrice: number;
172
+ underlyingPrice: number;
173
+ info: any;
174
+ };
153
175
  nonce(): number;
154
176
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
155
177
  url: string;
package/js/src/deribit.js CHANGED
@@ -59,6 +59,7 @@ export default class deribit extends Exchange {
59
59
  'fetchDepositWithdrawFees': true,
60
60
  'fetchFundingRate': true,
61
61
  'fetchFundingRateHistory': true,
62
+ 'fetchGreeks': true,
62
63
  'fetchIndexOHLCV': false,
63
64
  'fetchLeverageTiers': false,
64
65
  'fetchLiquidations': true,
@@ -3082,6 +3083,137 @@ export default class deribit extends Exchange {
3082
3083
  'datetime': this.iso8601(timestamp),
3083
3084
  });
3084
3085
  }
3086
+ async fetchGreeks(symbol, params = {}) {
3087
+ /**
3088
+ * @method
3089
+ * @name deribit#fetchGreeks
3090
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
3091
+ * @see https://docs.deribit.com/#public-ticker
3092
+ * @param {string} symbol unified symbol of the market to fetch greeks for
3093
+ * @param {object} [params] extra parameters specific to the deribit api endpoint
3094
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
3095
+ */
3096
+ await this.loadMarkets();
3097
+ const market = this.market(symbol);
3098
+ const request = {
3099
+ 'instrument_name': market['id'],
3100
+ };
3101
+ const response = await this.publicGetTicker(this.extend(request, params));
3102
+ //
3103
+ // {
3104
+ // "jsonrpc": "2.0",
3105
+ // "result": {
3106
+ // "estimated_delivery_price": 36552.72,
3107
+ // "best_bid_amount": 0.2,
3108
+ // "best_ask_amount": 9.1,
3109
+ // "interest_rate": 0.0,
3110
+ // "best_bid_price": 0.214,
3111
+ // "best_ask_price": 0.219,
3112
+ // "open_interest": 368.8,
3113
+ // "settlement_price": 0.22103022,
3114
+ // "last_price": 0.215,
3115
+ // "bid_iv": 60.51,
3116
+ // "ask_iv": 61.88,
3117
+ // "mark_iv": 61.27,
3118
+ // "underlying_index": "BTC-27SEP24",
3119
+ // "underlying_price": 38992.71,
3120
+ // "min_price": 0.1515,
3121
+ // "max_price": 0.326,
3122
+ // "mark_price": 0.2168,
3123
+ // "instrument_name": "BTC-27SEP24-40000-C",
3124
+ // "index_price": 36552.72,
3125
+ // "greeks": {
3126
+ // "rho": 130.63998,
3127
+ // "theta": -13.48784,
3128
+ // "vega": 141.90146,
3129
+ // "gamma": 0.00002,
3130
+ // "delta": 0.59621
3131
+ // },
3132
+ // "stats": {
3133
+ // "volume_usd": 100453.9,
3134
+ // "volume": 12.0,
3135
+ // "price_change": -2.2727,
3136
+ // "low": 0.2065,
3137
+ // "high": 0.238
3138
+ // },
3139
+ // "state": "open",
3140
+ // "timestamp": 1699578548021
3141
+ // },
3142
+ // "usIn": 1699578548308414,
3143
+ // "usOut": 1699578548308606,
3144
+ // "usDiff": 192,
3145
+ // "testnet": false
3146
+ // }
3147
+ //
3148
+ const result = this.safeValue(response, 'result', {});
3149
+ return this.parseGreeks(result, market);
3150
+ }
3151
+ parseGreeks(greeks, market = undefined) {
3152
+ //
3153
+ // {
3154
+ // "estimated_delivery_price": 36552.72,
3155
+ // "best_bid_amount": 0.2,
3156
+ // "best_ask_amount": 9.1,
3157
+ // "interest_rate": 0.0,
3158
+ // "best_bid_price": 0.214,
3159
+ // "best_ask_price": 0.219,
3160
+ // "open_interest": 368.8,
3161
+ // "settlement_price": 0.22103022,
3162
+ // "last_price": 0.215,
3163
+ // "bid_iv": 60.51,
3164
+ // "ask_iv": 61.88,
3165
+ // "mark_iv": 61.27,
3166
+ // "underlying_index": "BTC-27SEP24",
3167
+ // "underlying_price": 38992.71,
3168
+ // "min_price": 0.1515,
3169
+ // "max_price": 0.326,
3170
+ // "mark_price": 0.2168,
3171
+ // "instrument_name": "BTC-27SEP24-40000-C",
3172
+ // "index_price": 36552.72,
3173
+ // "greeks": {
3174
+ // "rho": 130.63998,
3175
+ // "theta": -13.48784,
3176
+ // "vega": 141.90146,
3177
+ // "gamma": 0.00002,
3178
+ // "delta": 0.59621
3179
+ // },
3180
+ // "stats": {
3181
+ // "volume_usd": 100453.9,
3182
+ // "volume": 12.0,
3183
+ // "price_change": -2.2727,
3184
+ // "low": 0.2065,
3185
+ // "high": 0.238
3186
+ // },
3187
+ // "state": "open",
3188
+ // "timestamp": 1699578548021
3189
+ // }
3190
+ //
3191
+ const timestamp = this.safeInteger(greeks, 'timestamp');
3192
+ const marketId = this.safeString(greeks, 'instrument_name');
3193
+ const symbol = this.safeSymbol(marketId, market);
3194
+ const stats = this.safeValue(greeks, 'greeks', {});
3195
+ return {
3196
+ 'symbol': symbol,
3197
+ 'timestamp': timestamp,
3198
+ 'datetime': this.iso8601(timestamp),
3199
+ 'delta': this.safeNumber(stats, 'delta'),
3200
+ 'gamma': this.safeNumber(stats, 'gamma'),
3201
+ 'theta': this.safeNumber(stats, 'theta'),
3202
+ 'vega': this.safeNumber(stats, 'vega'),
3203
+ 'rho': this.safeNumber(stats, 'rho'),
3204
+ 'bidSize': this.safeNumber(greeks, 'best_bid_amount'),
3205
+ 'askSize': this.safeNumber(greeks, 'best_ask_amount'),
3206
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
3207
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
3208
+ 'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
3209
+ 'bidPrice': this.safeNumber(greeks, 'best_bid_price'),
3210
+ 'askPrice': this.safeNumber(greeks, 'best_ask_price'),
3211
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
3212
+ 'lastPrice': this.safeNumber(greeks, 'last_price'),
3213
+ 'underlyingPrice': this.safeNumber(greeks, 'underlying_price'),
3214
+ 'info': greeks,
3215
+ };
3216
+ }
3085
3217
  nonce() {
3086
3218
  return this.milliseconds();
3087
3219
  }
package/js/src/gate.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/gate.js';
2
- import { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Transaction, Ticker, OrderBook, Tickers } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Transaction, Ticker, OrderBook, Tickers, Greeks } from './base/types.js';
3
3
  /**
4
4
  * @class gate
5
5
  * @extends Exchange
@@ -371,5 +371,27 @@ export default class gate extends Exchange {
371
371
  fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
372
372
  fetchMyLiquidations(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
373
373
  parseLiquidation(liquidation: any, market?: any): import("./base/types.js").Liquidation;
374
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
375
+ parseGreeks(greeks: any, market?: any): {
376
+ symbol: any;
377
+ timestamp: any;
378
+ datetime: any;
379
+ delta: number;
380
+ gamma: number;
381
+ theta: number;
382
+ vega: number;
383
+ rho: any;
384
+ bidSize: number;
385
+ askSize: number;
386
+ bidImpliedVolatility: number;
387
+ askImpliedVolatility: number;
388
+ markImpliedVolatility: number;
389
+ bidPrice: number;
390
+ askPrice: number;
391
+ markPrice: number;
392
+ lastPrice: number;
393
+ underlyingPrice: number;
394
+ info: any;
395
+ };
374
396
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
375
397
  }
package/js/src/gate.js CHANGED
@@ -105,6 +105,7 @@ export default class gate extends Exchange {
105
105
  'fetchFundingRate': true,
106
106
  'fetchFundingRateHistory': true,
107
107
  'fetchFundingRates': true,
108
+ 'fetchGreeks': true,
108
109
  'fetchIndexOHLCV': true,
109
110
  'fetchLedger': true,
110
111
  'fetchLeverage': false,
@@ -4078,6 +4079,7 @@ export default class gate extends Exchange {
4078
4079
  * @name gate#editOrder
4079
4080
  * @description edit a trade order, gate currently only supports the modification of the price or amount fields
4080
4081
  * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order
4082
+ * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order-2
4081
4083
  * @param {string} id order id
4082
4084
  * @param {string} symbol unified symbol of the market to create an order in
4083
4085
  * @param {string} type 'market' or 'limit'
@@ -4089,9 +4091,6 @@ export default class gate extends Exchange {
4089
4091
  */
4090
4092
  await this.loadMarkets();
4091
4093
  const market = this.market(symbol);
4092
- if (!market['spot']) {
4093
- throw new BadRequest(this.id + ' editOrder() supports only spot markets');
4094
- }
4095
4094
  const [marketType, query] = this.handleMarketTypeAndParams('editOrder', market, params);
4096
4095
  const account = this.convertTypeToAccount(marketType);
4097
4096
  const isLimitOrder = (type === 'limit');
@@ -4112,7 +4111,14 @@ export default class gate extends Exchange {
4112
4111
  if (price !== undefined) {
4113
4112
  request['price'] = this.priceToPrecision(symbol, price);
4114
4113
  }
4115
- const response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
4114
+ let response = undefined;
4115
+ if (market['spot']) {
4116
+ response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
4117
+ }
4118
+ else {
4119
+ request['settle'] = market['settleId'];
4120
+ response = await this.privateFuturesPutSettleOrdersOrderId(this.extend(request, query));
4121
+ }
4116
4122
  //
4117
4123
  // {
4118
4124
  // "id": "243233276443",
@@ -6671,6 +6677,98 @@ export default class gate extends Exchange {
6671
6677
  'datetime': this.iso8601(timestamp),
6672
6678
  });
6673
6679
  }
6680
+ async fetchGreeks(symbol, params = {}) {
6681
+ /**
6682
+ * @method
6683
+ * @name gate#fetchGreeks
6684
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
6685
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-tickers-of-options-contracts
6686
+ * @param {string} symbol unified symbol of the market to fetch greeks for
6687
+ * @param {object} [params] extra parameters specific to the gate api endpoint
6688
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
6689
+ */
6690
+ await this.loadMarkets();
6691
+ const market = this.market(symbol);
6692
+ const request = {
6693
+ 'underlying': market['info']['underlying'],
6694
+ };
6695
+ const response = await this.publicOptionsGetTickers(this.extend(request, params));
6696
+ //
6697
+ // [
6698
+ // {
6699
+ // "vega": "1.78992",
6700
+ // "leverage": "6.2096777055417",
6701
+ // "ask_iv": "0.6245",
6702
+ // "delta": "-0.69397",
6703
+ // "last_price": "0",
6704
+ // "theta": "-2.5723",
6705
+ // "bid1_price": "222.9",
6706
+ // "mark_iv": "0.5909",
6707
+ // "name": "ETH_USDT-20231201-2300-P",
6708
+ // "bid_iv": "0.5065",
6709
+ // "ask1_price": "243.6",
6710
+ // "mark_price": "236.57",
6711
+ // "position_size": 0,
6712
+ // "bid1_size": 368,
6713
+ // "ask1_size": -335,
6714
+ // "gamma": "0.00116"
6715
+ // },
6716
+ // ]
6717
+ //
6718
+ const marketId = market['id'];
6719
+ for (let i = 0; i < response.length; i++) {
6720
+ const entry = response[i];
6721
+ const entryMarketId = this.safeString(entry, 'name');
6722
+ if (entryMarketId === marketId) {
6723
+ return this.parseGreeks(entry, market);
6724
+ }
6725
+ }
6726
+ }
6727
+ parseGreeks(greeks, market = undefined) {
6728
+ //
6729
+ // {
6730
+ // "vega": "1.78992",
6731
+ // "leverage": "6.2096777055417",
6732
+ // "ask_iv": "0.6245",
6733
+ // "delta": "-0.69397",
6734
+ // "last_price": "0",
6735
+ // "theta": "-2.5723",
6736
+ // "bid1_price": "222.9",
6737
+ // "mark_iv": "0.5909",
6738
+ // "name": "ETH_USDT-20231201-2300-P",
6739
+ // "bid_iv": "0.5065",
6740
+ // "ask1_price": "243.6",
6741
+ // "mark_price": "236.57",
6742
+ // "position_size": 0,
6743
+ // "bid1_size": 368,
6744
+ // "ask1_size": -335,
6745
+ // "gamma": "0.00116"
6746
+ // }
6747
+ //
6748
+ const marketId = this.safeString(greeks, 'name');
6749
+ const symbol = this.safeSymbol(marketId, market);
6750
+ return {
6751
+ 'symbol': symbol,
6752
+ 'timestamp': undefined,
6753
+ 'datetime': undefined,
6754
+ 'delta': this.safeNumber(greeks, 'delta'),
6755
+ 'gamma': this.safeNumber(greeks, 'gamma'),
6756
+ 'theta': this.safeNumber(greeks, 'theta'),
6757
+ 'vega': this.safeNumber(greeks, 'vega'),
6758
+ 'rho': undefined,
6759
+ 'bidSize': this.safeNumber(greeks, 'bid1_size'),
6760
+ 'askSize': this.safeNumber(greeks, 'ask1_size'),
6761
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
6762
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
6763
+ 'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
6764
+ 'bidPrice': this.safeNumber(greeks, 'bid1_price'),
6765
+ 'askPrice': this.safeNumber(greeks, 'ask1_price'),
6766
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
6767
+ 'lastPrice': this.safeNumber(greeks, 'last_price'),
6768
+ 'underlyingPrice': this.parseNumber(market['info']['underlying_price']),
6769
+ 'info': greeks,
6770
+ };
6771
+ }
6674
6772
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
6675
6773
  if (response === undefined) {
6676
6774
  return undefined;
package/js/src/htx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/htx.js';
2
- import { Int, OrderSide, OrderType, Order, OHLCV, Trade, FundingRateHistory, Balances, Transaction, Ticker, OrderBook, Tickers } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, Order, OHLCV, Trade, FundingRateHistory, Balances, Transaction, Ticker, OrderBook, Tickers, OrderRequest } from './base/types.js';
3
3
  /**
4
4
  * @class huobi
5
5
  * @extends Exchange
@@ -83,9 +83,10 @@ export default class htx extends Exchange {
83
83
  fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
84
84
  parseOrderStatus(status: any): string;
85
85
  parseOrder(order: any, market?: any): Order;
86
+ createSpotOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<any>;
87
+ createContractOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
86
88
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
87
- createSpotOrder(symbol: string, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
88
- createContractOrder(symbol: string, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
89
+ createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
89
90
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<any>;
90
91
  cancelOrders(ids: any, symbol?: string, params?: {}): Promise<any>;
91
92
  cancelAllOrders(symbol?: string, params?: {}): Promise<any>;