ccxt 4.4.24 → 4.4.26

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 (74) hide show
  1. package/README.md +6 -6
  2. package/dist/ccxt.browser.min.js +4 -4
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +257 -11
  5. package/dist/cjs/src/base/Exchange.js +14 -1
  6. package/dist/cjs/src/binance.js +2 -3
  7. package/dist/cjs/src/bingx.js +7 -1
  8. package/dist/cjs/src/bitget.js +2 -2
  9. package/dist/cjs/src/bitmart.js +3 -3
  10. package/dist/cjs/src/bitmex.js +8 -7
  11. package/dist/cjs/src/bybit.js +3 -14
  12. package/dist/cjs/src/cex.js +40 -0
  13. package/dist/cjs/src/coinex.js +48 -29
  14. package/dist/cjs/src/digifinex.js +2 -2
  15. package/dist/cjs/src/exmo.js +1 -0
  16. package/dist/cjs/src/gate.js +3 -3
  17. package/dist/cjs/src/hitbtc.js +6 -12
  18. package/dist/cjs/src/htx.js +18 -19
  19. package/dist/cjs/src/hyperliquid.js +14 -4
  20. package/dist/cjs/src/kucoin.js +2 -2
  21. package/dist/cjs/src/okx.js +3 -2
  22. package/dist/cjs/src/phemex.js +4 -2
  23. package/dist/cjs/src/pro/exmo.js +216 -3
  24. package/dist/cjs/src/whitebit.js +2 -2
  25. package/dist/cjs/src/woofipro.js +1 -1
  26. package/dist/cjs/src/xt.js +44 -28
  27. package/js/ccxt.d.ts +1 -1
  28. package/js/ccxt.js +1 -1
  29. package/js/src/abstract/alpaca.d.ts +1 -0
  30. package/js/src/abstract/bingx.d.ts +1 -0
  31. package/js/src/abstract/okx.d.ts +1 -0
  32. package/js/src/abstract/phemex.d.ts +1 -0
  33. package/js/src/alpaca.d.ts +6 -1
  34. package/js/src/alpaca.js +258 -12
  35. package/js/src/base/Exchange.d.ts +7 -6
  36. package/js/src/base/Exchange.js +14 -1
  37. package/js/src/base/types.d.ts +3 -3
  38. package/js/src/binance.d.ts +3 -14
  39. package/js/src/binance.js +2 -3
  40. package/js/src/bingx.js +7 -1
  41. package/js/src/bitget.d.ts +3 -13
  42. package/js/src/bitget.js +2 -2
  43. package/js/src/bitmart.d.ts +3 -13
  44. package/js/src/bitmart.js +3 -3
  45. package/js/src/bitmex.js +8 -7
  46. package/js/src/bybit.d.ts +3 -14
  47. package/js/src/bybit.js +3 -14
  48. package/js/src/cex.d.ts +2 -0
  49. package/js/src/cex.js +40 -0
  50. package/js/src/coinex.d.ts +3 -15
  51. package/js/src/coinex.js +48 -29
  52. package/js/src/digifinex.d.ts +3 -13
  53. package/js/src/digifinex.js +2 -2
  54. package/js/src/exmo.js +1 -0
  55. package/js/src/gate.d.ts +3 -13
  56. package/js/src/gate.js +3 -3
  57. package/js/src/hitbtc.d.ts +0 -1
  58. package/js/src/hitbtc.js +6 -12
  59. package/js/src/htx.d.ts +3 -14
  60. package/js/src/htx.js +18 -19
  61. package/js/src/hyperliquid.js +14 -4
  62. package/js/src/kucoin.d.ts +3 -13
  63. package/js/src/kucoin.js +2 -2
  64. package/js/src/okx.d.ts +3 -13
  65. package/js/src/okx.js +3 -2
  66. package/js/src/phemex.js +4 -2
  67. package/js/src/pro/exmo.d.ts +5 -1
  68. package/js/src/pro/exmo.js +216 -3
  69. package/js/src/whitebit.d.ts +3 -13
  70. package/js/src/whitebit.js +2 -2
  71. package/js/src/woo.d.ts +1 -1
  72. package/js/src/woofipro.js +1 -1
  73. package/js/src/xt.js +44 -28
  74. package/package.json +1 -1
package/js/src/htx.js CHANGED
@@ -5256,17 +5256,17 @@ export default class htx extends Exchange {
5256
5256
  let orderType = type.replace('buy-', '');
5257
5257
  orderType = orderType.replace('sell-', '');
5258
5258
  const options = this.safeValue(this.options, market['type'], {});
5259
- const stopPrice = this.safeString2(params, 'stopPrice', 'stop-price');
5260
- if (stopPrice === undefined) {
5259
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'stop-price']);
5260
+ if (triggerPrice === undefined) {
5261
5261
  const stopOrderTypes = this.safeValue(options, 'stopOrderTypes', {});
5262
5262
  if (orderType in stopOrderTypes) {
5263
- throw new ArgumentsRequired(this.id + ' createOrder() requires a stopPrice or a stop-price parameter for a stop order');
5263
+ throw new ArgumentsRequired(this.id + ' createOrder() requires a triggerPrice for a stop order');
5264
5264
  }
5265
5265
  }
5266
5266
  else {
5267
5267
  const defaultOperator = (side === 'sell') ? 'lte' : 'gte';
5268
5268
  const stopOperator = this.safeString(params, 'operator', defaultOperator);
5269
- request['stop-price'] = this.priceToPrecision(symbol, stopPrice);
5269
+ request['stop-price'] = this.priceToPrecision(symbol, triggerPrice);
5270
5270
  request['operator'] = stopOperator;
5271
5271
  if ((orderType === 'limit') || (orderType === 'limit-fok')) {
5272
5272
  orderType = 'stop-' + orderType;
@@ -5343,7 +5343,7 @@ export default class htx extends Exchange {
5343
5343
  if (orderType in limitOrderTypes) {
5344
5344
  request['price'] = this.priceToPrecision(symbol, price);
5345
5345
  }
5346
- params = this.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
5346
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
5347
5347
  return this.extend(request, params);
5348
5348
  }
5349
5349
  createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
@@ -5381,16 +5381,16 @@ export default class htx extends Exchange {
5381
5381
  else if (timeInForce === 'IOC') {
5382
5382
  type = 'ioc';
5383
5383
  }
5384
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
5384
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
5385
5385
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
5386
5386
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
5387
5387
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
5388
5388
  const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
5389
5389
  const isTrailingPercentOrder = trailingPercent !== undefined;
5390
- const isStop = triggerPrice !== undefined;
5390
+ const isTrigger = triggerPrice !== undefined;
5391
5391
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
5392
5392
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
5393
- if (isStop) {
5393
+ if (isTrigger) {
5394
5394
  const triggerType = this.safeString2(params, 'triggerType', 'trigger_type', 'le');
5395
5395
  request['trigger_type'] = triggerType;
5396
5396
  request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
@@ -5443,7 +5443,7 @@ export default class htx extends Exchange {
5443
5443
  const broker = this.safeValue(this.options, 'broker', {});
5444
5444
  const brokerId = this.safeString(broker, 'id');
5445
5445
  request['channel_code'] = brokerId;
5446
- params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
5446
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
5447
5447
  return this.extend(request, params);
5448
5448
  }
5449
5449
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -5466,7 +5466,7 @@ export default class htx extends Exchange {
5466
5466
  * @param {float} amount how much you want to trade in units of the base currency
5467
5467
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
5468
5468
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5469
- * @param {float} [params.stopPrice] the price a trigger order is triggered at
5469
+ * @param {float} [params.triggerPrice] the price a trigger order is triggered at
5470
5470
  * @param {string} [params.triggerType] *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
5471
5471
  * @param {float} [params.stopLossPrice] *contract only* the price a stop-loss order is triggered at
5472
5472
  * @param {float} [params.takeProfitPrice] *contract only* the price a take-profit order is triggered at
@@ -5482,12 +5482,12 @@ export default class htx extends Exchange {
5482
5482
  */
5483
5483
  await this.loadMarkets();
5484
5484
  const market = this.market(symbol);
5485
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
5485
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
5486
5486
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
5487
5487
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
5488
5488
  const trailingPercent = this.safeNumber(params, 'trailingPercent');
5489
5489
  const isTrailingPercentOrder = trailingPercent !== undefined;
5490
- const isStop = triggerPrice !== undefined;
5490
+ const isTrigger = triggerPrice !== undefined;
5491
5491
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
5492
5492
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
5493
5493
  let response = undefined;
@@ -5505,7 +5505,7 @@ export default class htx extends Exchange {
5505
5505
  [marginMode, contractRequest] = this.handleMarginModeAndParams('createOrder', contractRequest);
5506
5506
  marginMode = (marginMode === undefined) ? 'cross' : marginMode;
5507
5507
  if (marginMode === 'isolated') {
5508
- if (isStop) {
5508
+ if (isTrigger) {
5509
5509
  response = await this.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(contractRequest);
5510
5510
  }
5511
5511
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -5519,7 +5519,7 @@ export default class htx extends Exchange {
5519
5519
  }
5520
5520
  }
5521
5521
  else if (marginMode === 'cross') {
5522
- if (isStop) {
5522
+ if (isTrigger) {
5523
5523
  response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(contractRequest);
5524
5524
  }
5525
5525
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -5539,7 +5539,7 @@ export default class htx extends Exchange {
5539
5539
  throw new ArgumentsRequired(this.id + ' createOrder () requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse markets');
5540
5540
  }
5541
5541
  if (market['swap']) {
5542
- if (isStop) {
5542
+ if (isTrigger) {
5543
5543
  response = await this.contractPrivatePostSwapApiV1SwapTriggerOrder(contractRequest);
5544
5544
  }
5545
5545
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -5553,7 +5553,7 @@ export default class htx extends Exchange {
5553
5553
  }
5554
5554
  }
5555
5555
  else if (market['future']) {
5556
- if (isStop) {
5556
+ if (isTrigger) {
5557
5557
  response = await this.contractPrivatePostApiV1ContractTriggerOrder(contractRequest);
5558
5558
  }
5559
5559
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -7304,16 +7304,15 @@ export default class htx extends Exchange {
7304
7304
  const symbol = this.safeString(market, 'symbol');
7305
7305
  const timestamp = this.safeInteger(info, 'accrued-at');
7306
7306
  return {
7307
- 'account': (marginMode === 'isolated') ? symbol : 'cross',
7307
+ 'info': info,
7308
7308
  'symbol': symbol,
7309
- 'marginMode': marginMode,
7310
7309
  'currency': this.safeCurrencyCode(this.safeString(info, 'currency')),
7311
7310
  'interest': this.safeNumber(info, 'interest-amount'),
7312
7311
  'interestRate': this.safeNumber(info, 'interest-rate'),
7313
7312
  'amountBorrowed': this.safeNumber(info, 'loan-amount'),
7313
+ 'marginMode': marginMode,
7314
7314
  'timestamp': timestamp,
7315
7315
  'datetime': this.iso8601(timestamp),
7316
- 'info': info,
7317
7316
  };
7318
7317
  }
7319
7318
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
@@ -785,9 +785,18 @@ export default class hyperliquid extends Exchange {
785
785
  await this.loadMarkets();
786
786
  const market = this.market(symbol);
787
787
  const until = this.safeInteger(params, 'until', this.milliseconds());
788
- const useTail = (since === undefined);
788
+ let useTail = since === undefined;
789
+ const originalSince = since;
789
790
  if (since === undefined) {
790
- since = 0;
791
+ if (limit !== undefined) {
792
+ // optimization if limit is provided
793
+ const timeframeInMilliseconds = this.parseTimeframe(timeframe) * 1000;
794
+ since = this.sum(until, timeframeInMilliseconds * limit * -1);
795
+ useTail = false;
796
+ }
797
+ else {
798
+ since = 0;
799
+ }
791
800
  }
792
801
  params = this.omit(params, ['until']);
793
802
  const request = {
@@ -816,7 +825,7 @@ export default class hyperliquid extends Exchange {
816
825
  // }
817
826
  // ]
818
827
  //
819
- return this.parseOHLCVs(response, market, timeframe, since, limit, useTail);
828
+ return this.parseOHLCVs(response, market, timeframe, originalSince, limit, useTail);
820
829
  }
821
830
  parseOHLCV(ohlcv, market = undefined) {
822
831
  //
@@ -1618,7 +1627,8 @@ export default class hyperliquid extends Exchange {
1618
1627
  request['startTime'] = since;
1619
1628
  }
1620
1629
  else {
1621
- request['startTime'] = this.milliseconds() - 100 * 60 * 60 * 1000;
1630
+ const maxLimit = (limit === undefined) ? 500 : limit;
1631
+ request['startTime'] = this.milliseconds() - maxLimit * 60 * 60 * 1000;
1622
1632
  }
1623
1633
  const until = this.safeInteger(params, 'until');
1624
1634
  params = this.omit(params, 'until');
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/kucoin.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Order, OHLCV, Trade, Balances, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, Num, Account, Dict, TradingFeeInterface, Currencies, int, LedgerEntry, DepositAddress } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Order, OHLCV, Trade, Balances, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, Num, Account, Dict, TradingFeeInterface, Currencies, int, LedgerEntry, DepositAddress, BorrowInterest } from './base/types.js';
3
3
  /**
4
4
  * @class kucoin
5
5
  * @augments Exchange
@@ -83,18 +83,8 @@ export default class kucoin extends Exchange {
83
83
  datetime: string;
84
84
  info: any;
85
85
  };
86
- fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
87
- parseBorrowInterest(info: Dict, market?: Market): {
88
- symbol: string;
89
- marginMode: string;
90
- currency: string;
91
- interest: any;
92
- interestRate: number;
93
- amountBorrowed: any;
94
- timestamp: number;
95
- datetime: string;
96
- info: Dict;
97
- };
86
+ fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<BorrowInterest[]>;
87
+ parseBorrowInterest(info: Dict, market?: Market): BorrowInterest;
98
88
  fetchBorrowRateHistories(codes?: any, since?: Int, limit?: Int, params?: {}): Promise<Dict>;
99
89
  fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
100
90
  parseBorrowRateHistories(response: any, codes: any, since: any, limit: any): Dict;
package/js/src/kucoin.js CHANGED
@@ -4593,15 +4593,15 @@ export default class kucoin extends Exchange {
4593
4593
  currencyId = this.safeString(info, 'currency');
4594
4594
  }
4595
4595
  return {
4596
+ 'info': info,
4596
4597
  'symbol': symbol,
4597
- 'marginMode': marginMode,
4598
4598
  'currency': this.safeCurrencyCode(currencyId),
4599
4599
  'interest': interest,
4600
4600
  'interestRate': this.safeNumber(info, 'dailyIntRate'),
4601
4601
  'amountBorrowed': amountBorrowed,
4602
+ 'marginMode': marginMode,
4602
4603
  'timestamp': timestamp,
4603
4604
  'datetime': this.iso8601(timestamp),
4604
- 'info': info,
4605
4605
  };
4606
4606
  }
4607
4607
  async fetchBorrowRateHistories(codes = undefined, since = undefined, limit = undefined, params = {}) {
package/js/src/okx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/okx.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification, TradingFeeInterface, Currencies, Conversion, CancellationRequest, Dict, Position, CrossBorrowRate, CrossBorrowRates, LeverageTier, int, LedgerEntry, FundingRate, DepositAddress, LongShortRatio } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification, TradingFeeInterface, Currencies, Conversion, CancellationRequest, Dict, Position, CrossBorrowRate, CrossBorrowRates, LeverageTier, int, LedgerEntry, FundingRate, DepositAddress, LongShortRatio, BorrowInterest } from './base/types.js';
3
3
  /**
4
4
  * @class okx
5
5
  * @augments Exchange
@@ -115,18 +115,8 @@ export default class okx extends Exchange {
115
115
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
116
116
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<LeverageTier[]>;
117
117
  parseMarketLeverageTiers(info: any, market?: Market): LeverageTier[];
118
- fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
119
- parseBorrowInterest(info: Dict, market?: Market): {
120
- symbol: string;
121
- marginMode: string;
122
- currency: string;
123
- interest: number;
124
- interestRate: number;
125
- amountBorrowed: number;
126
- timestamp: number;
127
- datetime: string;
128
- info: Dict;
129
- };
118
+ fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<BorrowInterest[]>;
119
+ parseBorrowInterest(info: Dict, market?: Market): BorrowInterest;
130
120
  borrowCrossMargin(code: string, amount: number, params?: {}): Promise<{
131
121
  id: any;
132
122
  currency: string;
package/js/src/okx.js CHANGED
@@ -398,6 +398,7 @@ export default class okx extends Exchange {
398
398
  // eth staking
399
399
  'finance/staking-defi/eth/balance': 5 / 3,
400
400
  'finance/staking-defi/eth/purchase-redeem-history': 5 / 3,
401
+ 'finance/staking-defi/eth/product-info': 3,
401
402
  // copytrading
402
403
  'copytrading/current-subpositions': 1,
403
404
  'copytrading/subpositions-history': 1,
@@ -7076,15 +7077,15 @@ export default class okx extends Exchange {
7076
7077
  }
7077
7078
  const timestamp = this.safeInteger(info, 'ts');
7078
7079
  return {
7080
+ 'info': info,
7079
7081
  'symbol': this.safeString(market, 'symbol'),
7080
- 'marginMode': this.safeString(info, 'mgnMode'),
7081
7082
  'currency': this.safeCurrencyCode(this.safeString(info, 'ccy')),
7082
7083
  'interest': this.safeNumber(info, 'interest'),
7083
7084
  'interestRate': this.safeNumber(info, 'interestRate'),
7084
7085
  'amountBorrowed': this.safeNumber(info, 'liab'),
7086
+ 'marginMode': this.safeString(info, 'mgnMode'),
7085
7087
  'timestamp': timestamp,
7086
7088
  'datetime': this.iso8601(timestamp),
7087
- 'info': info,
7088
7089
  };
7089
7090
  }
7090
7091
  async borrowCrossMargin(code, amount, params = {}) {
package/js/src/phemex.js CHANGED
@@ -108,7 +108,7 @@ export default class phemex extends Exchange {
108
108
  'private': 'https://{hostname}',
109
109
  },
110
110
  'www': 'https://phemex.com',
111
- 'doc': 'https://github.com/phemex/phemex-api-docs',
111
+ 'doc': 'https://phemex-docs.github.io/#overview',
112
112
  'fees': 'https://phemex.com/fees-conditions',
113
113
  'referral': {
114
114
  'url': 'https://phemex.com/register?referralCode=EDNVJ',
@@ -166,6 +166,7 @@ export default class phemex extends Exchange {
166
166
  'v2': {
167
167
  'get': {
168
168
  'public/products': 5,
169
+ 'public/products-plus': 5,
169
170
  'md/v2/orderbook': 5,
170
171
  'md/v2/trade': 5,
171
172
  'md/v2/ticker/24hr': 5,
@@ -738,7 +739,7 @@ export default class phemex extends Exchange {
738
739
  'max': this.parseSafeNumber(this.safeString(market, 'maxOrderValue')),
739
740
  },
740
741
  },
741
- 'created': undefined,
742
+ 'created': this.safeInteger(market, 'listTime'),
742
743
  'info': market,
743
744
  });
744
745
  }
@@ -747,6 +748,7 @@ export default class phemex extends Exchange {
747
748
  * @method
748
749
  * @name phemex#fetchMarkets
749
750
  * @description retrieves data on all markets for phemex
751
+ * @see https://phemex-docs.github.io/#query-product-information-3
750
752
  * @param {object} [params] extra parameters specific to the exchange API endpoint
751
753
  * @returns {object[]} an array of objects representing market data
752
754
  */
@@ -1,5 +1,5 @@
1
1
  import exmoRest from '../exmo.js';
2
- import type { Int, Str, OrderBook, Trade, Ticker, Balances, Strings, Tickers } from '../base/types.js';
2
+ import type { Int, Str, OrderBook, Trade, Ticker, Balances, Market, Dict, Strings, Tickers, Order } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class exmo extends exmoRest {
5
5
  describe(): any;
@@ -19,6 +19,10 @@ export default class exmo extends exmoRest {
19
19
  handleOrderBook(client: Client, message: any): void;
20
20
  handleDelta(bookside: any, delta: any): void;
21
21
  handleDeltas(bookside: any, deltas: any): void;
22
+ watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
23
+ handleOrders(client: Client, message: any): void;
24
+ parseWsOrder(order: Dict, market?: Market): Order;
25
+ parseWsTrade(trade: Dict, market?: Market): Trade;
22
26
  handleMessage(client: Client, message: any): void;
23
27
  handleSubscribed(client: Client, message: any): any;
24
28
  handleInfo(client: Client, message: any): any;
@@ -20,7 +20,7 @@ export default class exmo extends exmoRest {
20
20
  'watchTickers': true,
21
21
  'watchTrades': true,
22
22
  'watchMyTrades': true,
23
- 'watchOrders': false,
23
+ 'watchOrders': true,
24
24
  'watchOrderBook': true,
25
25
  'watchOHLCV': false,
26
26
  },
@@ -573,6 +573,219 @@ export default class exmo extends exmoRest {
573
573
  this.handleDelta(bookside, deltas[i]);
574
574
  }
575
575
  }
576
+ async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
577
+ /**
578
+ * @method
579
+ * @name exmo#watchOrders
580
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#85f7bc03-b1c9-4cd2-bd22-8fd422272825
581
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#95e4ed18-1791-4e6d-83ad-cbfe9be1051c
582
+ * @description watches information on multiple orders made by the user
583
+ * @param {string} symbol unified market symbol of the market orders were made in
584
+ * @param {int} [since] the earliest time in ms to fetch orders for
585
+ * @param {int} [limit] the maximum number of order structures to retrieve
586
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
587
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
588
+ */
589
+ await this.loadMarkets();
590
+ await this.authenticate(params);
591
+ const [type, query] = this.handleMarketTypeAndParams('watchOrders', undefined, params);
592
+ const url = this.urls['api']['ws'][type];
593
+ let messageHash = undefined;
594
+ if (symbol === undefined) {
595
+ messageHash = 'orders:' + type;
596
+ }
597
+ else {
598
+ const market = this.market(symbol);
599
+ symbol = market['symbol'];
600
+ messageHash = 'orders:' + market['symbol'];
601
+ }
602
+ const message = {
603
+ 'method': 'subscribe',
604
+ 'topics': [
605
+ type + '/orders',
606
+ ],
607
+ 'id': this.requestId(),
608
+ };
609
+ const request = this.deepExtend(message, query);
610
+ const orders = await this.watch(url, messageHash, request, messageHash, request);
611
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
612
+ }
613
+ handleOrders(client, message) {
614
+ //
615
+ // spot
616
+ // {
617
+ // "ts": 1574427585174,
618
+ // "event": "snapshot",
619
+ // "topic": "spot/orders",
620
+ // "data": [
621
+ // {
622
+ // "order_id": "14",
623
+ // "client_id":"100500",
624
+ // "created": "1574427585",
625
+ // "pair": "BTC_USD",
626
+ // "price": "7750",
627
+ // "quantity": "0.1",
628
+ // "amount": "775",
629
+ // "original_quantity": "0.1",
630
+ // "original_amount": "775",
631
+ // "type": "sell",
632
+ // "status": "open"
633
+ // }
634
+ // ]
635
+ // }
636
+ //
637
+ // margin
638
+ // {
639
+ // "ts":1624371281773,
640
+ // "event":"snapshot",
641
+ // "topic":"margin/orders",
642
+ // "data":[
643
+ // {
644
+ // "order_id":"692844278081168665",
645
+ // "created":"1624371250919761600",
646
+ // "type":"limit_buy",
647
+ // "previous_type":"limit_buy",
648
+ // "pair":"BTC_USD",
649
+ // "leverage":"2",
650
+ // "price":"10000",
651
+ // "stop_price":"0",
652
+ // "distance":"0",
653
+ // "trigger_price":"10000",
654
+ // "init_quantity":"0.1",
655
+ // "quantity":"0.1",
656
+ // "funding_currency":"USD",
657
+ // "funding_quantity":"1000",
658
+ // "funding_rate":"0",
659
+ // "client_id":"111111",
660
+ // "expire":0,
661
+ // "src":1,
662
+ // "comment":"comment1",
663
+ // "updated":1624371250938136600,
664
+ // "status":"active"
665
+ // }
666
+ // ]
667
+ // }
668
+ //
669
+ const topic = this.safeString(message, 'topic');
670
+ const parts = topic.split('/');
671
+ const type = this.safeString(parts, 0);
672
+ const messageHash = 'orders:' + type;
673
+ const event = this.safeString(message, 'event');
674
+ if (this.orders === undefined) {
675
+ const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
676
+ this.orders = new ArrayCacheBySymbolById(limit);
677
+ }
678
+ const cachedOrders = this.orders;
679
+ let rawOrders = [];
680
+ if (event === 'snapshot') {
681
+ rawOrders = this.safeValue(message, 'data', []);
682
+ }
683
+ else if (event === 'update') {
684
+ const rawOrder = this.safeDict(message, 'data', {});
685
+ rawOrders.push(rawOrder);
686
+ }
687
+ const symbols = {};
688
+ for (let j = 0; j < rawOrders.length; j++) {
689
+ const order = this.parseWsOrder(rawOrders[j]);
690
+ cachedOrders.append(order);
691
+ symbols[order['symbol']] = true;
692
+ }
693
+ const symbolKeys = Object.keys(symbols);
694
+ for (let i = 0; i < symbolKeys.length; i++) {
695
+ const symbol = symbolKeys[i];
696
+ const symbolSpecificMessageHash = 'orders:' + symbol;
697
+ client.resolve(cachedOrders, symbolSpecificMessageHash);
698
+ }
699
+ client.resolve(cachedOrders, messageHash);
700
+ }
701
+ parseWsOrder(order, market = undefined) {
702
+ //
703
+ // {
704
+ // order_id: '43226756791',
705
+ // client_id: 0,
706
+ // created: '1730371416',
707
+ // type: 'market_buy',
708
+ // pair: 'TRX_USD',
709
+ // quantity: '0',
710
+ // original_quantity: '30',
711
+ // status: 'cancelled',
712
+ // last_trade_id: '726480870',
713
+ // last_trade_price: '0.17',
714
+ // last_trade_quantity: '30'
715
+ // }
716
+ //
717
+ const id = this.safeString(order, 'order_id');
718
+ const timestamp = this.safeTimestamp(order, 'created');
719
+ const orderType = this.safeString(order, 'type');
720
+ const side = this.parseSide(orderType);
721
+ const marketId = this.safeString(order, 'pair');
722
+ market = this.safeMarket(marketId, market);
723
+ const symbol = market['symbol'];
724
+ let amount = this.safeString(order, 'quantity');
725
+ if (amount === undefined) {
726
+ const amountField = (side === 'buy') ? 'in_amount' : 'out_amount';
727
+ amount = this.safeString(order, amountField);
728
+ }
729
+ const price = this.safeString(order, 'price');
730
+ const clientOrderId = this.omitZero(this.safeString(order, 'client_id'));
731
+ const triggerPrice = this.omitZero(this.safeString(order, 'stop_price'));
732
+ let type = undefined;
733
+ if ((orderType !== 'buy') && (orderType !== 'sell')) {
734
+ type = orderType;
735
+ }
736
+ let trades = undefined;
737
+ if ('last_trade_id' in order) {
738
+ const trade = this.parseWsTrade(order, market);
739
+ trades = [trade];
740
+ }
741
+ return this.safeOrder({
742
+ 'id': id,
743
+ 'clientOrderId': clientOrderId,
744
+ 'datetime': this.iso8601(timestamp),
745
+ 'timestamp': timestamp,
746
+ 'lastTradeTimestamp': undefined,
747
+ 'status': this.parseStatus(this.safeString(order, 'status')),
748
+ 'symbol': symbol,
749
+ 'type': type,
750
+ 'timeInForce': undefined,
751
+ 'postOnly': undefined,
752
+ 'side': side,
753
+ 'price': price,
754
+ 'stopPrice': triggerPrice,
755
+ 'triggerPrice': triggerPrice,
756
+ 'cost': undefined,
757
+ 'amount': this.safeString(order, 'original_quantity'),
758
+ 'filled': undefined,
759
+ 'remaining': this.safeString(order, 'quantity'),
760
+ 'average': undefined,
761
+ 'trades': trades,
762
+ 'fee': undefined,
763
+ 'info': order,
764
+ }, market);
765
+ }
766
+ parseWsTrade(trade, market = undefined) {
767
+ const id = this.safeString(trade, 'order_id');
768
+ const orderType = this.safeString(trade, 'type');
769
+ const side = this.parseSide(orderType);
770
+ const marketId = this.safeString(trade, 'pair');
771
+ market = this.safeMarket(marketId, market);
772
+ const symbol = market['symbol'];
773
+ let type = undefined;
774
+ if ((orderType !== 'buy') && (orderType !== 'sell')) {
775
+ type = orderType;
776
+ }
777
+ return this.safeTrade({
778
+ 'id': this.safeString(trade, 'last_trade_id'),
779
+ 'symbol': symbol,
780
+ 'order': id,
781
+ 'type': type,
782
+ 'side': side,
783
+ 'price': this.safeString(trade, 'last_trade_price'),
784
+ 'amount': this.safeString(trade, 'last_trade_quantity'),
785
+ 'cost': undefined,
786
+ 'fee': undefined,
787
+ }, market);
788
+ }
576
789
  handleMessage(client, message) {
577
790
  //
578
791
  // {
@@ -613,8 +826,8 @@ export default class exmo extends exmoRest {
613
826
  'spot/trades': this.handleTrades,
614
827
  'margin/trades': this.handleTrades,
615
828
  'spot/order_book_updates': this.handleOrderBook,
616
- // 'spot/orders': this.handleOrders,
617
- // 'margin/orders': this.handleOrders,
829
+ 'spot/orders': this.handleOrders,
830
+ 'margin/orders': this.handleOrders,
618
831
  'spot/user_trades': this.handleMyTrades,
619
832
  'margin/user_trades': this.handleMyTrades,
620
833
  };
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/whitebit.js';
2
- import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num, Currencies, TradingFees, Dict, int, FundingRate, FundingRates, DepositAddress } from './base/types.js';
2
+ import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num, Currencies, TradingFees, Dict, int, FundingRate, FundingRates, DepositAddress, BorrowInterest } from './base/types.js';
3
3
  /**
4
4
  * @class whitebit
5
5
  * @augments Exchange
@@ -57,18 +57,8 @@ export default class whitebit extends Exchange {
57
57
  parseTransactionStatus(status: Str): string;
58
58
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
59
59
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
60
- fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
61
- parseBorrowInterest(info: Dict, market?: Market): {
62
- symbol: string;
63
- marginMode: string;
64
- currency: string;
65
- interest: number;
66
- interestRate: number;
67
- amountBorrowed: number;
68
- timestamp: number;
69
- datetime: string;
70
- info: Dict;
71
- };
60
+ fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<BorrowInterest[]>;
61
+ parseBorrowInterest(info: Dict, market?: Market): BorrowInterest;
72
62
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
73
63
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<FundingRates>;
74
64
  parseFundingRate(contract: any, market?: Market): FundingRate;
@@ -2360,15 +2360,15 @@ export default class whitebit extends Exchange {
2360
2360
  const symbol = this.safeSymbol(marketId, market, '_');
2361
2361
  const timestamp = this.safeTimestamp(info, 'modifyDate');
2362
2362
  return {
2363
+ 'info': info,
2363
2364
  'symbol': symbol,
2364
- 'marginMode': 'cross',
2365
2365
  'currency': 'USDT',
2366
2366
  'interest': this.safeNumber(info, 'unrealizedFunding'),
2367
2367
  'interestRate': 0.00098,
2368
2368
  'amountBorrowed': this.safeNumber(info, 'amount'),
2369
+ 'marginMode': 'cross',
2369
2370
  'timestamp': timestamp,
2370
2371
  'datetime': this.iso8601(timestamp),
2371
- 'info': info,
2372
2372
  };
2373
2373
  }
2374
2374
  async fetchFundingRate(symbol, params = {}) {
package/js/src/woo.d.ts CHANGED
@@ -69,7 +69,7 @@ export default class woo extends Exchange {
69
69
  parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
70
70
  parseTransferStatus(status: Str): Str;
71
71
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
72
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
72
+ repayMargin(code: string, amount: number, symbol?: Str, params?: {}): Promise<any>;
73
73
  parseMarginLoan(info: any, currency?: Currency): {
74
74
  id: any;
75
75
  currency: string;
@@ -129,7 +129,7 @@ export default class woofipro extends Exchange {
129
129
  '1y': '1y',
130
130
  },
131
131
  'urls': {
132
- 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/b1e7b348-a0fc-4605-8b7f-91176958fd69',
132
+ 'logo': 'https://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1',
133
133
  'api': {
134
134
  'public': 'https://api-evm.orderly.org',
135
135
  'private': 'https://api-evm.orderly.org',