ccxt 4.3.24 → 4.3.28

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ascendex.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +24 -25
  5. package/dist/cjs/src/base/functions/number.js +10 -5
  6. package/dist/cjs/src/bingx.js +43 -7
  7. package/dist/cjs/src/bitget.js +1 -0
  8. package/dist/cjs/src/bitmart.js +65 -2
  9. package/dist/cjs/src/bybit.js +3 -3
  10. package/dist/cjs/src/coinbase.js +1 -1
  11. package/dist/cjs/src/coinex.js +44 -75
  12. package/dist/cjs/src/kraken.js +60 -7
  13. package/dist/cjs/src/krakenfutures.js +1 -1
  14. package/dist/cjs/src/phemex.js +18 -2
  15. package/dist/cjs/src/pro/binance.js +1 -1
  16. package/dist/cjs/src/pro/coinbase.js +5 -1
  17. package/dist/cjs/src/pro/cryptocom.js +9 -7
  18. package/dist/cjs/src/pro/kraken.js +6 -4
  19. package/dist/cjs/src/pro/okx.js +1 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/bitget.d.ts +1 -0
  23. package/js/src/abstract/bitmart.d.ts +1 -0
  24. package/js/src/ascendex.js +1 -1
  25. package/js/src/base/Exchange.d.ts +4 -2
  26. package/js/src/base/Exchange.js +24 -25
  27. package/js/src/base/functions/number.js +10 -5
  28. package/js/src/bingx.js +43 -7
  29. package/js/src/bitget.js +1 -0
  30. package/js/src/bitmart.d.ts +1 -0
  31. package/js/src/bitmart.js +65 -2
  32. package/js/src/bybit.js +3 -3
  33. package/js/src/coinbase.js +1 -1
  34. package/js/src/coinex.js +44 -75
  35. package/js/src/kraken.d.ts +3 -1
  36. package/js/src/kraken.js +60 -7
  37. package/js/src/krakenfutures.js +1 -1
  38. package/js/src/phemex.js +18 -2
  39. package/js/src/pro/binance.d.ts +1 -1
  40. package/js/src/pro/binance.js +1 -1
  41. package/js/src/pro/coinbase.js +5 -1
  42. package/js/src/pro/cryptocom.js +9 -7
  43. package/js/src/pro/kraken.d.ts +1 -1
  44. package/js/src/pro/kraken.js +6 -4
  45. package/js/src/pro/okx.d.ts +1 -1
  46. package/js/src/pro/okx.js +1 -1
  47. package/package.json +1 -1
@@ -40,6 +40,9 @@ class kraken extends kraken$1 {
40
40
  'cancelOrder': true,
41
41
  'cancelOrders': true,
42
42
  'createDepositAddress': true,
43
+ 'createMarketBuyOrderWithCost': true,
44
+ 'createMarketOrderWithCost': false,
45
+ 'createMarketSellOrderWithCost': false,
43
46
  'createOrder': true,
44
47
  'createStopLimitOrder': true,
45
48
  'createStopMarketOrder': true,
@@ -1350,6 +1353,37 @@ class kraken extends kraken$1 {
1350
1353
  //
1351
1354
  return this.parseBalance(response);
1352
1355
  }
1356
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1357
+ /**
1358
+ * @method
1359
+ * @name kraken#createMarketOrderWithCost
1360
+ * @description create a market order by providing the symbol, side and cost
1361
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1362
+ * @param {string} symbol unified symbol of the market to create an order in (only USD markets are supported)
1363
+ * @param {string} side 'buy' or 'sell'
1364
+ * @param {float} cost how much you want to trade in units of the quote currency
1365
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1366
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1367
+ */
1368
+ await this.loadMarkets();
1369
+ // only buy orders are supported by the endpoint
1370
+ params['cost'] = cost;
1371
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
1372
+ }
1373
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1374
+ /**
1375
+ * @method
1376
+ * @name kraken#createMarketBuyOrderWithCost
1377
+ * @description create a market buy order by providing the symbol, side and cost
1378
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1379
+ * @param {string} symbol unified symbol of the market to create an order in
1380
+ * @param {float} cost how much you want to trade in units of the quote currency
1381
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1382
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1383
+ */
1384
+ await this.loadMarkets();
1385
+ return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
1386
+ }
1353
1387
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1354
1388
  /**
1355
1389
  * @method
@@ -1380,7 +1414,7 @@ class kraken extends kraken$1 {
1380
1414
  'ordertype': type,
1381
1415
  'volume': this.amountToPrecision(symbol, amount),
1382
1416
  };
1383
- const orderRequest = this.orderRequest('createOrder', symbol, type, request, price, params);
1417
+ const orderRequest = this.orderRequest('createOrder', symbol, type, request, amount, price, params);
1384
1418
  const response = await this.privatePostAddOrder(this.extend(orderRequest[0], orderRequest[1]));
1385
1419
  //
1386
1420
  // {
@@ -1686,7 +1720,7 @@ class kraken extends kraken$1 {
1686
1720
  'trades': trades,
1687
1721
  }, market);
1688
1722
  }
1689
- orderRequest(method, symbol, type, request, price = undefined, params = {}) {
1723
+ orderRequest(method, symbol, type, request, amount, price = undefined, params = {}) {
1690
1724
  const clientOrderId = this.safeString2(params, 'userref', 'clientOrderId');
1691
1725
  params = this.omit(params, ['userref', 'clientOrderId']);
1692
1726
  if (clientOrderId !== undefined) {
@@ -1701,10 +1735,25 @@ class kraken extends kraken$1 {
1701
1735
  const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
1702
1736
  const isTrailingAmountOrder = trailingAmount !== undefined;
1703
1737
  const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
1704
- if (isLimitOrder && !isTrailingAmountOrder) {
1738
+ const isMarketOrder = type === 'market';
1739
+ const cost = this.safeString(params, 'cost');
1740
+ const flags = this.safeString(params, 'oflags');
1741
+ params = this.omit(params, ['cost', 'oflags']);
1742
+ const isViqcOrder = (flags !== undefined) && (flags.indexOf('viqc') > -1); // volume in quote currency
1743
+ if (isMarketOrder && (cost !== undefined || isViqcOrder)) {
1744
+ if (cost === undefined && (amount !== undefined)) {
1745
+ request['volume'] = this.costToPrecision(symbol, this.numberToString(amount));
1746
+ }
1747
+ else {
1748
+ request['volume'] = this.costToPrecision(symbol, cost);
1749
+ }
1750
+ const extendedOflags = (flags !== undefined) ? flags + ',viqc' : 'viqc';
1751
+ request['oflags'] = extendedOflags;
1752
+ }
1753
+ else if (isLimitOrder && !isTrailingAmountOrder) {
1705
1754
  request['price'] = this.priceToPrecision(symbol, price);
1706
1755
  }
1707
- const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1756
+ const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
1708
1757
  if (isStopLossOrTakeProfitTrigger) {
1709
1758
  if (isStopLossTriggerOrder) {
1710
1759
  request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
@@ -1752,7 +1801,7 @@ class kraken extends kraken$1 {
1752
1801
  request['reduce_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
1753
1802
  }
1754
1803
  }
1755
- let close = this.safeValue(params, 'close');
1804
+ let close = this.safeDict(params, 'close');
1756
1805
  if (close !== undefined) {
1757
1806
  close = this.extend({}, close);
1758
1807
  const closePrice = this.safeValue(close, 'price');
@@ -1773,7 +1822,8 @@ class kraken extends kraken$1 {
1773
1822
  let postOnly = undefined;
1774
1823
  [postOnly, params] = this.handlePostOnly(isMarket, false, params);
1775
1824
  if (postOnly) {
1776
- request['oflags'] = 'post';
1825
+ const extendedPostFlags = (flags !== undefined) ? flags + ',post' : 'post';
1826
+ request['oflags'] = extendedPostFlags;
1777
1827
  }
1778
1828
  params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset']);
1779
1829
  return [request, params];
@@ -1811,7 +1861,7 @@ class kraken extends kraken$1 {
1811
1861
  if (amount !== undefined) {
1812
1862
  request['volume'] = this.amountToPrecision(symbol, amount);
1813
1863
  }
1814
- const orderRequest = this.orderRequest('editOrder', symbol, type, request, price, params);
1864
+ const orderRequest = this.orderRequest('editOrder', symbol, type, request, amount, price, params);
1815
1865
  const response = await this.privatePostEditOrder(this.extend(orderRequest[0], orderRequest[1]));
1816
1866
  //
1817
1867
  // {
@@ -3004,6 +3054,9 @@ class kraken extends kraken$1 {
3004
3054
  if (body.indexOf('Invalid arguments:volume') >= 0) {
3005
3055
  throw new errors.InvalidOrder(this.id + ' ' + body);
3006
3056
  }
3057
+ if (body.indexOf('Invalid arguments:viqc') >= 0) {
3058
+ throw new errors.InvalidOrder(this.id + ' ' + body);
3059
+ }
3007
3060
  if (body.indexOf('Rate limit exceeded') >= 0) {
3008
3061
  throw new errors.RateLimitExceeded(this.id + ' ' + body);
3009
3062
  }
@@ -2237,7 +2237,7 @@ class krakenfutures extends krakenfutures$1 {
2237
2237
  /**
2238
2238
  * @method
2239
2239
  * @name krakenfutures#fetchPositions
2240
- * @see https://docs.futures.kraken.com/#websocket-api-private-feeds-open-positions
2240
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-open-positions
2241
2241
  * @description Fetches current contract trading positions
2242
2242
  * @param {string[]} symbols List of unified symbols
2243
2243
  * @param {object} [params] Not used by krakenfutures
@@ -2249,7 +2249,7 @@ class phemex extends phemex$1 {
2249
2249
  if (feeCost !== undefined) {
2250
2250
  fee = {
2251
2251
  'cost': feeCost,
2252
- 'currency': undefined,
2252
+ 'currency': this.safeCurrencyCode(this.safeString(order, 'feeCurrency')),
2253
2253
  };
2254
2254
  }
2255
2255
  const timeInForce = this.parseTimeInForce(this.safeString(order, 'timeInForce'));
@@ -2396,6 +2396,7 @@ class phemex extends phemex$1 {
2396
2396
  }
2397
2397
  const marketId = this.safeString(order, 'symbol');
2398
2398
  const symbol = this.safeSymbol(marketId, market);
2399
+ market = this.safeMarket(marketId, market);
2399
2400
  const status = this.parseOrderStatus(this.safeString(order, 'ordStatus'));
2400
2401
  const side = this.parseOrderSide(this.safeStringLower(order, 'side'));
2401
2402
  const type = this.parseOrderType(this.safeString(order, 'orderType'));
@@ -2425,6 +2426,21 @@ class phemex extends phemex$1 {
2425
2426
  }
2426
2427
  const takeProfit = this.safeString(order, 'takeProfitRp');
2427
2428
  const stopLoss = this.safeString(order, 'stopLossRp');
2429
+ const feeValue = this.omitZero(this.safeString(order, 'execFeeRv'));
2430
+ const ptFeeRv = this.omitZero(this.safeString(order, 'ptFeeRv'));
2431
+ let fee = undefined;
2432
+ if (feeValue !== undefined) {
2433
+ fee = {
2434
+ 'cost': feeValue,
2435
+ 'currency': market['quote'],
2436
+ };
2437
+ }
2438
+ else if (ptFeeRv !== undefined) {
2439
+ fee = {
2440
+ 'cost': ptFeeRv,
2441
+ 'currency': 'PT',
2442
+ };
2443
+ }
2428
2444
  return this.safeOrder({
2429
2445
  'info': order,
2430
2446
  'id': id,
@@ -2449,7 +2465,7 @@ class phemex extends phemex$1 {
2449
2465
  'cost': cost,
2450
2466
  'average': undefined,
2451
2467
  'status': status,
2452
- 'fee': undefined,
2468
+ 'fee': fee,
2453
2469
  'trades': undefined,
2454
2470
  });
2455
2471
  }
@@ -2131,7 +2131,7 @@ class binance extends binance$1 {
2131
2131
  const orders = this.parseOrders(result);
2132
2132
  client.resolve(orders, messageHash);
2133
2133
  }
2134
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
2134
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
2135
2135
  /**
2136
2136
  * @method
2137
2137
  * @name binance#editOrderWs
@@ -246,13 +246,17 @@ class coinbase extends coinbase$1 {
246
246
  //
247
247
  const channel = this.safeString(message, 'channel');
248
248
  const events = this.safeValue(message, 'events', []);
249
+ const datetime = this.safeString(message, 'timestamp');
250
+ const timestamp = this.parse8601(datetime);
249
251
  const newTickers = [];
250
252
  for (let i = 0; i < events.length; i++) {
251
253
  const tickersObj = events[i];
252
- const tickers = this.safeValue(tickersObj, 'tickers', []);
254
+ const tickers = this.safeList(tickersObj, 'tickers', []);
253
255
  for (let j = 0; j < tickers.length; j++) {
254
256
  const ticker = tickers[j];
255
257
  const result = this.parseWsTicker(ticker);
258
+ result['timestamp'] = timestamp;
259
+ result['datetime'] = datetime;
256
260
  const symbol = result['symbol'];
257
261
  this.tickers[symbol] = result;
258
262
  const wsMarketId = this.safeString(ticker, 'product_id');
@@ -102,14 +102,16 @@ class cryptocom extends cryptocom$1 {
102
102
  params['params'] = {};
103
103
  }
104
104
  let bookSubscriptionType = undefined;
105
- [bookSubscriptionType, params] = this.handleOptionAndParams2(params, 'watchOrderBook', 'watchOrderBookForSymbols', 'bookSubscriptionType', 'SNAPSHOT_AND_UPDATE');
106
- if (bookSubscriptionType !== undefined) {
107
- params['params']['bookSubscriptionType'] = bookSubscriptionType;
108
- }
105
+ let bookSubscriptionType2 = undefined;
106
+ [bookSubscriptionType, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'bookSubscriptionType', 'SNAPSHOT_AND_UPDATE');
107
+ [bookSubscriptionType2, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'bookSubscriptionType', bookSubscriptionType);
108
+ params['params']['bookSubscriptionType'] = bookSubscriptionType2;
109
109
  let bookUpdateFrequency = undefined;
110
- [bookUpdateFrequency, params] = this.handleOptionAndParams2(params, 'watchOrderBook', 'watchOrderBookForSymbols', 'bookUpdateFrequency');
111
- if (bookUpdateFrequency !== undefined) {
112
- params['params']['bookSubscriptionType'] = bookSubscriptionType;
110
+ let bookUpdateFrequency2 = undefined;
111
+ [bookUpdateFrequency, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'bookUpdateFrequency');
112
+ [bookUpdateFrequency2, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'bookUpdateFrequency', bookUpdateFrequency);
113
+ if (bookUpdateFrequency2 !== undefined) {
114
+ params['params']['bookSubscriptionType'] = bookUpdateFrequency2;
113
115
  }
114
116
  for (let i = 0; i < symbols.length; i++) {
115
117
  const symbol = symbols[i];
@@ -134,7 +134,7 @@ class kraken extends kraken$1 {
134
134
  'pair': market['wsId'],
135
135
  'volume': this.amountToPrecision(symbol, amount),
136
136
  };
137
- [request, params] = this.orderRequest('createOrderWs', symbol, type, request, price, params);
137
+ [request, params] = this.orderRequest('createOrderWs', symbol, type, request, amount, price, params);
138
138
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
139
139
  }
140
140
  handleCreateEditOrder(client, message) {
@@ -161,7 +161,7 @@ class kraken extends kraken$1 {
161
161
  const messageHash = this.safeValue(message, 'reqid');
162
162
  client.resolve(order, messageHash);
163
163
  }
164
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
164
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
165
165
  /**
166
166
  * @method
167
167
  * @name kraken#editOrderWs
@@ -188,9 +188,11 @@ class kraken extends kraken$1 {
188
188
  'reqid': requestId,
189
189
  'orderid': id,
190
190
  'pair': market['wsId'],
191
- 'volume': this.amountToPrecision(symbol, amount),
192
191
  };
193
- [request, params] = this.orderRequest('editOrderWs', symbol, type, request, price, params);
192
+ if (amount !== undefined) {
193
+ request['volume'] = this.amountToPrecision(symbol, amount);
194
+ }
195
+ [request, params] = this.orderRequest('editOrderWs', symbol, type, request, amount, price, params);
194
196
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
195
197
  }
196
198
  async cancelOrdersWs(ids, symbol = undefined, params = {}) {
@@ -1433,7 +1433,7 @@ class okx extends okx$1 {
1433
1433
  const first = this.safeDict(orders, 0, {});
1434
1434
  client.resolve(first, messageHash);
1435
1435
  }
1436
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
1436
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1437
1437
  /**
1438
1438
  * @method
1439
1439
  * @name okx#editOrderWs
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 type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.23";
7
+ declare const version = "4.3.27";
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, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.24';
41
+ const version = '4.3.28';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -497,6 +497,7 @@ interface Exchange {
497
497
  privateEarnGetV2EarnLoanBorrowHistory(params?: {}): Promise<implicitReturnType>;
498
498
  privateEarnGetV2EarnLoanDebts(params?: {}): Promise<implicitReturnType>;
499
499
  privateEarnGetV2EarnLoanReduces(params?: {}): Promise<implicitReturnType>;
500
+ privateEarnGetV2EarnAccountAssets(params?: {}): Promise<implicitReturnType>;
500
501
  privateEarnPostV2EarnSavingsSubscribe(params?: {}): Promise<implicitReturnType>;
501
502
  privateEarnPostV2EarnSavingsRedeem(params?: {}): Promise<implicitReturnType>;
502
503
  privateEarnPostV2EarnSharkfinSubscribe(params?: {}): Promise<implicitReturnType>;
@@ -79,6 +79,7 @@ interface Exchange {
79
79
  privatePostSpotV4QueryHistoryOrders(params?: {}): Promise<implicitReturnType>;
80
80
  privatePostSpotV4QueryTrades(params?: {}): Promise<implicitReturnType>;
81
81
  privatePostSpotV4QueryOrderTrades(params?: {}): Promise<implicitReturnType>;
82
+ privatePostSpotV4CancelOrders(params?: {}): Promise<implicitReturnType>;
82
83
  privatePostSpotV3CancelOrder(params?: {}): Promise<implicitReturnType>;
83
84
  privatePostSpotV2BatchOrders(params?: {}): Promise<implicitReturnType>;
84
85
  privatePostSpotV2SubmitOrder(params?: {}): Promise<implicitReturnType>;
@@ -1406,7 +1406,7 @@ export default class ascendex extends Exchange {
1406
1406
  'currency': feeCurrencyCode,
1407
1407
  };
1408
1408
  }
1409
- const stopPrice = this.safeNumber(order, 'stopPrice');
1409
+ const stopPrice = this.omitZero(this.safeString(order, 'stopPrice'));
1410
1410
  let reduceOnly = undefined;
1411
1411
  const execInst = this.safeString(order, 'execInst');
1412
1412
  if (execInst === 'reduceOnly') {
@@ -845,7 +845,9 @@ export default class Exchange {
845
845
  marketId(symbol: string): string;
846
846
  symbol(symbol: string): string;
847
847
  handleParamString(params: object, paramName: string, defaultValue?: Str): [string, object];
848
+ handleParamString2(params: object, paramName1: string, paramName2: string, defaultValue?: Str): [string, object];
848
849
  handleParamInteger(params: object, paramName: string, defaultValue?: Int): [Int, object];
850
+ handleParamInteger2(params: object, paramName1: string, paramName2: string, defaultValue?: Int): [Int, object];
849
851
  resolvePath(path: any, params: any): any[];
850
852
  getListFromObjectValues(objects: any, key: IndexType): any[];
851
853
  getSymbolsForMarketType(marketType?: Str, subType?: Str, symbolWithActiveStatus?: boolean, symbolWithUnknownStatus?: boolean): any[];
@@ -859,7 +861,7 @@ export default class Exchange {
859
861
  editLimitSellOrder(id: string, symbol: string, amount: number, price?: Num, params?: {}): Promise<Order>;
860
862
  editLimitOrder(id: string, symbol: string, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
861
863
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
862
- editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
864
+ editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
863
865
  fetchPermissions(params?: {}): Promise<{}>;
864
866
  fetchPosition(symbol: string, params?: {}): Promise<Position>;
865
867
  fetchPositionWs(symbol: string, params?: {}): Promise<Position[]>;
@@ -897,7 +899,7 @@ export default class Exchange {
897
899
  fetchCrossBorrowRate(code: string, params?: {}): Promise<CrossBorrowRate>;
898
900
  fetchIsolatedBorrowRate(symbol: string, params?: {}): Promise<IsolatedBorrowRate>;
899
901
  handleOptionAndParams(params: object, methodName: string, optionName: string, defaultValue?: any): any[];
900
- handleOptionAndParams2(params: object, methodName: string, methodName2: string, optionName: string, defaultValue?: any): any[];
902
+ handleOptionAndParams2(params: object, methodName1: string, optionName1: string, optionName2: string, defaultValue?: any): any[];
901
903
  handleOption(methodName: string, optionName: string, defaultValue?: any): any;
902
904
  handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}, defaultValue?: any): any;
903
905
  handleSubTypeAndParams(methodName: string, market?: any, params?: {}, defaultValue?: any): any[];
@@ -2493,6 +2493,7 @@ export default class Exchange {
2493
2493
  const shouldParseFees = parseFee || parseFees;
2494
2494
  const fees = this.safeList(order, 'fees', []);
2495
2495
  let trades = [];
2496
+ const isTriggerOrSLTpOrder = ((this.safeString(order, 'triggerPrice') !== undefined || (this.safeString(order, 'stopLossPrice') !== undefined)) || (this.safeString(order, 'takeProfitPrice') !== undefined));
2496
2497
  if (parseFilled || parseCost || shouldParseFees) {
2497
2498
  const rawTrades = this.safeValue(order, 'trades', trades);
2498
2499
  const oldNumber = this.number;
@@ -2695,7 +2696,7 @@ export default class Exchange {
2695
2696
  let postOnly = this.safeValue(order, 'postOnly');
2696
2697
  // timeInForceHandling
2697
2698
  if (timeInForce === undefined) {
2698
- if (this.safeString(order, 'type') === 'market') {
2699
+ if (!isTriggerOrSLTpOrder && (this.safeString(order, 'type') === 'market')) {
2699
2700
  timeInForce = 'IOC';
2700
2701
  }
2701
2702
  // allow postOnly override
@@ -3661,6 +3662,13 @@ export default class Exchange {
3661
3662
  }
3662
3663
  return [value, params];
3663
3664
  }
3665
+ handleParamString2(params, paramName1, paramName2, defaultValue = undefined) {
3666
+ const value = this.safeString2(params, paramName1, paramName2, defaultValue);
3667
+ if (value !== undefined) {
3668
+ params = this.omit(params, [paramName1, paramName2]);
3669
+ }
3670
+ return [value, params];
3671
+ }
3664
3672
  handleParamInteger(params, paramName, defaultValue = undefined) {
3665
3673
  const value = this.safeInteger(params, paramName, defaultValue);
3666
3674
  if (value !== undefined) {
@@ -3668,6 +3676,13 @@ export default class Exchange {
3668
3676
  }
3669
3677
  return [value, params];
3670
3678
  }
3679
+ handleParamInteger2(params, paramName1, paramName2, defaultValue = undefined) {
3680
+ const value = this.safeInteger2(params, paramName1, paramName2, defaultValue);
3681
+ if (value !== undefined) {
3682
+ params = this.omit(params, [paramName1, paramName2]);
3683
+ }
3684
+ return [value, params];
3685
+ }
3671
3686
  resolvePath(path, params) {
3672
3687
  return [
3673
3688
  this.implodeParams(path, params),
@@ -3811,7 +3826,7 @@ export default class Exchange {
3811
3826
  await this.cancelOrder(id, symbol);
3812
3827
  return await this.createOrder(symbol, type, side, amount, price, params);
3813
3828
  }
3814
- async editOrderWs(id, symbol, type, side, amount, price = undefined, params = {}) {
3829
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
3815
3830
  await this.cancelOrderWs(id, symbol);
3816
3831
  return await this.createOrderWs(symbol, type, side, amount, price, params);
3817
3832
  }
@@ -4087,29 +4102,13 @@ export default class Exchange {
4087
4102
  }
4088
4103
  return [value, params];
4089
4104
  }
4090
- handleOptionAndParams2(params, methodName, methodName2, optionName, defaultValue = undefined) {
4091
- // This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
4092
- const defaultOptionName = 'default' + this.capitalize(optionName); // we also need to check the 'defaultXyzWhatever'
4093
- // check if params contain the key
4094
- let value = this.safeValue2(params, optionName, defaultOptionName);
4095
- if (value !== undefined) {
4096
- params = this.omit(params, [optionName, defaultOptionName]);
4097
- }
4098
- else {
4099
- // check if exchange has properties for this method
4100
- const exchangeWideMethodOptions = this.safeValue2(this.options, methodName, methodName2);
4101
- if (exchangeWideMethodOptions !== undefined) {
4102
- // check if the option is defined inside this method's props
4103
- value = this.safeValue2(exchangeWideMethodOptions, optionName, defaultOptionName);
4104
- }
4105
- if (value === undefined) {
4106
- // if it's still undefined, check if global exchange-wide option exists
4107
- value = this.safeValue2(this.options, optionName, defaultOptionName);
4108
- }
4109
- // if it's still undefined, use the default value
4110
- value = (value !== undefined) ? value : defaultValue;
4111
- }
4112
- return [value, params];
4105
+ handleOptionAndParams2(params, methodName1, optionName1, optionName2, defaultValue = undefined) {
4106
+ let value = undefined;
4107
+ [value, params] = this.handleOptionAndParams(params, methodName1, optionName1, defaultValue);
4108
+ // if still undefined, try optionName2
4109
+ let value2 = undefined;
4110
+ [value2, params] = this.handleOptionAndParams(params, methodName1, optionName2, value);
4111
+ return [value2, params];
4113
4112
  }
4114
4113
  handleOption(methodName, optionName, defaultValue = undefined) {
4115
4114
  // eslint-disable-next-line no-unused-vars
@@ -274,13 +274,18 @@ const _decimalToPrecision = (x, roundingMode, numPrecisionDigits, countingMode =
274
274
  return String.fromCharCode(...out);
275
275
  };
276
276
  function omitZero(stringNumber) {
277
- if (stringNumber === undefined || stringNumber === '') {
278
- return undefined;
277
+ try {
278
+ if (stringNumber === undefined || stringNumber === '') {
279
+ return undefined;
280
+ }
281
+ if (parseFloat(stringNumber) === 0) {
282
+ return undefined;
283
+ }
284
+ return stringNumber;
279
285
  }
280
- if (parseFloat(stringNumber) === 0) {
281
- return undefined;
286
+ catch (e) {
287
+ return stringNumber;
282
288
  }
283
- return stringNumber;
284
289
  }
285
290
  /* ------------------------------------------------------------------------ */
286
291
  export { numberToString, precisionFromString, decimalToPrecision, truncate_to_string, truncate, omitZero, precisionConstants, ROUND, TRUNCATE, ROUND_UP, ROUND_DOWN, DECIMAL_PLACES, SIGNIFICANT_DIGITS, TICK_SIZE, NO_PADDING, PAD_WITH_ZERO, };
package/js/src/bingx.js CHANGED
@@ -2217,6 +2217,10 @@ export default class bingx extends Exchange {
2217
2217
  const types = {
2218
2218
  'trigger_market': 'market',
2219
2219
  'trigger_limit': 'limit',
2220
+ 'stop_limit': 'limit',
2221
+ 'stop_market': 'market',
2222
+ 'take_profit_market': 'market',
2223
+ 'stop': 'limit',
2220
2224
  };
2221
2225
  return this.safeString(types, type, type);
2222
2226
  }
@@ -2420,6 +2424,25 @@ export default class bingx extends Exchange {
2420
2424
  // side: 'SELL'
2421
2425
  // }
2422
2426
  // }
2427
+ // stop loss order
2428
+ // {
2429
+ // "symbol": "ETH-USDT",
2430
+ // "orderId": "1792461744476422144",
2431
+ // "price": "2775.65",
2432
+ // "StopPrice": "2778.42",
2433
+ // "origQty": "0.032359",
2434
+ // "executedQty": "0",
2435
+ // "cummulativeQuoteQty": "0",
2436
+ // "status": "NEW",
2437
+ // "type": "TAKE_STOP_LIMIT",
2438
+ // "side": "SELL",
2439
+ // "time": "1716191156868",
2440
+ // "updateTime": "1716191156868",
2441
+ // "origQuoteOrderQty": "0",
2442
+ // "fee": "0",
2443
+ // "feeAsset": "USDT",
2444
+ // "clientOrderID": ""
2445
+ // }
2423
2446
  //
2424
2447
  const info = order;
2425
2448
  const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
@@ -2454,26 +2477,39 @@ export default class bingx extends Exchange {
2454
2477
  let stopLoss = this.safeValue(order, 'stopLoss');
2455
2478
  let stopLossPrice = undefined;
2456
2479
  if ((stopLoss !== undefined) && (stopLoss !== '')) {
2457
- stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
2480
+ stopLossPrice = this.omitZero(this.safeString(stopLoss, 'stopLoss'));
2458
2481
  }
2459
2482
  if ((stopLoss !== undefined) && (typeof stopLoss !== 'number') && (stopLoss !== '')) {
2460
2483
  // stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
2461
2484
  if (typeof stopLoss === 'string') {
2462
2485
  stopLoss = this.parseJson(stopLoss);
2463
2486
  }
2464
- stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
2487
+ stopLossPrice = this.omitZero(this.safeString(stopLoss, 'stopPrice'));
2465
2488
  }
2466
2489
  let takeProfit = this.safeValue(order, 'takeProfit');
2467
2490
  let takeProfitPrice = undefined;
2468
2491
  if (takeProfit !== undefined && (takeProfit !== '')) {
2469
- takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
2492
+ takeProfitPrice = this.omitZero(this.safeString(takeProfit, 'takeProfit'));
2470
2493
  }
2471
2494
  if ((takeProfit !== undefined) && (typeof takeProfit !== 'number') && (takeProfit !== '')) {
2472
2495
  // takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
2473
2496
  if (typeof takeProfit === 'string') {
2474
2497
  takeProfit = this.parseJson(takeProfit);
2475
2498
  }
2476
- takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
2499
+ takeProfitPrice = this.omitZero(this.safeString(takeProfit, 'stopPrice'));
2500
+ }
2501
+ const rawType = this.safeStringLower2(order, 'type', 'o');
2502
+ const stopPrice = this.omitZero(this.safeString2(order, 'StopPrice', 'stopPrice'));
2503
+ let triggerPrice = stopPrice;
2504
+ if (stopPrice !== undefined) {
2505
+ if ((rawType.indexOf('stop') > -1) && (stopLossPrice === undefined)) {
2506
+ stopLossPrice = stopPrice;
2507
+ triggerPrice = undefined;
2508
+ }
2509
+ if ((rawType.indexOf('take') > -1) && (takeProfitPrice === undefined)) {
2510
+ takeProfitPrice = stopPrice;
2511
+ triggerPrice = undefined;
2512
+ }
2477
2513
  }
2478
2514
  return this.safeOrder({
2479
2515
  'info': info,
@@ -2484,13 +2520,13 @@ export default class bingx extends Exchange {
2484
2520
  'datetime': this.iso8601(timestamp),
2485
2521
  'lastTradeTimestamp': lastTradeTimestamp,
2486
2522
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
2487
- 'type': this.parseOrderType(this.safeStringLower2(order, 'type', 'o')),
2523
+ 'type': this.parseOrderType(rawType),
2488
2524
  'timeInForce': this.safeString(order, 'timeInForce'),
2489
2525
  'postOnly': undefined,
2490
2526
  'side': this.parseOrderSide(side),
2491
2527
  'price': this.safeString2(order, 'price', 'p'),
2492
- 'stopPrice': this.safeNumber(order, 'stopPrice'),
2493
- 'triggerPrice': this.safeNumber(order, 'stopPrice'),
2528
+ 'stopPrice': triggerPrice,
2529
+ 'triggerPrice': triggerPrice,
2494
2530
  'stopLossPrice': stopLossPrice,
2495
2531
  'takeProfitPrice': takeProfitPrice,
2496
2532
  'average': this.safeString2(order, 'avgPrice', 'ap'),
package/js/src/bitget.js CHANGED
@@ -760,6 +760,7 @@ export default class bitget extends Exchange {
760
760
  'v2/earn/loan/borrow-history': 2,
761
761
  'v2/earn/loan/debts': 2,
762
762
  'v2/earn/loan/reduces': 2,
763
+ 'v2/earn/account/assets': 2,
763
764
  },
764
765
  'post': {
765
766
  'v2/earn/savings/subscribe': 2,
@@ -59,6 +59,7 @@ export default class bitmart extends Exchange {
59
59
  createSwapOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
60
60
  createSpotOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
61
61
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
62
+ cancelOrders(ids: string[], symbol?: Str, params?: {}): Promise<any[]>;
62
63
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
63
64
  fetchOrdersByStatus(status: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
64
65
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;