ccxt 4.2.14 → 4.2.16

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 (55) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +805 -184
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/js/ccxt.js +3 -1
  6. package/dist/cjs/js/src/ascendex.js +11 -6
  7. package/dist/cjs/js/src/base/Exchange.js +12 -12
  8. package/dist/cjs/js/src/binance.js +2 -2
  9. package/dist/cjs/js/src/bingx.js +41 -6
  10. package/dist/cjs/js/src/bitget.js +3 -3
  11. package/dist/cjs/js/src/bitmex.js +3 -6
  12. package/dist/cjs/js/src/bybit.js +3 -3
  13. package/dist/cjs/js/src/coinex.js +3 -3
  14. package/dist/cjs/js/src/coinone.js +1 -1
  15. package/dist/cjs/js/src/gate.js +3 -3
  16. package/dist/cjs/js/src/htx.js +2 -2
  17. package/dist/cjs/js/src/kraken.js +24 -2
  18. package/dist/cjs/js/src/kucoin.js +1 -1
  19. package/dist/cjs/js/src/kucoinfutures.js +2 -2
  20. package/dist/cjs/js/src/okx.js +1 -1
  21. package/dist/cjs/js/src/phemex.js +28 -25
  22. package/dist/cjs/js/src/pro/coinone.js +411 -0
  23. package/dist/cjs/js/src/pro/htx.js +6 -1
  24. package/dist/cjs/js/src/pro/krakenfutures.js +7 -1
  25. package/dist/cjs/js/src/pro/woo.js +126 -0
  26. package/dist/cjs/js/src/woo.js +3 -3
  27. package/js/ccxt.d.ts +4 -1
  28. package/js/ccxt.js +3 -1
  29. package/js/src/ascendex.js +11 -6
  30. package/js/src/base/Exchange.js +12 -12
  31. package/js/src/binance.js +2 -2
  32. package/js/src/bingx.d.ts +1 -0
  33. package/js/src/bingx.js +42 -7
  34. package/js/src/bitget.js +3 -3
  35. package/js/src/bitmex.js +3 -6
  36. package/js/src/bybit.js +3 -3
  37. package/js/src/coinex.js +3 -3
  38. package/js/src/coinone.js +1 -1
  39. package/js/src/gate.js +3 -3
  40. package/js/src/htx.js +2 -2
  41. package/js/src/kraken.d.ts +1 -0
  42. package/js/src/kraken.js +24 -2
  43. package/js/src/kucoin.js +1 -1
  44. package/js/src/kucoinfutures.js +2 -2
  45. package/js/src/okx.js +1 -1
  46. package/js/src/phemex.js +28 -25
  47. package/js/src/pro/coinone.d.ts +21 -0
  48. package/js/src/pro/coinone.js +412 -0
  49. package/js/src/pro/htx.js +6 -1
  50. package/js/src/pro/krakenfutures.js +7 -1
  51. package/js/src/pro/woo.d.ts +5 -1
  52. package/js/src/pro/woo.js +127 -1
  53. package/js/src/woo.js +3 -3
  54. package/package.json +1 -1
  55. package/skip-tests.json +1 -0
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.14';
41
+ const version = '4.2.16';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -165,6 +165,7 @@ import cexPro from './src/pro/cex.js';
165
165
  import coinbasePro from './src/pro/coinbase.js';
166
166
  import coinbaseproPro from './src/pro/coinbasepro.js';
167
167
  import coinexPro from './src/pro/coinex.js';
168
+ import coinonePro from './src/pro/coinone.js';
168
169
  import cryptocomPro from './src/pro/cryptocom.js';
169
170
  import currencycomPro from './src/pro/currencycom.js';
170
171
  import deribitPro from './src/pro/deribit.js';
@@ -322,6 +323,7 @@ const pro = {
322
323
  'coinbase': coinbasePro,
323
324
  'coinbasepro': coinbaseproPro,
324
325
  'coinex': coinexPro,
326
+ 'coinone': coinonePro,
325
327
  'cryptocom': cryptocomPro,
326
328
  'currencycom': currencycomPro,
327
329
  'deribit': deribitPro,
@@ -811,12 +811,14 @@ export default class ascendex extends Exchange {
811
811
  */
812
812
  await this.loadMarkets();
813
813
  await this.loadAccounts();
814
- let query = undefined;
815
814
  let marketType = undefined;
816
- [marketType, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
815
+ let marginMode = undefined;
816
+ [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
817
+ [marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
817
818
  const isMargin = this.safeValue(params, 'margin', false);
818
- marketType = isMargin ? 'margin' : marketType;
819
- query = this.omit(query, 'margin');
819
+ const isCross = marginMode === 'cross';
820
+ marketType = (isMargin || isCross) ? 'margin' : marketType;
821
+ params = this.omit(params, 'margin');
820
822
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
821
823
  const accountCategory = this.safeString(accountsByType, marketType, 'cash');
822
824
  const account = this.safeValue(this.accounts, 0, {});
@@ -824,15 +826,18 @@ export default class ascendex extends Exchange {
824
826
  const request = {
825
827
  'account-group': accountGroup,
826
828
  };
829
+ if ((marginMode === 'isolated') && (marketType !== 'swap')) {
830
+ throw new BadRequest(this.id + ' does not supported isolated margin trading');
831
+ }
827
832
  if ((accountCategory === 'cash') || (accountCategory === 'margin')) {
828
833
  request['account-category'] = accountCategory;
829
834
  }
830
835
  let response = undefined;
831
836
  if ((marketType === 'spot') || (marketType === 'margin')) {
832
- response = await this.v1PrivateAccountCategoryGetBalance(this.extend(request, query));
837
+ response = await this.v1PrivateAccountCategoryGetBalance(this.extend(request, params));
833
838
  }
834
839
  else if (marketType === 'swap') {
835
- response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, query));
840
+ response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
836
841
  }
837
842
  else {
838
843
  throw new NotSupported(this.id + ' fetchBalance() is not currently supported for ' + marketType + ' markets');
@@ -1448,11 +1448,11 @@ export default class Exchange {
1448
1448
  let httpsProxy = undefined;
1449
1449
  let socksProxy = undefined;
1450
1450
  // httpProxy
1451
- if (this.httpProxy !== undefined) {
1451
+ if (this.valueIsDefined(this.httpProxy)) {
1452
1452
  usedProxies.push('httpProxy');
1453
1453
  httpProxy = this.httpProxy;
1454
1454
  }
1455
- if (this.http_proxy !== undefined) {
1455
+ if (this.valueIsDefined(this.http_proxy)) {
1456
1456
  usedProxies.push('http_proxy');
1457
1457
  httpProxy = this.http_proxy;
1458
1458
  }
@@ -1465,11 +1465,11 @@ export default class Exchange {
1465
1465
  httpProxy = this.http_proxy_callback(url, method, headers, body);
1466
1466
  }
1467
1467
  // httpsProxy
1468
- if (this.httpsProxy !== undefined) {
1468
+ if (this.valueIsDefined(this.httpsProxy)) {
1469
1469
  usedProxies.push('httpsProxy');
1470
1470
  httpsProxy = this.httpsProxy;
1471
1471
  }
1472
- if (this.https_proxy !== undefined) {
1472
+ if (this.valueIsDefined(this.https_proxy)) {
1473
1473
  usedProxies.push('https_proxy');
1474
1474
  httpsProxy = this.https_proxy;
1475
1475
  }
@@ -1482,11 +1482,11 @@ export default class Exchange {
1482
1482
  httpsProxy = this.https_proxy_callback(url, method, headers, body);
1483
1483
  }
1484
1484
  // socksProxy
1485
- if (this.socksProxy !== undefined) {
1485
+ if (this.valueIsDefined(this.socksProxy)) {
1486
1486
  usedProxies.push('socksProxy');
1487
1487
  socksProxy = this.socksProxy;
1488
1488
  }
1489
- if (this.socks_proxy !== undefined) {
1489
+ if (this.valueIsDefined(this.socks_proxy)) {
1490
1490
  usedProxies.push('socks_proxy');
1491
1491
  socksProxy = this.socks_proxy;
1492
1492
  }
@@ -1512,29 +1512,29 @@ export default class Exchange {
1512
1512
  let wssProxy = undefined;
1513
1513
  let wsSocksProxy = undefined;
1514
1514
  // ws proxy
1515
- if (this.wsProxy !== undefined) {
1515
+ if (this.valueIsDefined(this.wsProxy)) {
1516
1516
  usedProxies.push('wsProxy');
1517
1517
  wsProxy = this.wsProxy;
1518
1518
  }
1519
- if (this.ws_proxy !== undefined) {
1519
+ if (this.valueIsDefined(this.ws_proxy)) {
1520
1520
  usedProxies.push('ws_proxy');
1521
1521
  wsProxy = this.ws_proxy;
1522
1522
  }
1523
1523
  // wss proxy
1524
- if (this.wssProxy !== undefined) {
1524
+ if (this.valueIsDefined(this.wssProxy)) {
1525
1525
  usedProxies.push('wssProxy');
1526
1526
  wssProxy = this.wssProxy;
1527
1527
  }
1528
- if (this.wss_proxy !== undefined) {
1528
+ if (this.valueIsDefined(this.wss_proxy)) {
1529
1529
  usedProxies.push('wss_proxy');
1530
1530
  wssProxy = this.wss_proxy;
1531
1531
  }
1532
1532
  // ws socks proxy
1533
- if (this.wsSocksProxy !== undefined) {
1533
+ if (this.valueIsDefined(this.wsSocksProxy)) {
1534
1534
  usedProxies.push('wsSocksProxy');
1535
1535
  wsSocksProxy = this.wsSocksProxy;
1536
1536
  }
1537
- if (this.ws_socks_proxy !== undefined) {
1537
+ if (this.valueIsDefined(this.ws_socks_proxy)) {
1538
1538
  usedProxies.push('ws_socks_proxy');
1539
1539
  wsSocksProxy = this.ws_socks_proxy;
1540
1540
  }
package/js/src/binance.js CHANGED
@@ -52,12 +52,12 @@ export default class binance extends Exchange {
52
52
  'createPostOnlyOrder': true,
53
53
  'createReduceOnlyOrder': true,
54
54
  'createStopLimitOrder': true,
55
+ 'createStopLossOrder': true,
55
56
  'createStopMarketOrder': false,
56
57
  'createStopOrder': true,
58
+ 'createTakeProfitOrder': true,
57
59
  'createTrailingPercentOrder': true,
58
60
  'createTriggerOrder': true,
59
- 'createTakeProfitOrder': true,
60
- 'createStopLossOrder': true,
61
61
  'editOrder': true,
62
62
  'fetchAccounts': undefined,
63
63
  'fetchBalance': true,
package/js/src/bingx.d.ts CHANGED
@@ -143,5 +143,6 @@ export default class bingx extends Exchange {
143
143
  headers: any;
144
144
  };
145
145
  nonce(): number;
146
+ setSandboxMode(enable: any): void;
146
147
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
147
148
  }
package/js/src/bingx.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bingx.js';
9
- import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired } from './base/errors.js';
9
+ import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired, NotSupported } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  import { DECIMAL_PLACES } from './base/functions/number.js';
@@ -25,7 +25,7 @@ export default class bingx extends Exchange {
25
25
  'has': {
26
26
  'CORS': undefined,
27
27
  'spot': true,
28
- 'margin': true,
28
+ 'margin': false,
29
29
  'swap': true,
30
30
  'future': false,
31
31
  'option': false,
@@ -39,12 +39,12 @@ export default class bingx extends Exchange {
39
39
  'createMarketSellOrderWithCost': true,
40
40
  'createOrder': true,
41
41
  'createOrders': true,
42
+ 'createOrderWithTakeProfitAndStopLoss': true,
43
+ 'createStopLossOrder': true,
44
+ 'createTakeProfitOrder': true,
42
45
  'createTrailingAmountOrder': true,
43
46
  'createTrailingPercentOrder': true,
44
47
  'createTriggerOrder': true,
45
- 'createTakeProfitOrder': true,
46
- 'createStopLossOrder': true,
47
- 'createOrderWithTakeProfitAndStopLoss': true,
48
48
  'fetchBalance': true,
49
49
  'fetchClosedOrders': true,
50
50
  'fetchCurrencies': true,
@@ -88,6 +88,9 @@ export default class bingx extends Exchange {
88
88
  'account': 'https://open-api.{hostname}/openApi',
89
89
  'copyTrading': 'https://open-api.{hostname}/openApi',
90
90
  },
91
+ 'test': {
92
+ 'swap': 'https://open-api-vst.{hostname}/openApi', // only swap is really "test" but since the API keys are the same, we want to keep all the functionalities when the user enables the sandboxmode
93
+ },
91
94
  'www': 'https://bingx.com/',
92
95
  'doc': 'https://bingx-api.github.io/docs/',
93
96
  'referral': 'https://bingx.com/invite/OHETOM',
@@ -364,6 +367,7 @@ export default class bingx extends Exchange {
364
367
  '80016': OrderNotFound,
365
368
  '80017': OrderNotFound,
366
369
  '100414': AccountSuspended,
370
+ '100419': PermissionDenied,
367
371
  '100437': BadRequest, // {"code":100437,"msg":"The withdrawal amount is lower than the minimum limit, please re-enter.","timestamp":1689258588845}
368
372
  },
369
373
  'broad': {},
@@ -420,6 +424,10 @@ export default class bingx extends Exchange {
420
424
  if (!this.checkRequiredCredentials(false)) {
421
425
  return undefined;
422
426
  }
427
+ const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
428
+ if (isSandbox) {
429
+ return undefined;
430
+ }
423
431
  const response = await this.walletsV1PrivateGetCapitalConfigGetall(params);
424
432
  //
425
433
  // {
@@ -659,7 +667,11 @@ export default class bingx extends Exchange {
659
667
  * @param {object} [params] extra parameters specific to the exchange API endpoint
660
668
  * @returns {object[]} an array of objects representing market data
661
669
  */
662
- const requests = [this.fetchSpotMarkets(params), this.fetchSwapMarkets(params)];
670
+ const requests = [this.fetchSwapMarkets(params)];
671
+ const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
672
+ if (!isSandbox) {
673
+ requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
674
+ }
663
675
  const promises = await Promise.all(requests);
664
676
  const spotMarkets = this.safeValue(promises, 0, []);
665
677
  const swapMarkets = this.safeValue(promises, 1, []);
@@ -3090,6 +3102,21 @@ export default class bingx extends Exchange {
3090
3102
  // "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268"
3091
3103
  // }
3092
3104
  //
3105
+ // withdraw
3106
+ //
3107
+ // {
3108
+ // "code":0,
3109
+ // "timestamp":1705274263621,
3110
+ // "data":{
3111
+ // "id":"1264246141278773252"
3112
+ // }
3113
+ // }
3114
+ //
3115
+ // parse withdraw-type output first...
3116
+ //
3117
+ const data = this.safeValue(transaction, 'data');
3118
+ const dataId = (data === undefined) ? undefined : this.safeString(data, 'id');
3119
+ const id = this.safeString(transaction, 'id', dataId);
3093
3120
  const address = this.safeString(transaction, 'address');
3094
3121
  const tag = this.safeString(transaction, 'addressTag');
3095
3122
  let timestamp = this.safeInteger(transaction, 'insertTime');
@@ -3110,7 +3137,7 @@ export default class bingx extends Exchange {
3110
3137
  const type = (rawType === '0') ? 'deposit' : 'withdrawal';
3111
3138
  return {
3112
3139
  'info': transaction,
3113
- 'id': this.safeString(transaction, 'id'),
3140
+ 'id': id,
3114
3141
  'txid': this.safeString(transaction, 'txId'),
3115
3142
  'type': type,
3116
3143
  'currency': code,
@@ -3744,6 +3771,10 @@ export default class bingx extends Exchange {
3744
3771
  const type = section[0];
3745
3772
  const version = section[1];
3746
3773
  const access = section[2];
3774
+ const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
3775
+ if (isSandbox && (type !== 'swap')) {
3776
+ throw new NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
3777
+ }
3747
3778
  let url = this.implodeHostname(this.urls['api'][type]);
3748
3779
  if (type === 'spot' && version === 'v3') {
3749
3780
  url += '/api';
@@ -3786,6 +3817,10 @@ export default class bingx extends Exchange {
3786
3817
  nonce() {
3787
3818
  return this.milliseconds();
3788
3819
  }
3820
+ setSandboxMode(enable) {
3821
+ super.setSandboxMode(enable);
3822
+ this.options['sandboxMode'] = enable;
3823
+ }
3789
3824
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3790
3825
  if (response === undefined) {
3791
3826
  return undefined; // fallback to default error handler
package/js/src/bitget.js CHANGED
@@ -45,12 +45,12 @@ export default class bitget extends Exchange {
45
45
  'createMarketSellOrderWithCost': false,
46
46
  'createOrder': true,
47
47
  'createOrders': true,
48
+ 'createOrderWithTakeProfitAndStopLoss': true,
48
49
  'createReduceOnlyOrder': false,
50
+ 'createStopLossOrder': true,
51
+ 'createTakeProfitOrder': true,
49
52
  'createTrailingPercentOrder': true,
50
53
  'createTriggerOrder': true,
51
- 'createTakeProfitOrder': true,
52
- 'createStopLossOrder': true,
53
- 'createOrderWithTakeProfitAndStopLoss': true,
54
54
  'editOrder': true,
55
55
  'fetchAccounts': false,
56
56
  'fetchBalance': true,
package/js/src/bitmex.js CHANGED
@@ -1503,8 +1503,8 @@ export default class bitmex extends Exchange {
1503
1503
  if (fetchOHLCVOpenTimestamp) {
1504
1504
  timestamp = this.sum(timestamp, duration);
1505
1505
  }
1506
- const ymdhms = this.ymdhms(timestamp);
1507
- request['startTime'] = ymdhms; // starting date filter for results
1506
+ const startTime = this.iso8601(timestamp);
1507
+ request['startTime'] = startTime; // starting date filter for results
1508
1508
  }
1509
1509
  else {
1510
1510
  request['reverse'] = true;
@@ -2614,12 +2614,9 @@ export default class bitmex extends Exchange {
2614
2614
  throw new ArgumentsRequired(this.id + ' fetchDepositAddress requires params["network"]');
2615
2615
  }
2616
2616
  const currency = this.currency(code);
2617
- let currencyId = currency['id'];
2618
- const idLength = currencyId.length;
2619
- currencyId = currencyId.slice(0, idLength - 1) + currencyId.slice(idLength - 1, idLength).toLowerCase(); // make the last letter lowercase
2620
2617
  params = this.omit(params, 'network');
2621
2618
  const request = {
2622
- 'currency': currencyId,
2619
+ 'currency': currency['id'],
2623
2620
  'network': this.networkCodeToId(networkCode, currency['code']),
2624
2621
  };
2625
2622
  const response = await this.privateGetUserDepositAddress(this.extend(request, params));
package/js/src/bybit.js CHANGED
@@ -44,16 +44,16 @@ export default class bybit extends Exchange {
44
44
  'createMarketSellOrderWithCost': false,
45
45
  'createOrder': true,
46
46
  'createOrders': true,
47
+ 'createOrderWithTakeProfitAndStopLoss': true,
47
48
  'createPostOnlyOrder': true,
48
49
  'createReduceOnlyOrder': true,
49
50
  'createStopLimitOrder': true,
51
+ 'createStopLossOrder': true,
50
52
  'createStopMarketOrder': true,
51
53
  'createStopOrder': true,
54
+ 'createTakeProfitOrder': true,
52
55
  'createTrailingAmountOrder': true,
53
56
  'createTriggerOrder': true,
54
- 'createTakeProfitOrder': true,
55
- 'createStopLossOrder': true,
56
- 'createOrderWithTakeProfitAndStopLoss': true,
57
57
  'editOrder': true,
58
58
  'fetchBalance': true,
59
59
  'fetchBorrowInterest': false,
package/js/src/coinex.js CHANGED
@@ -51,12 +51,12 @@ export default class coinex extends Exchange {
51
51
  'createMarketBuyOrderWithCost': true,
52
52
  'createMarketOrderWithCost': false,
53
53
  'createMarketSellOrderWithCost': false,
54
- 'createTriggerOrder': true,
55
- 'createTakeProfitOrder': true,
56
- 'createStopLossOrder': true,
57
54
  'createOrder': true,
58
55
  'createOrders': true,
59
56
  'createReduceOnlyOrder': true,
57
+ 'createStopLossOrder': true,
58
+ 'createTakeProfitOrder': true,
59
+ 'createTriggerOrder': true,
60
60
  'editOrder': true,
61
61
  'fetchBalance': true,
62
62
  'fetchBorrowInterest': true,
package/js/src/coinone.js CHANGED
@@ -79,7 +79,7 @@ export default class coinone extends Exchange {
79
79
  'setLeverage': false,
80
80
  'setMarginMode': false,
81
81
  'setPositionMode': false,
82
- 'ws': false,
82
+ 'ws': true,
83
83
  },
84
84
  'urls': {
85
85
  'logo': 'https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg',
package/js/src/gate.js CHANGED
@@ -92,11 +92,11 @@ export default class gate extends Exchange {
92
92
  'createPostOnlyOrder': true,
93
93
  'createReduceOnlyOrder': true,
94
94
  'createStopLimitOrder': true,
95
- 'createStopMarketOrder': false,
96
- 'createTriggerOrder': true,
97
- 'createTakeProfitOrder': true,
98
95
  'createStopLossOrder': true,
96
+ 'createStopMarketOrder': false,
99
97
  'createStopOrder': true,
98
+ 'createTakeProfitOrder': true,
99
+ 'createTriggerOrder': true,
100
100
  'editOrder': true,
101
101
  'fetchBalance': true,
102
102
  'fetchBorrowRateHistories': false,
package/js/src/htx.js CHANGED
@@ -48,12 +48,12 @@ export default class htx extends Exchange {
48
48
  'createOrders': true,
49
49
  'createReduceOnlyOrder': false,
50
50
  'createStopLimitOrder': true,
51
+ 'createStopLossOrder': true,
51
52
  'createStopMarketOrder': true,
52
53
  'createStopOrder': true,
54
+ 'createTakeProfitOrder': true,
53
55
  'createTrailingPercentOrder': true,
54
56
  'createTriggerOrder': true,
55
- 'createTakeProfitOrder': true,
56
- 'createStopLossOrder': true,
57
57
  'fetchAccounts': true,
58
58
  'fetchBalance': true,
59
59
  'fetchBidsAsks': undefined,
@@ -66,6 +66,7 @@ export default class kraken extends Exchange {
66
66
  findMarketByAltnameOrId(id: any): any;
67
67
  getDelistedMarketById(id: any): any;
68
68
  parseOrderStatus(status: any): string;
69
+ parseOrderType(status: any): string;
69
70
  parseOrder(order: any, market?: Market): Order;
70
71
  orderRequest(method: any, symbol: any, type: any, request: any, price?: any, params?: {}): any[];
71
72
  editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
package/js/src/kraken.js CHANGED
@@ -1441,6 +1441,16 @@ export default class kraken extends Exchange {
1441
1441
  };
1442
1442
  return this.safeString(statuses, status, status);
1443
1443
  }
1444
+ parseOrderType(status) {
1445
+ const statuses = {
1446
+ 'take-profit': 'market',
1447
+ 'stop-loss-limit': 'limit',
1448
+ 'stop-loss': 'market',
1449
+ 'take-profit-limit': 'limit',
1450
+ 'trailing-stop-limit': 'limit',
1451
+ };
1452
+ return this.safeString(statuses, status, status);
1453
+ }
1444
1454
  parseOrder(order, market = undefined) {
1445
1455
  //
1446
1456
  // createOrder for regular orders
@@ -1583,7 +1593,17 @@ export default class kraken extends Exchange {
1583
1593
  trades.push(rawTrade);
1584
1594
  }
1585
1595
  }
1586
- stopPrice = this.safeNumber(order, 'stopprice', stopPrice);
1596
+ stopPrice = this.omitZero(this.safeString(order, 'stopprice', stopPrice));
1597
+ let stopLossPrice = undefined;
1598
+ let takeProfitPrice = undefined;
1599
+ if (type.startsWith('take-profit')) {
1600
+ takeProfitPrice = this.safeString(description, 'price');
1601
+ price = this.omitZero(this.safeString(description, 'price2'));
1602
+ }
1603
+ else if (type.startsWith('stop-loss')) {
1604
+ stopLossPrice = this.safeString(description, 'price');
1605
+ price = this.omitZero(this.safeString(description, 'price2'));
1606
+ }
1587
1607
  return this.safeOrder({
1588
1608
  'id': id,
1589
1609
  'clientOrderId': clientOrderId,
@@ -1593,13 +1613,15 @@ export default class kraken extends Exchange {
1593
1613
  'lastTradeTimestamp': undefined,
1594
1614
  'status': status,
1595
1615
  'symbol': symbol,
1596
- 'type': type,
1616
+ 'type': this.parseOrderType(type),
1597
1617
  'timeInForce': undefined,
1598
1618
  'postOnly': isPostOnly,
1599
1619
  'side': side,
1600
1620
  'price': price,
1601
1621
  'stopPrice': stopPrice,
1602
1622
  'triggerPrice': stopPrice,
1623
+ 'takeProfitPrice': takeProfitPrice,
1624
+ 'stopLossPrice': stopLossPrice,
1603
1625
  'cost': undefined,
1604
1626
  'amount': amount,
1605
1627
  'filled': filled,
package/js/src/kucoin.js CHANGED
@@ -49,8 +49,8 @@ export default class kucoin extends Exchange {
49
49
  'createPostOnlyOrder': true,
50
50
  'createStopLimitOrder': true,
51
51
  'createStopMarketOrder': true,
52
- 'createTriggerOrder': true,
53
52
  'createStopOrder': true,
53
+ 'createTriggerOrder': true,
54
54
  'editOrder': true,
55
55
  'fetchAccounts': true,
56
56
  'fetchBalance': true,
@@ -39,11 +39,11 @@ export default class kucoinfutures extends kucoin {
39
39
  'createOrders': true,
40
40
  'createReduceOnlyOrder': true,
41
41
  'createStopLimitOrder': true,
42
+ 'createStopLossOrder': true,
42
43
  'createStopMarketOrder': true,
43
44
  'createStopOrder': true,
44
- 'createTriggerOrder': true,
45
45
  'createTakeProfitOrder': true,
46
- 'createStopLossOrder': true,
46
+ 'createTriggerOrder': true,
47
47
  'fetchAccounts': true,
48
48
  'fetchBalance': true,
49
49
  'fetchBorrowRateHistories': false,
package/js/src/okx.js CHANGED
@@ -46,8 +46,8 @@ export default class okx extends Exchange {
46
46
  'createOrderWithTakeProfitAndStopLoss': true,
47
47
  'createPostOnlyOrder': true,
48
48
  'createReduceOnlyOrder': true,
49
- 'createStopLossOrder': true,
50
49
  'createStopLimitOrder': true,
50
+ 'createStopLossOrder': true,
51
51
  'createStopMarketOrder': true,
52
52
  'createStopOrder': true,
53
53
  'createTakeProfitOrder': true,
package/js/src/phemex.js CHANGED
@@ -2979,12 +2979,14 @@ export default class phemex extends Exchange {
2979
2979
  * @description fetch all unfilled currently open orders
2980
2980
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#queryopenorder
2981
2981
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md
2982
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#spotListAllOpenOrder
2982
2983
  * @param {string} symbol unified market symbol
2983
2984
  * @param {int} [since] the earliest time in ms to fetch open orders for
2984
2985
  * @param {int} [limit] the maximum number of open order structures to retrieve
2985
2986
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2986
2987
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2987
2988
  */
2989
+ await this.loadMarkets();
2988
2990
  if (symbol === undefined) {
2989
2991
  throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
2990
2992
  }
@@ -3026,20 +3028,25 @@ export default class phemex extends Exchange {
3026
3028
  * @name phemex#fetchClosedOrders
3027
3029
  * @description fetches information on multiple closed orders made by the user
3028
3030
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#queryorder
3031
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#queryorder
3032
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedgedd-Perpetual-API.md#query-closed-orders-by-symbol
3033
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#spotDataOrdersByIds
3029
3034
  * @param {string} symbol unified market symbol of the market orders were made in
3030
3035
  * @param {int} [since] the earliest time in ms to fetch orders for
3031
3036
  * @param {int} [limit] the maximum number of order structures to retrieve
3032
3037
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3038
+ * @param {string} [params.settle] the settlement currency to fetch orders for
3033
3039
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3034
3040
  */
3035
- if (symbol === undefined) {
3036
- throw new ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
3037
- }
3038
3041
  await this.loadMarkets();
3039
- const market = this.market(symbol);
3040
- const request = {
3041
- 'symbol': market['id'],
3042
- };
3042
+ let market = undefined;
3043
+ if (symbol !== undefined) {
3044
+ market = this.market(symbol);
3045
+ }
3046
+ const request = {};
3047
+ if (market !== undefined) {
3048
+ request['symbol'] = market['id'];
3049
+ }
3043
3050
  if (since !== undefined) {
3044
3051
  request['start'] = since;
3045
3052
  }
@@ -3047,8 +3054,8 @@ export default class phemex extends Exchange {
3047
3054
  request['limit'] = limit;
3048
3055
  }
3049
3056
  let response = undefined;
3050
- if (market['settle'] === 'USDT') {
3051
- request['currency'] = market['settle'];
3057
+ if ((symbol === undefined) || (this.safeString(market, 'settle') === 'USDT')) {
3058
+ request['currency'] = this.safeString(params, 'settle', 'USDT');
3052
3059
  response = await this.privateGetExchangeOrderV2OrderList(this.extend(request, params));
3053
3060
  }
3054
3061
  else if (market['swap']) {
@@ -3109,23 +3116,25 @@ export default class phemex extends Exchange {
3109
3116
  * @description fetch all trades made by the user
3110
3117
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-user-trade
3111
3118
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-user-trade
3119
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#spotDataTradesHist
3112
3120
  * @param {string} symbol unified market symbol
3113
3121
  * @param {int} [since] the earliest time in ms to fetch trades for
3114
3122
  * @param {int} [limit] the maximum number of trades structures to retrieve
3115
3123
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3116
3124
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
3117
3125
  */
3118
- if (symbol === undefined) {
3119
- throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
3120
- }
3121
3126
  await this.loadMarkets();
3122
- const market = this.market(symbol);
3127
+ let market = undefined;
3128
+ if (symbol !== undefined) {
3129
+ market = this.market(symbol);
3130
+ }
3123
3131
  const request = {};
3124
3132
  if (limit !== undefined) {
3125
3133
  limit = Math.min(200, limit);
3126
3134
  request['limit'] = limit;
3127
3135
  }
3128
- if (market['settle'] === 'USDT') {
3136
+ const isUSDTSettled = (symbol === undefined) || (this.safeString(market, 'settle') === 'USDT');
3137
+ if (isUSDTSettled) {
3129
3138
  request['currency'] = 'USDT';
3130
3139
  request['offset'] = 0;
3131
3140
  if (limit === undefined) {
@@ -3138,18 +3147,12 @@ export default class phemex extends Exchange {
3138
3147
  if (since !== undefined) {
3139
3148
  request['start'] = since;
3140
3149
  }
3141
- if (market['swap'] && (limit !== undefined)) {
3142
- request['limit'] = limit;
3143
- }
3144
- const isUSDTSettled = market['settle'] === 'USDT';
3145
3150
  let response = undefined;
3146
- if (market['swap']) {
3147
- if (isUSDTSettled) {
3148
- response = await this.privateGetExchangeOrderV2TradingList(this.extend(request, params));
3149
- }
3150
- else {
3151
- response = await this.privateGetExchangeOrderTrade(this.extend(request, params));
3152
- }
3151
+ if (isUSDTSettled) {
3152
+ response = await this.privateGetExchangeOrderV2TradingList(this.extend(request, params));
3153
+ }
3154
+ else if (market['swap']) {
3155
+ response = await this.privateGetExchangeOrderTrade(this.extend(request, params));
3153
3156
  }
3154
3157
  else {
3155
3158
  response = await this.privateGetExchangeSpotOrderTrades(this.extend(request, params));