ccxt 4.4.74 → 4.4.77

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 (65) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +16 -9
  5. package/dist/cjs/src/binance.js +43 -219
  6. package/dist/cjs/src/bitget.js +1 -1
  7. package/dist/cjs/src/bitopro.js +37 -0
  8. package/dist/cjs/src/bitrue.js +48 -0
  9. package/dist/cjs/src/coinex.js +3 -0
  10. package/dist/cjs/src/coinlist.js +90 -1
  11. package/dist/cjs/src/okx.js +47 -33
  12. package/dist/cjs/src/paradex.js +3 -12
  13. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  14. package/dist/cjs/src/upbit.js +64 -46
  15. package/dist/cjs/src/xt.js +122 -4
  16. package/js/ccxt.d.ts +1 -1
  17. package/js/ccxt.js +1 -1
  18. package/js/src/abstract/coinlist.d.ts +3 -0
  19. package/js/src/abstract/myokx.d.ts +4 -0
  20. package/js/src/abstract/okx.d.ts +4 -0
  21. package/js/src/abstract/upbit.d.ts +15 -1
  22. package/js/src/abstract/xt.d.ts +3 -0
  23. package/js/src/base/Exchange.d.ts +1 -0
  24. package/js/src/base/Exchange.js +16 -9
  25. package/js/src/binance.d.ts +2 -0
  26. package/js/src/binance.js +43 -219
  27. package/js/src/bitget.js +1 -1
  28. package/js/src/bitopro.js +37 -0
  29. package/js/src/bitrue.js +48 -0
  30. package/js/src/coinex.js +3 -0
  31. package/js/src/coinlist.d.ts +12 -1
  32. package/js/src/coinlist.js +90 -1
  33. package/js/src/okx.js +47 -33
  34. package/js/src/paradex.js +3 -12
  35. package/js/src/pro/hyperliquid.js +1 -1
  36. package/js/src/upbit.js +64 -46
  37. package/js/src/xt.d.ts +19 -0
  38. package/js/src/xt.js +122 -4
  39. package/package.json +1 -1
  40. package/js/src/abstract/bitcoincom.d.ts +0 -118
  41. package/js/src/abstract/bitcoincom.js +0 -11
  42. package/js/src/abstract/bitfinex1.d.ts +0 -72
  43. package/js/src/abstract/bitfinex1.js +0 -11
  44. package/js/src/abstract/bitpanda.d.ts +0 -26
  45. package/js/src/abstract/bitpanda.js +0 -5
  46. package/js/src/abstract/poloniexfutures.d.ts +0 -51
  47. package/js/src/abstract/poloniexfutures.js +0 -11
  48. package/js/src/abstract/wazirx.d.ts +0 -33
  49. package/js/src/abstract/wazirx.js +0 -11
  50. package/js/src/bitcoincom.d.ts +0 -4
  51. package/js/src/bitcoincom.js +0 -18
  52. package/js/src/bitpanda.d.ts +0 -4
  53. package/js/src/bitpanda.js +0 -17
  54. package/js/src/poloniexfutures.d.ts +0 -321
  55. package/js/src/poloniexfutures.js +0 -1941
  56. package/js/src/pro/bitcoincom.d.ts +0 -4
  57. package/js/src/pro/bitcoincom.js +0 -34
  58. package/js/src/pro/bitpanda.d.ts +0 -4
  59. package/js/src/pro/bitpanda.js +0 -17
  60. package/js/src/pro/poloniexfutures.d.ts +0 -108
  61. package/js/src/pro/poloniexfutures.js +0 -1042
  62. package/js/src/pro/wazirx.d.ts +0 -102
  63. package/js/src/pro/wazirx.js +0 -784
  64. package/js/src/static_dependencies/starknet/utils/json.d.ts +0 -24
  65. package/js/src/static_dependencies/starknet/utils/json.js +0 -43
@@ -63,7 +63,7 @@ class coinlist extends coinlist$1 {
63
63
  'fetchDepositWithdrawFee': false,
64
64
  'fetchDepositWithdrawFees': false,
65
65
  'fetchFundingHistory': false,
66
- 'fetchFundingRate': false,
66
+ 'fetchFundingRate': true,
67
67
  'fetchFundingRateHistory': false,
68
68
  'fetchFundingRates': false,
69
69
  'fetchIndexOHLCV': false,
@@ -155,6 +155,7 @@ class coinlist extends coinlist$1 {
155
155
  'v1/leaderboard': 1,
156
156
  'v1/affiliate/{competition_code}': 1,
157
157
  'v1/competition/{competition_id}': 1,
158
+ 'v1/symbols/{symbol}/funding': 1,
158
159
  },
159
160
  },
160
161
  'private': {
@@ -178,6 +179,7 @@ class coinlist extends coinlist$1 {
178
179
  'v1/credits': 1,
179
180
  'v1/positions': 1,
180
181
  'v1/accounts/{trader_id}/competitions': 1,
182
+ 'v1/closedPositions': 1,
181
183
  },
182
184
  'post': {
183
185
  'v1/keys': 1,
@@ -196,6 +198,9 @@ class coinlist extends coinlist$1 {
196
198
  'v1/orders/{order_id}': 1,
197
199
  'v1/orders/bulk': 1, // not unified
198
200
  },
201
+ 'put': {
202
+ 'v1/accounts/{trader_id}/alias': 1,
203
+ },
199
204
  'delete': {
200
205
  'v1/keys/{key}': 1,
201
206
  'v1/orders': 1,
@@ -2454,6 +2459,90 @@ class coinlist extends coinlist$1 {
2454
2459
  };
2455
2460
  return this.safeString(types, type, type);
2456
2461
  }
2462
+ /**
2463
+ * @method
2464
+ * @name coinlist#fetchFundingRate
2465
+ * @description fetch the current funding rate
2466
+ * @see https://trade-docs.coinlist.co/#coinlist-pro-api-Funding-Rates
2467
+ * @param {string} symbol unified market symbol
2468
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2469
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2470
+ */
2471
+ async fetchFundingRate(symbol, params = {}) {
2472
+ await this.loadMarkets();
2473
+ const market = this.market(symbol);
2474
+ if (!market['swap']) {
2475
+ throw new errors.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
2476
+ }
2477
+ const request = {
2478
+ 'symbol': market['id'],
2479
+ };
2480
+ const response = await this.publicGetV1SymbolsSymbolFunding(this.extend(request, params));
2481
+ //
2482
+ // {
2483
+ // "last": {
2484
+ // "funding_rate": "-0.00043841",
2485
+ // "funding_time": "2025-04-15T04:00:00.000Z"
2486
+ // },
2487
+ // "next": {
2488
+ // "funding_rate": "-0.00046952",
2489
+ // "funding_time": "2025-04-15T12:00:00.000Z"
2490
+ // },
2491
+ // "indicative": {
2492
+ // "funding_rate": "-0.00042517",
2493
+ // "funding_time": "2025-04-15T20:00:00.000Z"
2494
+ // },
2495
+ // "timestamp": "2025-04-15T07:01:15.219Z"
2496
+ // }
2497
+ //
2498
+ return this.parseFundingRate(response, market);
2499
+ }
2500
+ parseFundingRate(contract, market = undefined) {
2501
+ //
2502
+ // {
2503
+ // "last": {
2504
+ // "funding_rate": "-0.00043841",
2505
+ // "funding_time": "2025-04-15T04:00:00.000Z"
2506
+ // },
2507
+ // "next": {
2508
+ // "funding_rate": "-0.00046952",
2509
+ // "funding_time": "2025-04-15T12:00:00.000Z"
2510
+ // },
2511
+ // "indicative": {
2512
+ // "funding_rate": "-0.00042517",
2513
+ // "funding_time": "2025-04-15T20:00:00.000Z"
2514
+ // },
2515
+ // "timestamp": "2025-04-15T07:01:15.219Z"
2516
+ // }
2517
+ //
2518
+ const previous = this.safeDict(contract, 'last', {});
2519
+ const current = this.safeDict(contract, 'next', {});
2520
+ const next = this.safeDict(contract, 'indicative', {});
2521
+ const previousDatetime = this.safeString(previous, 'funding_time');
2522
+ const currentDatetime = this.safeString(current, 'funding_time');
2523
+ const nextDatetime = this.safeString(next, 'funding_time');
2524
+ const datetime = this.safeString(contract, 'timestamp');
2525
+ return {
2526
+ 'info': contract,
2527
+ 'symbol': this.safeSymbol(undefined, market),
2528
+ 'markPrice': undefined,
2529
+ 'indexPrice': undefined,
2530
+ 'interestRate': undefined,
2531
+ 'estimatedSettlePrice': undefined,
2532
+ 'timestamp': this.parse8601(datetime),
2533
+ 'datetime': datetime,
2534
+ 'fundingRate': this.safeNumber(current, 'funding_rate'),
2535
+ 'fundingTimestamp': this.parse8601(currentDatetime),
2536
+ 'fundingDatetime': currentDatetime,
2537
+ 'nextFundingRate': this.safeNumber(next, 'funding_rate'),
2538
+ 'nextFundingTimestamp': this.parse8601(nextDatetime),
2539
+ 'nextFundingDatetime': nextDatetime,
2540
+ 'previousFundingRate': this.safeNumber(previous, 'funding_rate'),
2541
+ 'previousFundingTimestamp': this.parse8601(previousDatetime),
2542
+ 'previousFundingDatetime': previousDatetime,
2543
+ 'interval': '8h',
2544
+ };
2545
+ }
2457
2546
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2458
2547
  const request = this.omit(params, this.extractParams(path));
2459
2548
  const endpoint = '/' + this.implodeParams(path, params);
@@ -372,6 +372,7 @@ class okx extends okx$1 {
372
372
  'asset/subaccount/managed-subaccount-bills': 5 / 3,
373
373
  'users/entrust-subaccount-list': 10,
374
374
  'account/subaccount/interest-limits': 4,
375
+ 'users/subaccount/apikey': 10,
375
376
  // grid trading
376
377
  'tradingBot/grid/orders-algo-pending': 1,
377
378
  'tradingBot/grid/orders-algo-history': 1,
@@ -504,6 +505,9 @@ class okx extends okx$1 {
504
505
  'asset/subaccount/transfer': 10,
505
506
  'users/subaccount/set-transfer-out': 10,
506
507
  'account/subaccount/set-loan-allocation': 4,
508
+ 'users/subaccount/create-subaccount': 10,
509
+ 'users/subaccount/subaccount-apikey': 10,
510
+ 'users/subaccount/delete-apikey': 10,
507
511
  // grid trading
508
512
  'tradingBot/grid/order-algo': 1,
509
513
  'tradingBot/grid/amend-order-algo': 1,
@@ -914,6 +918,11 @@ class okx extends okx$1 {
914
918
  '59506': errors.ExchangeError,
915
919
  '59507': errors.ExchangeError,
916
920
  '59508': errors.AccountSuspended,
921
+ '59515': errors.ExchangeError,
922
+ '59516': errors.ExchangeError,
923
+ '59517': errors.ExchangeError,
924
+ '59518': errors.ExchangeError,
925
+ '59519': errors.ExchangeError,
917
926
  '59642': errors.BadRequest,
918
927
  '59643': errors.ExchangeError,
919
928
  // WebSocket error Codes from 60000-63999
@@ -1596,8 +1605,8 @@ class okx extends okx$1 {
1596
1605
  const swap = (type === 'swap');
1597
1606
  const option = (type === 'option');
1598
1607
  const contract = swap || future || option;
1599
- let baseId = this.safeString(market, 'baseCcy');
1600
- let quoteId = this.safeString(market, 'quoteCcy');
1608
+ let baseId = this.safeString(market, 'baseCcy', ''); // defaulting to '' because some weird preopen markets have empty baseId
1609
+ let quoteId = this.safeString(market, 'quoteCcy', '');
1601
1610
  const settleId = this.safeString(market, 'settleCcy');
1602
1611
  const settle = this.safeCurrencyCode(settleId);
1603
1612
  const underlying = this.safeString(market, 'uly');
@@ -1613,19 +1622,25 @@ class okx extends okx$1 {
1613
1622
  let strikePrice = undefined;
1614
1623
  let optionType = undefined;
1615
1624
  if (contract) {
1616
- symbol = symbol + ':' + settle;
1625
+ if (settle !== undefined) {
1626
+ symbol = symbol + ':' + settle;
1627
+ }
1617
1628
  if (future) {
1618
1629
  expiry = this.safeInteger(market, 'expTime');
1619
- const ymd = this.yymmdd(expiry);
1620
- symbol = symbol + '-' + ymd;
1630
+ if (expiry !== undefined) {
1631
+ const ymd = this.yymmdd(expiry);
1632
+ symbol = symbol + '-' + ymd;
1633
+ }
1621
1634
  }
1622
1635
  else if (option) {
1623
1636
  expiry = this.safeInteger(market, 'expTime');
1624
1637
  strikePrice = this.safeString(market, 'stk');
1625
1638
  optionType = this.safeString(market, 'optType');
1626
- const ymd = this.yymmdd(expiry);
1627
- symbol = symbol + '-' + ymd + '-' + strikePrice + '-' + optionType;
1628
- optionType = (optionType === 'P') ? 'put' : 'call';
1639
+ if (expiry !== undefined) {
1640
+ const ymd = this.yymmdd(expiry);
1641
+ symbol = symbol + '-' + ymd + '-' + strikePrice + '-' + optionType;
1642
+ optionType = (optionType === 'P') ? 'put' : 'call';
1643
+ }
1629
1644
  }
1630
1645
  }
1631
1646
  const tickSize = this.safeString(market, 'tickSz');
@@ -1821,33 +1836,32 @@ class okx extends okx$1 {
1821
1836
  const chainsLength = chains.length;
1822
1837
  for (let j = 0; j < chainsLength; j++) {
1823
1838
  const chain = chains[j];
1824
- const networkId = this.safeString(chain, 'chain'); // USDT-BEP20, USDT-Avalance-C, etc
1825
- if (networkId !== undefined) {
1826
- const idParts = networkId.split('-');
1827
- const parts = this.arraySlice(idParts, 1);
1828
- const chainPart = parts.join('-');
1829
- const networkCode = this.networkIdToCode(chainPart, currency['code']);
1830
- networks[networkCode] = {
1831
- 'id': networkId,
1832
- 'network': networkCode,
1833
- 'active': undefined,
1834
- 'deposit': this.safeBool(chain, 'canDep'),
1835
- 'withdraw': this.safeBool(chain, 'canWd'),
1836
- 'fee': this.safeNumber(chain, 'fee'),
1837
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'wdTickSz'))),
1838
- 'limits': {
1839
- 'withdraw': {
1840
- 'min': this.safeNumber(chain, 'minWd'),
1841
- 'max': this.safeNumber(chain, 'maxWd'),
1842
- },
1843
- },
1844
- 'info': chain,
1845
- };
1846
- }
1847
- else {
1848
- // only happens for FIAT currency
1839
+ // allow empty string for rare fiat-currencies, e.g. TRY
1840
+ const networkId = this.safeString(chain, 'chain', ''); // USDT-BEP20, USDT-Avalance-C, etc
1841
+ if (networkId === '') {
1842
+ // only happens for fiat 'TRY' currency
1849
1843
  type = 'fiat';
1850
1844
  }
1845
+ const idParts = networkId.split('-');
1846
+ const parts = this.arraySlice(idParts, 1);
1847
+ const chainPart = parts.join('-');
1848
+ const networkCode = this.networkIdToCode(chainPart, currency['code']);
1849
+ networks[networkCode] = {
1850
+ 'id': networkId,
1851
+ 'network': networkCode,
1852
+ 'active': undefined,
1853
+ 'deposit': this.safeBool(chain, 'canDep'),
1854
+ 'withdraw': this.safeBool(chain, 'canWd'),
1855
+ 'fee': this.safeNumber(chain, 'fee'),
1856
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'wdTickSz'))),
1857
+ 'limits': {
1858
+ 'withdraw': {
1859
+ 'min': this.safeNumber(chain, 'minWd'),
1860
+ 'max': this.safeNumber(chain, 'maxWd'),
1861
+ },
1862
+ },
1863
+ 'info': chain,
1864
+ };
1851
1865
  }
1852
1866
  const firstChain = this.safeDict(chains, 0, {});
1853
1867
  result[code] = this.safeCurrencyStructure({
@@ -707,18 +707,9 @@ class paradex extends paradex$1 {
707
707
  async fetchTickers(symbols = undefined, params = {}) {
708
708
  await this.loadMarkets();
709
709
  symbols = this.marketSymbols(symbols);
710
- const request = {};
711
- if (symbols !== undefined) {
712
- if (Array.isArray(symbols)) {
713
- request['market'] = this.marketId(symbols[0]);
714
- }
715
- else {
716
- request['market'] = this.marketId(symbols);
717
- }
718
- }
719
- else {
720
- request['market'] = 'ALL';
721
- }
710
+ const request = {
711
+ 'market': 'ALL',
712
+ };
722
713
  const response = await this.publicGetMarketsSummary(this.extend(request, params));
723
714
  //
724
715
  // {
@@ -617,7 +617,7 @@ class hyperliquid extends hyperliquid$1 {
617
617
  'datetime': this.iso8601(timestamp),
618
618
  'symbol': symbol,
619
619
  'id': id,
620
- 'order': undefined,
620
+ 'order': this.safeString(trade, 'oid'),
621
621
  'type': undefined,
622
622
  'side': side,
623
623
  'takerOrMaker': undefined,
@@ -21,7 +21,7 @@ class upbit extends upbit$1 {
21
21
  'name': 'Upbit',
22
22
  'countries': ['KR'],
23
23
  'version': 'v1',
24
- 'rateLimit': 1000,
24
+ 'rateLimit': 50,
25
25
  'pro': true,
26
26
  // new metainfo interface
27
27
  'has': {
@@ -76,6 +76,7 @@ class upbit extends upbit$1 {
76
76
  'withdraw': true,
77
77
  },
78
78
  'timeframes': {
79
+ '1s': 'seconds',
79
80
  '1m': 'minutes',
80
81
  '3m': 'minutes',
81
82
  '5m': 'minutes',
@@ -87,6 +88,7 @@ class upbit extends upbit$1 {
87
88
  '1d': 'days',
88
89
  '1w': 'weeks',
89
90
  '1M': 'months',
91
+ '1y': 'years',
90
92
  },
91
93
  'hostname': 'api.upbit.com',
92
94
  'urls': {
@@ -100,54 +102,70 @@ class upbit extends upbit$1 {
100
102
  'fees': 'https://upbit.com/service_center/guide',
101
103
  },
102
104
  'api': {
105
+ // 'endpoint','API Cost'
106
+ // cost = 1000 / (rateLimit * RPS)
103
107
  'public': {
104
- 'get': [
105
- 'market/all',
106
- 'candles/{timeframe}',
107
- 'candles/{timeframe}/{unit}',
108
- 'candles/minutes/{unit}',
109
- 'candles/minutes/1',
110
- 'candles/minutes/3',
111
- 'candles/minutes/5',
112
- 'candles/minutes/10',
113
- 'candles/minutes/15',
114
- 'candles/minutes/30',
115
- 'candles/minutes/60',
116
- 'candles/minutes/240',
117
- 'candles/days',
118
- 'candles/weeks',
119
- 'candles/months',
120
- 'trades/ticks',
121
- 'ticker',
122
- 'orderbook',
123
- ],
108
+ 'get': {
109
+ 'market/all': 2,
110
+ 'candles/{timeframe}': 2,
111
+ 'candles/{timeframe}/{unit}': 2,
112
+ 'candles/seconds': 2,
113
+ 'candles/minutes/{unit}': 2,
114
+ 'candles/minutes/1': 2,
115
+ 'candles/minutes/3': 2,
116
+ 'candles/minutes/5': 2,
117
+ 'candles/minutes/10': 2,
118
+ 'candles/minutes/15': 2,
119
+ 'candles/minutes/30': 2,
120
+ 'candles/minutes/60': 2,
121
+ 'candles/minutes/240': 2,
122
+ 'candles/days': 2,
123
+ 'candles/weeks': 2,
124
+ 'candles/months': 2,
125
+ 'candles/years': 2,
126
+ 'trades/ticks': 2,
127
+ 'ticker': 2,
128
+ 'ticker/all': 2,
129
+ 'orderbook': 2,
130
+ 'orderbook/supported_levels': 2, // Upbit KR only
131
+ },
124
132
  },
125
133
  'private': {
126
- 'get': [
127
- 'accounts',
128
- 'orders/chance',
129
- 'order',
130
- 'orders',
131
- 'orders/closed',
132
- 'orders/open',
133
- 'orders/uuids',
134
- 'withdraws',
135
- 'withdraw',
136
- 'withdraws/chance',
137
- 'deposits',
138
- 'deposit',
139
- 'deposits/coin_addresses',
140
- 'deposits/coin_address',
141
- ],
142
- 'post': [
143
- 'orders',
144
- 'withdraws/coin',
145
- 'withdraws/krw',
146
- 'deposits/generate_coin_address',
147
- ],
148
- 'delete': [
149
- 'order',
150
- ],
134
+ 'get': {
135
+ 'accounts': 0.67,
136
+ 'orders/chance': 0.67,
137
+ 'order': 0.67,
138
+ 'orders/closed': 0.67,
139
+ 'orders/open': 0.67,
140
+ 'orders/uuids': 0.67,
141
+ 'withdraws': 0.67,
142
+ 'withdraw': 0.67,
143
+ 'withdraws/chance': 0.67,
144
+ 'withdraws/coin_addresses': 0.67,
145
+ 'deposits': 0.67,
146
+ 'deposits/chance/coin': 0.67,
147
+ 'deposit': 0.67,
148
+ 'deposits/coin_addresses': 0.67,
149
+ 'deposits/coin_address': 0.67,
150
+ 'travel_rule/vasps': 0.67,
151
+ 'status/wallet': 0.67,
152
+ 'api_keys': 0.67, // Upbit KR only
153
+ },
154
+ 'post': {
155
+ 'orders': 2.5,
156
+ 'orders/cancel_and_new': 2.5,
157
+ 'withdraws/coin': 0.67,
158
+ 'withdraws/krw': 0.67,
159
+ 'deposits/krw': 0.67,
160
+ 'deposits/generate_coin_address': 0.67,
161
+ 'travel_rule/deposit/uuid': 0.67,
162
+ 'travel_rule/deposit/txid': 0.67, // RPS: 30, but each deposit can only be queried once every 10 minutes
163
+ },
164
+ 'delete': {
165
+ 'order': 0.67,
166
+ 'orders/open': 40,
167
+ 'orders/uuids': 0.67,
168
+ },
151
169
  },
152
170
  },
153
171
  'fees': {
@@ -44,7 +44,7 @@ class xt extends xt$1 {
44
44
  'createOrder': true,
45
45
  'createPostOnlyOrder': false,
46
46
  'createReduceOnlyOrder': true,
47
- 'editOrder': false,
47
+ 'editOrder': true,
48
48
  'fetchAccounts': false,
49
49
  'fetchBalance': true,
50
50
  'fetchBidsAsks': true,
@@ -231,6 +231,9 @@ class xt extends xt$1 {
231
231
  'open-order': 1,
232
232
  'order/{orderId}': 1,
233
233
  },
234
+ 'put': {
235
+ 'order/{orderId}': 1,
236
+ },
234
237
  },
235
238
  'linear': {
236
239
  'get': {
@@ -265,6 +268,7 @@ class xt extends xt$1 {
265
268
  'future/trade/v1/order/cancel-all': 1,
266
269
  'future/trade/v1/order/create': 1,
267
270
  'future/trade/v1/order/create-batch': 1,
271
+ 'future/trade/v1/order/update': 1,
268
272
  'future/user/v1/account/open': 1,
269
273
  'future/user/v1/position/adjust-leverage': 1,
270
274
  'future/user/v1/position/auto-margin': 1,
@@ -308,6 +312,7 @@ class xt extends xt$1 {
308
312
  'future/trade/v1/order/cancel-all': 1,
309
313
  'future/trade/v1/order/create': 1,
310
314
  'future/trade/v1/order/create-batch': 1,
315
+ 'future/trade/v1/order/update': 1,
311
316
  'future/user/v1/account/open': 1,
312
317
  'future/user/v1/position/adjust-leverage': 1,
313
318
  'future/user/v1/position/auto-margin': 1,
@@ -3509,7 +3514,7 @@ class xt extends xt$1 {
3509
3514
  // "cancelId": "208322474307982720"
3510
3515
  // }
3511
3516
  //
3512
- // swap and future: createOrder, cancelOrder
3517
+ // swap and future: createOrder, cancelOrder, editOrder
3513
3518
  //
3514
3519
  // {
3515
3520
  // "returnCode": 0,
@@ -3614,6 +3619,14 @@ class xt extends xt$1 {
3614
3619
  // "createdTime": 1681273420039
3615
3620
  // }
3616
3621
  //
3622
+ // spot editOrder
3623
+ //
3624
+ // {
3625
+ // "orderId": "484203027161892224",
3626
+ // "modifyId": "484203544105344000",
3627
+ // "clientModifyId": null
3628
+ // }
3629
+ //
3617
3630
  const marketId = this.safeString(order, 'symbol');
3618
3631
  const marketType = ('result' in order) || ('positionSide' in order) ? 'contract' : 'spot';
3619
3632
  market = this.safeMarket(marketId, market, undefined, marketType);
@@ -3627,7 +3640,7 @@ class xt extends xt$1 {
3627
3640
  return this.safeOrder({
3628
3641
  'info': order,
3629
3642
  'id': this.safeStringN(order, ['orderId', 'result', 'cancelId', 'entrustId', 'profitId']),
3630
- 'clientOrderId': this.safeString(order, 'clientOrderId'),
3643
+ 'clientOrderId': this.safeString2(order, 'clientOrderId', 'clientModifyId'),
3631
3644
  'timestamp': timestamp,
3632
3645
  'datetime': this.iso8601(timestamp),
3633
3646
  'lastTradeTimestamp': lastUpdatedTimestamp,
@@ -4908,6 +4921,108 @@ class xt extends xt$1 {
4908
4921
  //
4909
4922
  return response; // unify return type
4910
4923
  }
4924
+ /**
4925
+ * @method
4926
+ * @name xt#editOrder
4927
+ * @description cancels an order and places a new order
4928
+ * @see https://doc.xt.com/#orderorderUpdate
4929
+ * @see https://doc.xt.com/#futures_orderupdate
4930
+ * @see https://doc.xt.com/#futures_entrustupdateProfit
4931
+ * @param {string} id order id
4932
+ * @param {string} symbol unified symbol of the market to create an order in
4933
+ * @param {string} type 'market' or 'limit'
4934
+ * @param {string} side 'buy' or 'sell'
4935
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
4936
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4937
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4938
+ * @param {float} [params.stopLoss] price to set a stop-loss on an open position
4939
+ * @param {float} [params.takeProfit] price to set a take-profit on an open position
4940
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4941
+ */
4942
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4943
+ if (amount === undefined) {
4944
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an amount argument');
4945
+ }
4946
+ await this.loadMarkets();
4947
+ const market = this.market(symbol);
4948
+ const request = {};
4949
+ const stopLoss = this.safeNumber2(params, 'stopLoss', 'triggerStopPrice');
4950
+ const takeProfit = this.safeNumber2(params, 'takeProfit', 'triggerProfitPrice');
4951
+ params = this.omit(params, ['stopLoss', 'takeProfit']);
4952
+ const isStopLoss = (stopLoss !== undefined);
4953
+ const isTakeProfit = (takeProfit !== undefined);
4954
+ if (isStopLoss || isTakeProfit) {
4955
+ request['profitId'] = id;
4956
+ }
4957
+ else {
4958
+ request['orderId'] = id;
4959
+ request['price'] = this.priceToPrecision(symbol, price);
4960
+ }
4961
+ let response = undefined;
4962
+ if (market['swap']) {
4963
+ if (isStopLoss) {
4964
+ request['triggerStopPrice'] = this.priceToPrecision(symbol, stopLoss);
4965
+ }
4966
+ else if (takeProfit !== undefined) {
4967
+ request['triggerProfitPrice'] = this.priceToPrecision(symbol, takeProfit);
4968
+ }
4969
+ else {
4970
+ request['origQty'] = this.amountToPrecision(symbol, amount);
4971
+ }
4972
+ let subType = undefined;
4973
+ [subType, params] = this.handleSubTypeAndParams('editOrder', market, params);
4974
+ if (subType === 'inverse') {
4975
+ if (isStopLoss || isTakeProfit) {
4976
+ response = await this.privateInversePostFutureTradeV1EntrustUpdateProfitStop(this.extend(request, params));
4977
+ }
4978
+ else {
4979
+ response = await this.privateInversePostFutureTradeV1OrderUpdate(this.extend(request, params));
4980
+ //
4981
+ // {
4982
+ // "returnCode": 0,
4983
+ // "msgInfo": "success",
4984
+ // "error": null,
4985
+ // "result": "483869474947826752"
4986
+ // }
4987
+ //
4988
+ }
4989
+ }
4990
+ else {
4991
+ if (isStopLoss || isTakeProfit) {
4992
+ response = await this.privateLinearPostFutureTradeV1EntrustUpdateProfitStop(this.extend(request, params));
4993
+ }
4994
+ else {
4995
+ response = await this.privateLinearPostFutureTradeV1OrderUpdate(this.extend(request, params));
4996
+ //
4997
+ // {
4998
+ // "returnCode": 0,
4999
+ // "msgInfo": "success",
5000
+ // "error": null,
5001
+ // "result": "483869474947826752"
5002
+ // }
5003
+ //
5004
+ }
5005
+ }
5006
+ }
5007
+ else {
5008
+ request['quantity'] = this.amountToPrecision(symbol, amount);
5009
+ response = await this.privateSpotPutOrderOrderId(this.extend(request, params));
5010
+ //
5011
+ // {
5012
+ // "rc": 0,
5013
+ // "mc": "SUCCESS",
5014
+ // "ma": [],
5015
+ // "result": {
5016
+ // "orderId": "484203027161892224",
5017
+ // "modifyId": "484203544105344000",
5018
+ // "clientModifyId": null
5019
+ // }
5020
+ // }
5021
+ //
5022
+ }
5023
+ const result = (market['swap']) ? response : this.safeDict(response, 'result', {});
5024
+ return this.parseOrder(result, market);
5025
+ }
4911
5026
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
4912
5027
  //
4913
5028
  // spot: error
@@ -5012,7 +5127,10 @@ class xt extends xt$1 {
5012
5127
  body['media'] = id;
5013
5128
  }
5014
5129
  }
5015
- const isUndefinedBody = ((method === 'GET') || (path === 'order/{orderId}') || (path === 'ws-token'));
5130
+ let isUndefinedBody = ((method === 'GET') || (path === 'order/{orderId}') || (path === 'ws-token'));
5131
+ if ((method === 'PUT') && (endpoint === 'spot')) {
5132
+ isUndefinedBody = false;
5133
+ }
5016
5134
  body = isUndefinedBody ? undefined : this.json(body);
5017
5135
  let payloadString = undefined;
5018
5136
  if ((endpoint === 'spot') || (endpoint === 'user')) {
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 { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.73";
7
+ declare const version = "4.4.76";
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
@@ -32,7 +32,7 @@ import * as errors from './src/base/errors.js';
32
32
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
33
33
  //-----------------------------------------------------------------------------
34
34
  // this is updated by vss.js when building
35
- const version = '4.4.74';
35
+ const version = '4.4.76';
36
36
  Exchange.ccxtVersion = version;
37
37
  //-----------------------------------------------------------------------------
38
38
  import ace from './src/ace.js';