ccxt 4.1.71 → 4.1.73

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/dist/cjs/ccxt.js CHANGED
@@ -173,7 +173,7 @@ var woo$1 = require('./src/pro/woo.js');
173
173
 
174
174
  //-----------------------------------------------------------------------------
175
175
  // this is updated by vss.js when building
176
- const version = '4.1.71';
176
+ const version = '4.1.73';
177
177
  Exchange["default"].ccxtVersion = version;
178
178
  const exchanges = {
179
179
  'ace': ace,
@@ -359,6 +359,8 @@ class Exchange {
359
359
  'createLimitOrder': true,
360
360
  'createMarketOrder': true,
361
361
  'createOrder': true,
362
+ 'createMarketBuyOrderWithCost': undefined,
363
+ 'createMarketSellOrderWithCost': undefined,
362
364
  'createOrders': undefined,
363
365
  'createPostOnlyOrder': undefined,
364
366
  'createReduceOnlyOrder': undefined,
@@ -3558,6 +3560,30 @@ class Exchange {
3558
3560
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
3559
3561
  throw new errors.NotSupported(this.id + ' createOrder() is not supported yet');
3560
3562
  }
3563
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
3564
+ /**
3565
+ * @method
3566
+ * @name createMarketBuyWithCost
3567
+ * @description create a market buy order by providing the symbol and cost
3568
+ * @param {string} symbol unified symbol of the market to create an order in
3569
+ * @param {float} cost how much you want to trade in units of the quote currency
3570
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3571
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3572
+ */
3573
+ throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() is not supported yet');
3574
+ }
3575
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
3576
+ /**
3577
+ * @method
3578
+ * @name createMarketSellOrderWithCost
3579
+ * @description create a market buy order by providing the symbol and cost
3580
+ * @param {string} symbol unified symbol of the market to create an order in
3581
+ * @param {float} cost how much you want to trade in units of the quote currency
3582
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3583
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3584
+ */
3585
+ throw new errors.NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
3586
+ }
3561
3587
  async createOrders(orders, params = {}) {
3562
3588
  throw new errors.NotSupported(this.id + ' createOrders() is not supported yet');
3563
3589
  }
@@ -3634,10 +3660,10 @@ class Exchange {
3634
3660
  */
3635
3661
  throw new errors.NotSupported(this.id + ' fetchDepositsWithdrawals() is not supported yet');
3636
3662
  }
3637
- async fetchDeposits(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3663
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
3638
3664
  throw new errors.NotSupported(this.id + ' fetchDeposits() is not supported yet');
3639
3665
  }
3640
- async fetchWithdrawals(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3666
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
3641
3667
  throw new errors.NotSupported(this.id + ' fetchWithdrawals() is not supported yet');
3642
3668
  }
3643
3669
  async fetchOpenInterest(symbol, params = {}) {
@@ -1963,15 +1963,17 @@ class bingx extends bingx$1 {
1963
1963
  // "symbol": "XRP-USDT",
1964
1964
  // "orderId": 1514073325788200960,
1965
1965
  // "price": "0.5",
1966
+ // "StopPrice": "0",
1966
1967
  // "origQty": "20",
1967
- // "executedQty": "0",
1968
- // "cummulativeQuoteQty": "0",
1968
+ // "executedQty": "10",
1969
+ // "cummulativeQuoteQty": "5",
1969
1970
  // "status": "PENDING",
1970
1971
  // "type": "LIMIT",
1971
1972
  // "side": "BUY",
1972
1973
  // "time": 1649818185647,
1973
1974
  // "updateTime": 1649818185647,
1974
1975
  // "origQuoteOrderQty": "0"
1976
+ // "fee": "-0.01"
1975
1977
  // }
1976
1978
  //
1977
1979
  //
@@ -2031,9 +2033,24 @@ class bingx extends bingx$1 {
2031
2033
  const amount = this.safeString2(order, 'origQty', 'q');
2032
2034
  const filled = this.safeString2(order, 'executedQty', 'z');
2033
2035
  const statusId = this.safeString2(order, 'status', 'X');
2036
+ let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
2037
+ const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
2038
+ if ((feeCurrencyCode === undefined)) {
2039
+ if (market['spot']) {
2040
+ if (side === 'buy') {
2041
+ feeCurrencyCode = market['base'];
2042
+ }
2043
+ else {
2044
+ feeCurrencyCode = market['quote'];
2045
+ }
2046
+ }
2047
+ else {
2048
+ feeCurrencyCode = market['quote'];
2049
+ }
2050
+ }
2034
2051
  const fee = {
2035
- 'currency': this.safeString2(order, 'feeAsset', 'N'),
2036
- 'rate': this.safeStringN(order, ['fee', 'commission', 'n']),
2052
+ 'currency': feeCurrencyCode,
2053
+ 'cost': Precise["default"].stringAbs(feeCost),
2037
2054
  };
2038
2055
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
2039
2056
  return this.safeOrder({
@@ -44,6 +44,7 @@ class coinex extends coinex$1 {
44
44
  'cancelOrder': true,
45
45
  'cancelOrders': true,
46
46
  'createDepositAddress': true,
47
+ 'createMarketBuyOrderWithCost': true,
47
48
  'createOrder': true,
48
49
  'createOrders': true,
49
50
  'createReduceOnlyOrder': true,
@@ -1883,6 +1884,19 @@ class coinex extends coinex$1 {
1883
1884
  'info': order,
1884
1885
  }, market);
1885
1886
  }
1887
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1888
+ /**
1889
+ * @method
1890
+ * @name coinex#createMarketBuyWithCost
1891
+ * @description create a market buy order by providing the symbol and cost
1892
+ * @param {string} symbol unified symbol of the market to create an order in
1893
+ * @param {float} cost how much you want to trade in units of the quote currency
1894
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1895
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1896
+ */
1897
+ params['createMarketBuyOrderRequiresPrice'] = false;
1898
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1899
+ }
1886
1900
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1887
1901
  const market = this.market(symbol);
1888
1902
  const swap = market['swap'];
@@ -1983,16 +1997,20 @@ class coinex extends coinex$1 {
1983
1997
  else {
1984
1998
  request['type'] = side;
1985
1999
  if ((type === 'market') && (side === 'buy')) {
1986
- if (this.options['createMarketBuyOrderRequiresPrice']) {
1987
- if (price === undefined) {
1988
- throw new errors.InvalidOrder(this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false to supply the cost in the amount argument (the exchange-specific behaviour)");
2000
+ let createMarketBuyOrderRequiresPrice = true;
2001
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
2002
+ const cost = this.safeNumber(params, 'cost');
2003
+ params = this.omit(params, 'cost');
2004
+ if (createMarketBuyOrderRequiresPrice) {
2005
+ if ((price === undefined) && (cost === undefined)) {
2006
+ throw new errors.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 in the amount argument');
1989
2007
  }
1990
2008
  else {
1991
- const amountString = this.amountToPrecision(symbol, amount);
1992
- const priceString = this.priceToPrecision(symbol, price);
1993
- const costString = Precise["default"].stringMul(amountString, priceString);
1994
- const costNumber = this.parseNumber(costString);
1995
- request['amount'] = this.costToPrecision(symbol, costNumber);
2009
+ const amountString = this.numberToString(amount);
2010
+ const priceString = this.numberToString(price);
2011
+ const quoteAmount = this.parseToNumeric(Precise["default"].stringMul(amountString, priceString));
2012
+ const costRequest = (cost !== undefined) ? cost : quoteAmount;
2013
+ request['amount'] = this.costToPrecision(symbol, costRequest);
1996
2014
  }
1997
2015
  }
1998
2016
  else {
@@ -3620,7 +3620,14 @@ class gate extends gate$1 {
3620
3620
  'PEND': 'pending',
3621
3621
  'REQUEST': 'pending',
3622
3622
  'DMOVE': 'pending',
3623
- 'CANCEL': 'failed',
3623
+ 'MANUAL': 'pending',
3624
+ 'VERIFY': 'pending',
3625
+ 'PROCES': 'pending',
3626
+ 'EXTPEND': 'pending',
3627
+ 'SPLITPEND': 'pending',
3628
+ 'CANCEL': 'canceled',
3629
+ 'FAIL': 'failed',
3630
+ 'INVALID': 'failed',
3624
3631
  'DONE': 'ok',
3625
3632
  'BCODE': 'ok', // GateCode withdrawal
3626
3633
  };
@@ -826,13 +826,19 @@ class latoken extends latoken$1 {
826
826
  * @param {object} [params] extra parameters specific to the exchange API endpoint
827
827
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
828
828
  */
829
- let method = this.safeString(params, 'method');
829
+ const options = this.safeValue(this.options, 'fetchTradingFee', {});
830
+ const defaultMethod = this.safeString(options, 'method', 'fetchPrivateTradingFee');
831
+ const method = this.safeString(params, 'method', defaultMethod);
830
832
  params = this.omit(params, 'method');
831
- if (method === undefined) {
832
- const options = this.safeValue(this.options, 'fetchTradingFee', {});
833
- method = this.safeString(options, 'method', 'fetchPrivateTradingFee');
833
+ if (method === 'fetchPrivateTradingFee') {
834
+ return await this.fetchPrivateTradingFee(symbol, params);
835
+ }
836
+ else if (method === 'fetchPublicTradingFee') {
837
+ return await this.fetchPublicTradingFee(symbol, params);
838
+ }
839
+ else {
840
+ throw new errors.NotSupported(this.id + ' not support this method');
834
841
  }
835
- return await this[method](symbol, params);
836
842
  }
837
843
  async fetchPublicTradingFee(symbol, params = {}) {
838
844
  await this.loadMarkets();
@@ -898,18 +904,20 @@ class latoken extends latoken$1 {
898
904
  // 'from': this.milliseconds (),
899
905
  // 'limit': limit, // default '100'
900
906
  };
901
- let method = 'privateGetAuthTrade';
902
907
  let market = undefined;
908
+ if (limit !== undefined) {
909
+ request['limit'] = limit; // default 100
910
+ }
911
+ let response = undefined;
903
912
  if (symbol !== undefined) {
904
913
  market = this.market(symbol);
905
914
  request['currency'] = market['baseId'];
906
915
  request['quote'] = market['quoteId'];
907
- method = 'privateGetAuthTradePairCurrencyQuote';
916
+ response = await this.privateGetAuthTradePairCurrencyQuote(this.extend(request, params));
908
917
  }
909
- if (limit !== undefined) {
910
- request['limit'] = limit; // default 100
918
+ else {
919
+ response = await this.privateGetAuthTrade(this.extend(request, params));
911
920
  }
912
- const response = await this[method](this.extend(request, params));
913
921
  //
914
922
  // [
915
923
  // {
@@ -1575,22 +1583,21 @@ class latoken extends latoken$1 {
1575
1583
  */
1576
1584
  await this.loadMarkets();
1577
1585
  const currency = this.currency(code);
1578
- let method = undefined;
1586
+ const request = {
1587
+ 'currency': currency['id'],
1588
+ 'recipient': toAccount,
1589
+ 'value': this.currencyToPrecision(code, amount),
1590
+ };
1591
+ let response = undefined;
1579
1592
  if (toAccount.indexOf('@') >= 0) {
1580
- method = 'privatePostAuthTransferEmail';
1593
+ response = await this.privatePostAuthTransferEmail(this.extend(request, params));
1581
1594
  }
1582
1595
  else if (toAccount.length === 36) {
1583
- method = 'privatePostAuthTransferId';
1596
+ response = await this.privatePostAuthTransferId(this.extend(request, params));
1584
1597
  }
1585
1598
  else {
1586
- method = 'privatePostAuthTransferPhone';
1599
+ response = await this.privatePostAuthTransferPhone(this.extend(request, params));
1587
1600
  }
1588
- const request = {
1589
- 'currency': currency['id'],
1590
- 'recipient': toAccount,
1591
- 'value': this.currencyToPrecision(code, amount),
1592
- };
1593
- const response = await this[method](this.extend(request, params));
1594
1601
  //
1595
1602
  // {
1596
1603
  // "id": "e6fc4ace-7750-44e4-b7e9-6af038ac7107",
@@ -2083,7 +2083,7 @@ class mexc extends mexc$1 {
2083
2083
  }
2084
2084
  createSpotOrderRequest(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2085
2085
  const symbol = market['symbol'];
2086
- const orderSide = (side === 'buy') ? 'BUY' : 'SELL';
2086
+ const orderSide = side.toUpperCase();
2087
2087
  const request = {
2088
2088
  'symbol': market['id'],
2089
2089
  'side': orderSide,
@@ -2102,10 +2102,10 @@ class mexc extends mexc$1 {
2102
2102
  const amountString = this.numberToString(amount);
2103
2103
  const priceString = this.numberToString(price);
2104
2104
  const quoteAmount = Precise["default"].stringMul(amountString, priceString);
2105
- amount = this.parseNumber(quoteAmount);
2105
+ amount = quoteAmount;
2106
2106
  }
2107
2107
  }
2108
- request['quoteOrderQty'] = amount;
2108
+ request['quoteOrderQty'] = this.costToPrecision(symbol, amount);
2109
2109
  }
2110
2110
  else {
2111
2111
  request['quantity'] = this.amountToPrecision(symbol, amount);
@@ -2305,7 +2305,7 @@ class mexc extends mexc$1 {
2305
2305
  ordersRequests.push(orderRequest);
2306
2306
  }
2307
2307
  const request = {
2308
- 'batchOrders': ordersRequests,
2308
+ 'batchOrders': this.json(ordersRequests),
2309
2309
  };
2310
2310
  const response = await this.spotPrivatePostBatchOrders(request);
2311
2311
  //
@@ -2393,6 +2393,9 @@ class binance extends binance$1 {
2393
2393
  return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
2394
2394
  }
2395
2395
  setPositionsCache(client, type, symbols = undefined) {
2396
+ if (type === 'spot') {
2397
+ return;
2398
+ }
2396
2399
  if (this.positions === undefined) {
2397
2400
  this.positions = {};
2398
2401
  }
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.70";
7
+ declare const version = "4.1.72";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.71';
41
+ const version = '4.1.73';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -295,6 +295,8 @@ export default class Exchange {
295
295
  createLimitOrder: boolean;
296
296
  createMarketOrder: boolean;
297
297
  createOrder: boolean;
298
+ createMarketBuyOrderWithCost: any;
299
+ createMarketSellOrderWithCost: any;
298
300
  createOrders: any;
299
301
  createPostOnlyOrder: any;
300
302
  createReduceOnlyOrder: any;
@@ -757,6 +759,8 @@ export default class Exchange {
757
759
  fetchOrderStatus(id: string, symbol?: string, params?: {}): Promise<string>;
758
760
  fetchUnifiedOrder(order: any, params?: {}): Promise<Order>;
759
761
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
762
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
763
+ createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
760
764
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
761
765
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
762
766
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<any>;
@@ -779,8 +783,8 @@ export default class Exchange {
779
783
  fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
780
784
  fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
781
785
  fetchDepositsWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
782
- fetchDeposits(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
783
- fetchWithdrawals(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
786
+ fetchDeposits(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
787
+ fetchWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
784
788
  fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
785
789
  fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
786
790
  fetchFundingHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
@@ -353,6 +353,8 @@ export default class Exchange {
353
353
  'createLimitOrder': true,
354
354
  'createMarketOrder': true,
355
355
  'createOrder': true,
356
+ 'createMarketBuyOrderWithCost': undefined,
357
+ 'createMarketSellOrderWithCost': undefined,
356
358
  'createOrders': undefined,
357
359
  'createPostOnlyOrder': undefined,
358
360
  'createReduceOnlyOrder': undefined,
@@ -3554,6 +3556,30 @@ export default class Exchange {
3554
3556
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
3555
3557
  throw new NotSupported(this.id + ' createOrder() is not supported yet');
3556
3558
  }
3559
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
3560
+ /**
3561
+ * @method
3562
+ * @name createMarketBuyWithCost
3563
+ * @description create a market buy order by providing the symbol and cost
3564
+ * @param {string} symbol unified symbol of the market to create an order in
3565
+ * @param {float} cost how much you want to trade in units of the quote currency
3566
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3567
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3568
+ */
3569
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() is not supported yet');
3570
+ }
3571
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
3572
+ /**
3573
+ * @method
3574
+ * @name createMarketSellOrderWithCost
3575
+ * @description create a market buy order by providing the symbol and cost
3576
+ * @param {string} symbol unified symbol of the market to create an order in
3577
+ * @param {float} cost how much you want to trade in units of the quote currency
3578
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3579
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3580
+ */
3581
+ throw new NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
3582
+ }
3557
3583
  async createOrders(orders, params = {}) {
3558
3584
  throw new NotSupported(this.id + ' createOrders() is not supported yet');
3559
3585
  }
@@ -3630,10 +3656,10 @@ export default class Exchange {
3630
3656
  */
3631
3657
  throw new NotSupported(this.id + ' fetchDepositsWithdrawals() is not supported yet');
3632
3658
  }
3633
- async fetchDeposits(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3659
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
3634
3660
  throw new NotSupported(this.id + ' fetchDeposits() is not supported yet');
3635
3661
  }
3636
- async fetchWithdrawals(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3662
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
3637
3663
  throw new NotSupported(this.id + ' fetchWithdrawals() is not supported yet');
3638
3664
  }
3639
3665
  async fetchOpenInterest(symbol, params = {}) {
package/js/src/bingx.js CHANGED
@@ -1966,15 +1966,17 @@ export default class bingx extends Exchange {
1966
1966
  // "symbol": "XRP-USDT",
1967
1967
  // "orderId": 1514073325788200960,
1968
1968
  // "price": "0.5",
1969
+ // "StopPrice": "0",
1969
1970
  // "origQty": "20",
1970
- // "executedQty": "0",
1971
- // "cummulativeQuoteQty": "0",
1971
+ // "executedQty": "10",
1972
+ // "cummulativeQuoteQty": "5",
1972
1973
  // "status": "PENDING",
1973
1974
  // "type": "LIMIT",
1974
1975
  // "side": "BUY",
1975
1976
  // "time": 1649818185647,
1976
1977
  // "updateTime": 1649818185647,
1977
1978
  // "origQuoteOrderQty": "0"
1979
+ // "fee": "-0.01"
1978
1980
  // }
1979
1981
  //
1980
1982
  //
@@ -2034,9 +2036,24 @@ export default class bingx extends Exchange {
2034
2036
  const amount = this.safeString2(order, 'origQty', 'q');
2035
2037
  const filled = this.safeString2(order, 'executedQty', 'z');
2036
2038
  const statusId = this.safeString2(order, 'status', 'X');
2039
+ let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
2040
+ const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
2041
+ if ((feeCurrencyCode === undefined)) {
2042
+ if (market['spot']) {
2043
+ if (side === 'buy') {
2044
+ feeCurrencyCode = market['base'];
2045
+ }
2046
+ else {
2047
+ feeCurrencyCode = market['quote'];
2048
+ }
2049
+ }
2050
+ else {
2051
+ feeCurrencyCode = market['quote'];
2052
+ }
2053
+ }
2037
2054
  const fee = {
2038
- 'currency': this.safeString2(order, 'feeAsset', 'N'),
2039
- 'rate': this.safeStringN(order, ['fee', 'commission', 'n']),
2055
+ 'currency': feeCurrencyCode,
2056
+ 'cost': Precise.stringAbs(feeCost),
2040
2057
  };
2041
2058
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
2042
2059
  return this.safeOrder({
@@ -43,6 +43,7 @@ export default class coinex extends Exchange {
43
43
  fetchBalance(params?: {}): Promise<Balances>;
44
44
  parseOrderStatus(status: any): string;
45
45
  parseOrder(order: any, market?: Market): Order;
46
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
46
47
  createOrderRequest(symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): any;
47
48
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
48
49
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
package/js/src/coinex.js CHANGED
@@ -47,6 +47,7 @@ export default class coinex extends Exchange {
47
47
  'cancelOrder': true,
48
48
  'cancelOrders': true,
49
49
  'createDepositAddress': true,
50
+ 'createMarketBuyOrderWithCost': true,
50
51
  'createOrder': true,
51
52
  'createOrders': true,
52
53
  'createReduceOnlyOrder': true,
@@ -1886,6 +1887,19 @@ export default class coinex extends Exchange {
1886
1887
  'info': order,
1887
1888
  }, market);
1888
1889
  }
1890
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1891
+ /**
1892
+ * @method
1893
+ * @name coinex#createMarketBuyWithCost
1894
+ * @description create a market buy order by providing the symbol and cost
1895
+ * @param {string} symbol unified symbol of the market to create an order in
1896
+ * @param {float} cost how much you want to trade in units of the quote currency
1897
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1898
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1899
+ */
1900
+ params['createMarketBuyOrderRequiresPrice'] = false;
1901
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1902
+ }
1889
1903
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1890
1904
  const market = this.market(symbol);
1891
1905
  const swap = market['swap'];
@@ -1986,16 +2000,20 @@ export default class coinex extends Exchange {
1986
2000
  else {
1987
2001
  request['type'] = side;
1988
2002
  if ((type === 'market') && (side === 'buy')) {
1989
- if (this.options['createMarketBuyOrderRequiresPrice']) {
1990
- if (price === undefined) {
1991
- throw new InvalidOrder(this.id + " createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false to supply the cost in the amount argument (the exchange-specific behaviour)");
2003
+ let createMarketBuyOrderRequiresPrice = true;
2004
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
2005
+ const cost = this.safeNumber(params, 'cost');
2006
+ params = this.omit(params, 'cost');
2007
+ if (createMarketBuyOrderRequiresPrice) {
2008
+ if ((price === undefined) && (cost === undefined)) {
2009
+ 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 in the amount argument');
1992
2010
  }
1993
2011
  else {
1994
- const amountString = this.amountToPrecision(symbol, amount);
1995
- const priceString = this.priceToPrecision(symbol, price);
1996
- const costString = Precise.stringMul(amountString, priceString);
1997
- const costNumber = this.parseNumber(costString);
1998
- request['amount'] = this.costToPrecision(symbol, costNumber);
2012
+ const amountString = this.numberToString(amount);
2013
+ const priceString = this.numberToString(price);
2014
+ const quoteAmount = this.parseToNumeric(Precise.stringMul(amountString, priceString));
2015
+ const costRequest = (cost !== undefined) ? cost : quoteAmount;
2016
+ request['amount'] = this.costToPrecision(symbol, costRequest);
1999
2017
  }
2000
2018
  }
2001
2019
  else {
package/js/src/gate.js CHANGED
@@ -3623,7 +3623,14 @@ export default class gate extends Exchange {
3623
3623
  'PEND': 'pending',
3624
3624
  'REQUEST': 'pending',
3625
3625
  'DMOVE': 'pending',
3626
- 'CANCEL': 'failed',
3626
+ 'MANUAL': 'pending',
3627
+ 'VERIFY': 'pending',
3628
+ 'PROCES': 'pending',
3629
+ 'EXTPEND': 'pending',
3630
+ 'SPLITPEND': 'pending',
3631
+ 'CANCEL': 'canceled',
3632
+ 'FAIL': 'failed',
3633
+ 'INVALID': 'failed',
3627
3634
  'DONE': 'ok',
3628
3635
  'BCODE': 'ok', // GateCode withdrawal
3629
3636
  };
@@ -18,7 +18,12 @@ export default class latoken extends Exchange {
18
18
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
19
19
  parseTrade(trade: any, market?: Market): Trade;
20
20
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
21
- fetchTradingFee(symbol: string, params?: {}): Promise<any>;
21
+ fetchTradingFee(symbol: string, params?: {}): Promise<{
22
+ info: any;
23
+ symbol: string;
24
+ maker: number;
25
+ taker: number;
26
+ }>;
22
27
  fetchPublicTradingFee(symbol: string, params?: {}): Promise<{
23
28
  info: any;
24
29
  symbol: string;