ccxt 4.2.2 → 4.2.4

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.
@@ -3029,12 +3029,13 @@ class okx extends okx$1 {
3029
3029
  * @param {string} id order id
3030
3030
  * @param {string} symbol unified symbol of the market the order was made in
3031
3031
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3032
+ * @param {boolean} [params.trigger] true if trigger orders
3032
3033
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3033
3034
  */
3034
3035
  if (symbol === undefined) {
3035
3036
  throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
3036
3037
  }
3037
- const stop = this.safeValue(params, 'stop');
3038
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3038
3039
  if (stop) {
3039
3040
  const orderInner = await this.cancelOrders([id], symbol, params);
3040
3041
  return this.safeValue(orderInner, 0);
@@ -3406,6 +3407,7 @@ class okx extends okx$1 {
3406
3407
  * @param {string} id the order id
3407
3408
  * @param {string} symbol unified market symbol
3408
3409
  * @param {object} [params] extra and exchange specific parameters
3410
+ * @param {boolean} [params.trigger] true if fetching trigger orders
3409
3411
  * @returns [an order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3410
3412
  */
3411
3413
  if (symbol === undefined) {
@@ -3423,7 +3425,7 @@ class okx extends okx$1 {
3423
3425
  const options = this.safeValue(this.options, 'fetchOrder', {});
3424
3426
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrder');
3425
3427
  let method = this.safeString(params, 'method', defaultMethod);
3426
- const stop = this.safeValue(params, 'stop');
3428
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3427
3429
  if (stop) {
3428
3430
  method = 'privateGetTradeOrderAlgo';
3429
3431
  if (clientOrderId !== undefined) {
@@ -3441,7 +3443,7 @@ class okx extends okx$1 {
3441
3443
  request['ordId'] = id;
3442
3444
  }
3443
3445
  }
3444
- const query = this.omit(params, ['method', 'clOrdId', 'clientOrderId', 'stop']);
3446
+ const query = this.omit(params, ['method', 'clOrdId', 'clientOrderId', 'stop', 'trigger']);
3445
3447
  let response = undefined;
3446
3448
  if (method === 'privateGetTradeOrderAlgo') {
3447
3449
  response = await this.privateGetTradeOrderAlgo(this.extend(request, query));
@@ -3597,7 +3599,7 @@ class okx extends okx$1 {
3597
3599
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersPending');
3598
3600
  let method = this.safeString(params, 'method', defaultMethod);
3599
3601
  const ordType = this.safeString(params, 'ordType');
3600
- const stop = this.safeValue(params, 'stop');
3602
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3601
3603
  if (stop || (ordType in algoOrderTypes)) {
3602
3604
  method = 'privateGetTradeOrdersAlgoPending';
3603
3605
  if (stop) {
@@ -3606,7 +3608,7 @@ class okx extends okx$1 {
3606
3608
  }
3607
3609
  }
3608
3610
  }
3609
- const query = this.omit(params, ['method', 'stop']);
3611
+ const query = this.omit(params, ['method', 'stop', 'trigger']);
3610
3612
  let response = undefined;
3611
3613
  if (method === 'privateGetTradeOrdersAlgoPending') {
3612
3614
  response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
@@ -3759,7 +3761,7 @@ class okx extends okx$1 {
3759
3761
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
3760
3762
  let method = this.safeString(params, 'method', defaultMethod);
3761
3763
  const ordType = this.safeString(params, 'ordType');
3762
- const stop = this.safeValue(params, 'stop');
3764
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3763
3765
  if (stop || (ordType in algoOrderTypes)) {
3764
3766
  method = 'privateGetTradeOrdersAlgoHistory';
3765
3767
  const algoId = this.safeString(params, 'algoId');
@@ -3784,7 +3786,7 @@ class okx extends okx$1 {
3784
3786
  query = this.omit(query, ['until', 'till']);
3785
3787
  }
3786
3788
  }
3787
- const send = this.omit(query, ['method', 'stop', 'ordType']);
3789
+ const send = this.omit(query, ['method', 'stop', 'ordType', 'trigger']);
3788
3790
  let response = undefined;
3789
3791
  if (method === 'privateGetTradeOrdersAlgoHistory') {
3790
3792
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -3901,6 +3903,7 @@ class okx extends okx$1 {
3901
3903
  * @description fetches information on multiple closed orders made by the user
3902
3904
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
3903
3905
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
3906
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
3904
3907
  * @param {string} symbol unified market symbol of the market orders were made in
3905
3908
  * @param {int} [since] the earliest time in ms to fetch orders for
3906
3909
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -3910,6 +3913,7 @@ class okx extends okx$1 {
3910
3913
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
3911
3914
  * @param {int} [params.until] timestamp in ms to fetch orders for
3912
3915
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3916
+ * @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
3913
3917
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3914
3918
  */
3915
3919
  await this.loadMarkets();
@@ -3946,7 +3950,7 @@ class okx extends okx$1 {
3946
3950
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
3947
3951
  let method = this.safeString(params, 'method', defaultMethod);
3948
3952
  const ordType = this.safeString(params, 'ordType');
3949
- const stop = this.safeValue(params, 'stop');
3953
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3950
3954
  if (stop || (ordType in algoOrderTypes)) {
3951
3955
  method = 'privateGetTradeOrdersAlgoHistory';
3952
3956
  if (stop) {
@@ -3967,11 +3971,14 @@ class okx extends okx$1 {
3967
3971
  }
3968
3972
  request['state'] = 'filled';
3969
3973
  }
3970
- const send = this.omit(query, ['method', 'stop']);
3974
+ const send = this.omit(query, ['method', 'stop', 'trigger']);
3971
3975
  let response = undefined;
3972
3976
  if (method === 'privateGetTradeOrdersAlgoHistory') {
3973
3977
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
3974
3978
  }
3979
+ else if (method === 'privateGetTradeOrdersHistoryArchive') {
3980
+ response = await this.privateGetTradeOrdersHistoryArchive(this.extend(request, send));
3981
+ }
3975
3982
  else {
3976
3983
  response = await this.privateGetTradeOrdersHistory(this.extend(request, send));
3977
3984
  }
@@ -1485,7 +1485,7 @@ class phemex extends phemex$1 {
1485
1485
  if (type === 'spot') {
1486
1486
  response = await this.v1GetMdSpotTicker24hrAll(query);
1487
1487
  }
1488
- else if (subType === 'inverse' || market['settle'] === 'USD') {
1488
+ else if (subType === 'inverse' || this.safeString(market, 'settle') === 'USD') {
1489
1489
  response = await this.v1GetMdTicker24hrAll(query);
1490
1490
  }
1491
1491
  else {
@@ -30,6 +30,7 @@ class bingx extends bingx$1 {
30
30
  },
31
31
  },
32
32
  'options': {
33
+ 'listenKeyRefreshRate': 3540000,
33
34
  'ws': {
34
35
  'gunzip': true,
35
36
  },
@@ -627,7 +628,7 @@ class bingx extends bingx$1 {
627
628
  const lastAuthenticatedTime = this.safeInteger(this.options, 'lastAuthenticatedTime', 0);
628
629
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000); // 1 hour
629
630
  if (time - lastAuthenticatedTime > listenKeyRefreshRate) {
630
- const response = await this.userAuthPrivatePostUserDataStream({ 'listenKey': listenKey }); // extend the expiry
631
+ const response = await this.userAuthPrivatePutUserDataStream({ 'listenKey': listenKey }); // extend the expiry
631
632
  this.options['listenKey'] = this.safeString(response, 'listenKey');
632
633
  this.options['lastAuthenticatedTime'] = time;
633
634
  }
@@ -208,7 +208,7 @@ class bybit extends bybit$1 {
208
208
  */
209
209
  await this.loadMarkets();
210
210
  symbols = this.marketSymbols(symbols, undefined, false);
211
- const messageHash = 'tickers::' + symbols.join(',');
211
+ const messageHashes = [];
212
212
  const url = this.getUrlByMarketType(symbols[0], false, params);
213
213
  params = this.cleanParams(params);
214
214
  const options = this.safeValue(this.options, 'watchTickers', {});
@@ -218,8 +218,9 @@ class bybit extends bybit$1 {
218
218
  for (let i = 0; i < marketIds.length; i++) {
219
219
  const marketId = marketIds[i];
220
220
  topics.push(topic + '.' + marketId);
221
+ messageHashes.push('ticker:' + symbols[i]);
221
222
  }
222
- const ticker = await this.watchTopics(url, messageHash, topics, params);
223
+ const ticker = await this.watchTopics(url, messageHashes, topics, params);
223
224
  if (this.newUpdates) {
224
225
  return ticker;
225
226
  }
@@ -355,17 +356,6 @@ class bybit extends bybit$1 {
355
356
  this.tickers[symbol] = parsed;
356
357
  const messageHash = 'ticker:' + symbol;
357
358
  client.resolve(this.tickers[symbol], messageHash);
358
- // watchTickers part
359
- const messageHashes = this.findMessageHashes(client, 'tickers::');
360
- for (let i = 0; i < messageHashes.length; i++) {
361
- const messageHashTicker = messageHashes[i];
362
- const parts = messageHashTicker.split('::');
363
- const symbolsString = parts[1];
364
- const symbols = symbolsString.split(',');
365
- if (this.inArray(parsed['symbol'], symbols)) {
366
- client.resolve(parsed, messageHashTicker);
367
- }
368
- }
369
359
  }
370
360
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
371
361
  /**
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 } 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.2.1";
7
+ declare const version = "4.2.3";
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.2.2';
41
+ const version = '4.2.4';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -82,6 +82,7 @@ interface Exchange {
82
82
  accountV1PrivateGetUid(params?: {}): Promise<implicitReturnType>;
83
83
  accountV1PrivatePostInnerTransferAuthorizeSubAccount(params?: {}): Promise<implicitReturnType>;
84
84
  userAuthPrivatePostUserDataStream(params?: {}): Promise<implicitReturnType>;
85
+ userAuthPrivatePutUserDataStream(params?: {}): Promise<implicitReturnType>;
85
86
  copyTradingV1PrivateGetSwapTraceCurrentTrack(params?: {}): Promise<implicitReturnType>;
86
87
  copyTradingV1PrivatePostSwapTraceCloseTrackOrder(params?: {}): Promise<implicitReturnType>;
87
88
  copyTradingV1PrivatePostSwapTraceSetTPSL(params?: {}): Promise<implicitReturnType>;
@@ -58,6 +58,7 @@ interface Exchange {
58
58
  privateGetContractPrivateOrderHistory(params?: {}): Promise<implicitReturnType>;
59
59
  privateGetContractPrivatePosition(params?: {}): Promise<implicitReturnType>;
60
60
  privateGetContractPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
61
+ privateGetContractPrivateCurrentPlanOrder(params?: {}): Promise<implicitReturnType>;
61
62
  privateGetContractPrivateTrades(params?: {}): Promise<implicitReturnType>;
62
63
  privatePostAccountSubAccountMainV1SubToMain(params?: {}): Promise<implicitReturnType>;
63
64
  privatePostAccountSubAccountSubV1SubToMain(params?: {}): Promise<implicitReturnType>;
package/js/src/alpaca.js CHANGED
@@ -53,7 +53,7 @@ export default class alpaca extends Exchange {
53
53
  'closeAllPositions': false,
54
54
  'closePosition': false,
55
55
  'createOrder': true,
56
- 'fetchBalance': true,
56
+ 'fetchBalance': false,
57
57
  'fetchBidsAsks': false,
58
58
  'fetchClosedOrders': true,
59
59
  'fetchCurrencies': false,
@@ -751,8 +751,11 @@ export default class Exchange {
751
751
  // proxy agents
752
752
  const [httpProxy, httpsProxy, socksProxy] = this.checkProxySettings(url, method, headers, body);
753
753
  this.checkConflictingProxies(httpProxy || httpsProxy || socksProxy, proxyUrl);
754
- if (!this.proxyModulesLoaded) {
755
- await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
754
+ if (isNode) {
755
+ // skip this on the browser
756
+ if (!this.proxyModulesLoaded) {
757
+ await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
758
+ }
756
759
  }
757
760
  const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
758
761
  // user-agent
package/js/src/bingx.js CHANGED
@@ -280,6 +280,9 @@ export default class bingx extends Exchange {
280
280
  'post': {
281
281
  'userDataStream': 1,
282
282
  },
283
+ 'put': {
284
+ 'userDataStream': 1,
285
+ },
283
286
  },
284
287
  },
285
288
  },
@@ -1721,6 +1724,10 @@ export default class bingx extends Exchange {
1721
1724
  const isTrailingAmountOrder = trailingAmount !== undefined;
1722
1725
  const isTrailingPercentOrder = trailingPercent !== undefined;
1723
1726
  const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
1727
+ const stopLoss = this.safeValue(params, 'stopLoss');
1728
+ const takeProfit = this.safeValue(params, 'takeProfit');
1729
+ const isStopLoss = stopLoss !== undefined;
1730
+ const isTakeProfit = takeProfit !== undefined;
1724
1731
  if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
1725
1732
  request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
1726
1733
  }
@@ -1766,6 +1773,42 @@ export default class bingx extends Exchange {
1766
1773
  request['priceRate'] = this.parseToNumeric(requestTrailingPercent);
1767
1774
  }
1768
1775
  }
1776
+ if (isStopLoss || isTakeProfit) {
1777
+ if (isStopLoss) {
1778
+ const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
1779
+ const slWorkingType = this.safeString(stopLoss, 'workingType', 'MARK_PRICE');
1780
+ const slType = this.safeString(stopLoss, 'type', 'STOP_MARKET');
1781
+ const slRequest = {
1782
+ 'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, slTriggerPrice)),
1783
+ 'workingType': slWorkingType,
1784
+ 'type': slType,
1785
+ };
1786
+ const slPrice = this.safeString(stopLoss, 'price');
1787
+ if (slPrice !== undefined) {
1788
+ slRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
1789
+ }
1790
+ const slQuantity = this.safeString(stopLoss, 'quantity', amount);
1791
+ slRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, slQuantity));
1792
+ request['stopLoss'] = this.json(slRequest);
1793
+ }
1794
+ if (isTakeProfit) {
1795
+ const tkTriggerPrice = this.safeString2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
1796
+ const tkWorkingType = this.safeString(takeProfit, 'workingType', 'MARK_PRICE');
1797
+ const tpType = this.safeString(takeProfit, 'type', 'TAKE_PROFIT_MARKET');
1798
+ const tpRequest = {
1799
+ 'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, tkTriggerPrice)),
1800
+ 'workingType': tkWorkingType,
1801
+ 'type': tpType,
1802
+ };
1803
+ const slPrice = this.safeString(takeProfit, 'price');
1804
+ if (slPrice !== undefined) {
1805
+ tpRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
1806
+ }
1807
+ const tkQuantity = this.safeString(takeProfit, 'quantity', amount);
1808
+ tpRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, tkQuantity));
1809
+ request['takeProfit'] = this.json(tpRequest);
1810
+ }
1811
+ }
1769
1812
  let positionSide = undefined;
1770
1813
  if (reduceOnly) {
1771
1814
  positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
@@ -1775,7 +1818,7 @@ export default class bingx extends Exchange {
1775
1818
  }
1776
1819
  request['positionSide'] = positionSide;
1777
1820
  request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
1778
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent']);
1821
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss']);
1779
1822
  }
1780
1823
  return this.extend(request, params);
1781
1824
  }
@@ -1785,6 +1828,7 @@ export default class bingx extends Exchange {
1785
1828
  * @name bingx#createOrder
1786
1829
  * @description create a trade order
1787
1830
  * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
1831
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
1788
1832
  * @param {string} symbol unified symbol of the market to create an order in
1789
1833
  * @param {string} type 'market' or 'limit'
1790
1834
  * @param {string} side 'buy' or 'sell'
@@ -1800,6 +1844,10 @@ export default class bingx extends Exchange {
1800
1844
  * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
1801
1845
  * @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
1802
1846
  * @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
1847
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
1848
+ * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
1849
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
1850
+ * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
1803
1851
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1804
1852
  */
1805
1853
  await this.loadMarkets();
@@ -1850,6 +1898,9 @@ export default class bingx extends Exchange {
1850
1898
  // }
1851
1899
  // }
1852
1900
  //
1901
+ if (typeof response === 'string') {
1902
+ response = JSON.parse(response);
1903
+ }
1853
1904
  const data = this.safeValue(response, 'data', {});
1854
1905
  const order = this.safeValue(data, 'order', data);
1855
1906
  return this.parseOrder(order, market);
@@ -2054,6 +2105,24 @@ export default class bingx extends Exchange {
2054
2105
  // "orderType": "",
2055
2106
  // "workingType": "MARK_PRICE"
2056
2107
  // }
2108
+ // with tp and sl
2109
+ // {
2110
+ // orderId: 1741440894764281900,
2111
+ // symbol: 'LTC-USDT',
2112
+ // positionSide: 'LONG',
2113
+ // side: 'BUY',
2114
+ // type: 'MARKET',
2115
+ // price: 0,
2116
+ // quantity: 1,
2117
+ // stopPrice: 0,
2118
+ // workingType: 'MARK_PRICE',
2119
+ // clientOrderID: '',
2120
+ // timeInForce: 'GTC',
2121
+ // priceRate: 0,
2122
+ // stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
2123
+ // takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
2124
+ // reduceOnly: false
2125
+ // }
2057
2126
  //
2058
2127
  const positionSide = this.safeString2(order, 'positionSide', 'ps');
2059
2128
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
@@ -2092,6 +2161,30 @@ export default class bingx extends Exchange {
2092
2161
  'cost': Precise.stringAbs(feeCost),
2093
2162
  };
2094
2163
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
2164
+ let stopLoss = this.safeValue(order, 'stopLoss');
2165
+ let stopLossPrice = undefined;
2166
+ if (stopLoss !== undefined) {
2167
+ stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
2168
+ }
2169
+ if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
2170
+ // stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
2171
+ if (typeof stopLoss === 'string') {
2172
+ stopLoss = JSON.parse(stopLoss);
2173
+ }
2174
+ stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
2175
+ }
2176
+ let takeProfit = this.safeValue(order, 'takeProfit');
2177
+ let takeProfitPrice = undefined;
2178
+ if (takeProfit !== undefined) {
2179
+ takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
2180
+ }
2181
+ if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
2182
+ // takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
2183
+ if (typeof takeProfit === 'string') {
2184
+ takeProfit = JSON.parse(takeProfit);
2185
+ }
2186
+ takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
2187
+ }
2095
2188
  return this.safeOrder({
2096
2189
  'info': order,
2097
2190
  'id': orderId,
@@ -2108,8 +2201,8 @@ export default class bingx extends Exchange {
2108
2201
  'price': price,
2109
2202
  'stopPrice': this.safeNumber(order, 'stopPrice'),
2110
2203
  'triggerPrice': this.safeNumber(order, 'stopPrice'),
2111
- 'stopLossPrice': this.safeNumber(order, 'stopLoss'),
2112
- 'takeProfitPrice': this.safeNumber(order, 'takeProfit'),
2204
+ 'stopLossPrice': stopLossPrice,
2205
+ 'takeProfitPrice': takeProfitPrice,
2113
2206
  'average': average,
2114
2207
  'cost': undefined,
2115
2208
  'amount': amount,
@@ -2303,6 +2396,7 @@ export default class bingx extends Exchange {
2303
2396
  * @param {string[]} ids order ids
2304
2397
  * @param {string} symbol unified market symbol, default is undefined
2305
2398
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2399
+ * @param {string[]} [params.clientOrderIds] client order ids
2306
2400
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2307
2401
  */
2308
2402
  if (symbol === undefined) {
@@ -2313,19 +2407,27 @@ export default class bingx extends Exchange {
2313
2407
  const request = {
2314
2408
  'symbol': market['id'],
2315
2409
  };
2410
+ const clientOrderIds = this.safeValue(params, 'clientOrderIds');
2411
+ let idsToParse = ids;
2412
+ const areClientOrderIds = (clientOrderIds !== undefined);
2413
+ if (areClientOrderIds) {
2414
+ idsToParse = clientOrderIds;
2415
+ }
2316
2416
  const parsedIds = [];
2317
- for (let i = 0; i < ids.length; i++) {
2318
- const id = ids[i];
2417
+ for (let i = 0; i < idsToParse.length; i++) {
2418
+ const id = idsToParse[i];
2319
2419
  const stringId = id.toString();
2320
2420
  parsedIds.push(stringId);
2321
2421
  }
2322
2422
  let response = undefined;
2323
2423
  if (market['spot']) {
2324
- request['orderIds'] = parsedIds.join(',');
2424
+ const spotReqKey = areClientOrderIds ? 'clientOrderIds' : 'orderIds';
2425
+ request[spotReqKey] = parsedIds.join(',');
2325
2426
  response = await this.spotV1PrivatePostTradeCancelOrders(this.extend(request, params));
2326
2427
  }
2327
2428
  else {
2328
- request['orderIdList'] = parsedIds;
2429
+ const swapReqKey = areClientOrderIds ? 'ClientOrderIDList' : 'orderIdList';
2430
+ request[swapReqKey] = parsedIds;
2329
2431
  response = await this.swapV2PrivateDeleteTradeBatchOrders(this.extend(request, params));
2330
2432
  }
2331
2433
  //
package/js/src/bitget.js CHANGED
@@ -4745,8 +4745,8 @@ export default class bitget extends Exchange {
4745
4745
  }
4746
4746
  let marginMode = undefined;
4747
4747
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
4748
- const stop = this.safeValue(params, 'stop');
4749
- params = this.omit(params, 'stop');
4748
+ const stop = this.safeValue2(params, 'stop', 'trigger');
4749
+ params = this.omit(params, ['stop', 'trigger']);
4750
4750
  const orderIdList = [];
4751
4751
  for (let i = 0; i < ids.length; i++) {
4752
4752
  const individualId = ids[i];
@@ -4842,8 +4842,8 @@ export default class bitget extends Exchange {
4842
4842
  const request = {
4843
4843
  'symbol': market['id'],
4844
4844
  };
4845
- const stop = this.safeValue(params, 'stop');
4846
- params = this.omit(params, 'stop');
4845
+ const stop = this.safeValue2(params, 'stop', 'trigger');
4846
+ params = this.omit(params, ['stop', 'trigger']);
4847
4847
  let response = undefined;
4848
4848
  if (market['spot']) {
4849
4849
  if (marginMode !== undefined) {
package/js/src/bitmart.js CHANGED
@@ -199,6 +199,7 @@ export default class bitmart extends Exchange {
199
199
  'contract/private/order-history': 10,
200
200
  'contract/private/position': 10,
201
201
  'contract/private/get-open-orders': 1.2,
202
+ 'contract/private/current-plan-order': 1.2,
202
203
  'contract/private/trades': 10,
203
204
  },
204
205
  'post': {
@@ -2510,8 +2511,8 @@ export default class bitmart extends Exchange {
2510
2511
  response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
2511
2512
  }
2512
2513
  else {
2513
- const stop = this.safeValue(params, 'stop');
2514
- params = this.omit(params, ['stop']);
2514
+ const stop = this.safeValue2(params, 'stop', 'trigger');
2515
+ params = this.omit(params, ['stop', 'trigger']);
2515
2516
  if (!stop) {
2516
2517
  response = await this.privatePostContractPrivateCancelOrder(this.extend(request, params));
2517
2518
  }
@@ -2681,6 +2682,7 @@ export default class bitmart extends Exchange {
2681
2682
  * @name bitmart#fetchOpenOrders
2682
2683
  * @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
2683
2684
  * @see https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
2685
+ * @see https://developer-pro.bitmart.com/en/futures/#get-all-current-plan-orders-keyed
2684
2686
  * @description fetch all unfilled currently open orders
2685
2687
  * @param {string} symbol unified market symbol
2686
2688
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -2692,6 +2694,7 @@ export default class bitmart extends Exchange {
2692
2694
  * @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
2693
2695
  * @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
2694
2696
  * @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
2697
+ * @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
2695
2698
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2696
2699
  */
2697
2700
  await this.loadMarkets();
@@ -2724,16 +2727,23 @@ export default class bitmart extends Exchange {
2724
2727
  response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
2725
2728
  }
2726
2729
  else if (type === 'swap') {
2727
- const trailing = this.safeValue(params, 'trailing', false);
2728
- let orderType = this.safeString(params, 'orderType');
2729
- params = this.omit(params, ['orderType', 'trailing']);
2730
- if (trailing) {
2731
- orderType = 'trailing';
2730
+ const isStop = this.safeValue2(params, 'stop', 'trigger');
2731
+ params = this.omit(params, ['stop', 'trigger']);
2732
+ if (isStop) {
2733
+ response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
2732
2734
  }
2733
- if (orderType !== undefined) {
2734
- request['type'] = orderType;
2735
+ else {
2736
+ const trailing = this.safeValue(params, 'trailing', false);
2737
+ let orderType = this.safeString(params, 'orderType');
2738
+ params = this.omit(params, ['orderType', 'trailing']);
2739
+ if (trailing) {
2740
+ orderType = 'trailing';
2741
+ }
2742
+ if (orderType !== undefined) {
2743
+ request['type'] = orderType;
2744
+ }
2745
+ response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
2735
2746
  }
2736
- response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
2737
2747
  }
2738
2748
  else {
2739
2749
  throw new NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' orders, only spot and swap orders are accepted');
package/js/src/bybit.js CHANGED
@@ -629,6 +629,8 @@ export default class bybit extends Exchange {
629
629
  '131215': BadRequest,
630
630
  '131216': ExchangeError,
631
631
  '131217': ExchangeError,
632
+ '131231': NotSupported,
633
+ '131232': NotSupported,
632
634
  '131002': BadRequest,
633
635
  '131003': ExchangeError,
634
636
  '131004': AuthenticationError,
package/js/src/coinsph.js CHANGED
@@ -631,7 +631,16 @@ export default class coinsph extends Exchange {
631
631
  const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
632
632
  const options = this.safeValue(this.options, 'fetchTickers', {});
633
633
  const method = this.safeString(options, 'method', defaultMethod);
634
- const tickers = await this[method](this.extend(request, params));
634
+ let tickers = undefined;
635
+ if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
636
+ tickers = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
637
+ }
638
+ else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
639
+ tickers = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
640
+ }
641
+ else {
642
+ tickers = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
643
+ }
635
644
  return this.parseTickers(tickers, symbols, params);
636
645
  }
637
646
  async fetchTicker(symbol, params = {}) {
@@ -651,7 +660,16 @@ export default class coinsph extends Exchange {
651
660
  const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
652
661
  const options = this.safeValue(this.options, 'fetchTicker', {});
653
662
  const method = this.safeString(options, 'method', defaultMethod);
654
- const ticker = await this[method](this.extend(request, params));
663
+ let ticker = undefined;
664
+ if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
665
+ ticker = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
666
+ }
667
+ else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
668
+ ticker = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
669
+ }
670
+ else {
671
+ ticker = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
672
+ }
655
673
  return this.parseTicker(ticker, market);
656
674
  }
657
675
  parseTicker(ticker, market = undefined) {