ccxt 4.1.48 → 4.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.js +1134 -216
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +76 -0
  7. package/dist/cjs/src/bybit.js +121 -0
  8. package/dist/cjs/src/coinex.js +67 -18
  9. package/dist/cjs/src/cryptocom.js +1 -0
  10. package/dist/cjs/src/delta.js +149 -0
  11. package/dist/cjs/src/deribit.js +132 -0
  12. package/dist/cjs/src/gate.js +102 -4
  13. package/dist/cjs/src/htx.js +313 -135
  14. package/dist/cjs/src/mexc.js +21 -21
  15. package/dist/cjs/src/okx.js +108 -0
  16. package/js/ccxt.d.ts +3 -3
  17. package/js/ccxt.js +1 -1
  18. package/js/src/abstract/htx.d.ts +1 -1
  19. package/js/src/abstract/huobi.d.ts +1 -1
  20. package/js/src/abstract/huobi.js +3 -3
  21. package/js/src/abstract/huobipro.d.ts +1 -1
  22. package/js/src/base/Exchange.d.ts +4 -2
  23. package/js/src/base/Exchange.js +6 -0
  24. package/js/src/base/types.d.ts +21 -0
  25. package/js/src/binance.d.ts +23 -1
  26. package/js/src/binance.js +76 -0
  27. package/js/src/bybit.d.ts +23 -1
  28. package/js/src/bybit.js +121 -0
  29. package/js/src/coinex.js +67 -18
  30. package/js/src/cryptocom.js +1 -0
  31. package/js/src/delta.d.ts +23 -1
  32. package/js/src/delta.js +149 -0
  33. package/js/src/deribit.d.ts +23 -1
  34. package/js/src/deribit.js +132 -0
  35. package/js/src/gate.d.ts +23 -1
  36. package/js/src/gate.js +102 -4
  37. package/js/src/htx.d.ts +4 -3
  38. package/js/src/htx.js +313 -135
  39. package/js/src/mexc.js +21 -21
  40. package/js/src/okx.d.ts +23 -1
  41. package/js/src/okx.js +108 -0
  42. package/package.json +1 -1
  43. package/skip-tests.json +2 -0
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>;