ccxt 4.4.49 → 4.4.53

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 (158) hide show
  1. package/README.md +6 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +65 -2
  5. package/dist/cjs/src/base/Exchange.js +112 -3
  6. package/dist/cjs/src/binance.js +42 -19
  7. package/dist/cjs/src/bitfinex1.js +22 -22
  8. package/dist/cjs/src/blofin.js +6 -2
  9. package/dist/cjs/src/bybit.js +2 -2
  10. package/dist/cjs/src/coinex.js +5 -5
  11. package/dist/cjs/src/coinmetro.js +21 -4
  12. package/dist/cjs/src/defx.js +1 -1
  13. package/dist/cjs/src/deribit.js +23 -4
  14. package/dist/cjs/src/ellipx.js +1 -0
  15. package/dist/cjs/src/gate.js +2 -2
  16. package/dist/cjs/src/hollaex.js +15 -20
  17. package/dist/cjs/src/htx.js +6 -4
  18. package/dist/cjs/src/hyperliquid.js +4 -4
  19. package/dist/cjs/src/krakenfutures.js +1 -1
  20. package/dist/cjs/src/kucoin.js +52 -74
  21. package/dist/cjs/src/kuna.js +1 -1
  22. package/dist/cjs/src/mexc.js +29 -8
  23. package/dist/cjs/src/okcoin.js +13 -5
  24. package/dist/cjs/src/okx.js +1 -1
  25. package/dist/cjs/src/onetrading.js +1 -1
  26. package/dist/cjs/src/paradex.js +2 -2
  27. package/dist/cjs/src/paymium.js +42 -0
  28. package/dist/cjs/src/pro/binance.js +2 -0
  29. package/dist/cjs/src/pro/bitfinex1.js +4 -4
  30. package/dist/cjs/src/pro/bitvavo.js +1 -1
  31. package/dist/cjs/src/pro/blofin.js +9 -1
  32. package/dist/cjs/src/pro/bybit.js +1 -1
  33. package/dist/cjs/src/pro/coincatch.js +2 -2
  34. package/dist/cjs/src/pro/coinex.js +4 -1
  35. package/dist/cjs/src/pro/cryptocom.js +2 -2
  36. package/dist/cjs/src/pro/defx.js +1 -1
  37. package/dist/cjs/src/pro/exmo.js +1 -1
  38. package/dist/cjs/src/pro/gemini.js +1 -1
  39. package/dist/cjs/src/pro/hashkey.js +2 -2
  40. package/dist/cjs/src/pro/htx.js +8 -8
  41. package/dist/cjs/src/pro/hyperliquid.js +2 -2
  42. package/dist/cjs/src/pro/kucoin.js +1 -1
  43. package/dist/cjs/src/pro/okx.js +1 -1
  44. package/dist/cjs/src/pro/oxfun.js +1 -1
  45. package/dist/cjs/src/probit.js +77 -9
  46. package/dist/cjs/src/timex.js +67 -0
  47. package/dist/cjs/src/tokocrypto.js +82 -5
  48. package/dist/cjs/src/tradeogre.js +55 -2
  49. package/dist/cjs/src/vertex.js +65 -2
  50. package/dist/cjs/src/wavesexchange.js +73 -0
  51. package/dist/cjs/src/wazirx.js +59 -3
  52. package/dist/cjs/src/whitebit.js +80 -4
  53. package/dist/cjs/src/xt.js +112 -0
  54. package/dist/cjs/src/yobit.js +56 -0
  55. package/dist/cjs/src/zaif.js +55 -0
  56. package/dist/cjs/src/zonda.js +56 -0
  57. package/examples/README.md +6 -0
  58. package/js/ccxt.d.ts +1 -1
  59. package/js/ccxt.js +1 -1
  60. package/js/src/abstract/binance.d.ts +1 -0
  61. package/js/src/abstract/binancecoinm.d.ts +1 -0
  62. package/js/src/abstract/binanceus.d.ts +1 -0
  63. package/js/src/abstract/binanceusdm.d.ts +1 -0
  64. package/js/src/alpaca.d.ts +35 -0
  65. package/js/src/alpaca.js +65 -2
  66. package/js/src/base/Exchange.d.ts +2 -0
  67. package/js/src/base/Exchange.js +112 -3
  68. package/js/src/binance.d.ts +4 -1
  69. package/js/src/binance.js +42 -19
  70. package/js/src/bitfinex1.d.ts +22 -22
  71. package/js/src/bitfinex1.js +22 -22
  72. package/js/src/blofin.d.ts +1 -1
  73. package/js/src/blofin.js +6 -2
  74. package/js/src/bybit.d.ts +2 -2
  75. package/js/src/bybit.js +2 -2
  76. package/js/src/coinex.js +5 -5
  77. package/js/src/coinmetro.d.ts +1 -1
  78. package/js/src/coinmetro.js +21 -4
  79. package/js/src/defx.d.ts +1 -1
  80. package/js/src/defx.js +1 -1
  81. package/js/src/deribit.d.ts +1 -1
  82. package/js/src/deribit.js +23 -4
  83. package/js/src/ellipx.d.ts +1 -0
  84. package/js/src/ellipx.js +1 -0
  85. package/js/src/gate.d.ts +1 -1
  86. package/js/src/gate.js +2 -2
  87. package/js/src/hollaex.d.ts +2 -1
  88. package/js/src/hollaex.js +15 -20
  89. package/js/src/htx.d.ts +1 -1
  90. package/js/src/htx.js +6 -4
  91. package/js/src/hyperliquid.d.ts +3 -3
  92. package/js/src/hyperliquid.js +4 -4
  93. package/js/src/krakenfutures.d.ts +1 -1
  94. package/js/src/krakenfutures.js +1 -1
  95. package/js/src/kucoin.js +52 -74
  96. package/js/src/kuna.d.ts +1 -1
  97. package/js/src/kuna.js +1 -1
  98. package/js/src/mexc.d.ts +1 -1
  99. package/js/src/mexc.js +29 -8
  100. package/js/src/okcoin.js +13 -5
  101. package/js/src/okx.d.ts +1 -1
  102. package/js/src/okx.js +1 -1
  103. package/js/src/onetrading.d.ts +1 -1
  104. package/js/src/onetrading.js +1 -1
  105. package/js/src/paradex.d.ts +1 -1
  106. package/js/src/paradex.js +2 -2
  107. package/js/src/paymium.js +42 -0
  108. package/js/src/pro/binance.js +2 -0
  109. package/js/src/pro/bitfinex1.d.ts +4 -4
  110. package/js/src/pro/bitfinex1.js +4 -4
  111. package/js/src/pro/bitvavo.d.ts +1 -1
  112. package/js/src/pro/bitvavo.js +1 -1
  113. package/js/src/pro/blofin.d.ts +1 -1
  114. package/js/src/pro/blofin.js +9 -1
  115. package/js/src/pro/bybit.d.ts +1 -1
  116. package/js/src/pro/bybit.js +1 -1
  117. package/js/src/pro/coincatch.d.ts +2 -2
  118. package/js/src/pro/coincatch.js +2 -2
  119. package/js/src/pro/coinex.js +4 -1
  120. package/js/src/pro/cryptocom.d.ts +2 -2
  121. package/js/src/pro/cryptocom.js +2 -2
  122. package/js/src/pro/defx.d.ts +1 -1
  123. package/js/src/pro/defx.js +1 -1
  124. package/js/src/pro/exmo.d.ts +1 -1
  125. package/js/src/pro/exmo.js +1 -1
  126. package/js/src/pro/gemini.d.ts +1 -1
  127. package/js/src/pro/gemini.js +1 -1
  128. package/js/src/pro/hashkey.d.ts +2 -2
  129. package/js/src/pro/hashkey.js +2 -2
  130. package/js/src/pro/htx.d.ts +8 -8
  131. package/js/src/pro/htx.js +8 -8
  132. package/js/src/pro/hyperliquid.d.ts +2 -2
  133. package/js/src/pro/hyperliquid.js +2 -2
  134. package/js/src/pro/kucoin.d.ts +1 -1
  135. package/js/src/pro/kucoin.js +1 -1
  136. package/js/src/pro/okx.d.ts +1 -1
  137. package/js/src/pro/okx.js +1 -1
  138. package/js/src/pro/oxfun.d.ts +1 -1
  139. package/js/src/pro/oxfun.js +1 -1
  140. package/js/src/probit.d.ts +1 -0
  141. package/js/src/probit.js +77 -9
  142. package/js/src/timex.js +67 -0
  143. package/js/src/tokocrypto.d.ts +2 -3
  144. package/js/src/tokocrypto.js +82 -5
  145. package/js/src/tradeogre.d.ts +4 -2
  146. package/js/src/tradeogre.js +55 -2
  147. package/js/src/vertex.js +65 -2
  148. package/js/src/wavesexchange.js +73 -0
  149. package/js/src/wazirx.js +59 -3
  150. package/js/src/whitebit.js +80 -4
  151. package/js/src/xt.js +112 -0
  152. package/js/src/yobit.js +56 -0
  153. package/js/src/zaif.js +55 -0
  154. package/js/src/zonda.d.ts +1 -0
  155. package/js/src/zonda.js +56 -0
  156. package/package.json +2 -2
  157. package/js/src/hitbtc3.d.ts +0 -8
  158. package/js/src/hitbtc3.js +0 -20
package/dist/cjs/ccxt.js CHANGED
@@ -202,7 +202,7 @@ var xt$1 = require('./src/pro/xt.js');
202
202
 
203
203
  //-----------------------------------------------------------------------------
204
204
  // this is updated by vss.js when building
205
- const version = '4.4.49';
205
+ const version = '4.4.52';
206
206
  Exchange["default"].ccxtVersion = version;
207
207
  const exchanges = {
208
208
  'ace': ace,
@@ -50,6 +50,9 @@ class alpaca extends alpaca$1 {
50
50
  'cancelOrder': true,
51
51
  'closeAllPositions': false,
52
52
  'closePosition': false,
53
+ 'createMarketBuyOrder': true,
54
+ 'createMarketBuyOrderWithCost': true,
55
+ 'createMarketOrderWithCost': true,
53
56
  'createOrder': true,
54
57
  'createStopOrder': true,
55
58
  'createTriggerOrder': true,
@@ -433,7 +436,7 @@ class alpaca extends alpaca$1 {
433
436
  // "status": "active",
434
437
  // "tradable": true,
435
438
  // "marginable": false,
436
- // "maintenance_margin_requirement": 100,
439
+ // "maintenance_margin_requirement": 101,
437
440
  // "shortable": false,
438
441
  // "easy_to_borrow": false,
439
442
  // "fractionable": true,
@@ -909,6 +912,58 @@ class alpaca extends alpaca$1 {
909
912
  const clientOrderId = this.safeString(params, 'clientOrderId', defaultClientId);
910
913
  return clientOrderId;
911
914
  }
915
+ /**
916
+ * @method
917
+ * @name alpaca#createMarketOrderWithCost
918
+ * @description create a market order by providing the symbol, side and cost
919
+ * @see https://docs.alpaca.markets/reference/postorder
920
+ * @param {string} symbol unified symbol of the market to create an order in
921
+ * @param {string} side 'buy' or 'sell'
922
+ * @param {float} cost how much you want to trade in units of the quote currency
923
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
924
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
925
+ */
926
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
927
+ await this.loadMarkets();
928
+ const req = {
929
+ 'cost': cost,
930
+ };
931
+ return await this.createOrder(symbol, 'market', side, 0, undefined, this.extend(req, params));
932
+ }
933
+ /**
934
+ * @method
935
+ * @name alpaca#createMarketBuyOrderWithCost
936
+ * @description create a market buy order by providing the symbol and cost
937
+ * @see https://docs.alpaca.markets/reference/postorder
938
+ * @param {string} symbol unified symbol of the market to create an order in
939
+ * @param {float} cost how much you want to trade in units of the quote currency
940
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
941
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
942
+ */
943
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
944
+ await this.loadMarkets();
945
+ const req = {
946
+ 'cost': cost,
947
+ };
948
+ return await this.createOrder(symbol, 'market', 'buy', 0, undefined, this.extend(req, params));
949
+ }
950
+ /**
951
+ * @method
952
+ * @name alpaca#createMarketSellOrderWithCost
953
+ * @description create a market sell order by providing the symbol and cost
954
+ * @see https://docs.alpaca.markets/reference/postorder
955
+ * @param {string} symbol unified symbol of the market to create an order in
956
+ * @param {float} cost how much you want to trade in units of the quote currency
957
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
958
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
959
+ */
960
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
961
+ await this.loadMarkets();
962
+ const req = {
963
+ 'cost': cost,
964
+ };
965
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, this.extend(req, params));
966
+ }
912
967
  /**
913
968
  * @method
914
969
  * @name alpaca#createOrder
@@ -921,6 +976,7 @@ class alpaca extends alpaca$1 {
921
976
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
922
977
  * @param {object} [params] extra parameters specific to the exchange API endpoint
923
978
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
979
+ * @param {float} [params.cost] *market orders only* the cost of the order in units of the quote currency
924
980
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
925
981
  */
926
982
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -929,7 +985,6 @@ class alpaca extends alpaca$1 {
929
985
  const id = market['id'];
930
986
  const request = {
931
987
  'symbol': id,
932
- 'qty': this.amountToPrecision(symbol, amount),
933
988
  'side': side,
934
989
  'type': type, // market, limit, stop_limit
935
990
  };
@@ -948,6 +1003,14 @@ class alpaca extends alpaca$1 {
948
1003
  if (type.indexOf('limit') >= 0) {
949
1004
  request['limit_price'] = this.priceToPrecision(symbol, price);
950
1005
  }
1006
+ const cost = this.safeString(params, 'cost');
1007
+ if (cost !== undefined) {
1008
+ params = this.omit(params, 'cost');
1009
+ request['notional'] = this.costToPrecision(symbol, cost);
1010
+ }
1011
+ else {
1012
+ request['qty'] = this.amountToPrecision(symbol, amount);
1013
+ }
951
1014
  const defaultTIF = this.safeString(this.options, 'defaultTimeInForce');
952
1015
  request['time_in_force'] = this.safeString(params, 'timeInForce', defaultTIF);
953
1016
  params = this.omit(params, ['timeInForce', 'triggerPrice']);
@@ -2312,6 +2312,11 @@ class Exchange {
2312
2312
  const res = this.parseToNumeric((value % 1));
2313
2313
  return res === 0;
2314
2314
  }
2315
+ safeNumberOmitZero(obj, key, defaultValue = undefined) {
2316
+ const value = this.safeString(obj, key);
2317
+ const final = this.parseNumber(this.omitZero(value));
2318
+ return (final === undefined) ? defaultValue : final;
2319
+ }
2315
2320
  safeIntegerOmitZero(obj, key, defaultValue = undefined) {
2316
2321
  const timestamp = this.safeInteger(obj, key, defaultValue);
2317
2322
  if (timestamp === undefined || timestamp === 0) {
@@ -2407,13 +2412,16 @@ class Exchange {
2407
2412
  featuresObj['createOrder']['stopLoss'] = value;
2408
2413
  featuresObj['createOrder']['takeProfit'] = value;
2409
2414
  }
2410
- // for spot, default 'hedged' to false
2411
2415
  if (marketType === 'spot') {
2416
+ // default 'hedged': false
2412
2417
  featuresObj['createOrder']['hedged'] = false;
2418
+ // default 'leverage': false
2419
+ if (!('leverage' in featuresObj['createOrder'])) {
2420
+ featuresObj['createOrder']['leverage'] = false;
2421
+ }
2413
2422
  }
2414
2423
  // default 'GTC' to true
2415
- const gtcValue = this.safeBool(featuresObj['createOrder']['timeInForce'], 'gtc');
2416
- if (gtcValue === undefined) {
2424
+ if (this.safeBool(featuresObj['createOrder']['timeInForce'], 'GTC') === undefined) {
2417
2425
  featuresObj['createOrder']['timeInForce']['GTC'] = true;
2418
2426
  }
2419
2427
  }
@@ -2486,6 +2494,81 @@ class Exchange {
2486
2494
  };
2487
2495
  }
2488
2496
  safeCurrencyStructure(currency) {
2497
+ // derive data from networks: deposit, withdraw, active, fee, limits, precision
2498
+ const networks = this.safeDict(currency, 'networks', {});
2499
+ const keys = Object.keys(networks);
2500
+ const length = keys.length;
2501
+ if (length !== 0) {
2502
+ for (let i = 0; i < length; i++) {
2503
+ const network = networks[keys[i]];
2504
+ const deposit = this.safeBool(network, 'deposit');
2505
+ if (currency['deposit'] === undefined || deposit) {
2506
+ currency['deposit'] = deposit;
2507
+ }
2508
+ const withdraw = this.safeBool(network, 'withdraw');
2509
+ if (currency['withdraw'] === undefined || withdraw) {
2510
+ currency['withdraw'] = withdraw;
2511
+ }
2512
+ const active = this.safeBool(network, 'active');
2513
+ if (currency['active'] === undefined || active) {
2514
+ currency['active'] = active;
2515
+ }
2516
+ // find lowest fee (which is more desired)
2517
+ const fee = this.safeString(network, 'fee');
2518
+ const feeMain = this.safeString(currency, 'fee');
2519
+ if (feeMain === undefined || Precise["default"].stringLt(fee, feeMain)) {
2520
+ currency['fee'] = this.parseNumber(fee);
2521
+ }
2522
+ // find lowest precision (which is more desired)
2523
+ const precision = this.safeString(network, 'precision');
2524
+ const precisionMain = this.safeString(currency, 'precision');
2525
+ if (precisionMain === undefined || Precise["default"].stringLt(precision, precisionMain)) {
2526
+ currency['precision'] = this.parseNumber(precision);
2527
+ }
2528
+ // limits
2529
+ const limits = this.safeDict(network, 'limits');
2530
+ const limitsMain = this.safeDict(currency, 'limits');
2531
+ if (limitsMain === undefined) {
2532
+ currency['limits'] = {};
2533
+ }
2534
+ // deposits
2535
+ const limitsDeposit = this.safeDict(limits, 'deposit');
2536
+ const limitsDepositMain = this.safeDict(limitsMain, 'deposit');
2537
+ if (limitsDepositMain === undefined) {
2538
+ currency['limits']['deposit'] = {};
2539
+ }
2540
+ const limitsDepositMin = this.safeString(limitsDeposit, 'min');
2541
+ const limitsDepositMax = this.safeString(limitsDeposit, 'max');
2542
+ const limitsDepositMinMain = this.safeString(limitsDepositMain, 'min');
2543
+ const limitsDepositMaxMain = this.safeString(limitsDepositMain, 'max');
2544
+ // find min
2545
+ if (limitsDepositMinMain === undefined || Precise["default"].stringLt(limitsDepositMin, limitsDepositMinMain)) {
2546
+ currency['limits']['deposit']['min'] = this.parseNumber(limitsDepositMin);
2547
+ }
2548
+ // find max
2549
+ if (limitsDepositMaxMain === undefined || Precise["default"].stringGt(limitsDepositMax, limitsDepositMaxMain)) {
2550
+ currency['limits']['deposit']['max'] = this.parseNumber(limitsDepositMax);
2551
+ }
2552
+ // withdrawals
2553
+ const limitsWithdraw = this.safeDict(limits, 'withdraw');
2554
+ const limitsWithdrawMain = this.safeDict(limitsMain, 'withdraw');
2555
+ if (limitsWithdrawMain === undefined) {
2556
+ currency['limits']['withdraw'] = {};
2557
+ }
2558
+ const limitsWithdrawMin = this.safeString(limitsWithdraw, 'min');
2559
+ const limitsWithdrawMax = this.safeString(limitsWithdraw, 'max');
2560
+ const limitsWithdrawMinMain = this.safeString(limitsWithdrawMain, 'min');
2561
+ const limitsWithdrawMaxMain = this.safeString(limitsWithdrawMain, 'max');
2562
+ // find min
2563
+ if (limitsWithdrawMinMain === undefined || Precise["default"].stringLt(limitsWithdrawMin, limitsWithdrawMinMain)) {
2564
+ currency['limits']['withdraw']['min'] = this.parseNumber(limitsWithdrawMin);
2565
+ }
2566
+ // find max
2567
+ if (limitsWithdrawMaxMain === undefined || Precise["default"].stringGt(limitsWithdrawMax, limitsWithdrawMaxMain)) {
2568
+ currency['limits']['withdraw']['max'] = this.parseNumber(limitsWithdrawMax);
2569
+ }
2570
+ }
2571
+ }
2489
2572
  return this.extend({
2490
2573
  'info': undefined,
2491
2574
  'id': undefined,
@@ -5756,6 +5839,32 @@ class Exchange {
5756
5839
  const symbol = (market === undefined) ? undefined : market['symbol'];
5757
5840
  return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
5758
5841
  }
5842
+ handleTriggerDirectionAndParams(params, exchangeSpecificKey = undefined, allowEmpty = false) {
5843
+ /**
5844
+ * @ignore
5845
+ * @method
5846
+ * @returns {[string, object]} the trigger-direction value and omited params
5847
+ */
5848
+ let triggerDirection = this.safeString(params, 'triggerDirection');
5849
+ const exchangeSpecificDefined = (exchangeSpecificKey !== undefined) && (exchangeSpecificKey in params);
5850
+ if (triggerDirection !== undefined) {
5851
+ params = this.omit(params, 'triggerDirection');
5852
+ }
5853
+ // throw exception if:
5854
+ // A) if provided value is not unified (support old "up/down" strings too)
5855
+ // B) if exchange specific "trigger direction key" (eg. "stopPriceSide") was not provided
5856
+ if (!this.inArray(triggerDirection, ['ascending', 'descending', 'up', 'down', 'above', 'below']) && !exchangeSpecificDefined && !allowEmpty) {
5857
+ throw new errors.ArgumentsRequired(this.id + ' createOrder() : trigger orders require params["triggerDirection"] to be either "ascending" or "descending"');
5858
+ }
5859
+ // if old format was provided, overwrite to new
5860
+ if (triggerDirection === 'up' || triggerDirection === 'above') {
5861
+ triggerDirection = 'ascending';
5862
+ }
5863
+ else if (triggerDirection === 'down' || triggerDirection === 'below') {
5864
+ triggerDirection = 'descending';
5865
+ }
5866
+ return [triggerDirection, params];
5867
+ }
5759
5868
  handleTriggerAndParams(params) {
5760
5869
  const isTrigger = this.safeBool2(params, 'trigger', 'stop');
5761
5870
  if (isTrigger) {
@@ -479,6 +479,7 @@ class binance extends binance$1 {
479
479
  'portfolio/repay-futures-switch': 3,
480
480
  'portfolio/margin-asset-leverage': 5,
481
481
  'portfolio/balance': 2,
482
+ 'portfolio/negative-balance-exchange-record': 2,
482
483
  // staking
483
484
  'staking/productList': 0.1,
484
485
  'staking/position': 0.1,
@@ -1584,12 +1585,16 @@ class binance extends binance$1 {
1584
1585
  },
1585
1586
  'hedged': true,
1586
1587
  'leverage': false,
1587
- 'marketBuyRequiresPrice': false,
1588
1588
  'marketBuyByCost': true,
1589
- // exchange-supported features
1590
- 'selfTradePrevention': true,
1591
- 'trailing': true,
1592
- 'iceberg': true, // todo implementation
1589
+ 'marketBuyRequiresPrice': false,
1590
+ 'selfTradePrevention': {
1591
+ 'expire_maker': true,
1592
+ 'expire_taker': true,
1593
+ 'expire_both': true,
1594
+ 'none': true,
1595
+ },
1596
+ 'trailing': false,
1597
+ 'icebergAmount': true,
1593
1598
  },
1594
1599
  'createOrders': undefined,
1595
1600
  'fetchMyTrades': {
@@ -1630,7 +1635,7 @@ class binance extends binance$1 {
1630
1635
  'limit': 1000,
1631
1636
  },
1632
1637
  },
1633
- 'default': {
1638
+ 'forDerivatives': {
1634
1639
  'sandbox': true,
1635
1640
  'createOrder': {
1636
1641
  'marginMode': false,
@@ -1702,18 +1707,18 @@ class binance extends binance$1 {
1702
1707
  },
1703
1708
  'swap': {
1704
1709
  'linear': {
1705
- 'extends': 'default',
1710
+ 'extends': 'forDerivatives',
1706
1711
  },
1707
1712
  'inverse': {
1708
- 'extends': 'default',
1713
+ 'extends': 'forDerivatives',
1709
1714
  },
1710
1715
  },
1711
1716
  'future': {
1712
1717
  'linear': {
1713
- 'extends': 'default',
1718
+ 'extends': 'forDerivatives',
1714
1719
  },
1715
1720
  'inverse': {
1716
- 'extends': 'default',
1721
+ 'extends': 'forDerivatives',
1717
1722
  },
1718
1723
  },
1719
1724
  },
@@ -4509,12 +4514,11 @@ class binance extends binance$1 {
4509
4514
  const type = (timestamp === undefined) ? 'spot' : 'swap';
4510
4515
  const marketId = this.safeString(entry, 'symbol');
4511
4516
  market = this.safeMarket(marketId, market, undefined, type);
4512
- const price = this.safeNumber(entry, 'price');
4513
4517
  return {
4514
4518
  'symbol': market['symbol'],
4515
4519
  'timestamp': timestamp,
4516
4520
  'datetime': this.iso8601(timestamp),
4517
- 'price': price,
4521
+ 'price': this.safeNumberOmitZero(entry, 'price'),
4518
4522
  'side': undefined,
4519
4523
  'info': entry,
4520
4524
  };
@@ -5158,12 +5162,14 @@ class binance extends binance$1 {
5158
5162
  request['endTime'] = until;
5159
5163
  }
5160
5164
  }
5165
+ let method = this.safeString(this.options, 'fetchTradesMethod');
5166
+ method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
5161
5167
  if (limit !== undefined) {
5162
5168
  const isFutureOrSwap = (market['swap'] || market['future']);
5163
- request['limit'] = isFutureOrSwap ? Math.min(limit, 1000) : limit; // default = 500, maximum = 1000
5169
+ const isHistoricalEndpoint = (method !== undefined) && (method.indexOf('GetHistoricalTrades') >= 0);
5170
+ const maxLimitForContractHistorical = isHistoricalEndpoint ? 500 : 1000;
5171
+ request['limit'] = isFutureOrSwap ? Math.min(limit, maxLimitForContractHistorical) : limit; // default = 500, maximum = 1000
5164
5172
  }
5165
- let method = this.safeString(this.options, 'fetchTradesMethod');
5166
- method = this.safeString2(params, 'fetchTradesMethod', 'method', method);
5167
5173
  params = this.omit(params, ['until', 'fetchTradesMethod']);
5168
5174
  let response = undefined;
5169
5175
  if (market['option'] || method === 'eapiPublicGetTrades') {
@@ -6241,7 +6247,7 @@ class binance extends binance$1 {
6241
6247
  * @method
6242
6248
  * @name binance#createOrder
6243
6249
  * @description create a trade order
6244
- * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#new-order-trade
6250
+ * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
6245
6251
  * @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade
6246
6252
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
6247
6253
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/New-Order
@@ -6269,6 +6275,8 @@ class binance extends binance$1 {
6269
6275
  * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
6270
6276
  * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
6271
6277
  * @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
6278
+ * @param {string} [params.selfTradePrevention] set unified value for stp (see .features for available values)
6279
+ * @param {float} [params.icebergAmount] set iceberg amount for limit orders
6272
6280
  * @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
6273
6281
  * @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
6274
6282
  * @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
@@ -6655,7 +6663,7 @@ class binance extends binance$1 {
6655
6663
  }
6656
6664
  }
6657
6665
  if (timeInForceIsRequired && (this.safeString(params, 'timeInForce') === undefined) && (this.safeString(request, 'timeInForce') === undefined)) {
6658
- request['timeInForce'] = this.options['defaultTimeInForce']; // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
6666
+ request['timeInForce'] = this.safeString(this.options, 'defaultTimeInForce'); // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
6659
6667
  }
6660
6668
  if (!isPortfolioMargin && market['contract'] && postOnly) {
6661
6669
  request['timeInForce'] = 'GTX';
@@ -6672,7 +6680,21 @@ class binance extends binance$1 {
6672
6680
  }
6673
6681
  request['positionSide'] = (side === 'buy') ? 'LONG' : 'SHORT';
6674
6682
  }
6675
- const requestParams = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test', 'hedged']);
6683
+ // unified stp
6684
+ const selfTradePrevention = this.safeString(params, 'selfTradePrevention');
6685
+ if (selfTradePrevention !== undefined) {
6686
+ if (market['spot']) {
6687
+ request['selfTradePreventionMode'] = selfTradePrevention.toUpperCase(); // binance enums exactly match the unified ccxt enums (but needs uppercase)
6688
+ }
6689
+ }
6690
+ // unified iceberg
6691
+ const icebergAmount = this.safeNumber(params, 'icebergAmount');
6692
+ if (icebergAmount !== undefined) {
6693
+ if (market['spot']) {
6694
+ request['icebergQty'] = this.amountToPrecision(symbol, icebergAmount);
6695
+ }
6696
+ }
6697
+ const requestParams = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test', 'hedged', 'selfTradePrevention', 'icebergAmount']);
6676
6698
  return this.extend(request, requestParams);
6677
6699
  }
6678
6700
  /**
@@ -7217,6 +7239,7 @@ class binance extends binance$1 {
7217
7239
  * @param {string} symbol unified market symbol
7218
7240
  * @param {object} [params] extra parameters specific to the exchange API endpoint
7219
7241
  * @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
7242
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch for a portfolio margin account
7220
7243
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
7221
7244
  */
7222
7245
  async fetchOpenOrder(id, symbol = undefined, params = {}) {
@@ -10817,7 +10840,7 @@ class binance extends binance$1 {
10817
10840
  // }
10818
10841
  //
10819
10842
  const marketId = this.safeString(position, 'symbol');
10820
- market = this.safeMarket(marketId, market);
10843
+ market = this.safeMarket(marketId, market, undefined, 'swap');
10821
10844
  const symbol = market['symbol'];
10822
10845
  const side = this.safeStringLower(position, 'side');
10823
10846
  let quantity = this.safeString(position, 'quantity');
@@ -401,7 +401,7 @@ class bitfinex1 extends bitfinex1$1 {
401
401
  }
402
402
  /**
403
403
  * @method
404
- * @name bitfinex#fetchTransactionFees
404
+ * @name bitfinex1#fetchTransactionFees
405
405
  * @deprecated
406
406
  * @description please use fetchDepositWithdrawFees instead
407
407
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-fees
@@ -438,7 +438,7 @@ class bitfinex1 extends bitfinex1$1 {
438
438
  }
439
439
  /**
440
440
  * @method
441
- * @name bitfinex#fetchDepositWithdrawFees
441
+ * @name bitfinex1#fetchDepositWithdrawFees
442
442
  * @description fetch deposit and withdraw fees
443
443
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-fees
444
444
  * @param {string[]|undefined} codes list of unified currency codes
@@ -478,7 +478,7 @@ class bitfinex1 extends bitfinex1$1 {
478
478
  }
479
479
  /**
480
480
  * @method
481
- * @name bitfinex#fetchTradingFees
481
+ * @name bitfinex1#fetchTradingFees
482
482
  * @description fetch the trading fees for multiple markets
483
483
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-summary
484
484
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -561,7 +561,7 @@ class bitfinex1 extends bitfinex1$1 {
561
561
  }
562
562
  /**
563
563
  * @method
564
- * @name bitfinex#fetchMarkets
564
+ * @name bitfinex1#fetchMarkets
565
565
  * @description retrieves data on all markets for bitfinex
566
566
  * @see https://docs.bitfinex.com/v1/reference/rest-public-symbols
567
567
  * @see https://docs.bitfinex.com/v1/reference/rest-public-symbol-details
@@ -688,7 +688,7 @@ class bitfinex1 extends bitfinex1$1 {
688
688
  }
689
689
  /**
690
690
  * @method
691
- * @name bitfinex#fetchBalance
691
+ * @name bitfinex1#fetchBalance
692
692
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
693
693
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-wallet-balances
694
694
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -746,7 +746,7 @@ class bitfinex1 extends bitfinex1$1 {
746
746
  }
747
747
  /**
748
748
  * @method
749
- * @name bitfinex#transfer
749
+ * @name bitfinex1#transfer
750
750
  * @description transfer currency internally between wallets on the same account
751
751
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-transfer-between-wallets
752
752
  * @param {string} code unified currency code
@@ -832,7 +832,7 @@ class bitfinex1 extends bitfinex1$1 {
832
832
  }
833
833
  /**
834
834
  * @method
835
- * @name bitfinex#fetchOrderBook
835
+ * @name bitfinex1#fetchOrderBook
836
836
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
837
837
  * @see https://docs.bitfinex.com/v1/reference/rest-public-orderbook
838
838
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -855,7 +855,7 @@ class bitfinex1 extends bitfinex1$1 {
855
855
  }
856
856
  /**
857
857
  * @method
858
- * @name bitfinex#fetchTickers
858
+ * @name bitfinex1#fetchTickers
859
859
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
860
860
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
861
861
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -875,7 +875,7 @@ class bitfinex1 extends bitfinex1$1 {
875
875
  }
876
876
  /**
877
877
  * @method
878
- * @name bitfinex#fetchTicker
878
+ * @name bitfinex1#fetchTicker
879
879
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
880
880
  * @see https://docs.bitfinex.com/v1/reference/rest-public-ticker
881
881
  * @param {string} symbol unified symbol of the market to fetch the ticker for
@@ -1016,7 +1016,7 @@ class bitfinex1 extends bitfinex1$1 {
1016
1016
  }
1017
1017
  /**
1018
1018
  * @method
1019
- * @name bitfinex#fetchTrades
1019
+ * @name bitfinex1#fetchTrades
1020
1020
  * @description get the list of most recent trades for a particular symbol
1021
1021
  * @see https://docs.bitfinex.com/v1/reference/rest-public-trades
1022
1022
  * @param {string} symbol unified symbol of the market to fetch trades for
@@ -1052,7 +1052,7 @@ class bitfinex1 extends bitfinex1$1 {
1052
1052
  }
1053
1053
  /**
1054
1054
  * @method
1055
- * @name bitfinex#fetchMyTrades
1055
+ * @name bitfinex1#fetchMyTrades
1056
1056
  * @description fetch all trades made by the user
1057
1057
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-past-trades
1058
1058
  * @param {string} symbol unified market symbol
@@ -1081,7 +1081,7 @@ class bitfinex1 extends bitfinex1$1 {
1081
1081
  }
1082
1082
  /**
1083
1083
  * @method
1084
- * @name bitfinex#createOrder
1084
+ * @name bitfinex1#createOrder
1085
1085
  * @description create a trade order
1086
1086
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-new-order
1087
1087
  * @param {string} symbol unified symbol of the market to create an order in
@@ -1149,7 +1149,7 @@ class bitfinex1 extends bitfinex1$1 {
1149
1149
  }
1150
1150
  /**
1151
1151
  * @method
1152
- * @name bitfinex#cancelOrder
1152
+ * @name bitfinex1#cancelOrder
1153
1153
  * @description cancels an open order
1154
1154
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-order
1155
1155
  * @param {string} id order id
@@ -1192,7 +1192,7 @@ class bitfinex1 extends bitfinex1$1 {
1192
1192
  }
1193
1193
  /**
1194
1194
  * @method
1195
- * @name bitfinex#cancelAllOrders
1195
+ * @name bitfinex1#cancelAllOrders
1196
1196
  * @description cancel all open orders
1197
1197
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-all-orders
1198
1198
  * @param {string} symbol not used by bitfinex cancelAllOrders
@@ -1284,7 +1284,7 @@ class bitfinex1 extends bitfinex1$1 {
1284
1284
  }
1285
1285
  /**
1286
1286
  * @method
1287
- * @name bitfinex#fetchOpenOrders
1287
+ * @name bitfinex1#fetchOpenOrders
1288
1288
  * @description fetch all unfilled currently open orders
1289
1289
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-active-orders
1290
1290
  * @param {string} symbol unified market symbol
@@ -1309,7 +1309,7 @@ class bitfinex1 extends bitfinex1$1 {
1309
1309
  }
1310
1310
  /**
1311
1311
  * @method
1312
- * @name bitfinex#fetchClosedOrders
1312
+ * @name bitfinex1#fetchClosedOrders
1313
1313
  * @description fetches information on multiple closed orders made by the user
1314
1314
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-orders-history
1315
1315
  * @param {string} symbol unified market symbol of the market orders were made in
@@ -1335,7 +1335,7 @@ class bitfinex1 extends bitfinex1$1 {
1335
1335
  }
1336
1336
  /**
1337
1337
  * @method
1338
- * @name bitfinex#fetchOrder
1338
+ * @name bitfinex1#fetchOrder
1339
1339
  * @description fetches information on an order made by the user
1340
1340
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-order-status
1341
1341
  * @param {string} id the order id
@@ -1431,7 +1431,7 @@ class bitfinex1 extends bitfinex1$1 {
1431
1431
  }
1432
1432
  /**
1433
1433
  * @method
1434
- * @name bitfinex#createDepositAddress
1434
+ * @name bitfinex1#createDepositAddress
1435
1435
  * @description create a currency deposit address
1436
1436
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit
1437
1437
  * @param {string} code unified currency code of the currency for the deposit address
@@ -1447,7 +1447,7 @@ class bitfinex1 extends bitfinex1$1 {
1447
1447
  }
1448
1448
  /**
1449
1449
  * @method
1450
- * @name bitfinex#fetchDepositAddress
1450
+ * @name bitfinex1#fetchDepositAddress
1451
1451
  * @description fetch the deposit address for a currency associated with this account
1452
1452
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit
1453
1453
  * @param {string} code unified currency code
@@ -1481,7 +1481,7 @@ class bitfinex1 extends bitfinex1$1 {
1481
1481
  }
1482
1482
  /**
1483
1483
  * @method
1484
- * @name bitfinex#fetchDepositsWithdrawals
1484
+ * @name bitfinex1#fetchDepositsWithdrawals
1485
1485
  * @description fetch history of deposits and withdrawals
1486
1486
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit-withdrawal-history
1487
1487
  * @param {string} code unified currency code for the currency of the deposit/withdrawals
@@ -1618,7 +1618,7 @@ class bitfinex1 extends bitfinex1$1 {
1618
1618
  }
1619
1619
  /**
1620
1620
  * @method
1621
- * @name bitfinex#withdraw
1621
+ * @name bitfinex1#withdraw
1622
1622
  * @description make a withdrawal
1623
1623
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-withdrawal
1624
1624
  * @param {string} code unified currency code
@@ -1669,7 +1669,7 @@ class bitfinex1 extends bitfinex1$1 {
1669
1669
  }
1670
1670
  /**
1671
1671
  * @method
1672
- * @name bitfinex#fetchPositions
1672
+ * @name bitfinex1#fetchPositions
1673
1673
  * @description fetch all open positions
1674
1674
  * @see https://docs.bitfinex.com/v1/reference/rest-auth-active-positions
1675
1675
  * @param {string[]|undefined} symbols list of unified market symbols
@@ -157,6 +157,9 @@ class blofin extends blofin$1 {
157
157
  'api': {
158
158
  'rest': 'https://openapi.blofin.com',
159
159
  },
160
+ 'test': {
161
+ 'rest': 'https://demo-trading-openapi.blofin.com',
162
+ },
160
163
  'referral': {
161
164
  'url': 'https://blofin.com/register?referral_code=f79EsS',
162
165
  'discount': 0.05,
@@ -286,7 +289,7 @@ class blofin extends blofin$1 {
286
289
  'trailing': false,
287
290
  },
288
291
  'fetchOHLCV': {
289
- 'max': 1440,
292
+ 'limit': 1440,
290
293
  },
291
294
  },
292
295
  'spot': {
@@ -314,6 +317,7 @@ class blofin extends blofin$1 {
314
317
  'attachedStopLossTakeProfit': {
315
318
  'triggerPriceType': undefined,
316
319
  'limit': true,
320
+ 'price': undefined,
317
321
  },
318
322
  'hedged': true,
319
323
  },
@@ -1955,7 +1959,7 @@ class blofin extends blofin$1 {
1955
1959
  }
1956
1960
  /**
1957
1961
  * @method
1958
- * @name blofin#fetchPosition
1962
+ * @name blofin#fetchPositions
1959
1963
  * @description fetch data on a single open contract trade position
1960
1964
  * @see https://blofin.com/docs#get-positions
1961
1965
  * @param {string[]} [symbols] list of unified market symbols