ccxt 4.3.65 → 4.3.67

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 (48) hide show
  1. package/README.md +4 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +2 -2
  5. package/dist/cjs/src/bingx.js +151 -19
  6. package/dist/cjs/src/bithumb.js +61 -17
  7. package/dist/cjs/src/hyperliquid.js +63 -7
  8. package/dist/cjs/src/independentreserve.js +0 -1
  9. package/dist/cjs/src/kraken.js +27 -0
  10. package/dist/cjs/src/pro/hyperliquid.js +103 -1
  11. package/dist/cjs/src/pro/okx.js +22 -9
  12. package/js/ccxt.d.ts +1 -1
  13. package/js/ccxt.js +1 -1
  14. package/js/src/abstract/bingx.d.ts +7 -0
  15. package/js/src/base/Exchange.d.ts +14 -13
  16. package/js/src/base/Exchange.js +2 -2
  17. package/js/src/bingx.js +151 -19
  18. package/js/src/bithumb.js +61 -17
  19. package/js/src/hyperliquid.d.ts +3 -1
  20. package/js/src/hyperliquid.js +63 -7
  21. package/js/src/independentreserve.js +1 -1
  22. package/js/src/kraken.d.ts +7 -0
  23. package/js/src/kraken.js +27 -0
  24. package/js/src/pro/bitget.d.ts +1 -1
  25. package/js/src/pro/bybit.d.ts +1 -1
  26. package/js/src/pro/coinone.d.ts +1 -1
  27. package/js/src/pro/currencycom.d.ts +1 -1
  28. package/js/src/pro/hollaex.d.ts +1 -1
  29. package/js/src/pro/hyperliquid.d.ts +5 -2
  30. package/js/src/pro/hyperliquid.js +103 -1
  31. package/js/src/pro/kucoin.d.ts +1 -1
  32. package/js/src/pro/kucoinfutures.d.ts +1 -1
  33. package/js/src/pro/mexc.d.ts +1 -1
  34. package/js/src/pro/okcoin.d.ts +1 -1
  35. package/js/src/pro/okx.d.ts +2 -2
  36. package/js/src/pro/okx.js +23 -10
  37. package/js/src/pro/oxfun.d.ts +1 -1
  38. package/js/src/pro/p2b.d.ts +1 -1
  39. package/js/src/pro/poloniex.d.ts +1 -1
  40. package/js/src/pro/whitebit.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/dist/cjs/src/abstract/bittrex.js +0 -9
  43. package/dist/cjs/src/bittrex.js +0 -2308
  44. package/dist/cjs/src/pro/bittrex.js +0 -959
  45. package/js/src/bittrex.d.ts +0 -97
  46. package/js/src/bittrex.js +0 -2309
  47. package/js/src/pro/bittrex.d.ts +0 -69
  48. package/js/src/pro/bittrex.js +0 -960
@@ -17,7 +17,7 @@ class hyperliquid extends hyperliquid$1 {
17
17
  'watchOrderBook': true,
18
18
  'watchOrders': true,
19
19
  'watchTicker': false,
20
- 'watchTickers': false,
20
+ 'watchTickers': true,
21
21
  'watchTrades': true,
22
22
  'watchPosition': false,
23
23
  },
@@ -118,6 +118,32 @@ class hyperliquid extends hyperliquid$1 {
118
118
  const messageHash = 'orderbook:' + symbol;
119
119
  client.resolve(orderbook, messageHash);
120
120
  }
121
+ async watchTickers(symbols = undefined, params = {}) {
122
+ /**
123
+ * @method
124
+ * @name hyperliquid#watchTickers
125
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
126
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
127
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
128
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
129
+ */
130
+ await this.loadMarkets();
131
+ symbols = this.marketSymbols(symbols, undefined, true);
132
+ const messageHash = 'tickers';
133
+ const url = this.urls['api']['ws']['public'];
134
+ const request = {
135
+ 'method': 'subscribe',
136
+ 'subscription': {
137
+ 'type': 'webData2',
138
+ 'user': '0x0000000000000000000000000000000000000000',
139
+ },
140
+ };
141
+ const tickers = await this.watch(url, messageHash, this.extend(request, params), messageHash);
142
+ if (this.newUpdates) {
143
+ return this.filterByArrayTickers(tickers, 'symbol', symbols);
144
+ }
145
+ return this.tickers;
146
+ }
121
147
  async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
122
148
  /**
123
149
  * @method
@@ -153,6 +179,81 @@ class hyperliquid extends hyperliquid$1 {
153
179
  }
154
180
  return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
155
181
  }
182
+ handleWsTickers(client, message) {
183
+ //
184
+ // {
185
+ // "channel": "webData2",
186
+ // "data": {
187
+ // "meta": {
188
+ // "universe": [
189
+ // {
190
+ // "szDecimals": 5,
191
+ // "name": "BTC",
192
+ // "maxLeverage": 50,
193
+ // "onlyIsolated": false
194
+ // },
195
+ // ...
196
+ // ],
197
+ // },
198
+ // "assetCtxs": [
199
+ // {
200
+ // "funding": "0.00003005",
201
+ // "openInterest": "2311.50778",
202
+ // "prevDayPx": "63475.0",
203
+ // "dayNtlVlm": "468043329.64289033",
204
+ // "premium": "0.00094264",
205
+ // "oraclePx": "64712.0",
206
+ // "markPx": "64774.0",
207
+ // "midPx": "64773.5",
208
+ // "impactPxs": [
209
+ // "64773.0",
210
+ // "64774.0"
211
+ // ]
212
+ // },
213
+ // ...
214
+ // ],
215
+ // "spotAssetCtxs": [
216
+ // {
217
+ // "prevDayPx": "0.20937",
218
+ // "dayNtlVlm": "11188888.61984999",
219
+ // "markPx": "0.19722",
220
+ // "midPx": "0.197145",
221
+ // "circulatingSupply": "598760557.12072003",
222
+ // "coin": "PURR/USDC"
223
+ // },
224
+ // ...
225
+ // ],
226
+ // }
227
+ // }
228
+ //
229
+ // spot
230
+ const rawData = this.safeDict(message, 'data', {});
231
+ const spotAssets = this.safeList(rawData, 'spotAssetCtxs', []);
232
+ const parsedTickers = [];
233
+ for (let i = 0; i < spotAssets.length; i++) {
234
+ const assetObject = spotAssets[i];
235
+ const marketId = this.safeString(assetObject, 'coin');
236
+ const market = this.safeMarket(marketId, undefined, undefined, 'spot');
237
+ const ticker = this.parseWsTicker(assetObject, market);
238
+ parsedTickers.push(ticker);
239
+ }
240
+ // perpetuals
241
+ const meta = this.safeDict(rawData, 'meta', {});
242
+ const universe = this.safeList(meta, 'universe', []);
243
+ const assetCtxs = this.safeList(rawData, 'assetCtxs', []);
244
+ for (let i = 0; i < universe.length; i++) {
245
+ const data = this.extend(this.safeDict(universe, i, {}), this.safeDict(assetCtxs, i, {}));
246
+ const id = data['name'] + '/USDC:USDC';
247
+ const market = this.safeMarket(id, undefined, undefined, 'swap');
248
+ const ticker = this.parseWsTicker(data, market);
249
+ parsedTickers.push(ticker);
250
+ }
251
+ const tickers = this.indexBy(parsedTickers, 'symbol');
252
+ client.resolve(tickers, 'tickers');
253
+ }
254
+ parseWsTicker(rawTicker, market = undefined) {
255
+ return this.parseTicker(rawTicker, market);
256
+ }
156
257
  handleMyTrades(client, message) {
157
258
  //
158
259
  // {
@@ -522,6 +623,7 @@ class hyperliquid extends hyperliquid$1 {
522
623
  'candle': this.handleOHLCV,
523
624
  'orderUpdates': this.handleOrder,
524
625
  'userFills': this.handleMyTrades,
626
+ 'webData2': this.handleWsTickers,
525
627
  };
526
628
  const exacMethod = this.safeValue(methods, topic);
527
629
  if (exacMethod !== undefined) {
@@ -894,7 +894,7 @@ class okx extends okx$1 {
894
894
  this.handleDelta(bookside, deltas[i]);
895
895
  }
896
896
  }
897
- handleOrderBookMessage(client, message, orderbook, messageHash) {
897
+ handleOrderBookMessage(client, message, orderbook, messageHash, market = undefined) {
898
898
  //
899
899
  // {
900
900
  // "asks": [
@@ -909,6 +909,9 @@ class okx extends okx$1 {
909
909
  // ],
910
910
  // "instId": "BTC-USDT",
911
911
  // "ts": "1626537446491"
912
+ // "checksum": -855196043,
913
+ // "prevSeqId": 123456,
914
+ // "seqId": 123457
912
915
  // }
913
916
  //
914
917
  const asks = this.safeValue(message, 'asks', []);
@@ -918,9 +921,12 @@ class okx extends okx$1 {
918
921
  this.handleDeltas(storedAsks, asks);
919
922
  this.handleDeltas(storedBids, bids);
920
923
  const marketId = this.safeString(message, 'instId');
921
- const symbol = this.safeSymbol(marketId);
924
+ const symbol = this.safeSymbol(marketId, market);
922
925
  const checksum = this.handleOption('watchOrderBook', 'checksum', true);
926
+ const seqId = this.safeInteger(message, 'seqId');
923
927
  if (checksum) {
928
+ const prevSeqId = this.safeInteger(message, 'prevSeqId');
929
+ const nonce = orderbook['nonce'];
924
930
  const asksLength = storedAsks.length;
925
931
  const bidsLength = storedBids.length;
926
932
  const payloadArray = [];
@@ -937,14 +943,21 @@ class okx extends okx$1 {
937
943
  const payload = payloadArray.join(':');
938
944
  const responseChecksum = this.safeInteger(message, 'checksum');
939
945
  const localChecksum = this.crc32(payload, true);
946
+ let error = undefined;
947
+ if (prevSeqId !== -1 && nonce !== prevSeqId) {
948
+ error = new errors.InvalidNonce(this.id + ' watchOrderBook received invalid nonce');
949
+ }
940
950
  if (responseChecksum !== localChecksum) {
941
- const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
951
+ error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
952
+ }
953
+ if (error !== undefined) {
942
954
  delete client.subscriptions[messageHash];
943
955
  delete this.orderbooks[symbol];
944
956
  client.reject(error, messageHash);
945
957
  }
946
958
  }
947
959
  const timestamp = this.safeInteger(message, 'ts');
960
+ orderbook['nonce'] = seqId;
948
961
  orderbook['timestamp'] = timestamp;
949
962
  orderbook['datetime'] = this.iso8601(timestamp);
950
963
  return orderbook;
@@ -1066,7 +1079,7 @@ class okx extends okx$1 {
1066
1079
  const orderbook = this.orderbooks[symbol];
1067
1080
  for (let i = 0; i < data.length; i++) {
1068
1081
  const update = data[i];
1069
- this.handleOrderBookMessage(client, update, orderbook, messageHash);
1082
+ this.handleOrderBookMessage(client, update, orderbook, messageHash, market);
1070
1083
  client.resolve(orderbook, messageHash);
1071
1084
  }
1072
1085
  }
@@ -1637,7 +1650,7 @@ class okx extends okx$1 {
1637
1650
  await this.loadMarkets();
1638
1651
  await this.authenticate();
1639
1652
  const url = this.getUrl('private', 'private');
1640
- const messageHash = this.nonce().toString();
1653
+ const messageHash = this.milliseconds().toString();
1641
1654
  let op = undefined;
1642
1655
  [op, params] = this.handleOptionAndParams(params, 'createOrderWs', 'op', 'batch-orders');
1643
1656
  const args = this.createOrderRequest(symbol, type, side, amount, price, params);
@@ -1707,7 +1720,7 @@ class okx extends okx$1 {
1707
1720
  await this.loadMarkets();
1708
1721
  await this.authenticate();
1709
1722
  const url = this.getUrl('private', 'private');
1710
- const messageHash = this.nonce().toString();
1723
+ const messageHash = this.milliseconds().toString();
1711
1724
  let op = undefined;
1712
1725
  [op, params] = this.handleOptionAndParams(params, 'editOrderWs', 'op', 'amend-order');
1713
1726
  const args = this.editOrderRequest(id, symbol, type, side, amount, price, params);
@@ -1736,7 +1749,7 @@ class okx extends okx$1 {
1736
1749
  await this.loadMarkets();
1737
1750
  await this.authenticate();
1738
1751
  const url = this.getUrl('private', 'private');
1739
- const messageHash = this.nonce().toString();
1752
+ const messageHash = this.milliseconds().toString();
1740
1753
  const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1741
1754
  params = this.omit(params, ['clientOrderId', 'clOrdId']);
1742
1755
  const arg = {
@@ -1776,7 +1789,7 @@ class okx extends okx$1 {
1776
1789
  await this.loadMarkets();
1777
1790
  await this.authenticate();
1778
1791
  const url = this.getUrl('private', 'private');
1779
- const messageHash = this.nonce().toString();
1792
+ const messageHash = this.milliseconds().toString();
1780
1793
  const args = [];
1781
1794
  for (let i = 0; i < idsLength; i++) {
1782
1795
  const arg = {
@@ -1812,7 +1825,7 @@ class okx extends okx$1 {
1812
1825
  throw new errors.BadRequest(this.id + 'cancelAllOrdersWs is only applicable to Option in Portfolio Margin mode, and MMP privilege is required.');
1813
1826
  }
1814
1827
  const url = this.getUrl('private', 'private');
1815
- const messageHash = this.nonce().toString();
1828
+ const messageHash = this.milliseconds().toString();
1816
1829
  const request = {
1817
1830
  'id': messageHash,
1818
1831
  'op': 'mass-cancel',
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, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, TransferEntries, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, 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 } from './src/base/errors.js';
7
- declare const version = "4.3.64";
7
+ declare const version = "4.3.66";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, 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 } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.65';
41
+ const version = '4.3.67';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -84,13 +84,20 @@ interface Exchange {
84
84
  cswapV1PrivateGetTradeLeverage(params?: {}): Promise<implicitReturnType>;
85
85
  cswapV1PrivateGetTradeForceOrders(params?: {}): Promise<implicitReturnType>;
86
86
  cswapV1PrivateGetTradeAllFillOrders(params?: {}): Promise<implicitReturnType>;
87
+ cswapV1PrivateGetTradeOpenOrders(params?: {}): Promise<implicitReturnType>;
88
+ cswapV1PrivateGetTradeOrderDetail(params?: {}): Promise<implicitReturnType>;
89
+ cswapV1PrivateGetTradeOrderHistory(params?: {}): Promise<implicitReturnType>;
90
+ cswapV1PrivateGetTradeMarginType(params?: {}): Promise<implicitReturnType>;
87
91
  cswapV1PrivateGetUserCommissionRate(params?: {}): Promise<implicitReturnType>;
88
92
  cswapV1PrivateGetUserPositions(params?: {}): Promise<implicitReturnType>;
89
93
  cswapV1PrivateGetUserBalance(params?: {}): Promise<implicitReturnType>;
90
94
  cswapV1PrivatePostTradeOrder(params?: {}): Promise<implicitReturnType>;
91
95
  cswapV1PrivatePostTradeLeverage(params?: {}): Promise<implicitReturnType>;
92
96
  cswapV1PrivatePostTradeCloseAllPositions(params?: {}): Promise<implicitReturnType>;
97
+ cswapV1PrivatePostTradeMarginType(params?: {}): Promise<implicitReturnType>;
98
+ cswapV1PrivatePostTradePositionMargin(params?: {}): Promise<implicitReturnType>;
93
99
  cswapV1PrivateDeleteTradeAllOpenOrders(params?: {}): Promise<implicitReturnType>;
100
+ cswapV1PrivateDeleteTradeCancelOrder(params?: {}): Promise<implicitReturnType>;
94
101
  contractV1PrivateGetAllPosition(params?: {}): Promise<implicitReturnType>;
95
102
  contractV1PrivateGetAllOrders(params?: {}): Promise<implicitReturnType>;
96
103
  contractV1PrivateGetBalance(params?: {}): Promise<implicitReturnType>;
@@ -7,6 +7,7 @@ import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, B
7
7
  export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, Bool, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, CrossBorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, Conversion } from './types.js';
8
8
  import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
9
9
  import { OrderBook as Ob } from './ws/OrderBook.js';
10
+ import Client from './ws/Client.js';
10
11
  /**
11
12
  * @class Exchange
12
13
  */
@@ -648,7 +649,7 @@ export default class Exchange {
648
649
  indexedOrderBook(snapshot?: {}, depth?: number): IndexedOrderBook;
649
650
  countedOrderBook(snapshot?: {}, depth?: number): CountedOrderBook;
650
651
  handleMessage(client: any, message: any): void;
651
- ping(client: any): any;
652
+ ping(client: Client): any;
652
653
  client(url: string): WsClient;
653
654
  watchMultiple(url: string, messageHashes: string[], message?: any, subscribeHashes?: any, subscription?: any): import("./ws/Future.js").FutureInterface;
654
655
  watch(url: string, messageHash: string, message?: any, subscribeHash?: any, subscription?: any): any;
@@ -658,7 +659,7 @@ export default class Exchange {
658
659
  close(): Promise<void>;
659
660
  loadOrderBook(client: any, messageHash: string, symbol: string, limit?: Int, params?: {}): Promise<void>;
660
661
  convertToBigInt(value: string): bigint;
661
- stringToCharsArray(value: any): any;
662
+ stringToCharsArray(value: string): string[];
662
663
  valueIsDefined(value: any): boolean;
663
664
  arraySlice(array: any, first: any, second?: any): any;
664
665
  getProperty(obj: any, property: any, defaultValue?: any): any;
@@ -668,9 +669,9 @@ export default class Exchange {
668
669
  ethAbiEncode(types: any, args: any): Uint8Array;
669
670
  ethEncodeStructuredData(domain: any, messageTypes: any, messageData: any): Uint8Array;
670
671
  intToBase16(elem: any): string;
671
- extendExchangeOptions(newOptions: any): void;
672
+ extendExchangeOptions(newOptions: Dict): void;
672
673
  createSafeDictionary(): {};
673
- randomBytes(length: any): string;
674
+ randomBytes(length: number): string;
674
675
  safeBoolN(dictionaryOrList: any, keys: IndexType[], defaultValue?: boolean): boolean | undefined;
675
676
  safeBool2(dictionary: any, key1: IndexType, key2: IndexType, defaultValue?: boolean): boolean | undefined;
676
677
  safeBool(dictionary: any, key: IndexType, defaultValue?: boolean): boolean | undefined;
@@ -722,7 +723,7 @@ export default class Exchange {
722
723
  parseTrade(trade: Dict, market?: Market): Trade;
723
724
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
724
725
  parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
725
- parseAccount(account: any): Account;
726
+ parseAccount(account: Dict): Account;
726
727
  parseLedgerEntry(item: Dict, currency?: Currency): object;
727
728
  parseOrder(order: Dict, market?: Market): Order;
728
729
  fetchCrossBorrowRates(params?: {}): Promise<CrossBorrowRates>;
@@ -796,11 +797,11 @@ export default class Exchange {
796
797
  info: Dictionary<any>;
797
798
  };
798
799
  safeCurrencyStructure(currency: object): CurrencyInterface;
799
- safeMarketStructure(market?: any): MarketInterface;
800
+ safeMarketStructure(market?: Dict): MarketInterface;
800
801
  setMarkets(markets: any, currencies?: any): Dictionary<any>;
801
802
  getDescribeForExtendedWsExchange(currentRestInstance: any, parentRestInstance: any, wsBaseDescribe: Dictionary<any>): any;
802
- safeBalance(balance: object): Balances;
803
- safeOrder(order: object, market?: Market): Order;
803
+ safeBalance(balance: Dict): Balances;
804
+ safeOrder(order: Dict, market?: Market): Order;
804
805
  parseOrders(orders: object, market?: Market, since?: Int, limit?: Int, params?: {}): Order[];
805
806
  calculateFee(symbol: string, type: string, side: string, amount: number, price: number, takerOrMaker?: string, params?: {}): {
806
807
  type: string;
@@ -808,12 +809,12 @@ export default class Exchange {
808
809
  rate: number;
809
810
  cost: number;
810
811
  };
811
- safeLiquidation(liquidation: object, market?: Market): Liquidation;
812
- safeTrade(trade: object, market?: Market): Trade;
812
+ safeLiquidation(liquidation: Dict, market?: Market): Liquidation;
813
+ safeTrade(trade: Dict, market?: Market): Trade;
813
814
  findNearestCeiling(arr: number[], providedValue: number): number;
814
815
  invertFlatStringDictionary(dict: any): {};
815
816
  reduceFeesByCurrency(fees: any): any[];
816
- safeTicker(ticker: object, market?: Market): Ticker;
817
+ safeTicker(ticker: Dict, market?: Market): Ticker;
817
818
  fetchBorrowRate(code: string, amount: any, params?: {}): Promise<{}>;
818
819
  repayCrossMargin(code: string, amount: any, params?: {}): Promise<{}>;
819
820
  repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{}>;
@@ -847,7 +848,7 @@ export default class Exchange {
847
848
  parseOHLCVs(ohlcvs: object[], market?: any, timeframe?: string, since?: Int, limit?: Int): OHLCV[];
848
849
  parseLeverageTiers(response: any, symbols?: string[], marketIdKey?: any): LeverageTiers;
849
850
  loadTradingLimits(symbols?: Strings, reload?: boolean, params?: {}): Promise<Dictionary<any>>;
850
- safePosition(position: any): Position;
851
+ safePosition(position: Dict): Position;
851
852
  parsePositions(positions: any[], symbols?: string[], params?: {}): Position[];
852
853
  parseAccounts(accounts: any[], params?: {}): Account[];
853
854
  parseTrades(trades: any[], market?: Market, since?: Int, limit?: Int, params?: {}): Trade[];
@@ -1092,7 +1093,7 @@ export default class Exchange {
1092
1093
  sortCursorPaginatedResult(result: any): any;
1093
1094
  removeRepeatedElementsFromArray(input: any): any;
1094
1095
  handleUntilOption(key: string, request: any, params: any, multiplier?: number): any[];
1095
- safeOpenInterest(interest: any, market?: Market): OpenInterest;
1096
+ safeOpenInterest(interest: Dict, market?: Market): OpenInterest;
1096
1097
  parseLiquidation(liquidation: any, market?: Market): Liquidation;
1097
1098
  parseLiquidations(liquidations: Dict[], market?: Market, since?: Int, limit?: Int): Liquidation[];
1098
1099
  parseGreeks(greeks: Dict, market?: Market): Greeks;
@@ -785,7 +785,7 @@ export default class Exchange {
785
785
  // @ts-ignore
786
786
  this.httpProxyAgentModule = await import(/* webpackIgnore: true */ 'http-proxy-agent');
787
787
  // @ts-ignore
788
- this.httpProxyAgentModule = await import(/* webpackIgnore: true */ 'https-proxy-agent');
788
+ this.httpsProxyAgentModule = await import(/* webpackIgnore: true */ 'https-proxy-agent');
789
789
  }
790
790
  catch (e) { }
791
791
  }
@@ -1165,7 +1165,7 @@ export default class Exchange {
1165
1165
  return new CountedOrderBook(snapshot, depth);
1166
1166
  }
1167
1167
  handleMessage(client, message) { } // stub to override
1168
- // ping (client) {} // stub to override
1168
+ // ping (client: Client) {} // stub to override
1169
1169
  ping(client) {
1170
1170
  return undefined;
1171
1171
  }
package/js/src/bingx.js CHANGED
@@ -286,6 +286,10 @@ export default class bingx extends Exchange {
286
286
  'trade/leverage': 2,
287
287
  'trade/forceOrders': 2,
288
288
  'trade/allFillOrders': 2,
289
+ 'trade/openOrders': 2,
290
+ 'trade/orderDetail': 2,
291
+ 'trade/orderHistory': 2,
292
+ 'trade/marginType': 2,
289
293
  'user/commissionRate': 2,
290
294
  'user/positions': 2,
291
295
  'user/balance': 2,
@@ -294,9 +298,12 @@ export default class bingx extends Exchange {
294
298
  'trade/order': 2,
295
299
  'trade/leverage': 2,
296
300
  'trade/closeAllPositions': 2,
301
+ 'trade/marginType': 2,
302
+ 'trade/positionMargin': 2,
297
303
  },
298
304
  'delete': {
299
305
  'trade/allOpenOrders': 2,
306
+ 'trade/cancelOrder': 2,
300
307
  },
301
308
  },
302
309
  },
@@ -3007,7 +3014,8 @@ export default class bingx extends Exchange {
3007
3014
  // "clientOrderID": ""
3008
3015
  // }
3009
3016
  //
3010
- // inverse swap cancelAllOrders
3017
+ // inverse swap cancelAllOrders, cancelOrder
3018
+ // inverse swap cancelAllOrders, cancelOrder, fetchOpenOrders
3011
3019
  //
3012
3020
  // {
3013
3021
  // "symbol": "SOL-USD",
@@ -3169,13 +3177,14 @@ export default class bingx extends Exchange {
3169
3177
  * @method
3170
3178
  * @name bingx#cancelOrder
3171
3179
  * @description cancels an open order
3172
- * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Cancel%20an%20Order
3173
- * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20an%20Order
3180
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20Order
3181
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20Order
3182
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20an%20Order
3174
3183
  * @param {string} id order id
3175
3184
  * @param {string} symbol unified symbol of the market the order was made in
3176
3185
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3177
3186
  * @param {string} [params.clientOrderId] a unique id for the order
3178
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3187
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3179
3188
  */
3180
3189
  if (symbol === undefined) {
3181
3190
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
@@ -3194,12 +3203,20 @@ export default class bingx extends Exchange {
3194
3203
  request['orderId'] = id;
3195
3204
  }
3196
3205
  let response = undefined;
3197
- const [marketType, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
3198
- if (marketType === 'spot') {
3199
- response = await this.spotV1PrivatePostTradeCancel(this.extend(request, query));
3206
+ let type = undefined;
3207
+ let subType = undefined;
3208
+ [type, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
3209
+ [subType, params] = this.handleSubTypeAndParams('cancelOrder', market, params);
3210
+ if (type === 'spot') {
3211
+ response = await this.spotV1PrivatePostTradeCancel(this.extend(request, params));
3200
3212
  }
3201
3213
  else {
3202
- response = await this.swapV2PrivateDeleteTradeOrder(this.extend(request, query));
3214
+ if (subType === 'inverse') {
3215
+ response = await this.cswapV1PrivateDeleteTradeCancelOrder(this.extend(request, params));
3216
+ }
3217
+ else {
3218
+ response = await this.swapV2PrivateDeleteTradeOrder(this.extend(request, params));
3219
+ }
3203
3220
  }
3204
3221
  //
3205
3222
  // spot
@@ -3220,7 +3237,59 @@ export default class bingx extends Exchange {
3220
3237
  // }
3221
3238
  // }
3222
3239
  //
3223
- // swap
3240
+ // inverse swap
3241
+ //
3242
+ // {
3243
+ // "code": 0,
3244
+ // "msg": "",
3245
+ // "data": {
3246
+ // "order": {
3247
+ // "symbol": "SOL-USD",
3248
+ // "orderId": "1816002957423951872",
3249
+ // "side": "BUY",
3250
+ // "positionSide": "Long",
3251
+ // "type": "Pending",
3252
+ // "quantity": 0,
3253
+ // "origQty": "0",
3254
+ // "price": "150",
3255
+ // "executedQty": "0",
3256
+ // "avgPrice": "0",
3257
+ // "cumQuote": "0",
3258
+ // "stopPrice": "",
3259
+ // "profit": "0.0000",
3260
+ // "commission": "0.000000",
3261
+ // "status": "CANCELLED",
3262
+ // "time": 1721803819410,
3263
+ // "updateTime": 1721803819427,
3264
+ // "clientOrderId": "",
3265
+ // "leverage": "",
3266
+ // "takeProfit": {
3267
+ // "type": "",
3268
+ // "quantity": 0,
3269
+ // "stopPrice": 0,
3270
+ // "price": 0,
3271
+ // "workingType": "",
3272
+ // "stopGuaranteed": ""
3273
+ // },
3274
+ // "stopLoss": {
3275
+ // "type": "",
3276
+ // "quantity": 0,
3277
+ // "stopPrice": 0,
3278
+ // "price": 0,
3279
+ // "workingType": "",
3280
+ // "stopGuaranteed": ""
3281
+ // },
3282
+ // "advanceAttr": 0,
3283
+ // "positionID": 0,
3284
+ // "takeProfitEntrustPrice": 0,
3285
+ // "stopLossEntrustPrice": 0,
3286
+ // "orderType": "",
3287
+ // "workingType": ""
3288
+ // }
3289
+ // }
3290
+ // }
3291
+ //
3292
+ // linear swap
3224
3293
  //
3225
3294
  // {
3226
3295
  // "code": 0,
@@ -3247,9 +3316,9 @@ export default class bingx extends Exchange {
3247
3316
  // }
3248
3317
  // }
3249
3318
  //
3250
- const data = this.safeValue(response, 'data');
3251
- const first = this.safeDict(data, 'order', data);
3252
- return this.parseOrder(first, market);
3319
+ const data = this.safeDict(response, 'data', {});
3320
+ const order = this.safeDict(data, 'order', data);
3321
+ return this.parseOrder(order, market);
3253
3322
  }
3254
3323
  async cancelAllOrders(symbol = undefined, params = {}) {
3255
3324
  /**
@@ -3729,9 +3798,10 @@ export default class bingx extends Exchange {
3729
3798
  /**
3730
3799
  * @method
3731
3800
  * @name bingx#fetchOpenOrders
3732
- * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Open%20Orders
3733
- * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20all%20current%20pending%20orders
3734
3801
  * @description fetch all unfilled currently open orders
3802
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Current%20Open%20Orders
3803
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Current%20All%20Open%20Orders
3804
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20all%20current%20pending%20orders
3735
3805
  * @param {string} symbol unified market symbol
3736
3806
  * @param {int} [since] the earliest time in ms to fetch open orders for
3737
3807
  * @param {int} [limit] the maximum number of open order structures to retrieve
@@ -3745,13 +3815,21 @@ export default class bingx extends Exchange {
3745
3815
  market = this.market(symbol);
3746
3816
  request['symbol'] = market['id'];
3747
3817
  }
3818
+ let type = undefined;
3819
+ let subType = undefined;
3748
3820
  let response = undefined;
3749
- const [marketType, query] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
3750
- if (marketType === 'spot') {
3751
- response = await this.spotV1PrivateGetTradeOpenOrders(this.extend(request, query));
3821
+ [type, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
3822
+ [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
3823
+ if (type === 'spot') {
3824
+ response = await this.spotV1PrivateGetTradeOpenOrders(this.extend(request, params));
3752
3825
  }
3753
3826
  else {
3754
- response = await this.swapV2PrivateGetTradeOpenOrders(this.extend(request, query));
3827
+ if (subType === 'inverse') {
3828
+ response = await this.cswapV1PrivateGetTradeOpenOrders(this.extend(request, params));
3829
+ }
3830
+ else {
3831
+ response = await this.swapV2PrivateGetTradeOpenOrders(this.extend(request, params));
3832
+ }
3755
3833
  }
3756
3834
  //
3757
3835
  // spot
@@ -3779,7 +3857,61 @@ export default class bingx extends Exchange {
3779
3857
  // }
3780
3858
  // }
3781
3859
  //
3782
- // swap
3860
+ // inverse swap
3861
+ //
3862
+ // {
3863
+ // "code": 0,
3864
+ // "msg": "",
3865
+ // "data": {
3866
+ // "orders": [
3867
+ // {
3868
+ // "symbol": "SOL-USD",
3869
+ // "orderId": "1816013900044320768",
3870
+ // "side": "BUY",
3871
+ // "positionSide": "Long",
3872
+ // "type": "LIMIT",
3873
+ // "quantity": 1,
3874
+ // "origQty": "",
3875
+ // "price": "150",
3876
+ // "executedQty": "0",
3877
+ // "avgPrice": "0.000",
3878
+ // "cumQuote": "",
3879
+ // "stopPrice": "",
3880
+ // "profit": "0.0000",
3881
+ // "commission": "0.0000",
3882
+ // "status": "Pending",
3883
+ // "time": 1721806428334,
3884
+ // "updateTime": 1721806428352,
3885
+ // "clientOrderId": "",
3886
+ // "leverage": "",
3887
+ // "takeProfit": {
3888
+ // "type": "TAKE_PROFIT",
3889
+ // "quantity": 0,
3890
+ // "stopPrice": 0,
3891
+ // "price": 0,
3892
+ // "workingType": "MARK_PRICE",
3893
+ // "stopGuaranteed": ""
3894
+ // },
3895
+ // "stopLoss": {
3896
+ // "type": "STOP",
3897
+ // "quantity": 0,
3898
+ // "stopPrice": 0,
3899
+ // "price": 0,
3900
+ // "workingType": "MARK_PRICE",
3901
+ // "stopGuaranteed": ""
3902
+ // },
3903
+ // "advanceAttr": 0,
3904
+ // "positionID": 0,
3905
+ // "takeProfitEntrustPrice": 0,
3906
+ // "stopLossEntrustPrice": 0,
3907
+ // "orderType": "",
3908
+ // "workingType": "MARK_PRICE"
3909
+ // }
3910
+ // ]
3911
+ // }
3912
+ // }
3913
+ //
3914
+ // linear swap
3783
3915
  //
3784
3916
  // {
3785
3917
  // "code": 0,