ccxt 4.0.98 → 4.0.99

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
@@ -215,13 +215,13 @@ console.log(version, Object.keys(exchanges));
215
215
 
216
216
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
217
217
 
218
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.98/dist/ccxt.browser.js
219
- * unpkg: https://unpkg.com/ccxt@4.0.98/dist/ccxt.browser.js
218
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.99/dist/ccxt.browser.js
219
+ * unpkg: https://unpkg.com/ccxt@4.0.99/dist/ccxt.browser.js
220
220
 
221
221
  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.
222
222
 
223
223
  ```HTML
224
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.98/dist/ccxt.browser.js"></script>
224
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.99/dist/ccxt.browser.js"></script>
225
225
  ```
226
226
 
227
227
  Creates a global `ccxt` object:
@@ -111644,6 +111644,7 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
111644
111644
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TICK_SIZE */ .sh,
111645
111645
  'exceptions': {
111646
111646
  'exact': {
111647
+ '140434': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
111647
111648
  '40005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
111648
111649
  '40009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidNonce,
111649
111650
  '40015': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
@@ -112823,34 +112824,42 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
112823
112824
  * @name exmo#createOrder
112824
112825
  * @description create a trade order
112825
112826
  * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
112827
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#de6f4321-eeac-468c-87f7-c4ad7062e265 // stop market
112828
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#3561b86c-9ff1-436e-8e68-ac926b7eb523 // margin
112826
112829
  * @param {string} symbol unified symbol of the market to create an order in
112827
112830
  * @param {string} type 'market' or 'limit'
112828
112831
  * @param {string} side 'buy' or 'sell'
112829
112832
  * @param {float} amount how much of currency you want to trade in units of base currency
112830
112833
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
112831
112834
  * @param {object} [params] extra parameters specific to the exmo api endpoint
112835
+ * @param {float} [params.stopPrice] the price at which a trigger order is triggered at
112836
+ * @param {string} [params.timeInForce] *spot only* 'fok', 'ioc' or 'post_only'
112837
+ * @param {boolean} [params.postOnly] *spot only* true for post only orders
112832
112838
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
112833
112839
  */
112834
112840
  await this.loadMarkets();
112835
112841
  const market = this.market(symbol);
112836
- const prefix = (type === 'market') ? (type + '_') : '';
112837
- const orderType = prefix + side;
112838
112842
  const isMarket = (type === 'market') && (price === undefined);
112843
+ let marginMode = undefined;
112844
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
112845
+ if (marginMode === 'cross') {
112846
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' only supports isolated margin');
112847
+ }
112848
+ const isSpot = (marginMode !== 'isolated');
112849
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
112839
112850
  const request = {
112840
112851
  'pair': market['id'],
112841
112852
  // 'leverage': 2,
112842
112853
  'quantity': this.amountToPrecision(market['symbol'], amount),
112843
112854
  // spot - buy, sell, market_buy, market_sell, market_buy_total, market_sell_total
112844
112855
  // margin - limit_buy, limit_sell, market_buy, market_sell, stop_buy, stop_sell, stop_limit_buy, stop_limit_sell, trailing_stop_buy, trailing_stop_sell
112845
- 'type': orderType,
112846
- 'price': isMarket ? 0 : this.priceToPrecision(market['symbol'], price),
112847
112856
  // 'stop_price': this.priceToPrecision (symbol, stopPrice),
112848
112857
  // 'distance': 0, // distance for trailing stop orders
112849
112858
  // 'expire': 0, // expiration timestamp in UTC timezone for the order, unless expire is 0
112850
112859
  // 'client_id': 123, // optional, must be a positive integer
112851
112860
  // 'comment': '', // up to 50 latin symbols, whitespaces, underscores
112852
112861
  };
112853
- let method = 'privatePostOrderCreate';
112862
+ let method = isSpot ? 'privatePostOrderCreate' : 'privatePostMarginUserOrderCreate';
112854
112863
  let clientOrderId = this.safeValue2(params, 'client_id', 'clientOrderId');
112855
112864
  if (clientOrderId !== undefined) {
112856
112865
  clientOrderId = this.safeInteger2(params, 'client_id', 'clientOrderId');
@@ -112860,19 +112869,68 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
112860
112869
  else {
112861
112870
  request['client_id'] = clientOrderId;
112862
112871
  }
112863
- params = this.omit(params, ['client_id', 'clientOrderId']);
112864
112872
  }
112865
- if ((type === 'stop') || (type === 'stop_limit') || (type === 'trailing_stop')) {
112866
- const stopPrice = this.safeNumber2(params, 'stop_price', 'stopPrice');
112867
- if (stopPrice === undefined) {
112868
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires a stopPrice extra param for a ' + type + ' order');
112873
+ const leverage = this.safeNumber(params, 'leverage');
112874
+ if (!isSpot && (leverage === undefined)) {
112875
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder requires an extra param params["leverage"] for margin orders');
112876
+ }
112877
+ params = this.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId']);
112878
+ if (triggerPrice !== undefined) {
112879
+ if (isSpot) {
112880
+ if (type === 'limit') {
112881
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder () cannot create stop limit orders for spot, only stop market');
112882
+ }
112883
+ else {
112884
+ method = 'privatePostStopMarketOrderCreate';
112885
+ request['type'] = side;
112886
+ request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
112887
+ }
112869
112888
  }
112870
112889
  else {
112871
- params = this.omit(params, ['stopPrice', 'stop_price']);
112872
- request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
112873
- method = 'privatePostMarginUserOrderCreate';
112890
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
112891
+ if (type === 'limit') {
112892
+ request['type'] = 'stop_limit_' + side;
112893
+ }
112894
+ else if (type === 'market') {
112895
+ request['type'] = 'stop_' + side;
112896
+ }
112897
+ else {
112898
+ request['type'] = type;
112899
+ }
112900
+ }
112901
+ }
112902
+ else {
112903
+ if (isSpot) {
112904
+ const execType = this.safeString(params, 'exec_type');
112905
+ let isPostOnly = undefined;
112906
+ [isPostOnly, params] = this.handlePostOnly(type === 'market', execType === 'post_only', params);
112907
+ const timeInForce = this.safeString(params, 'timeInForce');
112908
+ request['price'] = isMarket ? 0 : this.priceToPrecision(market['symbol'], price);
112909
+ if (type === 'limit') {
112910
+ request['type'] = side;
112911
+ }
112912
+ else if (type === 'market') {
112913
+ request['type'] = 'market_' + side;
112914
+ }
112915
+ if (isPostOnly) {
112916
+ request['exec_type'] = 'post_only';
112917
+ }
112918
+ else if (timeInForce !== undefined) {
112919
+ request['exec_type'] = timeInForce;
112920
+ }
112921
+ }
112922
+ else {
112923
+ if (type === 'limit' || type === 'market') {
112924
+ request['type'] = type + '_' + side;
112925
+ }
112926
+ else {
112927
+ request['type'] = type;
112928
+ }
112874
112929
  }
112875
112930
  }
112931
+ if (price !== undefined) {
112932
+ request['price'] = this.priceToPrecision(market['symbol'], price);
112933
+ }
112876
112934
  const response = await this[method](this.extend(request, params));
112877
112935
  return this.parseOrder(response, market);
112878
112936
  }
@@ -113681,6 +113739,19 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
113681
113739
  if (response === undefined) {
113682
113740
  return undefined; // fallback to default error handler
113683
113741
  }
113742
+ if ('error' in response) {
113743
+ // error: {
113744
+ // code: '140434',
113745
+ // msg: "Your margin balance is not sufficient to place the order for '5 TON'. Please top up your margin wallet by '2.5 USDT'."
113746
+ // }
113747
+ const errorCode = this.safeValue(response, 'error', {});
113748
+ const messageError = this.safeString(errorCode, 'msg');
113749
+ const code = this.safeString(errorCode, 'code');
113750
+ const feedback = this.id + ' ' + body;
113751
+ this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
113752
+ this.throwBroadlyMatchedException(this.exceptions['broad'], messageError, feedback);
113753
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(feedback);
113754
+ }
113684
113755
  if (('result' in response) || ('errmsg' in response)) {
113685
113756
  //
113686
113757
  // {"result":false,"error":"Error 50052: Insufficient funds"}
@@ -273698,7 +273769,7 @@ SOFTWARE.
273698
273769
 
273699
273770
  //-----------------------------------------------------------------------------
273700
273771
  // this is updated by vss.js when building
273701
- const version = '4.0.98';
273772
+ const version = '4.0.99';
273702
273773
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
273703
273774
  //-----------------------------------------------------------------------------
273704
273775