ccxt 4.1.88 → 4.1.90

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 (63) hide show
  1. package/CHANGELOG.md +8309 -5710
  2. package/README.md +3 -3
  3. package/changelog.js +101 -0
  4. package/dist/ccxt.browser.js +963 -387
  5. package/dist/ccxt.browser.min.js +3 -3
  6. package/dist/cjs/ccxt.js +1 -1
  7. package/dist/cjs/src/base/Exchange.js +2 -2
  8. package/dist/cjs/src/bigone.js +8 -1
  9. package/dist/cjs/src/bitforex.js +2 -0
  10. package/dist/cjs/src/bitget.js +11 -4
  11. package/dist/cjs/src/bitmex.js +2 -0
  12. package/dist/cjs/src/blockchaincom.js +0 -41
  13. package/dist/cjs/src/bybit.js +29 -14
  14. package/dist/cjs/src/coinex.js +14 -1
  15. package/dist/cjs/src/coinlist.js +2 -0
  16. package/dist/cjs/src/coinsph.js +2 -0
  17. package/dist/cjs/src/cryptocom.js +2 -0
  18. package/dist/cjs/src/gate.js +276 -11
  19. package/dist/cjs/src/htx.js +264 -219
  20. package/dist/cjs/src/kuna.js +2 -0
  21. package/dist/cjs/src/mexc.js +2 -0
  22. package/dist/cjs/src/okcoin.js +61 -17
  23. package/dist/cjs/src/phemex.js +159 -30
  24. package/dist/cjs/src/poloniex.js +28 -2
  25. package/dist/cjs/src/pro/binance.js +6 -6
  26. package/dist/cjs/src/pro/poloniex.js +15 -10
  27. package/dist/cjs/src/tokocrypto.js +30 -14
  28. package/dist/cjs/src/wazirx.js +2 -0
  29. package/dist/cjs/src/whitebit.js +2 -0
  30. package/dist/cjs/src/woo.js +41 -14
  31. package/js/ccxt.d.ts +1 -1
  32. package/js/ccxt.js +1 -1
  33. package/js/src/abstract/phemex.d.ts +1 -0
  34. package/js/src/base/Exchange.js +2 -2
  35. package/js/src/bigone.js +9 -2
  36. package/js/src/bitforex.js +2 -0
  37. package/js/src/bitget.js +11 -4
  38. package/js/src/bitmex.js +2 -0
  39. package/js/src/blockchaincom.d.ts +0 -2
  40. package/js/src/blockchaincom.js +0 -41
  41. package/js/src/bybit.js +29 -14
  42. package/js/src/coinex.js +14 -1
  43. package/js/src/coinlist.js +2 -0
  44. package/js/src/coinsph.js +2 -0
  45. package/js/src/cryptocom.js +2 -0
  46. package/js/src/gate.d.ts +47 -0
  47. package/js/src/gate.js +276 -11
  48. package/js/src/htx.js +264 -219
  49. package/js/src/kuna.js +2 -0
  50. package/js/src/mexc.js +2 -0
  51. package/js/src/okcoin.d.ts +1 -0
  52. package/js/src/okcoin.js +62 -18
  53. package/js/src/phemex.d.ts +3 -108
  54. package/js/src/phemex.js +159 -30
  55. package/js/src/poloniex.js +28 -2
  56. package/js/src/pro/binance.js +6 -6
  57. package/js/src/pro/poloniex.js +16 -11
  58. package/js/src/tokocrypto.js +30 -14
  59. package/js/src/wazirx.js +2 -0
  60. package/js/src/whitebit.js +2 -0
  61. package/js/src/woo.d.ts +1 -0
  62. package/js/src/woo.js +42 -15
  63. package/package.json +2 -2
package/js/src/woo.d.ts CHANGED
@@ -13,6 +13,7 @@ export default class woo extends Exchange {
13
13
  parseTokenAndFeeTemp(item: any, feeTokenKey: any, feeAmountKey: any): any;
14
14
  fetchTradingFees(params?: {}): Promise<{}>;
15
15
  fetchCurrencies(params?: {}): Promise<{}>;
16
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
16
17
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
17
18
  editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
18
19
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
package/js/src/woo.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/woo.js';
9
- import { AuthenticationError, RateLimitExceeded, BadRequest, ExchangeError, InvalidOrder, ArgumentsRequired } from './base/errors.js';
9
+ import { AuthenticationError, RateLimitExceeded, BadRequest, ExchangeError, InvalidOrder, ArgumentsRequired, NotSupported } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { TICK_SIZE } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
@@ -40,7 +40,10 @@ export default class woo extends Exchange {
40
40
  'closeAllPositions': false,
41
41
  'closePosition': false,
42
42
  'createDepositAddress': false,
43
+ 'createMarketBuyOrderWithCost': true,
43
44
  'createMarketOrder': false,
45
+ 'createMarketOrderWithCost': false,
46
+ 'createMarketSellOrderWithCost': false,
44
47
  'createOrder': true,
45
48
  'createReduceOnlyOrder': true,
46
49
  'createStopLimitOrder': false,
@@ -742,6 +745,25 @@ export default class woo extends Exchange {
742
745
  }
743
746
  return result;
744
747
  }
748
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
749
+ /**
750
+ * @method
751
+ * @name woo#createMarketBuyOrderWithCost
752
+ * @description create a market buy order by providing the symbol and cost
753
+ * @see https://docs.woo.org/#send-order
754
+ * @param {string} symbol unified symbol of the market to create an order in
755
+ * @param {float} cost how much you want to trade in units of the quote currency
756
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
757
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
758
+ */
759
+ await this.loadMarkets();
760
+ const market = this.market(symbol);
761
+ if (!market['spot']) {
762
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
763
+ }
764
+ params['createMarketBuyOrderRequiresPrice'] = false;
765
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
766
+ }
745
767
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
746
768
  /**
747
769
  * @method
@@ -761,9 +783,11 @@ export default class woo extends Exchange {
761
783
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
762
784
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
763
785
  * @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
786
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
764
787
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
765
788
  */
766
789
  const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
790
+ params = this.omit(params, ['reduceOnly', 'reduce_only']);
767
791
  const orderType = type.toUpperCase();
768
792
  await this.loadMarkets();
769
793
  const market = this.market(symbol);
@@ -806,26 +830,29 @@ export default class woo extends Exchange {
806
830
  if (isMarket && !isStop) {
807
831
  // for market buy it requires the amount of quote currency to spend
808
832
  if (market['spot'] && orderSide === 'BUY') {
809
- const cost = this.safeNumber(params, 'cost');
810
- if (this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true)) {
811
- if (cost === undefined) {
812
- if (price === undefined) {
813
- throw new InvalidOrder(this.id + " createOrder() requires the price argument for market buy orders to calculate total order cost. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or alternatively, supply the total cost value in the 'order_amount' in exchange-specific parameters");
814
- }
815
- else {
816
- const amountString = this.numberToString(amount);
817
- const priceString = this.numberToString(price);
818
- const orderAmount = Precise.stringMul(amountString, priceString);
819
- request['order_amount'] = this.costToPrecision(symbol, orderAmount);
820
- }
833
+ let quoteAmount = undefined;
834
+ let createMarketBuyOrderRequiresPrice = true;
835
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
836
+ const cost = this.safeNumber2(params, 'cost', 'order_amount');
837
+ params = this.omit(params, ['cost', 'order_amount']);
838
+ if (cost !== undefined) {
839
+ quoteAmount = this.costToPrecision(symbol, cost);
840
+ }
841
+ else if (createMarketBuyOrderRequiresPrice) {
842
+ if (price === undefined) {
843
+ throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
821
844
  }
822
845
  else {
823
- request['order_amount'] = this.costToPrecision(symbol, cost);
846
+ const amountString = this.numberToString(amount);
847
+ const priceString = this.numberToString(price);
848
+ const costRequest = Precise.stringMul(amountString, priceString);
849
+ quoteAmount = this.costToPrecision(symbol, costRequest);
824
850
  }
825
851
  }
826
852
  else {
827
- request['order_amount'] = this.costToPrecision(symbol, amount);
853
+ quoteAmount = this.costToPrecision(symbol, amount);
828
854
  }
855
+ request['order_amount'] = quoteAmount;
829
856
  }
830
857
  else {
831
858
  request['order_quantity'] = this.amountToPrecision(symbol, amount);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.88",
4
- "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
3
+ "version": "4.1.90",
4
+ "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",
7
7
  "exports": {