ccxt 4.2.78 → 4.2.80

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 (75) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.js +517 -79
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +35 -3
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/bingx.js +39 -5
  8. package/dist/cjs/src/bitstamp.js +21 -26
  9. package/dist/cjs/src/bybit.js +101 -0
  10. package/dist/cjs/src/coinbaseinternational.js +2 -2
  11. package/dist/cjs/src/deribit.js +155 -0
  12. package/dist/cjs/src/gate.js +15 -4
  13. package/dist/cjs/src/hyperliquid.js +54 -10
  14. package/dist/cjs/src/pro/alpaca.js +1 -1
  15. package/dist/cjs/src/pro/binance.js +5 -5
  16. package/dist/cjs/src/pro/bitfinex2.js +1 -1
  17. package/dist/cjs/src/pro/bitget.js +1 -1
  18. package/dist/cjs/src/pro/bitmart.js +1 -1
  19. package/dist/cjs/src/pro/bitmex.js +1 -1
  20. package/dist/cjs/src/pro/bitopro.js +2 -1
  21. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  22. package/dist/cjs/src/pro/bybit.js +16 -1
  23. package/dist/cjs/src/pro/cex.js +9 -5
  24. package/dist/cjs/src/pro/cryptocom.js +1 -1
  25. package/dist/cjs/src/pro/gemini.js +3 -2
  26. package/dist/cjs/src/pro/hitbtc.js +1 -1
  27. package/dist/cjs/src/pro/htx.js +1 -1
  28. package/dist/cjs/src/pro/okcoin.js +1 -1
  29. package/dist/cjs/src/pro/onetrading.js +1 -1
  30. package/dist/cjs/src/pro/phemex.js +7 -2
  31. package/dist/cjs/src/pro/woo.js +38 -0
  32. package/dist/cjs/src/upbit.js +2 -0
  33. package/js/ccxt.d.ts +3 -3
  34. package/js/ccxt.js +1 -1
  35. package/js/src/abstract/bingx.d.ts +1 -0
  36. package/js/src/abstract/gate.d.ts +1 -0
  37. package/js/src/abstract/gateio.d.ts +1 -0
  38. package/js/src/abstract/upbit.d.ts +1 -0
  39. package/js/src/base/Exchange.d.ts +14 -5
  40. package/js/src/base/Exchange.js +35 -3
  41. package/js/src/base/types.d.ts +21 -0
  42. package/js/src/binance.d.ts +2 -2
  43. package/js/src/binance.js +1 -1
  44. package/js/src/bingx.js +39 -5
  45. package/js/src/bitstamp.js +21 -26
  46. package/js/src/bybit.d.ts +12 -1
  47. package/js/src/bybit.js +101 -0
  48. package/js/src/coinbaseinternational.js +2 -2
  49. package/js/src/deribit.d.ts +22 -1
  50. package/js/src/deribit.js +155 -0
  51. package/js/src/gate.js +15 -4
  52. package/js/src/hyperliquid.d.ts +1 -0
  53. package/js/src/hyperliquid.js +54 -10
  54. package/js/src/pro/alpaca.js +1 -1
  55. package/js/src/pro/binance.js +5 -5
  56. package/js/src/pro/bitfinex2.js +1 -1
  57. package/js/src/pro/bitget.js +1 -1
  58. package/js/src/pro/bitmart.js +1 -1
  59. package/js/src/pro/bitmex.js +1 -1
  60. package/js/src/pro/bitopro.js +2 -1
  61. package/js/src/pro/blockchaincom.js +1 -1
  62. package/js/src/pro/bybit.js +16 -1
  63. package/js/src/pro/cex.js +9 -5
  64. package/js/src/pro/cryptocom.js +1 -1
  65. package/js/src/pro/gemini.d.ts +2 -2
  66. package/js/src/pro/gemini.js +3 -2
  67. package/js/src/pro/hitbtc.js +1 -1
  68. package/js/src/pro/htx.js +1 -1
  69. package/js/src/pro/okcoin.js +1 -1
  70. package/js/src/pro/onetrading.js +1 -1
  71. package/js/src/pro/phemex.js +7 -2
  72. package/js/src/pro/woo.js +38 -0
  73. package/js/src/upbit.js +2 -0
  74. package/package.json +1 -1
  75. package/skip-tests.json +7 -2
package/dist/cjs/ccxt.js CHANGED
@@ -181,7 +181,7 @@ var woo$1 = require('./src/pro/woo.js');
181
181
 
182
182
  //-----------------------------------------------------------------------------
183
183
  // this is updated by vss.js when building
184
- const version = '4.2.78';
184
+ const version = '4.2.80';
185
185
  Exchange["default"].ccxtVersion = version;
186
186
  const exchanges = {
187
187
  'ace': ace,
@@ -468,6 +468,8 @@ class Exchange {
468
468
  'fetchOpenOrder': undefined,
469
469
  'fetchOpenOrders': undefined,
470
470
  'fetchOpenOrdersWs': undefined,
471
+ 'fetchOption': undefined,
472
+ 'fetchOptionChain': undefined,
471
473
  'fetchOrder': undefined,
472
474
  'fetchOrderBook': true,
473
475
  'fetchOrderBooks': undefined,
@@ -1437,6 +1439,12 @@ class Exchange {
1437
1439
  intToBase16(elem) {
1438
1440
  return elem.toString(16);
1439
1441
  }
1442
+ extendExchangeOptions(newOptions) {
1443
+ this.options = this.extend(this.options, newOptions);
1444
+ }
1445
+ createSafeDictionary() {
1446
+ return {};
1447
+ }
1440
1448
  /* eslint-enable */
1441
1449
  // ------------------------------------------------------------------------
1442
1450
  // ########################################################################
@@ -3137,7 +3145,7 @@ class Exchange {
3137
3145
  throw new errors.BadResponse(errorMessage);
3138
3146
  }
3139
3147
  }
3140
- marketIds(symbols) {
3148
+ marketIds(symbols = undefined) {
3141
3149
  if (symbols === undefined) {
3142
3150
  return symbols;
3143
3151
  }
@@ -3147,7 +3155,7 @@ class Exchange {
3147
3155
  }
3148
3156
  return result;
3149
3157
  }
3150
- marketSymbols(symbols, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
3158
+ marketSymbols(symbols = undefined, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
3151
3159
  if (symbols === undefined) {
3152
3160
  if (!allowEmpty) {
3153
3161
  throw new errors.ArgumentsRequired(this.id + ' empty list of symbols is not supported');
@@ -3188,7 +3196,7 @@ class Exchange {
3188
3196
  }
3189
3197
  return result;
3190
3198
  }
3191
- marketCodes(codes) {
3199
+ marketCodes(codes = undefined) {
3192
3200
  if (codes === undefined) {
3193
3201
  return codes;
3194
3202
  }
@@ -4128,6 +4136,9 @@ class Exchange {
4128
4136
  async fetchOrderBooks(symbols = undefined, limit = undefined, params = {}) {
4129
4137
  throw new errors.NotSupported(this.id + ' fetchOrderBooks() is not supported yet');
4130
4138
  }
4139
+ async watchBidsAsks(symbols = undefined, params = {}) {
4140
+ throw new errors.NotSupported(this.id + ' watchBidsAsks() is not supported yet');
4141
+ }
4131
4142
  async watchTickers(symbols = undefined, params = {}) {
4132
4143
  throw new errors.NotSupported(this.id + ' watchTickers() is not supported yet');
4133
4144
  }
@@ -4480,6 +4491,12 @@ class Exchange {
4480
4491
  async fetchGreeks(symbol, params = {}) {
4481
4492
  throw new errors.NotSupported(this.id + ' fetchGreeks() is not supported yet');
4482
4493
  }
4494
+ async fetchOptionChain(code, params = {}) {
4495
+ throw new errors.NotSupported(this.id + ' fetchOptionChain() is not supported yet');
4496
+ }
4497
+ async fetchOption(symbol, params = {}) {
4498
+ throw new errors.NotSupported(this.id + ' fetchOption() is not supported yet');
4499
+ }
4483
4500
  async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
4484
4501
  /**
4485
4502
  * @method
@@ -5658,6 +5675,21 @@ class Exchange {
5658
5675
  parseGreeks(greeks, market = undefined) {
5659
5676
  throw new errors.NotSupported(this.id + ' parseGreeks () is not supported yet');
5660
5677
  }
5678
+ parseOption(chain, currency = undefined, market = undefined) {
5679
+ throw new errors.NotSupported(this.id + ' parseOption () is not supported yet');
5680
+ }
5681
+ parseOptionChain(response, currencyKey = undefined, symbolKey = undefined) {
5682
+ const optionStructures = {};
5683
+ for (let i = 0; i < response.length; i++) {
5684
+ const info = response[i];
5685
+ const currencyId = this.safeString(info, currencyKey);
5686
+ const currency = this.safeCurrency(currencyId);
5687
+ const marketId = this.safeString(info, symbolKey);
5688
+ const market = this.safeMarket(marketId, undefined, undefined, 'option');
5689
+ optionStructures[market['symbol']] = this.parseOption(info, currency, market);
5690
+ }
5691
+ return optionStructures;
5692
+ }
5661
5693
  parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
5662
5694
  const marginModeStructures = {};
5663
5695
  for (let i = 0; i < response.length; i++) {
@@ -2402,7 +2402,7 @@ class binance extends binance$1 {
2402
2402
  }
2403
2403
  isInverse(type, subType = undefined) {
2404
2404
  if (subType === undefined) {
2405
- return type === 'delivery';
2405
+ return (type === 'delivery');
2406
2406
  }
2407
2407
  else {
2408
2408
  return subType === 'inverse';
@@ -182,6 +182,7 @@ class bingx extends bingx$1 {
182
182
  'post': {
183
183
  'trade/cancelReplace': 1,
184
184
  'positionSide/dual': 1,
185
+ 'trade/closePosition': 1,
185
186
  },
186
187
  },
187
188
  },
@@ -2163,6 +2164,8 @@ class bingx extends bingx$1 {
2163
2164
  'SELL': 'sell',
2164
2165
  'SHORT': 'sell',
2165
2166
  'LONG': 'buy',
2167
+ 'ask': 'sell',
2168
+ 'bid': 'buy',
2166
2169
  };
2167
2170
  return this.safeString(sides, side, side);
2168
2171
  }
@@ -3910,14 +3913,45 @@ class bingx extends bingx$1 {
3910
3913
  * @param {string} symbol Unified CCXT market symbol
3911
3914
  * @param {string} [side] not used by bingx
3912
3915
  * @param {object} [params] extra parameters specific to the bingx api endpoint
3916
+ * @param {string|undefined} [params.positionId] it is recommended to fill in this parameter when closing a position
3913
3917
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3914
3918
  */
3915
3919
  await this.loadMarkets();
3916
- const market = this.market(symbol);
3917
- const request = {
3918
- 'symbol': market['id'],
3919
- };
3920
- const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
3920
+ const positionId = this.safeString(params, 'positionId');
3921
+ params = this.omit(params, 'positionId');
3922
+ let response = undefined;
3923
+ if (positionId !== undefined) {
3924
+ const request = {
3925
+ 'positionId': positionId,
3926
+ };
3927
+ response = await this.swapV1PrivatePostTradeClosePosition(this.extend(request, params));
3928
+ }
3929
+ else {
3930
+ const market = this.market(symbol);
3931
+ const request = {
3932
+ 'symbol': market['id'],
3933
+ };
3934
+ response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
3935
+ }
3936
+ //
3937
+ // swapV1PrivatePostTradeClosePosition
3938
+ //
3939
+ // {
3940
+ // "code": 0,
3941
+ // "msg": "",
3942
+ // "timestamp": 1710992264190,
3943
+ // "data": {
3944
+ // "orderId": 1770656007907930112,
3945
+ // "positionId": "1751667128353910784",
3946
+ // "symbol": "LTC-USDT",
3947
+ // "side": "Ask",
3948
+ // "type": "MARKET",
3949
+ // "positionSide": "Long",
3950
+ // "origQty": "0.2"
3951
+ // }
3952
+ // }
3953
+ //
3954
+ // swapV2PrivatePostTradeCloseAllPositions
3921
3955
  //
3922
3956
  // {
3923
3957
  // "code": 0,
@@ -1119,16 +1119,18 @@ class bitstamp extends bitstamp$1 {
1119
1119
  'timestamp': undefined,
1120
1120
  'datetime': undefined,
1121
1121
  };
1122
- const codes = Object.keys(this.currencies);
1123
- for (let i = 0; i < codes.length; i++) {
1124
- const code = codes[i];
1125
- const currency = this.currency(code);
1126
- const currencyId = currency['id'];
1122
+ if (response === undefined) {
1123
+ response = [];
1124
+ }
1125
+ for (let i = 0; i < response.length; i++) {
1126
+ const currencyBalance = response[i];
1127
+ const currencyId = this.safeString(currencyBalance, 'currency');
1128
+ const currencyCode = this.safeCurrencyCode(currencyId);
1127
1129
  const account = this.account();
1128
- account['free'] = this.safeString(response, currencyId + '_available');
1129
- account['used'] = this.safeString(response, currencyId + '_reserved');
1130
- account['total'] = this.safeString(response, currencyId + '_balance');
1131
- result[code] = account;
1130
+ account['free'] = this.safeString(currencyBalance, 'available');
1131
+ account['used'] = this.safeString(currencyBalance, 'reserved');
1132
+ account['total'] = this.safeString(currencyBalance, 'total');
1133
+ result[currencyCode] = account;
1132
1134
  }
1133
1135
  return this.safeBalance(result);
1134
1136
  }
@@ -1142,24 +1144,17 @@ class bitstamp extends bitstamp$1 {
1142
1144
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1143
1145
  */
1144
1146
  await this.loadMarkets();
1145
- const response = await this.privatePostBalance(params);
1147
+ const response = await this.privatePostAccountBalances(params);
1146
1148
  //
1147
- // {
1148
- // "aave_available": "0.00000000",
1149
- // "aave_balance": "0.00000000",
1150
- // "aave_reserved": "0.00000000",
1151
- // "aave_withdrawal_fee": "0.07000000",
1152
- // "aavebtc_fee": "0.000",
1153
- // "aaveeur_fee": "0.000",
1154
- // "aaveusd_fee": "0.000",
1155
- // "bat_available": "0.00000000",
1156
- // "bat_balance": "0.00000000",
1157
- // "bat_reserved": "0.00000000",
1158
- // "bat_withdrawal_fee": "5.00000000",
1159
- // "batbtc_fee": "0.000",
1160
- // "bateur_fee": "0.000",
1161
- // "batusd_fee": "0.000",
1162
- // }
1149
+ // [
1150
+ // {
1151
+ // "currency": "usdt",
1152
+ // "total": "7.00000",
1153
+ // "available": "7.00000",
1154
+ // "reserved": "0.00000"
1155
+ // },
1156
+ // ...
1157
+ // ]
1163
1158
  //
1164
1159
  return this.parseBalance(response);
1165
1160
  }
@@ -70,6 +70,7 @@ class bybit extends bybit$1 {
70
70
  'fetchDeposits': true,
71
71
  'fetchDepositWithdrawFee': 'emulated',
72
72
  'fetchDepositWithdrawFees': true,
73
+ 'fetchFundingHistory': true,
73
74
  'fetchFundingRate': true,
74
75
  'fetchFundingRateHistory': true,
75
76
  'fetchFundingRates': true,
@@ -8106,6 +8107,106 @@ class bybit extends bybit$1 {
8106
8107
  }
8107
8108
  return tiers;
8108
8109
  }
8110
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
8111
+ /**
8112
+ * @method
8113
+ * @name bybit#fetchFundingHistory
8114
+ * @description fetch the history of funding payments paid and received on this account
8115
+ * @see https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution
8116
+ * @param {string} [symbol] unified market symbol
8117
+ * @param {int} [since] the earliest time in ms to fetch funding history for
8118
+ * @param {int} [limit] the maximum number of funding history structures to retrieve
8119
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8120
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
8121
+ * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
8122
+ */
8123
+ await this.loadMarkets();
8124
+ let paginate = false;
8125
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate');
8126
+ if (paginate) {
8127
+ return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 100);
8128
+ }
8129
+ let request = {
8130
+ 'execType': 'Funding',
8131
+ };
8132
+ let market = undefined;
8133
+ if (symbol !== undefined) {
8134
+ market = this.market(symbol);
8135
+ request['symbol'] = market['id'];
8136
+ }
8137
+ let type = undefined;
8138
+ [type, params] = this.getBybitType('fetchFundingHistory', market, params);
8139
+ request['category'] = type;
8140
+ if (symbol !== undefined) {
8141
+ request['symbol'] = market['id'];
8142
+ }
8143
+ if (since !== undefined) {
8144
+ request['startTime'] = since;
8145
+ }
8146
+ if (limit !== undefined) {
8147
+ request['size'] = limit;
8148
+ }
8149
+ else {
8150
+ request['size'] = 100;
8151
+ }
8152
+ [request, params] = this.handleUntilOption('endTime', request, params);
8153
+ const response = await this.privateGetV5ExecutionList(this.extend(request, params));
8154
+ const fundings = this.addPaginationCursorToResult(response);
8155
+ return this.parseIncomes(fundings, market, since, limit);
8156
+ }
8157
+ parseIncome(income, market = undefined) {
8158
+ //
8159
+ // {
8160
+ // "symbol": "XMRUSDT",
8161
+ // "orderType": "UNKNOWN",
8162
+ // "underlyingPrice": "",
8163
+ // "orderLinkId": "",
8164
+ // "orderId": "a11e5fe2-1dbf-4bab-a9b2-af80a14efc5d",
8165
+ // "stopOrderType": "UNKNOWN",
8166
+ // "execTime": "1710950400000",
8167
+ // "feeCurrency": "",
8168
+ // "createType": "",
8169
+ // "feeRate": "-0.000761",
8170
+ // "tradeIv": "",
8171
+ // "blockTradeId": "",
8172
+ // "markPrice": "136.79",
8173
+ // "execPrice": "137.11",
8174
+ // "markIv": "",
8175
+ // "orderQty": "0",
8176
+ // "orderPrice": "0",
8177
+ // "execValue": "134.3678",
8178
+ // "closedSize": "0",
8179
+ // "execType": "Funding",
8180
+ // "seq": "28097658790",
8181
+ // "side": "Sell",
8182
+ // "indexPrice": "",
8183
+ // "leavesQty": "0",
8184
+ // "isMaker": false,
8185
+ // "execFee": "-0.10232512",
8186
+ // "execId": "8d1ef156-4ec6-4445-9a6c-1c0c24dbd046",
8187
+ // "marketUnit": "",
8188
+ // "execQty": "0.98",
8189
+ // "nextPageCursor": "5774437%3A0%2C5771289%3A0"
8190
+ // }
8191
+ //
8192
+ const marketId = this.safeString(income, 'symbol');
8193
+ market = this.safeMarket(marketId, market, undefined, 'contract');
8194
+ let code = 'USDT';
8195
+ if (market['inverse']) {
8196
+ code = market['quote'];
8197
+ }
8198
+ const timestamp = this.safeInteger(income, 'execTime');
8199
+ return {
8200
+ 'info': income,
8201
+ 'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
8202
+ 'code': code,
8203
+ 'timestamp': timestamp,
8204
+ 'datetime': this.iso8601(timestamp),
8205
+ 'id': this.safeString(income, 'execId'),
8206
+ 'amount': this.safeNumber(income, 'execQty'),
8207
+ 'rate': this.safeNumber(income, 'feeRate'),
8208
+ };
8209
+ }
8109
8210
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
8110
8211
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
8111
8212
  if (api === 'public') {
@@ -117,10 +117,10 @@ class coinbaseinternational extends coinbaseinternational$1 {
117
117
  },
118
118
  'www': 'https://international.coinbase.com',
119
119
  'doc': [
120
- 'https://docs.cloud.coinbaseinternational.com/intx/docs',
120
+ 'https://docs.cloud.coinbase.com/intx/docs',
121
121
  ],
122
122
  'fees': [
123
- 'https://help.coinbaseinternational.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees',
123
+ 'https://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees',
124
124
  ],
125
125
  'referral': '',
126
126
  },
@@ -70,6 +70,8 @@ class deribit extends deribit$1 {
70
70
  'fetchMyTrades': true,
71
71
  'fetchOHLCV': true,
72
72
  'fetchOpenOrders': true,
73
+ 'fetchOption': true,
74
+ 'fetchOptionChain': true,
73
75
  'fetchOrder': true,
74
76
  'fetchOrderBook': true,
75
77
  'fetchOrders': false,
@@ -3456,6 +3458,159 @@ class deribit extends deribit$1 {
3456
3458
  'info': greeks,
3457
3459
  };
3458
3460
  }
3461
+ async fetchOption(symbol, params = {}) {
3462
+ /**
3463
+ * @method
3464
+ * @name deribit#fetchOption
3465
+ * @description fetches option data that is commonly found in an option chain
3466
+ * @see https://docs.deribit.com/#public-get_book_summary_by_instrument
3467
+ * @param {string} symbol unified market symbol
3468
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3469
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3470
+ */
3471
+ await this.loadMarkets();
3472
+ const market = this.market(symbol);
3473
+ const request = {
3474
+ 'instrument_name': market['id'],
3475
+ };
3476
+ const response = await this.publicGetGetBookSummaryByInstrument(this.extend(request, params));
3477
+ //
3478
+ // {
3479
+ // "jsonrpc": "2.0",
3480
+ // "result": [
3481
+ // {
3482
+ // "mid_price": 0.04025,
3483
+ // "volume_usd": 11045.12,
3484
+ // "quote_currency": "BTC",
3485
+ // "estimated_delivery_price": 65444.72,
3486
+ // "creation_timestamp": 1711100949273,
3487
+ // "base_currency": "BTC",
3488
+ // "underlying_index": "BTC-27DEC24",
3489
+ // "underlying_price": 73742.14,
3490
+ // "volume": 4.0,
3491
+ // "interest_rate": 0.0,
3492
+ // "price_change": -6.9767,
3493
+ // "open_interest": 274.2,
3494
+ // "ask_price": 0.042,
3495
+ // "bid_price": 0.0385,
3496
+ // "instrument_name": "BTC-27DEC24-240000-C",
3497
+ // "mark_price": 0.04007735,
3498
+ // "last": 0.04,
3499
+ // "low": 0.04,
3500
+ // "high": 0.043
3501
+ // }
3502
+ // ],
3503
+ // "usIn": 1711100949273223,
3504
+ // "usOut": 1711100949273580,
3505
+ // "usDiff": 357,
3506
+ // "testnet": false
3507
+ // }
3508
+ //
3509
+ const result = this.safeList(response, 'result', []);
3510
+ const chain = this.safeDict(result, 0, {});
3511
+ return this.parseOption(chain, undefined, market);
3512
+ }
3513
+ async fetchOptionChain(code, params = {}) {
3514
+ /**
3515
+ * @method
3516
+ * @name deribit#fetchOptionChain
3517
+ * @description fetches data for an underlying asset that is commonly found in an option chain
3518
+ * @see https://docs.deribit.com/#public-get_book_summary_by_currency
3519
+ * @param {string} currency base currency to fetch an option chain for
3520
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3521
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3522
+ */
3523
+ await this.loadMarkets();
3524
+ const currency = this.currency(code);
3525
+ const request = {
3526
+ 'currency': currency['id'],
3527
+ 'kind': 'option',
3528
+ };
3529
+ const response = await this.publicGetGetBookSummaryByCurrency(this.extend(request, params));
3530
+ //
3531
+ // {
3532
+ // "jsonrpc": "2.0",
3533
+ // "result": [
3534
+ // {
3535
+ // "mid_price": 0.4075,
3536
+ // "volume_usd": 2836.83,
3537
+ // "quote_currency": "BTC",
3538
+ // "estimated_delivery_price": 65479.26,
3539
+ // "creation_timestamp": 1711101594477,
3540
+ // "base_currency": "BTC",
3541
+ // "underlying_index": "BTC-28JUN24",
3542
+ // "underlying_price": 68827.27,
3543
+ // "volume": 0.1,
3544
+ // "interest_rate": 0.0,
3545
+ // "price_change": 0.0,
3546
+ // "open_interest": 364.1,
3547
+ // "ask_price": 0.411,
3548
+ // "bid_price": 0.404,
3549
+ // "instrument_name": "BTC-28JUN24-42000-C",
3550
+ // "mark_price": 0.40752052,
3551
+ // "last": 0.423,
3552
+ // "low": 0.423,
3553
+ // "high": 0.423
3554
+ // }
3555
+ // ],
3556
+ // "usIn": 1711101594456388,
3557
+ // "usOut": 1711101594484065,
3558
+ // "usDiff": 27677,
3559
+ // "testnet": false
3560
+ // }
3561
+ //
3562
+ const result = this.safeList(response, 'result', []);
3563
+ return this.parseOptionChain(result, 'base_currency', 'instrument_name');
3564
+ }
3565
+ parseOption(chain, currency = undefined, market = undefined) {
3566
+ //
3567
+ // {
3568
+ // "mid_price": 0.04025,
3569
+ // "volume_usd": 11045.12,
3570
+ // "quote_currency": "BTC",
3571
+ // "estimated_delivery_price": 65444.72,
3572
+ // "creation_timestamp": 1711100949273,
3573
+ // "base_currency": "BTC",
3574
+ // "underlying_index": "BTC-27DEC24",
3575
+ // "underlying_price": 73742.14,
3576
+ // "volume": 4.0,
3577
+ // "interest_rate": 0.0,
3578
+ // "price_change": -6.9767,
3579
+ // "open_interest": 274.2,
3580
+ // "ask_price": 0.042,
3581
+ // "bid_price": 0.0385,
3582
+ // "instrument_name": "BTC-27DEC24-240000-C",
3583
+ // "mark_price": 0.04007735,
3584
+ // "last": 0.04,
3585
+ // "low": 0.04,
3586
+ // "high": 0.043
3587
+ // }
3588
+ //
3589
+ const marketId = this.safeString(chain, 'instrument_name');
3590
+ market = this.safeMarket(marketId, market);
3591
+ const currencyId = this.safeString(chain, 'base_currency');
3592
+ const code = this.safeCurrencyCode(currencyId, currency);
3593
+ const timestamp = this.safeInteger(chain, 'timestamp');
3594
+ return {
3595
+ 'info': chain,
3596
+ 'currency': code['code'],
3597
+ 'symbol': market['symbol'],
3598
+ 'timestamp': timestamp,
3599
+ 'datetime': this.iso8601(timestamp),
3600
+ 'impliedVolatility': undefined,
3601
+ 'openInterest': this.safeNumber(chain, 'open_interest'),
3602
+ 'bidPrice': this.safeNumber(chain, 'bid_price'),
3603
+ 'askPrice': this.safeNumber(chain, 'ask_price'),
3604
+ 'midPrice': this.safeNumber(chain, 'mid_price'),
3605
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
3606
+ 'lastPrice': this.safeNumber(chain, 'last'),
3607
+ 'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
3608
+ 'change': undefined,
3609
+ 'percentage': this.safeNumber(chain, 'price_change'),
3610
+ 'baseVolume': this.safeNumber(chain, 'volume'),
3611
+ 'quoteVolume': this.safeNumber(chain, 'volume_usd'),
3612
+ };
3613
+ }
3459
3614
  nonce() {
3460
3615
  return this.milliseconds();
3461
3616
  }
@@ -310,6 +310,7 @@ class gate extends gate$1 {
310
310
  'loan_records': 20 / 15,
311
311
  'interest_records': 20 / 15,
312
312
  'estimate_rate': 20 / 15,
313
+ 'currency_discount_tiers': 20 / 15,
313
314
  },
314
315
  'post': {
315
316
  'account_mode': 20 / 15,
@@ -4230,7 +4231,17 @@ class gate extends gate$1 {
4230
4231
  'account': account,
4231
4232
  };
4232
4233
  if (amount !== undefined) {
4233
- request['amount'] = this.amountToPrecision(symbol, amount);
4234
+ if (market['spot']) {
4235
+ request['amount'] = this.amountToPrecision(symbol, amount);
4236
+ }
4237
+ else {
4238
+ if (side === 'sell') {
4239
+ request['size'] = Precise["default"].stringNeg(this.amountToPrecision(symbol, amount));
4240
+ }
4241
+ else {
4242
+ request['size'] = this.amountToPrecision(symbol, amount);
4243
+ }
4244
+ }
4234
4245
  }
4235
4246
  if (price !== undefined) {
4236
4247
  request['price'] = this.priceToPrecision(symbol, price);
@@ -5028,8 +5039,8 @@ class gate extends gate$1 {
5028
5039
  */
5029
5040
  await this.loadMarkets();
5030
5041
  const market = (symbol === undefined) ? undefined : this.market(symbol);
5031
- const stop = this.safeValue(params, 'stop');
5032
- params = this.omit(params, 'stop');
5042
+ const stop = this.safeBool2(params, 'stop', 'trigger');
5043
+ params = this.omit(params, ['stop', 'trigger']);
5033
5044
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
5034
5045
  const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
5035
5046
  let response = undefined;
@@ -5357,7 +5368,7 @@ class gate extends gate$1 {
5357
5368
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
5358
5369
  'realizedPnl': this.safeNumber(position, 'realised_pnl'),
5359
5370
  'contracts': this.parseNumber(Precise["default"].stringAbs(size)),
5360
- 'contractSize': this.safeValue(market, 'contractSize'),
5371
+ 'contractSize': this.safeNumber(market, 'contractSize'),
5361
5372
  // 'realisedPnl': position['realised_pnl'],
5362
5373
  'marginRatio': undefined,
5363
5374
  'liquidationPrice': this.safeNumber(position, 'liq_price'),