ccxt 4.5.48 → 4.5.50

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 (60) hide show
  1. package/README.md +7 -5
  2. package/dist/ccxt.browser.min.js +10 -10
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/weex.js +11 -0
  5. package/dist/cjs/src/base/Exchange.js +48 -13
  6. package/dist/cjs/src/bitget.js +1 -0
  7. package/dist/cjs/src/btcbox.js +1 -1
  8. package/dist/cjs/src/bullish.js +2 -1
  9. package/dist/cjs/src/gate.js +0 -1
  10. package/dist/cjs/src/hibachi.js +1 -1
  11. package/dist/cjs/src/kraken.js +1 -0
  12. package/dist/cjs/src/krakenfutures.js +10 -1
  13. package/dist/cjs/src/kucoin.js +5 -1
  14. package/dist/cjs/src/lighter.js +312 -144
  15. package/dist/cjs/src/mexc.js +7 -12
  16. package/dist/cjs/src/okx.js +46 -1
  17. package/dist/cjs/src/paradex.js +5 -2
  18. package/dist/cjs/src/pro/binance.js +1 -1
  19. package/dist/cjs/src/pro/cex.js +1 -1
  20. package/dist/cjs/src/pro/coinbase.js +1 -1
  21. package/dist/cjs/src/pro/hyperliquid.js +361 -1
  22. package/dist/cjs/src/pro/lighter.js +339 -18
  23. package/dist/cjs/src/pro/weex.js +1906 -0
  24. package/dist/cjs/src/weex.js +3823 -0
  25. package/js/ccxt.d.ts +8 -2
  26. package/js/ccxt.js +6 -2
  27. package/js/src/abstract/myokx.d.ts +34 -0
  28. package/js/src/abstract/okx.d.ts +34 -0
  29. package/js/src/abstract/okxus.d.ts +34 -0
  30. package/js/src/abstract/weex.d.ts +83 -0
  31. package/js/src/abstract/weex.js +11 -0
  32. package/js/src/base/Exchange.d.ts +5 -1
  33. package/js/src/base/Exchange.js +48 -13
  34. package/js/src/bitget.js +1 -0
  35. package/js/src/btcbox.js +1 -1
  36. package/js/src/bullish.js +2 -1
  37. package/js/src/gate.js +0 -1
  38. package/js/src/hibachi.js +1 -1
  39. package/js/src/kraken.js +1 -0
  40. package/js/src/krakenfutures.js +10 -1
  41. package/js/src/kucoin.d.ts +4 -0
  42. package/js/src/kucoin.js +5 -1
  43. package/js/src/lighter.d.ts +12 -2
  44. package/js/src/lighter.js +313 -145
  45. package/js/src/mexc.d.ts +2 -0
  46. package/js/src/mexc.js +7 -12
  47. package/js/src/okx.js +46 -1
  48. package/js/src/paradex.js +5 -2
  49. package/js/src/pro/binance.js +1 -1
  50. package/js/src/pro/cex.js +1 -1
  51. package/js/src/pro/coinbase.js +1 -1
  52. package/js/src/pro/hyperliquid.d.ts +48 -1
  53. package/js/src/pro/hyperliquid.js +362 -2
  54. package/js/src/pro/lighter.d.ts +37 -2
  55. package/js/src/pro/lighter.js +339 -18
  56. package/js/src/pro/weex.d.ts +330 -0
  57. package/js/src/pro/weex.js +1905 -0
  58. package/js/src/weex.d.ts +675 -0
  59. package/js/src/weex.js +3822 -0
  60. package/package.json +1 -1
package/js/src/mexc.d.ts CHANGED
@@ -177,6 +177,7 @@ export default class mexc extends Exchange {
177
177
  * @name mexc#createOrder
178
178
  * @description create a trade order
179
179
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
180
+ * @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints#place-order
180
181
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
181
182
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
182
183
  * @param {string} symbol unified symbol of the market to create an order in
@@ -223,6 +224,7 @@ export default class mexc extends Exchange {
223
224
  * @method
224
225
  * @name mexc#createSwapOrder
225
226
  * @description create a trade order
227
+ * @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints#place-order
226
228
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
227
229
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
228
230
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
package/js/src/mexc.js CHANGED
@@ -480,11 +480,6 @@ export default class mexc extends Exchange {
480
480
  'options': {
481
481
  'adjustForTimeDifference': false,
482
482
  'timeDifference': 0,
483
- 'unavailableContracts': {
484
- 'BTC/USDT:USDT': true,
485
- 'LTC/USDT:USDT': true,
486
- 'ETH/USDT:USDT': true,
487
- },
488
483
  'fetchMarkets': {
489
484
  'types': {
490
485
  'spot': true,
@@ -2306,6 +2301,7 @@ export default class mexc extends Exchange {
2306
2301
  * @name mexc#createOrder
2307
2302
  * @description create a trade order
2308
2303
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2304
+ * @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints#place-order
2309
2305
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
2310
2306
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
2311
2307
  * @param {string} symbol unified symbol of the market to create an order in
@@ -2463,6 +2459,7 @@ export default class mexc extends Exchange {
2463
2459
  * @method
2464
2460
  * @name mexc#createSwapOrder
2465
2461
  * @description create a trade order
2462
+ * @see https://www.mexc.com/api-docs/futures/account-and-trading-endpoints#place-order
2466
2463
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2467
2464
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
2468
2465
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
@@ -2488,11 +2485,6 @@ export default class mexc extends Exchange {
2488
2485
  async createSwapOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2489
2486
  await this.loadMarkets();
2490
2487
  const symbol = market['symbol'];
2491
- const unavailableContracts = this.safeValue(this.options, 'unavailableContracts', {});
2492
- const isContractUnavaiable = this.safeBool(unavailableContracts, symbol, false);
2493
- if (isContractUnavaiable) {
2494
- throw new NotSupported(this.id + ' createSwapOrder() does not support yet this symbol:' + symbol);
2495
- }
2496
2488
  let openType = undefined;
2497
2489
  if (marginMode !== undefined) {
2498
2490
  if (marginMode === 'cross') {
@@ -2563,14 +2555,17 @@ export default class mexc extends Exchange {
2563
2555
  if (hedged) {
2564
2556
  if (reduceOnly) {
2565
2557
  params = this.omit(params, 'reduceOnly'); // hedged mode does not accept this parameter
2566
- side = (side === 'buy') ? 'sell' : 'buy';
2558
+ sideInteger = (side === 'buy') ? 4 : 2; // close short, close long
2559
+ }
2560
+ else {
2561
+ sideInteger = (side === 'buy') ? 1 : 3;
2567
2562
  }
2568
- sideInteger = (side === 'buy') ? 1 : 3;
2569
2563
  request['positionMode'] = 1;
2570
2564
  }
2571
2565
  else {
2572
2566
  if (reduceOnly) {
2573
2567
  sideInteger = (side === 'buy') ? 2 : 4;
2568
+ params = this.omit(params, 'reduceOnly');
2574
2569
  }
2575
2570
  else {
2576
2571
  sideInteger = (side === 'buy') ? 1 : 3;
package/js/src/okx.js CHANGED
@@ -207,6 +207,7 @@ export default class okx extends Exchange {
207
207
  'market/option/instrument-family-trades': 1,
208
208
  'market/platform-24-volume': 10,
209
209
  'market/call-auction-detail': 1,
210
+ 'market/call-auction-details': 1,
210
211
  'market/books-sbe': 10,
211
212
  'market/block-tickers': 1,
212
213
  'market/block-ticker': 1,
@@ -247,6 +248,9 @@ export default class okx extends Exchange {
247
248
  'public/premium-history': 1,
248
249
  'public/economic-calendar': 50,
249
250
  'public/market-data-history': 4,
251
+ 'public/event-contract/events': 1,
252
+ 'public/event-contract/markets': 1,
253
+ 'public/event-contract/series': 1,
250
254
  'public/vip-interest-rate-loan-quota': 10,
251
255
  // rubik
252
256
  'rubik/stat/trading-data/support-coin': 4,
@@ -255,6 +259,7 @@ export default class okx extends Exchange {
255
259
  'rubik/stat/taker-volume-contract': 4,
256
260
  'rubik/stat/margin/loan-ratio': 4,
257
261
  'rubik/stat/contracts/long-short-account-ratio-contract-top-trader': 4,
262
+ 'rubik/stat/contracts/long-short-position-ratio-contract-top-trader': 4,
258
263
  'rubik/stat/contracts/long-short-account-ratio-contract': 4,
259
264
  'rubik/stat/contracts/long-short-account-ratio': 4,
260
265
  'rubik/stat/contracts/open-interest-volume': 4,
@@ -296,6 +301,7 @@ export default class okx extends Exchange {
296
301
  'copytrading/public-copy-traders': 4,
297
302
  'support/announcements': 4,
298
303
  'support/announcements-types': 20,
304
+ 'support/announcement-types': 20,
299
305
  },
300
306
  'post': {
301
307
  'tradingBot/grid/min-investment': 1, // public
@@ -362,6 +368,7 @@ export default class okx extends Exchange {
362
368
  'account/bills-archive': 4,
363
369
  'account/bills-history-archive': 2,
364
370
  'account/config': 4,
371
+ 'account/subtypes': 4,
365
372
  'account/max-size': 1,
366
373
  'account/max-avail-size': 1,
367
374
  'account/leverage-info': 1,
@@ -421,6 +428,11 @@ export default class okx extends Exchange {
421
428
  'tradingBot/recurring/orders-algo-history': 1,
422
429
  'tradingBot/recurring/orders-algo-details': 1,
423
430
  'tradingBot/recurring/sub-orders': 1,
431
+ 'tradingBot/dca/ongoing-list': 1,
432
+ 'tradingBot/dca/history-list': 1,
433
+ 'tradingBot/dca/orders': 1,
434
+ 'tradingBot/dca/position-details': 1,
435
+ 'tradingBot/dca/cycle-list': 1,
424
436
  // earn
425
437
  'finance/savings/balance': 5 / 3,
426
438
  'finance/savings/lending-history': 5 / 3,
@@ -470,6 +482,9 @@ export default class okx extends Exchange {
470
482
  'broker/nd/rebate-per-orders': 300,
471
483
  'finance/sfp/dcd/order': 2,
472
484
  'finance/sfp/dcd/orders': 2,
485
+ 'finance/sfp/dcd/currency-pair': 2,
486
+ 'finance/sfp/dcd/order-status': 2,
487
+ 'finance/sfp/dcd/order-history': 2,
473
488
  // affiliate
474
489
  'affiliate/invitee/detail': 1,
475
490
  'users/partner/if-rebate': 1,
@@ -540,6 +555,7 @@ export default class okx extends Exchange {
540
555
  'account/position-builder': 10,
541
556
  'account/position-builder-graph': 50,
542
557
  'account/set-riskOffset-type': 2,
558
+ 'account/set-riskOffset-amt': 2,
543
559
  'account/activate-option': 4,
544
560
  'account/set-auto-loan': 4,
545
561
  'account/account-level-switch-preset': 4,
@@ -566,6 +582,7 @@ export default class okx extends Exchange {
566
582
  'users/subaccount/set-transfer-out': 10,
567
583
  // grid trading
568
584
  'tradingBot/grid/order-algo': 1,
585
+ 'tradingBot/grid/copy-order-algo': 1,
569
586
  'tradingBot/grid/amend-algo-basic-param': 1,
570
587
  'tradingBot/grid/amend-order-algo': 1,
571
588
  'tradingBot/grid/stop-order-algo': 1,
@@ -589,6 +606,20 @@ export default class okx extends Exchange {
589
606
  'tradingBot/recurring/order-algo': 1,
590
607
  'tradingBot/recurring/amend-order-algo': 1,
591
608
  'tradingBot/recurring/stop-order-algo': 1,
609
+ 'tradingBot/dca/create': 1,
610
+ 'tradingBot/dca/amend-order-algo': 1,
611
+ 'tradingBot/dca/stop': 1,
612
+ 'tradingBot/dca/orders/manual-buy': 1,
613
+ 'tradingBot/dca/settings/reinvestment': 1,
614
+ 'tradingBot/dca/settings/take-profit': 1,
615
+ 'tradingBot/dca/margin/add': 1,
616
+ 'tradingBot/dca/margin/reduce': 1,
617
+ 'tradingBot/recurring/add-investment': 1,
618
+ 'tradingBot/recurring/amend-price-range': 1,
619
+ 'tradingBot/recurring/amend-recurring-amount': 1,
620
+ 'tradingBot/recurring/amend-recurring-time': 1,
621
+ 'tradingBot/recurring/pause': 1,
622
+ 'tradingBot/recurring/restart': 1,
592
623
  // earn
593
624
  'finance/savings/purchase-redempt': 5 / 3,
594
625
  'finance/savings/set-lending-rate': 5 / 3,
@@ -627,6 +658,9 @@ export default class okx extends Exchange {
627
658
  'broker/nd/rebate-per-orders': 36000,
628
659
  'finance/sfp/dcd/quote': 10,
629
660
  'finance/sfp/dcd/order': 10,
661
+ 'finance/sfp/dcd/trade': 10,
662
+ 'finance/sfp/dcd/redeem-quote': 10,
663
+ 'finance/sfp/dcd/redeem': 10,
630
664
  'broker/nd/report-subaccount-ip': 0.25,
631
665
  'broker/dma/subaccount/apikey': 1 / 4,
632
666
  'broker/dma/trades': 36000,
@@ -5780,6 +5814,16 @@ export default class okx extends Exchange {
5780
5814
  }
5781
5815
  const currencyId = this.safeString(transaction, 'ccy');
5782
5816
  const code = this.safeCurrencyCode(currencyId);
5817
+ let network = undefined;
5818
+ const chain = this.safeString(transaction, 'chain');
5819
+ if (chain !== undefined) {
5820
+ const chainParts = chain.split('-');
5821
+ const networkParts = this.arraySlice(chainParts, 1);
5822
+ const networkId = networkParts.join('-');
5823
+ if (networkId !== undefined) {
5824
+ network = this.networkIdToCode(networkId, code);
5825
+ }
5826
+ }
5783
5827
  const amount = this.safeNumber(transaction, 'amt');
5784
5828
  const status = this.parseTransactionStatus(this.safeString(transaction, 'state'));
5785
5829
  const txid = this.safeString(transaction, 'txId');
@@ -5797,7 +5841,7 @@ export default class okx extends Exchange {
5797
5841
  'id': id,
5798
5842
  'currency': code,
5799
5843
  'amount': amount,
5800
- 'network': undefined,
5844
+ 'network': network,
5801
5845
  'addressFrom': addressFrom,
5802
5846
  'addressTo': addressTo,
5803
5847
  'address': address,
@@ -6614,6 +6658,7 @@ export default class okx extends Exchange {
6614
6658
  parseFundingInterval(interval) {
6615
6659
  const intervals = {
6616
6660
  '3600000': '1h',
6661
+ '7200000': '2h',
6617
6662
  '14400000': '4h',
6618
6663
  '28800000': '8h',
6619
6664
  '57600000': '16h',
package/js/src/paradex.js CHANGED
@@ -545,7 +545,9 @@ export default class paradex extends Exchange {
545
545
  // }
546
546
  //
547
547
  const assetKind = this.safeString(market, 'asset_kind');
548
- const isOption = (assetKind === 'PERP_OPTION');
548
+ const isOptionPerpetual = (assetKind === 'PERP_OPTION');
549
+ const isOptionDelivery = (assetKind === 'OPTION');
550
+ const isOption = isOptionPerpetual || isOptionDelivery;
549
551
  const type = (isOption) ? 'option' : 'swap';
550
552
  const isSwap = (type === 'swap');
551
553
  const marketId = this.safeString(market, 'symbol');
@@ -563,7 +565,8 @@ export default class paradex extends Exchange {
563
565
  let makerFee = this.parseNumber('-0.00005');
564
566
  if (isOption) {
565
567
  const optionTypeSuffix = (optionType === 'CALL') ? 'C' : 'P';
566
- symbol = symbol + '-' + strikePrice + '-' + optionTypeSuffix;
568
+ const deliveryValue = (expiry === 0) ? '' : this.yymmdd(expiry) + '-';
569
+ symbol = symbol + '-' + deliveryValue + strikePrice + '-' + optionTypeSuffix;
567
570
  makerFee = this.parseNumber('0.0003');
568
571
  }
569
572
  else {
@@ -250,7 +250,7 @@ export default class binance extends binanceRest {
250
250
  return baseUrl;
251
251
  }
252
252
  getFutureWsCategory(channel) {
253
- if (channel === 'depth' || channel === 'rpiDepth' || channel === 'bookTicker' || channel === 'trade' || channel === 'aggTrade') {
253
+ if (channel === 'depth' || channel === 'rpiDepth' || channel === 'bookTicker' || channel === 'trade') {
254
254
  return 'public';
255
255
  }
256
256
  return 'market';
package/js/src/pro/cex.js CHANGED
@@ -884,7 +884,7 @@ export default class cex extends cexRest {
884
884
  // {
885
885
  // "e": "open-orders",
886
886
  // "data": [{
887
- // "id": "59098421630",
887
+ // "id": "59098421631",
888
888
  // "time": "1664062285425",
889
889
  // "type": "buy",
890
890
  // "price": "18920",
@@ -692,7 +692,7 @@ export default class coinbase extends coinbaseRest {
692
692
  const currentEvent = events[i];
693
693
  const currentTrades = this.safeList(currentEvent, 'trades');
694
694
  for (let j = 0; j < currentTrades.length; j++) {
695
- const item = currentTrades[i];
695
+ const item = currentTrades[j];
696
696
  tradesArray.append(this.parseTrade(item));
697
697
  }
698
698
  }
@@ -1,6 +1,6 @@
1
1
  import hyperliquidRest from '../hyperliquid.js';
2
2
  import Client from '../base/ws/Client.js';
3
- import { Int, Str, Market, OrderBook, Trade, OHLCV, Order, Dict, Strings, Ticker, Tickers, type Num, OrderType, OrderSide, type OrderRequest, Bool } from '../base/types.js';
3
+ import { Int, Str, Market, OrderBook, Trade, OHLCV, Order, Dict, Strings, Ticker, Tickers, type Num, OrderType, OrderSide, type OrderRequest, Bool, Balances, Position } from '../base/types.js';
4
4
  export default class hyperliquid extends hyperliquidRest {
5
5
  describe(): any;
6
6
  /**
@@ -214,6 +214,51 @@ export default class hyperliquid extends hyperliquidRest {
214
214
  unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
215
215
  handleOHLCV(client: Client, message: any): void;
216
216
  handleWsPost(client: Client, message: Dict): void;
217
+ /**
218
+ * @method
219
+ * @name hyperliquid#watchBalance
220
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
221
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
222
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
223
+ * @param {string} [params.dex] for for hip3 tokens subscription, eg: 'xyz' or 'flx'
224
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
225
+ */
226
+ watchBalance(params?: {}): Promise<Balances>;
227
+ /**
228
+ * @method
229
+ * @name hyperliquid#unWatchBalance
230
+ * @description unWatches balance
231
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
232
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
233
+ * @returns {object} status of the unwatch request
234
+ */
235
+ unWatchBalance(params?: {}): Promise<any>;
236
+ handleBalance(client: Client, message: any): void;
237
+ parseWsBalance(balance: any, accountType?: any): void;
238
+ /**
239
+ * @method
240
+ * @name hyperliquid#watchPositions
241
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
242
+ * @description watch all open positions
243
+ * @param {string[]} [symbols] list of unified market symbols
244
+ * @param {int} [since] the earliest time in ms to fetch positions for
245
+ * @param {int} [limit] the maximum number of positions to retrieve
246
+ * @param {object} params extra parameters specific to the exchange API endpoint
247
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
248
+ */
249
+ watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
250
+ setPositionsCache(client: Client, symbols?: Strings): void;
251
+ handlePositions(client: any, message: any): void;
252
+ /**
253
+ * @method
254
+ * @name hyperliquid#unWatchPositions
255
+ * @description unWatches all open positions
256
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
257
+ * @param {string[]} [symbols] list of unified market symbols
258
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
259
+ * @returns {object} status of the unwatch request
260
+ */
261
+ unWatchPositions(symbols?: Strings, params?: {}): Promise<any>;
217
262
  /**
218
263
  * @method
219
264
  * @name hyperliquid#watchOrders
@@ -246,6 +291,8 @@ export default class hyperliquid extends hyperliquidRest {
246
291
  handleOHLCVUnsubscription(client: Client, subscription: Dict): void;
247
292
  handleOrderUnsubscription(client: Client, subscription: Dict): void;
248
293
  handleMyTradesUnsubscription(client: Client, subscription: Dict): void;
294
+ handlePositionsUnsubscription(client: Client, subscription: Dict): void;
295
+ handleSpotBalanceUnsubscription(client: Client, subscription: Dict): void;
249
296
  handleSubscriptionResponse(client: Client, message: any): void;
250
297
  handleMessage(client: Client, message: any): void;
251
298
  ping(client: Client): {