ccxt 4.0.97 → 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.
@@ -13758,6 +13758,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
13758
13758
  'cancelAllOrders': true,
13759
13759
  'cancelOrder': true,
13760
13760
  'createOrder': true,
13761
+ 'createPostOnlyOrder': true,
13761
13762
  'createStopLimitOrder': true,
13762
13763
  'createStopMarketOrder': true,
13763
13764
  'createStopOrder': true,
@@ -13859,6 +13860,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
13859
13860
  },
13860
13861
  },
13861
13862
  'options': {
13863
+ 'createMarketBuyOrderRequiresPrice': true,
13862
13864
  'accountsByType': {
13863
13865
  'spot': 'SPOT',
13864
13866
  'fund': 'FUND',
@@ -14815,30 +14817,39 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
14815
14817
  //
14816
14818
  return this.parseBalance(response);
14817
14819
  }
14820
+ parseType(type) {
14821
+ const types = {
14822
+ 'STOP_LIMIT': 'limit',
14823
+ 'STOP_MARKET': 'market',
14824
+ 'LIMIT': 'limit',
14825
+ 'MARKET': 'market',
14826
+ };
14827
+ return this.safeString(types, type, type);
14828
+ }
14818
14829
  parseOrder(order, market = undefined) {
14819
14830
  //
14820
14831
  // {
14821
- // "id": 10,
14822
- // "asset_pair_name": "EOS-BTC",
14823
- // "price": "10.00",
14824
- // "amount": "10.00",
14825
- // "filled_amount": "9.0",
14826
- // "avg_deal_price": "12.0",
14827
- // "side": "ASK",
14828
- // "state": "FILLED",
14829
- // "created_at":"2019-01-29T06:05:56Z",
14830
- // "updated_at":"2019-01-29T06:05:56Z",
14832
+ // "id": '42154072251',
14833
+ // "asset_pair_name": 'SOL-USDT',
14834
+ // "price": '20',
14835
+ // "amount": '0.5',
14836
+ // "filled_amount": '0',
14837
+ // "avg_deal_price": '0',
14838
+ // "side": 'ASK',
14839
+ // "state": 'PENDING',
14840
+ // "created_at": '2023-09-13T03:42:00Z',
14841
+ // "updated_at": '2023-09-13T03:42:00Z',
14842
+ // "type": 'LIMIT',
14843
+ // "stop_price": '0',
14844
+ // "immediate_or_cancel": false,
14845
+ // "post_only": false,
14846
+ // "client_order_id": ''
14831
14847
  // }
14832
14848
  //
14833
14849
  const id = this.safeString(order, 'id');
14834
14850
  const marketId = this.safeString(order, 'asset_pair_name');
14835
14851
  const symbol = this.safeSymbol(marketId, market, '-');
14836
14852
  const timestamp = this.parse8601(this.safeString(order, 'created_at'));
14837
- const price = this.safeString(order, 'price');
14838
- const amount = this.safeString(order, 'amount');
14839
- const average = this.safeString(order, 'avg_deal_price');
14840
- const filled = this.safeString(order, 'filled_amount');
14841
- const status = this.parseOrderStatus(this.safeString(order, 'state'));
14842
14853
  let side = this.safeString(order, 'side');
14843
14854
  if (side === 'BID') {
14844
14855
  side = 'buy';
@@ -14846,28 +14857,48 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
14846
14857
  else {
14847
14858
  side = 'sell';
14848
14859
  }
14849
- const lastTradeTimestamp = this.parse8601(this.safeString(order, 'updated_at'));
14860
+ let triggerPrice = this.safeString(order, 'stop_price');
14861
+ if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringEq */ .O.stringEq(triggerPrice, '0')) {
14862
+ triggerPrice = undefined;
14863
+ }
14864
+ const immediateOrCancel = this.safeValue(order, 'immediate_or_cancel');
14865
+ let timeInForce = undefined;
14866
+ if (immediateOrCancel) {
14867
+ timeInForce = 'IOC';
14868
+ }
14869
+ const type = this.parseType(this.safeString(order, 'type'));
14870
+ const price = this.safeString(order, 'price');
14871
+ let amount = undefined;
14872
+ let filled = undefined;
14873
+ let cost = undefined;
14874
+ if (type === 'market' && side === 'buy') {
14875
+ cost = this.safeString(order, 'filled_amount');
14876
+ }
14877
+ else {
14878
+ amount = this.safeString(order, 'amount');
14879
+ filled = this.safeString(order, 'filled_amount');
14880
+ }
14850
14881
  return this.safeOrder({
14851
14882
  'info': order,
14852
14883
  'id': id,
14853
- 'clientOrderId': undefined,
14884
+ 'clientOrderId': this.safeString(order, 'client_order_id'),
14854
14885
  'timestamp': timestamp,
14855
14886
  'datetime': this.iso8601(timestamp),
14856
- 'lastTradeTimestamp': lastTradeTimestamp,
14887
+ 'lastTradeTimestamp': this.parse8601(this.safeString(order, 'updated_at')),
14857
14888
  'symbol': symbol,
14858
- 'type': undefined,
14859
- 'timeInForce': undefined,
14860
- 'postOnly': undefined,
14889
+ 'type': type,
14890
+ 'timeInForce': timeInForce,
14891
+ 'postOnly': this.safeValue(order, 'post_only'),
14861
14892
  'side': side,
14862
14893
  'price': price,
14863
- 'stopPrice': undefined,
14864
- 'triggerPrice': undefined,
14894
+ 'stopPrice': triggerPrice,
14895
+ 'triggerPrice': triggerPrice,
14865
14896
  'amount': amount,
14866
- 'cost': undefined,
14867
- 'average': average,
14897
+ 'cost': cost,
14898
+ 'average': this.safeString(order, 'avg_deal_price'),
14868
14899
  'filled': filled,
14869
14900
  'remaining': undefined,
14870
- 'status': status,
14901
+ 'status': this.parseOrderStatus(this.safeString(order, 'state')),
14871
14902
  'fee': undefined,
14872
14903
  'trades': undefined,
14873
14904
  }, market);
@@ -14877,46 +14908,79 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
14877
14908
  * @method
14878
14909
  * @name bigone#createOrder
14879
14910
  * @description create a trade order
14911
+ * @see https://open.big.one/docs/spot_orders.html#create-order
14880
14912
  * @param {string} symbol unified symbol of the market to create an order in
14881
14913
  * @param {string} type 'market' or 'limit'
14882
14914
  * @param {string} side 'buy' or 'sell'
14883
14915
  * @param {float} amount how much of currency you want to trade in units of base currency
14884
14916
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
14885
14917
  * @param {object} [params] extra parameters specific to the bigone api endpoint
14918
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
14919
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
14920
+ * @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
14921
+ *
14922
+ * EXCHANGE SPECIFIC PARAMETERS
14923
+ * @param {string} operator *stop order only* GTE or LTE (default)
14924
+ * @param {string} client_order_id must match ^[a-zA-Z0-9-_]{1,36}$ this regex. client_order_id is unique in 24 hours, If created 24 hours later and the order closed, it will be released and can be reused
14886
14925
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
14887
14926
  */
14888
14927
  await this.loadMarkets();
14889
14928
  const market = this.market(symbol);
14890
- const requestSide = (side === 'buy') ? 'BID' : 'ASK';
14891
- const uppercaseType = type.toUpperCase();
14929
+ const isBuy = (side === 'buy');
14930
+ const requestSide = isBuy ? 'BID' : 'ASK';
14931
+ let uppercaseType = type.toUpperCase();
14932
+ const isLimit = uppercaseType === 'LIMIT';
14933
+ const exchangeSpecificParam = this.safeValue(params, 'post_only');
14934
+ let postOnly = undefined;
14935
+ [postOnly, params] = this.handlePostOnly((uppercaseType === 'MARKET'), exchangeSpecificParam, params);
14936
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
14892
14937
  const request = {
14893
14938
  'asset_pair_name': market['id'],
14894
14939
  'side': requestSide,
14895
- 'amount': this.amountToPrecision(symbol, amount),
14940
+ 'amount': this.amountToPrecision(symbol, amount), // order amount, string, required
14896
14941
  // 'price': this.priceToPrecision (symbol, price), // order price, string, required
14897
- 'type': uppercaseType,
14898
14942
  // 'operator': 'GTE', // stop orders only, GTE greater than and equal, LTE less than and equal
14899
14943
  // 'immediate_or_cancel': false, // limit orders only, must be false when post_only is true
14900
14944
  // 'post_only': false, // limit orders only, must be false when immediate_or_cancel is true
14901
14945
  };
14902
- if (uppercaseType === 'LIMIT') {
14946
+ if (isLimit || (uppercaseType === 'STOP_LIMIT')) {
14903
14947
  request['price'] = this.priceToPrecision(symbol, price);
14948
+ if (isLimit) {
14949
+ const timeInForce = this.safeString(params, 'timeInForce');
14950
+ if (timeInForce === 'IOC') {
14951
+ request['immediate_or_cancel'] = true;
14952
+ }
14953
+ if (postOnly) {
14954
+ request['post_only'] = true;
14955
+ }
14956
+ }
14904
14957
  }
14905
14958
  else {
14906
- const isStopLimit = (uppercaseType === 'STOP_LIMIT');
14907
- const isStopMarket = (uppercaseType === 'STOP_MARKET');
14908
- if (isStopLimit || isStopMarket) {
14909
- const stopPrice = this.safeNumber2(params, 'stop_price', 'stopPrice');
14910
- if (stopPrice === undefined) {
14911
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires a stop_price parameter');
14959
+ const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice');
14960
+ if (createMarketBuyOrderRequiresPrice && (side === 'buy')) {
14961
+ if (price === undefined) {
14962
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
14963
+ }
14964
+ else {
14965
+ const amountString = this.numberToString(amount);
14966
+ const priceString = this.numberToString(price);
14967
+ amount = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(amountString, priceString));
14912
14968
  }
14913
- request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
14914
- params = this.omit(params, ['stop_price', 'stopPrice']);
14915
14969
  }
14916
- if (isStopLimit) {
14917
- request['price'] = this.priceToPrecision(symbol, price);
14970
+ }
14971
+ request['amount'] = this.amountToPrecision(symbol, amount);
14972
+ if (triggerPrice !== undefined) {
14973
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
14974
+ request['operator'] = isBuy ? 'GTE' : 'LTE';
14975
+ if (isLimit) {
14976
+ uppercaseType = 'STOP_LIMIT';
14977
+ }
14978
+ else if (uppercaseType === 'MARKET') {
14979
+ uppercaseType = 'STOP_MARKET';
14918
14980
  }
14919
14981
  }
14982
+ request['type'] = uppercaseType;
14983
+ params = this.omit(params, ['stop_price', 'stopPrice', 'triggerPrice', 'timeInForce']);
14920
14984
  const response = await this.privatePostOrders(this.extend(request, params));
14921
14985
  //
14922
14986
  // {
@@ -42362,15 +42426,14 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42362
42426
  'api': {
42363
42427
  'public': {
42364
42428
  'get': [
42365
- 'ticker/{currency}',
42366
- 'ticker/all',
42367
- 'ticker/ALL_BTC',
42368
- 'ticker/ALL_KRW',
42369
- 'orderbook/{currency}',
42370
- 'orderbook/all',
42371
- 'transaction_history/{currency}',
42372
- 'transaction_history/all',
42373
- 'candlestick/{currency}/{interval}',
42429
+ 'ticker/ALL_{quoteId}',
42430
+ 'ticker/{baseId}_{quoteId}',
42431
+ 'orderbook/ALL_{quoteId}',
42432
+ 'orderbook/{baseId}_{quoteId}',
42433
+ 'transaction_history/{baseId}_{quoteId}',
42434
+ 'assetsstatus/ALL',
42435
+ 'assetsstatus/{baseId}',
42436
+ 'candlestick/{baseId}_{quoteId}/{interval}',
42374
42437
  ],
42375
42438
  },
42376
42439
  'private': {
@@ -42389,6 +42452,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42389
42452
  'trade/krw_withdrawal',
42390
42453
  'trade/market_buy',
42391
42454
  'trade/market_sell',
42455
+ 'trade/stop_limit',
42392
42456
  ],
42393
42457
  },
42394
42458
  },
@@ -42477,8 +42541,10 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42477
42541
  const quote = quotes[i];
42478
42542
  const quoteId = quote;
42479
42543
  const extension = this.safeValue(quoteCurrencies, quote, {});
42480
- const method = 'publicGetTickerALL' + quote;
42481
- const response = await this[method](params);
42544
+ const request = {
42545
+ 'quoteId': quoteId,
42546
+ };
42547
+ const response = await this.publicGetTickerALLQuoteId(this.extend(request, params));
42482
42548
  const data = this.safeValue(response, 'data');
42483
42549
  const currencyIds = Object.keys(data);
42484
42550
  for (let j = 0; j < currencyIds.length; j++) {
@@ -42589,12 +42655,13 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42589
42655
  await this.loadMarkets();
42590
42656
  const market = this.market(symbol);
42591
42657
  const request = {
42592
- 'currency': market['base'] + '_' + market['quote'],
42658
+ 'baseId': market['baseId'],
42659
+ 'quoteId': market['quoteId'],
42593
42660
  };
42594
42661
  if (limit !== undefined) {
42595
42662
  request['count'] = limit; // default 30, max 30
42596
42663
  }
42597
- const response = await this.publicGetOrderbookCurrency(this.extend(request, params));
42664
+ const response = await this.publicGetOrderbookBaseIdQuoteId(this.extend(request, params));
42598
42665
  //
42599
42666
  // {
42600
42667
  // "status":"0000",
@@ -42682,8 +42749,11 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42682
42749
  const quotes = Object.keys(quoteCurrencies);
42683
42750
  for (let i = 0; i < quotes.length; i++) {
42684
42751
  const quote = quotes[i];
42685
- const method = 'publicGetTickerALL' + quote;
42686
- const response = await this[method](params);
42752
+ const quoteId = quote;
42753
+ const request = {
42754
+ 'quoteId': quoteId,
42755
+ };
42756
+ const response = await this.publicGetTickerALLQuoteId(this.extend(request, params));
42687
42757
  //
42688
42758
  // {
42689
42759
  // "status":"0000",
@@ -42733,9 +42803,10 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42733
42803
  await this.loadMarkets();
42734
42804
  const market = this.market(symbol);
42735
42805
  const request = {
42736
- 'currency': market['base'],
42806
+ 'baseId': market['baseId'],
42807
+ 'quoteId': market['quoteId'],
42737
42808
  };
42738
- const response = await this.publicGetTickerCurrency(this.extend(request, params));
42809
+ const response = await this.publicGetTickerBaseIdQuoteId(this.extend(request, params));
42739
42810
  //
42740
42811
  // {
42741
42812
  // "status":"0000",
@@ -42793,10 +42864,11 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42793
42864
  await this.loadMarkets();
42794
42865
  const market = this.market(symbol);
42795
42866
  const request = {
42796
- 'currency': market['base'],
42867
+ 'baseId': market['baseId'],
42868
+ 'quoteId': market['quoteId'],
42797
42869
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
42798
42870
  };
42799
- const response = await this.publicGetCandlestickCurrencyInterval(this.extend(request, params));
42871
+ const response = await this.publicGetCandlestickBaseIdQuoteIdInterval(this.extend(request, params));
42800
42872
  //
42801
42873
  // {
42802
42874
  // 'status': '0000',
@@ -42915,12 +42987,13 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
42915
42987
  await this.loadMarkets();
42916
42988
  const market = this.market(symbol);
42917
42989
  const request = {
42918
- 'currency': market['base'] + '_' + market['quote'],
42990
+ 'baseId': market['baseId'],
42991
+ 'quoteId': market['quoteId'],
42919
42992
  };
42920
42993
  if (limit !== undefined) {
42921
42994
  request['count'] = limit; // default 20, max 100
42922
42995
  }
42923
- const response = await this.publicGetTransactionHistoryCurrency(this.extend(request, params));
42996
+ const response = await this.publicGetTransactionHistoryBaseIdQuoteId(this.extend(request, params));
42924
42997
  //
42925
42998
  // {
42926
42999
  // "status":"0000",
@@ -43453,7 +43526,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
43453
43526
  'fetchWithdrawals': true,
43454
43527
  'reduceMargin': false,
43455
43528
  'repayMargin': true,
43456
- 'setLeverage': false,
43529
+ 'setLeverage': true,
43457
43530
  'setMarginMode': false,
43458
43531
  'transfer': true,
43459
43532
  'withdraw': true,
@@ -43516,6 +43589,9 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
43516
43589
  'account/sub-account/v1/transfer-history': 7.5,
43517
43590
  'account/sub-account/main/v1/wallet': 5,
43518
43591
  'account/sub-account/main/v1/subaccount-list': 7.5,
43592
+ 'account/contract/sub-account/main/v1/wallet': 5,
43593
+ 'account/contract/sub-account/main/v1/transfer-list': 7.5,
43594
+ 'account/contract/sub-account/v1/transfer-history': 7.5,
43519
43595
  // account
43520
43596
  'account/v1/wallet': 5,
43521
43597
  'account/v1/currencies': 30,
@@ -43541,9 +43617,11 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
43541
43617
  'spot/v1/user_fee': 6,
43542
43618
  // contract
43543
43619
  'contract/private/assets-detail': 5,
43544
- 'contract/private/order': 2,
43620
+ 'contract/private/order': 1.2,
43545
43621
  'contract/private/order-history': 10,
43546
43622
  'contract/private/position': 10,
43623
+ 'contract/private/get-open-orders': 1.2,
43624
+ 'contract/private/trades': 10,
43547
43625
  },
43548
43626
  'post': {
43549
43627
  // sub-account endpoints
@@ -43552,6 +43630,9 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
43552
43630
  'account/sub-account/main/v1/main-to-sub': 30,
43553
43631
  'account/sub-account/sub/v1/sub-to-sub': 30,
43554
43632
  'account/sub-account/main/v1/sub-to-sub': 30,
43633
+ 'account/contract/sub-account/main/v1/sub-to-main': 7.5,
43634
+ 'account/contract/sub-account/main/v1/main-to-sub': 7.5,
43635
+ 'account/contract/sub-account/sub/v1/sub-to-main': 7.5,
43555
43636
  // account
43556
43637
  'account/v1/withdraw/apply': 7.5,
43557
43638
  // transaction and trading
@@ -43575,7 +43656,14 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
43575
43656
  'spot/v1/margin/isolated/repay': 6,
43576
43657
  'spot/v1/margin/isolated/transfer': 6,
43577
43658
  // contract
43578
- 'contract/private/trades': 10,
43659
+ 'account/v1/transfer-contract-list': 60,
43660
+ 'account/v1/transfer-contract': 60,
43661
+ 'contract/private/submit-order': 2.5,
43662
+ 'contract/private/cancel-order': 1.5,
43663
+ 'contract/private/cancel-orders': 30,
43664
+ 'contract/private/submit-plan-order': 2.5,
43665
+ 'contract/private/cancel-plan-order': 1.5,
43666
+ 'contract/private/submit-leverage': 2.5,
43579
43667
  },
43580
43668
  },
43581
43669
  },
@@ -45420,6 +45508,9 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
45420
45508
  }
45421
45509
  const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
45422
45510
  if (marginMode !== undefined) {
45511
+ if (marginMode !== 'isolated') {
45512
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' only isolated margin is supported');
45513
+ }
45423
45514
  method = 'privatePostSpotV1MarginSubmitOrder';
45424
45515
  }
45425
45516
  const response = await this[method](this.extend(request, query));
@@ -46572,22 +46663,33 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
46572
46663
  'info': interest,
46573
46664
  };
46574
46665
  }
46575
- handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
46666
+ async setLeverage(leverage, symbol = undefined, params = {}) {
46576
46667
  /**
46577
- * @ignore
46578
46668
  * @method
46579
- * @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
46580
- * @param {object} [params] extra parameters specific to the exchange api endpoint
46581
- * @returns {array} the marginMode in lowercase
46669
+ * @name bitmart#setLeverage
46670
+ * @description set the level of leverage for a market
46671
+ * @see https://developer-pro.bitmart.com/en/futures/#submit-leverage-signed
46672
+ * @param {float} leverage the rate of leverage
46673
+ * @param {string} symbol unified market symbol
46674
+ * @param {object} [params] extra parameters specific to the bitmart api endpoint
46675
+ * @param {string} [params.marginMode] 'isolated' or 'cross'
46676
+ * @returns {object} response from the exchange
46582
46677
  */
46678
+ this.checkRequiredSymbol('setLeverage', symbol);
46583
46679
  let marginMode = undefined;
46584
- [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
46585
- if (marginMode !== undefined) {
46586
- if (marginMode !== 'isolated') {
46587
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' only isolated margin is supported');
46588
- }
46680
+ [marginMode, params] = this.handleMarginModeAndParams('setLeverage', params);
46681
+ this.checkRequiredArgument('setLeverage', marginMode, 'marginMode', ['isolated', 'cross']);
46682
+ await this.loadMarkets();
46683
+ const market = this.market(symbol);
46684
+ if (!market['swap']) {
46685
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' setLeverage() supports swap contracts only');
46589
46686
  }
46590
- return [marginMode, params];
46687
+ const request = {
46688
+ 'symbol': market['id'],
46689
+ 'leverage': leverage.toString(),
46690
+ 'open_type': marginMode,
46691
+ };
46692
+ return await this.privatePostContractPrivateSubmitLeverage(this.extend(request, params));
46591
46693
  }
46592
46694
  nonce() {
46593
46695
  return this.milliseconds();
@@ -111542,6 +111644,7 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
111542
111644
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TICK_SIZE */ .sh,
111543
111645
  'exceptions': {
111544
111646
  'exact': {
111647
+ '140434': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
111545
111648
  '40005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
111546
111649
  '40009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidNonce,
111547
111650
  '40015': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
@@ -112721,34 +112824,42 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
112721
112824
  * @name exmo#createOrder
112722
112825
  * @description create a trade order
112723
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
112724
112829
  * @param {string} symbol unified symbol of the market to create an order in
112725
112830
  * @param {string} type 'market' or 'limit'
112726
112831
  * @param {string} side 'buy' or 'sell'
112727
112832
  * @param {float} amount how much of currency you want to trade in units of base currency
112728
112833
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
112729
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
112730
112838
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
112731
112839
  */
112732
112840
  await this.loadMarkets();
112733
112841
  const market = this.market(symbol);
112734
- const prefix = (type === 'market') ? (type + '_') : '';
112735
- const orderType = prefix + side;
112736
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']);
112737
112850
  const request = {
112738
112851
  'pair': market['id'],
112739
112852
  // 'leverage': 2,
112740
112853
  'quantity': this.amountToPrecision(market['symbol'], amount),
112741
112854
  // spot - buy, sell, market_buy, market_sell, market_buy_total, market_sell_total
112742
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
112743
- 'type': orderType,
112744
- 'price': isMarket ? 0 : this.priceToPrecision(market['symbol'], price),
112745
112856
  // 'stop_price': this.priceToPrecision (symbol, stopPrice),
112746
112857
  // 'distance': 0, // distance for trailing stop orders
112747
112858
  // 'expire': 0, // expiration timestamp in UTC timezone for the order, unless expire is 0
112748
112859
  // 'client_id': 123, // optional, must be a positive integer
112749
112860
  // 'comment': '', // up to 50 latin symbols, whitespaces, underscores
112750
112861
  };
112751
- let method = 'privatePostOrderCreate';
112862
+ let method = isSpot ? 'privatePostOrderCreate' : 'privatePostMarginUserOrderCreate';
112752
112863
  let clientOrderId = this.safeValue2(params, 'client_id', 'clientOrderId');
112753
112864
  if (clientOrderId !== undefined) {
112754
112865
  clientOrderId = this.safeInteger2(params, 'client_id', 'clientOrderId');
@@ -112758,19 +112869,68 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
112758
112869
  else {
112759
112870
  request['client_id'] = clientOrderId;
112760
112871
  }
112761
- params = this.omit(params, ['client_id', 'clientOrderId']);
112762
112872
  }
112763
- if ((type === 'stop') || (type === 'stop_limit') || (type === 'trailing_stop')) {
112764
- const stopPrice = this.safeNumber2(params, 'stop_price', 'stopPrice');
112765
- if (stopPrice === undefined) {
112766
- 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
+ }
112767
112888
  }
112768
112889
  else {
112769
- params = this.omit(params, ['stopPrice', 'stop_price']);
112770
- request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
112771
- 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
+ }
112772
112900
  }
112773
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
+ }
112929
+ }
112930
+ }
112931
+ if (price !== undefined) {
112932
+ request['price'] = this.priceToPrecision(market['symbol'], price);
112933
+ }
112774
112934
  const response = await this[method](this.extend(request, params));
112775
112935
  return this.parseOrder(response, market);
112776
112936
  }
@@ -113579,6 +113739,19 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
113579
113739
  if (response === undefined) {
113580
113740
  return undefined; // fallback to default error handler
113581
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
+ }
113582
113755
  if (('result' in response) || ('errmsg' in response)) {
113583
113756
  //
113584
113757
  // {"result":false,"error":"Error 50052: Insufficient funds"}
@@ -117833,7 +118006,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
117833
118006
  type = isMarketOrder ? 'market' : 'limit';
117834
118007
  side = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringGt */ .O.stringGt(amount, '0') ? 'buy' : 'sell';
117835
118008
  }
117836
- const rawStatus = this.safeStringN(order, ['status', 'finish_as', 'open']);
118009
+ const rawStatus = this.safeStringN(order, ['finish_as', 'status', 'open']);
117837
118010
  let timestamp = this.safeInteger(order, 'create_time_ms');
117838
118011
  if (timestamp === undefined) {
117839
118012
  timestamp = this.safeTimestamp2(order, 'create_time', 'ctime');
@@ -152977,6 +153150,7 @@ class latoken extends _abstract_latoken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
152977
153150
  'defaultType': 'spot',
152978
153151
  'types': {
152979
153152
  'wallet': 'ACCOUNT_TYPE_WALLET',
153153
+ 'funding': 'ACCOUNT_TYPE_WALLET',
152980
153154
  'spot': 'ACCOUNT_TYPE_SPOT',
152981
153155
  },
152982
153156
  'accounts': {
@@ -233188,8 +233362,8 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
233188
233362
  previousOrder['status'] = state;
233189
233363
  // update the newUpdates count
233190
233364
  orders.append(previousOrder);
233191
- marketIds.push(marketId);
233192
233365
  }
233366
+ marketIds.push(marketId);
233193
233367
  }
233194
233368
  }
233195
233369
  for (let i = 0; i < marketIds.length; i++) {
@@ -233197,7 +233371,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
233197
233371
  const market = this.market(marketId);
233198
233372
  const symbol = market['symbol'];
233199
233373
  const messageHash = 'orders::' + symbol;
233200
- client.resolve(orders[symbol], messageHash);
233374
+ client.resolve(orders, messageHash);
233201
233375
  }
233202
233376
  client.resolve(orders, 'orders');
233203
233377
  return message;
@@ -238283,8 +238457,8 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
238283
238457
  const networkList = {};
238284
238458
  for (let j = 0; j < platformsByPriority.length; j++) {
238285
238459
  const network = platformsByPriority[j];
238286
- const id = this.safeString(network, 'id');
238287
- const networkCode = this.networkIdToCode(id);
238460
+ const networkId = this.safeString(network, 'id');
238461
+ const networkCode = this.networkIdToCode(networkId);
238288
238462
  const currentDepositSuspended = this.safeValue(network, 'deposit_suspended');
238289
238463
  const currentWithdrawalSuspended = this.safeValue(network, 'withdrawal_suspended');
238290
238464
  const currentDeposit = !currentDepositSuspended;
@@ -238297,7 +238471,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
238297
238471
  const withdrawFee = this.safeValue(network, 'withdrawal_fee', []);
238298
238472
  const fee = this.safeValue(withdrawFee, 0, {});
238299
238473
  networkList[networkCode] = {
238300
- 'id': id,
238474
+ 'id': networkId,
238301
238475
  'network': networkCode,
238302
238476
  'active': currentActive,
238303
238477
  'deposit': currentDeposit,
@@ -273595,7 +273769,7 @@ SOFTWARE.
273595
273769
 
273596
273770
  //-----------------------------------------------------------------------------
273597
273771
  // this is updated by vss.js when building
273598
- const version = '4.0.97';
273772
+ const version = '4.0.99';
273599
273773
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
273600
273774
  //-----------------------------------------------------------------------------
273601
273775