ccxt 4.2.3 → 4.2.4

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.
package/README.md CHANGED
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
209
209
 
210
210
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
211
211
 
212
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.3/dist/ccxt.browser.js
213
- * unpkg: https://unpkg.com/ccxt@4.2.3/dist/ccxt.browser.js
212
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.4/dist/ccxt.browser.js
213
+ * unpkg: https://unpkg.com/ccxt@4.2.4/dist/ccxt.browser.js
214
214
 
215
215
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
216
216
 
217
217
  ```HTML
218
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.3/dist/ccxt.browser.js"></script>
218
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.4/dist/ccxt.browser.js"></script>
219
219
  ```
220
220
 
221
221
  Creates a global `ccxt` object:
@@ -7738,8 +7738,11 @@ class Exchange {
7738
7738
  // proxy agents
7739
7739
  const [httpProxy, httpsProxy, socksProxy] = this.checkProxySettings(url, method, headers, body);
7740
7740
  this.checkConflictingProxies(httpProxy || httpsProxy || socksProxy, proxyUrl);
7741
- if (!this.proxyModulesLoaded) {
7742
- await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
7741
+ if (isNode) {
7742
+ // skip this on the browser
7743
+ if (!this.proxyModulesLoaded) {
7744
+ await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
7745
+ }
7743
7746
  }
7744
7747
  const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
7745
7748
  // user-agent
@@ -50159,6 +50162,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50159
50162
  'contract/private/order-history': 10,
50160
50163
  'contract/private/position': 10,
50161
50164
  'contract/private/get-open-orders': 1.2,
50165
+ 'contract/private/current-plan-order': 1.2,
50162
50166
  'contract/private/trades': 10,
50163
50167
  },
50164
50168
  'post': {
@@ -52641,6 +52645,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52641
52645
  * @name bitmart#fetchOpenOrders
52642
52646
  * @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
52643
52647
  * @see https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
52648
+ * @see https://developer-pro.bitmart.com/en/futures/#get-all-current-plan-orders-keyed
52644
52649
  * @description fetch all unfilled currently open orders
52645
52650
  * @param {string} symbol unified market symbol
52646
52651
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -52652,6 +52657,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52652
52657
  * @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
52653
52658
  * @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
52654
52659
  * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
52660
+ * @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
52655
52661
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
52656
52662
  */
52657
52663
  await this.loadMarkets();
@@ -52684,16 +52690,23 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52684
52690
  response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
52685
52691
  }
52686
52692
  else if (type === 'swap') {
52687
- const trailing = this.safeValue(params, 'trailing', false);
52688
- let orderType = this.safeString(params, 'orderType');
52689
- params = this.omit(params, ['orderType', 'trailing']);
52690
- if (trailing) {
52691
- orderType = 'trailing';
52693
+ const isStop = this.safeValue2(params, 'stop', 'trigger');
52694
+ params = this.omit(params, ['stop', 'trigger']);
52695
+ if (isStop) {
52696
+ response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
52692
52697
  }
52693
- if (orderType !== undefined) {
52694
- request['type'] = orderType;
52698
+ else {
52699
+ const trailing = this.safeValue(params, 'trailing', false);
52700
+ let orderType = this.safeString(params, 'orderType');
52701
+ params = this.omit(params, ['orderType', 'trailing']);
52702
+ if (trailing) {
52703
+ orderType = 'trailing';
52704
+ }
52705
+ if (orderType !== undefined) {
52706
+ request['type'] = orderType;
52707
+ }
52708
+ response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
52695
52709
  }
52696
- response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
52697
52710
  }
52698
52711
  else {
52699
52712
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' orders, only spot and swap orders are accepted');
@@ -78386,6 +78399,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
78386
78399
  '131215': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
78387
78400
  '131216': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
78388
78401
  '131217': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
78402
+ '131231': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported,
78403
+ '131232': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported,
78389
78404
  '131002': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
78390
78405
  '131003': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
78391
78406
  '131004': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError,
@@ -103696,7 +103711,16 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
103696
103711
  const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
103697
103712
  const options = this.safeValue(this.options, 'fetchTickers', {});
103698
103713
  const method = this.safeString(options, 'method', defaultMethod);
103699
- const tickers = await this[method](this.extend(request, params));
103714
+ let tickers = undefined;
103715
+ if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
103716
+ tickers = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
103717
+ }
103718
+ else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
103719
+ tickers = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
103720
+ }
103721
+ else {
103722
+ tickers = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
103723
+ }
103700
103724
  return this.parseTickers(tickers, symbols, params);
103701
103725
  }
103702
103726
  async fetchTicker(symbol, params = {}) {
@@ -103716,7 +103740,16 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
103716
103740
  const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
103717
103741
  const options = this.safeValue(this.options, 'fetchTicker', {});
103718
103742
  const method = this.safeString(options, 'method', defaultMethod);
103719
- const ticker = await this[method](this.extend(request, params));
103743
+ let ticker = undefined;
103744
+ if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
103745
+ ticker = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
103746
+ }
103747
+ else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
103748
+ ticker = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
103749
+ }
103750
+ else {
103751
+ ticker = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
103752
+ }
103720
103753
  return this.parseTicker(ticker, market);
103721
103754
  }
103722
103755
  parseTicker(ticker, market = undefined) {
@@ -143676,6 +143709,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143676
143709
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
143677
143710
  * @param {object} [params] extra parameters specific to the exchange API endpoint
143678
143711
  * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
143712
+ * @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
143713
+ * @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
143679
143714
  * @returns {object} request to be sent to the exchange
143680
143715
  */
143681
143716
  const market = this.market(symbol);
@@ -143699,6 +143734,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143699
143734
  const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
143700
143735
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
143701
143736
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
143737
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
143738
+ const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
143739
+ const isTrailingPercentOrder = trailingPercent !== undefined;
143702
143740
  const isStop = triggerPrice !== undefined;
143703
143741
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
143704
143742
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
@@ -143726,6 +143764,12 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143726
143764
  }
143727
143765
  }
143728
143766
  }
143767
+ else if (isTrailingPercentOrder) {
143768
+ const trailingPercentString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
143769
+ request['callback_rate'] = this.parseToNumeric(trailingPercentString);
143770
+ request['active_price'] = trailingTriggerPrice;
143771
+ request['order_price_type'] = this.safeString(params, 'order_price_type', 'formula_price');
143772
+ }
143729
143773
  else {
143730
143774
  const clientOrderId = this.safeInteger2(params, 'client_order_id', 'clientOrderId');
143731
143775
  if (clientOrderId !== undefined) {
@@ -143737,7 +143781,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143737
143781
  }
143738
143782
  }
143739
143783
  if (!isStopLossTriggerOrder && !isTakeProfitTriggerOrder) {
143740
- const leverRate = this.safeInteger2(params, 'leverRate', 'lever_rate', 1);
143784
+ const leverRate = this.safeIntegerN(params, ['leverRate', 'lever_rate', 'leverage'], 1);
143741
143785
  const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only', false);
143742
143786
  const openOrClose = (reduceOnly) ? 'close' : 'open';
143743
143787
  const offset = this.safeString(params, 'offset', openOrClose);
@@ -143746,12 +143790,14 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143746
143790
  request['reduce_only'] = 1;
143747
143791
  }
143748
143792
  request['lever_rate'] = leverRate;
143749
- request['order_price_type'] = type;
143793
+ if (!isTrailingPercentOrder) {
143794
+ request['order_price_type'] = type;
143795
+ }
143750
143796
  }
143751
143797
  const broker = this.safeValue(this.options, 'broker', {});
143752
143798
  const brokerId = this.safeString(broker, 'id');
143753
143799
  request['channel_code'] = brokerId;
143754
- params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
143800
+ params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
143755
143801
  return this.extend(request, params);
143756
143802
  }
143757
143803
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -143784,6 +143830,8 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143784
143830
  * @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
143785
143831
  * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
143786
143832
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
143833
+ * @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
143834
+ * @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
143787
143835
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
143788
143836
  */
143789
143837
  await this.loadMarkets();
@@ -143791,11 +143839,16 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143791
143839
  const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
143792
143840
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
143793
143841
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
143842
+ const trailingPercent = this.safeNumber(params, 'trailingPercent');
143843
+ const isTrailingPercentOrder = trailingPercent !== undefined;
143794
143844
  const isStop = triggerPrice !== undefined;
143795
143845
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
143796
143846
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
143797
143847
  let response = undefined;
143798
143848
  if (market['spot']) {
143849
+ if (isTrailingPercentOrder) {
143850
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createOrder() does not support trailing orders for spot markets');
143851
+ }
143799
143852
  const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
143800
143853
  response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
143801
143854
  }
@@ -143812,6 +143865,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143812
143865
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
143813
143866
  response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest);
143814
143867
  }
143868
+ else if (isTrailingPercentOrder) {
143869
+ response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(contractRequest);
143870
+ }
143815
143871
  else {
143816
143872
  response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest);
143817
143873
  }
@@ -143823,6 +143879,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143823
143879
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
143824
143880
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest);
143825
143881
  }
143882
+ else if (isTrailingPercentOrder) {
143883
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder(contractRequest);
143884
+ }
143826
143885
  else {
143827
143886
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(contractRequest);
143828
143887
  }
@@ -143836,6 +143895,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143836
143895
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
143837
143896
  response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest);
143838
143897
  }
143898
+ else if (isTrailingPercentOrder) {
143899
+ response = await this.contractPrivatePostSwapApiV1SwapTrackOrder(contractRequest);
143900
+ }
143839
143901
  else {
143840
143902
  response = await this.contractPrivatePostSwapApiV1SwapOrder(contractRequest);
143841
143903
  }
@@ -143847,6 +143909,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
143847
143909
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
143848
143910
  response = await this.contractPrivatePostApiV1ContractTpslOrder(contractRequest);
143849
143911
  }
143912
+ else if (isTrailingPercentOrder) {
143913
+ response = await this.contractPrivatePostApiV1ContractTrackOrder(contractRequest);
143914
+ }
143850
143915
  else {
143851
143916
  response = await this.contractPrivatePostApiV1ContractOrder(contractRequest);
143852
143917
  }
@@ -192561,6 +192626,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192561
192626
  * @description fetches information on multiple closed orders made by the user
192562
192627
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
192563
192628
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
192629
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
192564
192630
  * @param {string} symbol unified market symbol of the market orders were made in
192565
192631
  * @param {int} [since] the earliest time in ms to fetch orders for
192566
192632
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -192570,6 +192636,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192570
192636
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192571
192637
  * @param {int} [params.until] timestamp in ms to fetch orders for
192572
192638
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
192639
+ * @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
192573
192640
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192574
192641
  */
192575
192642
  await this.loadMarkets();
@@ -192632,6 +192699,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192632
192699
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192633
192700
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
192634
192701
  }
192702
+ else if (method === 'privateGetTradeOrdersHistoryArchive') {
192703
+ response = await this.privateGetTradeOrdersHistoryArchive(this.extend(request, send));
192704
+ }
192635
192705
  else {
192636
192706
  response = await this.privateGetTradeOrdersHistory(this.extend(request, send));
192637
192707
  }
@@ -199295,7 +199365,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199295
199365
  if (type === 'spot') {
199296
199366
  response = await this.v1GetMdSpotTicker24hrAll(query);
199297
199367
  }
199298
- else if (subType === 'inverse' || market['settle'] === 'USD') {
199368
+ else if (subType === 'inverse' || this.safeString(market, 'settle') === 'USD') {
199299
199369
  response = await this.v1GetMdTicker24hrAll(query);
199300
199370
  }
199301
199371
  else {
@@ -291518,7 +291588,7 @@ SOFTWARE.
291518
291588
 
291519
291589
  //-----------------------------------------------------------------------------
291520
291590
  // this is updated by vss.js when building
291521
- const version = '4.2.3';
291591
+ const version = '4.2.4';
291522
291592
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
291523
291593
  //-----------------------------------------------------------------------------
291524
291594