ccxt 4.5.18 → 4.5.20

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 (152) hide show
  1. package/README.md +7 -6
  2. package/dist/ccxt.browser.min.js +40 -16
  3. package/dist/cjs/_virtual/index.cjs.js +1459 -9
  4. package/dist/cjs/ccxt.js +8 -2
  5. package/dist/cjs/src/abstract/dydx.js +11 -0
  6. package/dist/cjs/src/base/Exchange.js +164 -10
  7. package/dist/cjs/src/base/ws/Client.js +3 -1
  8. package/dist/cjs/src/binance.js +8 -1
  9. package/dist/cjs/src/bingx.js +20 -0
  10. package/dist/cjs/src/bitget.js +43 -41
  11. package/dist/cjs/src/bybit.js +21 -23
  12. package/dist/cjs/src/deribit.js +6 -0
  13. package/dist/cjs/src/dydx.js +2454 -0
  14. package/dist/cjs/src/gate.js +4 -4
  15. package/dist/cjs/src/hibachi.js +1 -1
  16. package/dist/cjs/src/hyperliquid.js +207 -9
  17. package/dist/cjs/src/kucoin.js +711 -109
  18. package/dist/cjs/src/mexc.js +2 -3
  19. package/dist/cjs/src/pro/binance.js +59 -144
  20. package/dist/cjs/src/pro/dydx.js +418 -0
  21. package/dist/cjs/src/pro/kraken.js +4 -3
  22. package/dist/cjs/src/pro/xt.js +218 -4
  23. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +1 -0
  24. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +56 -0
  25. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +56 -0
  26. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +48 -0
  27. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +343 -0
  28. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +717 -0
  29. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +60 -0
  30. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +45 -0
  31. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +380 -0
  32. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +72 -0
  33. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +211 -0
  34. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +195 -0
  35. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +49 -0
  36. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +57 -0
  37. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +56 -0
  38. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +79 -0
  39. package/dist/cjs/src/static_dependencies/dydx-v4-client/long/index.cjs.js +9 -0
  40. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +59 -0
  41. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +39 -0
  42. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +69 -0
  43. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +108 -0
  44. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +50 -1
  45. package/dist/cjs/src/static_dependencies/scure-base/index.js +29 -0
  46. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +278 -0
  47. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +97 -0
  48. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +2060 -0
  49. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2 -0
  50. package/dist/cjs/src/toobit.js +2 -1
  51. package/js/ccxt.d.ts +8 -2
  52. package/js/ccxt.js +6 -2
  53. package/js/src/abstract/binance.d.ts +7 -0
  54. package/js/src/abstract/binancecoinm.d.ts +7 -0
  55. package/js/src/abstract/binanceus.d.ts +7 -0
  56. package/js/src/abstract/binanceusdm.d.ts +7 -0
  57. package/js/src/abstract/bitget.d.ts +1 -0
  58. package/js/src/abstract/dydx.d.ts +61 -0
  59. package/js/src/abstract/dydx.js +11 -0
  60. package/js/src/abstract/kucoin.d.ts +1 -1
  61. package/js/src/abstract/kucoinfutures.d.ts +1 -1
  62. package/js/src/base/Exchange.d.ts +7 -0
  63. package/js/src/base/Exchange.js +163 -10
  64. package/js/src/base/ws/Client.js +3 -1
  65. package/js/src/binance.js +8 -1
  66. package/js/src/bingx.js +20 -0
  67. package/js/src/bitget.d.ts +3 -3
  68. package/js/src/bitget.js +43 -41
  69. package/js/src/bybit.d.ts +3 -3
  70. package/js/src/bybit.js +21 -23
  71. package/js/src/deribit.js +6 -0
  72. package/js/src/dydx.d.ts +364 -0
  73. package/js/src/dydx.js +2453 -0
  74. package/js/src/gate.d.ts +2 -2
  75. package/js/src/gate.js +4 -4
  76. package/js/src/hibachi.js +1 -1
  77. package/js/src/hyperliquid.d.ts +17 -0
  78. package/js/src/hyperliquid.js +207 -9
  79. package/js/src/kucoin.d.ts +48 -1
  80. package/js/src/kucoin.js +711 -109
  81. package/js/src/mexc.js +2 -3
  82. package/js/src/pro/binance.d.ts +2 -2
  83. package/js/src/pro/binance.js +59 -144
  84. package/js/src/pro/dydx.d.ts +81 -0
  85. package/js/src/pro/dydx.js +417 -0
  86. package/js/src/pro/kraken.js +4 -3
  87. package/js/src/pro/xt.d.ts +85 -2
  88. package/js/src/pro/xt.js +218 -4
  89. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.d.ts +90 -0
  90. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +163 -0
  91. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.d.ts +26 -0
  92. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +51 -0
  93. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.d.ts +48 -0
  94. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +85 -0
  95. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.d.ts +40 -0
  96. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +77 -0
  97. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.d.ts +162 -0
  98. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +329 -0
  99. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.d.ts +460 -0
  100. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +698 -0
  101. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.d.ts +127 -0
  102. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +286 -0
  103. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.d.ts +66 -0
  104. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +109 -0
  105. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.d.ts +127 -0
  106. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +257 -0
  107. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.d.ts +48 -0
  108. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +93 -0
  109. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.d.ts +23 -0
  110. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +43 -0
  111. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.d.ts +92 -0
  112. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +164 -0
  113. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.d.ts +124 -0
  114. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +196 -0
  115. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.d.ts +159 -0
  116. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +324 -0
  117. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.d.ts +546 -0
  118. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +872 -0
  119. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.d.ts +84 -0
  120. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +181 -0
  121. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.d.ts +397 -0
  122. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +757 -0
  123. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.d.ts +120 -0
  124. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +246 -0
  125. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.d.ts +79 -0
  126. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +147 -0
  127. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.d.ts +32 -0
  128. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +59 -0
  129. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.d.ts +34 -0
  130. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +66 -0
  131. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.d.ts +62 -0
  132. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +111 -0
  133. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.d.ts +207 -0
  134. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +50 -0
  135. package/js/src/static_dependencies/dydx-v4-client/helpers.d.ts +82 -0
  136. package/js/src/static_dependencies/dydx-v4-client/helpers.js +172 -0
  137. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +1473 -0
  138. package/js/src/static_dependencies/dydx-v4-client/long/index.d.cts +2 -0
  139. package/js/src/static_dependencies/dydx-v4-client/onboarding.d.ts +35 -0
  140. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +56 -0
  141. package/js/src/static_dependencies/dydx-v4-client/registry.d.ts +7 -0
  142. package/js/src/static_dependencies/dydx-v4-client/registry.js +36 -0
  143. package/js/src/static_dependencies/noble-hashes/utils.d.ts +1 -0
  144. package/js/src/static_dependencies/noble-hashes/utils.js +4 -0
  145. package/js/src/static_dependencies/scure-bip32/index.d.ts +49 -0
  146. package/js/src/static_dependencies/scure-bip32/index.js +295 -0
  147. package/js/src/static_dependencies/scure-bip39/index.d.ts +54 -0
  148. package/js/src/static_dependencies/scure-bip39/index.js +140 -0
  149. package/js/src/static_dependencies/scure-bip39/wordlists/english.d.ts +1 -0
  150. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +2054 -0
  151. package/js/src/toobit.js +2 -1
  152. package/package.json +9 -3
@@ -0,0 +1,417 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import dydxRest from '../dydx.js';
9
+ import { ArrayCache, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
10
+ import { ExchangeError } from '../base/errors.js';
11
+ // ---------------------------------------------------------------------------
12
+ export default class dydx extends dydxRest {
13
+ describe() {
14
+ return this.deepExtend(super.describe(), {
15
+ 'has': {
16
+ 'ws': true,
17
+ 'watchBalance': false,
18
+ 'watchTicker': false,
19
+ 'watchTickers': false,
20
+ 'watchTrades': true,
21
+ 'watchOrderBook': true,
22
+ 'watchOHLCV': true,
23
+ },
24
+ 'urls': {
25
+ 'test': {
26
+ 'ws': 'wss://indexer.v4testnet.dydx.exchange/v4/ws',
27
+ },
28
+ 'api': {
29
+ 'ws': 'wss://indexer.dydx.trade/v4/ws',
30
+ },
31
+ },
32
+ 'options': {},
33
+ 'streaming': {},
34
+ 'exceptions': {},
35
+ });
36
+ }
37
+ /**
38
+ * @method
39
+ * @name dydx#watchTrades
40
+ * @description get the list of most recent trades for a particular symbol
41
+ * @see https://docs.dydx.xyz/indexer-client/websockets#trades
42
+ * @param {string} symbol unified symbol of the market to fetch trades for
43
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
44
+ * @param {int} [limit] the maximum amount of trades to fetch
45
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
46
+ * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
47
+ */
48
+ async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
49
+ await this.loadMarkets();
50
+ const url = this.urls['api']['ws'];
51
+ const market = this.market(symbol);
52
+ const messageHash = 'trade:' + market['symbol'];
53
+ const request = {
54
+ 'type': 'subscribe',
55
+ 'channel': 'v4_trades',
56
+ 'id': market['id'],
57
+ };
58
+ const trades = await this.watch(url, messageHash, this.extend(request, params), messageHash);
59
+ if (this.newUpdates) {
60
+ limit = trades.getLimit(symbol, limit);
61
+ }
62
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
63
+ }
64
+ /**
65
+ * @method
66
+ * @name dydx#unWatchTrades
67
+ * @description unsubscribes from the trades channel
68
+ * @see https://docs.dydx.xyz/indexer-client/websockets#trades
69
+ * @param {string} symbol unified symbol of the market to fetch trades for
70
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
71
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
72
+ */
73
+ async unWatchTrades(symbol, params = {}) {
74
+ await this.loadMarkets();
75
+ const url = this.urls['api']['ws'];
76
+ const market = this.market(symbol);
77
+ const messageHash = 'trade:' + market['symbol'];
78
+ const request = {
79
+ 'type': 'unsubscribe',
80
+ 'channel': 'v4_trades',
81
+ 'id': market['id'],
82
+ };
83
+ return await this.watch(url, messageHash, this.extend(request, params), messageHash);
84
+ }
85
+ handleTrades(client, message) {
86
+ //
87
+ // {
88
+ // "type": "subscribed",
89
+ // "connection_id": "9011edff-d8f7-47fc-bbc6-0c7b5ba7dfae",
90
+ // "message_id": 3,
91
+ // "channel": "v4_trades",
92
+ // "id": "BTC-USD",
93
+ // "contents": {
94
+ // "trades": [
95
+ // {
96
+ // "id": "02b6148d0000000200000005",
97
+ // "side": "BUY",
98
+ // "size": "0.024",
99
+ // "price": "114581",
100
+ // "type": "LIMIT",
101
+ // "createdAt": "2025-08-04T00:42:07.118Z",
102
+ // "createdAtHeight": "45487245"
103
+ // }
104
+ // ]
105
+ // }
106
+ // }
107
+ //
108
+ const marketId = this.safeString(message, 'id');
109
+ const market = this.safeMarket(marketId);
110
+ const symbol = market['symbol'];
111
+ const content = this.safeDict(message, 'contents');
112
+ const rawTrades = this.safeList(content, 'trades', []);
113
+ let stored = this.safeValue(this.trades, symbol);
114
+ if (stored === undefined) {
115
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
116
+ stored = new ArrayCache(limit);
117
+ this.trades[symbol] = stored;
118
+ }
119
+ const parsedTrades = this.parseTrades(rawTrades, market);
120
+ for (let i = 0; i < parsedTrades.length; i++) {
121
+ const parsed = parsedTrades[i];
122
+ stored.append(parsed);
123
+ }
124
+ const messageHash = 'trade' + ':' + symbol;
125
+ client.resolve(stored, messageHash);
126
+ }
127
+ parseWsTrade(trade, market = undefined) {
128
+ //
129
+ // {
130
+ // "id": "02b6148d0000000200000005",
131
+ // "side": "BUY",
132
+ // "size": "0.024",
133
+ // "price": "114581",
134
+ // "type": "LIMIT",
135
+ // "createdAt": "2025-08-04T00:42:07.118Z",
136
+ // "createdAtHeight": "45487245"
137
+ // }
138
+ //
139
+ const timestamp = this.parse8601(this.safeString(trade, 'createdAt'));
140
+ return this.safeTrade({
141
+ 'id': this.safeString(trade, 'id'),
142
+ 'info': trade,
143
+ 'timestamp': timestamp,
144
+ 'datetime': this.iso8601(timestamp),
145
+ 'symbol': this.safeString(market, 'symbol'),
146
+ 'order': undefined,
147
+ 'type': this.safeStringLower(trade, 'type'),
148
+ 'side': this.safeStringLower(trade, 'side'),
149
+ 'takerOrMaker': undefined,
150
+ 'price': this.safeString(trade, 'price'),
151
+ 'amount': this.safeString(trade, 'size'),
152
+ 'cost': undefined,
153
+ 'fee': undefined,
154
+ }, market);
155
+ }
156
+ /**
157
+ * @method
158
+ * @name dydx#watchOrderBook
159
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
160
+ * @see https://docs.dydx.xyz/indexer-client/websockets#orders
161
+ * @param {string} symbol unified symbol of the market to fetch the order book for
162
+ * @param {int} [limit] the maximum amount of order book entries to return
163
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
164
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
165
+ */
166
+ async watchOrderBook(symbol, limit = undefined, params = {}) {
167
+ await this.loadMarkets();
168
+ const url = this.urls['api']['ws'];
169
+ const market = this.market(symbol);
170
+ const messageHash = 'orderbook:' + market['symbol'];
171
+ const request = {
172
+ 'type': 'subscribe',
173
+ 'channel': 'v4_orderbook',
174
+ 'id': market['id'],
175
+ };
176
+ const orderbook = await this.watch(url, messageHash, this.extend(request, params), messageHash);
177
+ return orderbook.limit();
178
+ }
179
+ /**
180
+ * @method
181
+ * @name dydx#unWatchOrderBook
182
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
183
+ * @see https://docs.dydx.xyz/indexer-client/websockets#orders
184
+ * @param {string} symbol unified array of symbols
185
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
186
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
187
+ */
188
+ async unWatchOrderBook(symbol, params = {}) {
189
+ await this.loadMarkets();
190
+ const url = this.urls['api']['ws'];
191
+ const market = this.market(symbol);
192
+ const messageHash = 'orderbook:' + market['symbol'];
193
+ const request = {
194
+ 'type': 'unsubscribe',
195
+ 'channel': 'v4_orderbook',
196
+ 'id': market['id'],
197
+ };
198
+ return await this.watch(url, messageHash, this.extend(request, params), messageHash);
199
+ }
200
+ handleOrderBook(client, message) {
201
+ //
202
+ // {
203
+ // "type": "subscribed",
204
+ // "connection_id": "7af140fb-b33d-4f0e-8f4c-30f16337b360",
205
+ // "message_id": 1,
206
+ // "channel": "v4_orderbook",
207
+ // "id": "BTC-USD",
208
+ // "contents": {
209
+ // "bids": [
210
+ // {
211
+ // "price": "114623",
212
+ // "size": "0.1112"
213
+ // }
214
+ // ],
215
+ // "asks": [
216
+ // {
217
+ // "price": "114624",
218
+ // "size": "0.0872"
219
+ // }
220
+ // ]
221
+ // }
222
+ // }
223
+ //
224
+ const marketId = this.safeString(message, 'id');
225
+ const market = this.safeMarket(marketId);
226
+ const symbol = market['symbol'];
227
+ const content = this.safeDict(message, 'contents');
228
+ let orderbook = this.safeValue(this.orderbooks, symbol);
229
+ if (orderbook === undefined) {
230
+ orderbook = this.orderBook();
231
+ }
232
+ orderbook['symbol'] = symbol;
233
+ const asks = this.safeList(content, 'asks', []);
234
+ const bids = this.safeList(content, 'bids', []);
235
+ this.handleDeltas(orderbook['asks'], asks);
236
+ this.handleDeltas(orderbook['bids'], bids);
237
+ orderbook['nonce'] = this.safeInteger(message, 'message_id');
238
+ const messageHash = 'orderbook:' + symbol;
239
+ this.orderbooks[symbol] = orderbook;
240
+ client.resolve(orderbook, messageHash);
241
+ }
242
+ handleDelta(bookside, delta) {
243
+ if (Array.isArray(delta)) {
244
+ const price = this.safeFloat(delta, 0);
245
+ const amount = this.safeFloat(delta, 1);
246
+ bookside.store(price, amount);
247
+ }
248
+ else {
249
+ const bidAsk = this.parseBidAsk(delta, 'price', 'size');
250
+ bookside.storeArray(bidAsk);
251
+ }
252
+ }
253
+ /**
254
+ * @method
255
+ * @name dydx#watchOHLCV
256
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
257
+ * @see https://docs.dydx.xyz/indexer-client/websockets#candles
258
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
259
+ * @param {string} timeframe the length of time each candle represents
260
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
261
+ * @param {int} [limit] the maximum amount of candles to fetch
262
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
263
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
264
+ */
265
+ async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
266
+ await this.loadMarkets();
267
+ const url = this.urls['api']['ws'];
268
+ const market = this.market(symbol);
269
+ const messageHash = 'ohlcv:' + market['symbol'];
270
+ const resolution = this.safeString(this.timeframes, timeframe, timeframe);
271
+ const request = {
272
+ 'type': 'subscribe',
273
+ 'channel': 'v4_candles',
274
+ 'id': market['id'] + '/' + resolution,
275
+ };
276
+ const ohlcv = await this.watch(url, messageHash, this.extend(request, params), messageHash);
277
+ if (this.newUpdates) {
278
+ limit = ohlcv.getLimit(symbol, limit);
279
+ }
280
+ return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
281
+ }
282
+ /**
283
+ * @method
284
+ * @name dydx#unWatchOHLCV
285
+ * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
286
+ * @see https://docs.dydx.xyz/indexer-client/websockets#candles
287
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
288
+ * @param {string} timeframe the length of time each candle represents
289
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
290
+ * @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
291
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
292
+ */
293
+ async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
294
+ await this.loadMarkets();
295
+ const url = this.urls['api']['ws'];
296
+ const market = this.market(symbol);
297
+ const messageHash = 'ohlcv:' + market['symbol'];
298
+ const resolution = this.safeString(this.timeframes, timeframe, timeframe);
299
+ const request = {
300
+ 'type': 'unsubscribe',
301
+ 'channel': 'v4_candles',
302
+ 'id': market['id'] + '/' + resolution,
303
+ };
304
+ return await this.watch(url, messageHash, this.extend(request, params), messageHash);
305
+ }
306
+ handleOHLCV(client, message) {
307
+ //
308
+ // {
309
+ // "type": "subscribed",
310
+ // "connection_id": "e00b6e27-590c-4e91-a24d-b0645289434b",
311
+ // "message_id": 1,
312
+ // "channel": "v4_candles",
313
+ // "id": "BTC-USD/1MIN",
314
+ // "contents": {
315
+ // "candles": [
316
+ // {
317
+ // "startedAt": "2025-08-05T03:40:00.000Z",
318
+ // "ticker": "BTC-USD",
319
+ // "resolution": "1MIN",
320
+ // "low": "114249",
321
+ // "high": "114256",
322
+ // "open": "114256",
323
+ // "close": "114249",
324
+ // "baseTokenVolume": "0.4726",
325
+ // "usdVolume": "53996.1818",
326
+ // "trades": 7,
327
+ // "startingOpenInterest": "501.7424",
328
+ // "orderbookMidPriceOpen": "114255.5",
329
+ // "orderbookMidPriceClose": "114255.5"
330
+ // }
331
+ // ]
332
+ // }
333
+ // }
334
+ // {
335
+ // "type": "channel_data",
336
+ // "connection_id": "e00b6e27-590c-4e91-a24d-b0645289434b",
337
+ // "message_id": 3,
338
+ // "id": "BTC-USD/1MIN",
339
+ // "channel": "v4_candles",
340
+ // "version": "1.0.0",
341
+ // "contents": {
342
+ // "startedAt": "2025-08-05T03:40:00.000Z",
343
+ // "ticker": "BTC-USD",
344
+ // "resolution": "1MIN",
345
+ // "low": "114249",
346
+ // "high": "114262",
347
+ // "open": "114256",
348
+ // "close": "114261",
349
+ // "baseTokenVolume": "0.4753",
350
+ // "usdVolume": "54304.6873",
351
+ // "trades": 9,
352
+ // "startingOpenInterest": "501.7424",
353
+ // "orderbookMidPriceOpen": "114255.5",
354
+ // "orderbookMidPriceClose": "114255.5"
355
+ // }
356
+ // }
357
+ //
358
+ const id = this.safeString(message, 'id');
359
+ const part = id.split('/');
360
+ const interval = this.safeString(part, 1);
361
+ const timeframe = this.findTimeframe(interval);
362
+ const marketId = this.safeString(part, 0);
363
+ const market = this.safeMarket(marketId);
364
+ const symbol = market['symbol'];
365
+ const content = this.safeDict(message, 'contents');
366
+ const candles = this.safeList(content, 'candles');
367
+ const messageHash = 'ohlcv:' + symbol;
368
+ const ohlcv = this.safeDict(candles, 0, content);
369
+ const parsed = this.parseOHLCV(ohlcv, market);
370
+ this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
371
+ let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
372
+ if (stored === undefined) {
373
+ const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
374
+ stored = new ArrayCacheByTimestamp(limit);
375
+ this.ohlcvs[symbol][timeframe] = stored;
376
+ }
377
+ stored.append(parsed);
378
+ client.resolve(stored, messageHash);
379
+ }
380
+ handleErrorMessage(client, message) {
381
+ //
382
+ // {
383
+ // "type": "error",
384
+ // "message": "....",
385
+ // "connection_id": "9011edff-d8f7-47fc-bbc6-0c7b5ba7dfae",
386
+ // "message_id": 4
387
+ // }
388
+ //
389
+ try {
390
+ const msg = this.safeString(message, 'message');
391
+ throw new ExchangeError(this.id + ' ' + msg);
392
+ }
393
+ catch (e) {
394
+ client.reject(e);
395
+ }
396
+ return true;
397
+ }
398
+ handleMessage(client, message) {
399
+ const type = this.safeString(message, 'type');
400
+ if (type === 'error') {
401
+ this.handleErrorMessage(client, message);
402
+ return;
403
+ }
404
+ if (type !== undefined) {
405
+ const topic = this.safeString(message, 'channel');
406
+ const methods = {
407
+ 'v4_trades': this.handleTrades,
408
+ 'v4_orderbook': this.handleOrderBook,
409
+ 'v4_candles': this.handleOHLCV,
410
+ };
411
+ const method = this.safeValue(methods, topic);
412
+ if (method !== undefined) {
413
+ method.call(this, client, message);
414
+ }
415
+ }
416
+ }
417
+ }
@@ -1244,8 +1244,7 @@ export default class kraken extends krakenRest {
1244
1244
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1245
1245
  */
1246
1246
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1247
- params['snap_orders'] = true;
1248
- return await this.watchPrivate('orders', symbol, since, limit, params);
1247
+ return await this.watchPrivate('orders', symbol, since, limit, this.extend(params, { 'snap_orders': true }));
1249
1248
  }
1250
1249
  handleOrders(client, message, subscription = undefined) {
1251
1250
  //
@@ -1305,7 +1304,9 @@ export default class kraken extends krakenRest {
1305
1304
  }
1306
1305
  }
1307
1306
  stored.append(newOrder);
1308
- symbols[symbol] = true;
1307
+ if (symbol !== undefined) {
1308
+ symbols[symbol] = true;
1309
+ }
1309
1310
  }
1310
1311
  const name = 'orders';
1311
1312
  client.resolve(this.orders, name);
@@ -30,6 +30,24 @@ export default class xt extends xtRest {
30
30
  * @returns {object} data from the websocket stream
31
31
  */
32
32
  subscribe(name: string, access: string, methodName: string, market?: Market, symbols?: string[], params?: {}): Promise<any>;
33
+ /**
34
+ * @ignore
35
+ * @method
36
+ * @description Connects to a websocket channel
37
+ * @see https://doc.xt.com/#websocket_privaterequestFormat
38
+ * @see https://doc.xt.com/#futures_market_websocket_v2base
39
+ * @param {string} messageHash the message hash of the subscription
40
+ * @param {string} name name of the channel
41
+ * @param {string} access public or private
42
+ * @param {string} methodName the name of the CCXT class method
43
+ * @param {string} topic topic of the subscription
44
+ * @param {object} [market] CCXT market
45
+ * @param {string[]} [symbols] unified market symbols
46
+ * @param {object} params extra parameters specific to the xt api
47
+ * @param {object} subscriptionParams extra parameters specific to the subscription
48
+ * @returns {object} data from the websocket stream
49
+ */
50
+ unSubscribe(messageHash: string, name: string, access: string, methodName: string, topic: string, market?: Market, symbols?: string[], params?: {}, subscriptionParams?: {}): Promise<any>;
33
51
  /**
34
52
  * @method
35
53
  * @name xt#watchTicker
@@ -45,7 +63,20 @@ export default class xt extends xtRest {
45
63
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
46
64
  /**
47
65
  * @method
48
- * @name xt#watchTicker
66
+ * @name xt#unWatchTicker
67
+ * @description stops watching a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
68
+ * @see https://doc.xt.com/#websocket_publictickerRealTime
69
+ * @see https://doc.xt.com/#futures_market_websocket_v2tickerRealTime
70
+ * @see https://doc.xt.com/#futures_market_websocket_v2aggTickerRealTime
71
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
72
+ * @param {object} params extra parameters specific to the xt api endpoint
73
+ * @param {string} [params.method] 'agg_ticker' (contract only) or 'ticker', default = 'ticker' - the endpoint that will be streamed
74
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
75
+ */
76
+ unWatchTicker(symbol: string, params?: {}): Promise<Ticker>;
77
+ /**
78
+ * @method
79
+ * @name xt#watchTickers
49
80
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
50
81
  * @see https://doc.xt.com/#websocket_publicallTicker
51
82
  * @see https://doc.xt.com/#futures_market_websocket_v2allTicker
@@ -58,7 +89,20 @@ export default class xt extends xtRest {
58
89
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
59
90
  /**
60
91
  * @method
61
- * @name hitbtc#watchOHLCV
92
+ * @name xt#unWatchTickers
93
+ * @description stops watching a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
94
+ * @see https://doc.xt.com/#websocket_publicallTicker
95
+ * @see https://doc.xt.com/#futures_market_websocket_v2allTicker
96
+ * @see https://doc.xt.com/#futures_market_websocket_v2allAggTicker
97
+ * @param {string} [symbols] unified market symbols
98
+ * @param {object} params extra parameters specific to the xt api endpoint
99
+ * @param {string} [params.method] 'agg_tickers' (contract only) or 'tickers', default = 'tickers' - the endpoint that will be streamed
100
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
101
+ */
102
+ unWatchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
103
+ /**
104
+ * @method
105
+ * @name xt#watchOHLCV
62
106
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
63
107
  * @see https://doc.xt.com/#websocket_publicsymbolKline
64
108
  * @see https://doc.xt.com/#futures_market_websocket_v2symbolKline
@@ -70,6 +114,18 @@ export default class xt extends xtRest {
70
114
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
71
115
  */
72
116
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
117
+ /**
118
+ * @method
119
+ * @name xt#unWatchOHLCV
120
+ * @description stops watching historical candlestick data containing the open, high, low, and close price, and the volume of a market
121
+ * @see https://doc.xt.com/#websocket_publicsymbolKline
122
+ * @see https://doc.xt.com/#futures_market_websocket_v2symbolKline
123
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
124
+ * @param {string} timeframe 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, or 1M
125
+ * @param {object} params extra parameters specific to the xt api endpoint
126
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
127
+ */
128
+ unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<OHLCV[]>;
73
129
  /**
74
130
  * @method
75
131
  * @name xt#watchTrades
@@ -83,6 +139,17 @@ export default class xt extends xtRest {
83
139
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
84
140
  */
85
141
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
142
+ /**
143
+ * @method
144
+ * @name xt#unWatchTrades
145
+ * @description stops watching the list of most recent trades for a particular symbol
146
+ * @see https://doc.xt.com/#websocket_publicdealRecord
147
+ * @see https://doc.xt.com/#futures_market_websocket_v2dealRecord
148
+ * @param {string} symbol unified symbol of the market to fetch trades for
149
+ * @param {object} params extra parameters specific to the xt api endpoint
150
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
151
+ */
152
+ unWatchTrades(symbol: string, params?: {}): Promise<Trade[]>;
86
153
  /**
87
154
  * @method
88
155
  * @name xt#watchOrderBook
@@ -98,6 +165,20 @@ export default class xt extends xtRest {
98
165
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-book-structure} indexed by market symbols
99
166
  */
100
167
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
168
+ /**
169
+ * @method
170
+ * @name xt#unWatchOrderBook
171
+ * @description stops watching information on open orders with bid (buy) and ask (sell) prices, volumes and other data
172
+ * @see https://doc.xt.com/#websocket_publiclimitDepth
173
+ * @see https://doc.xt.com/#websocket_publicincreDepth
174
+ * @see https://doc.xt.com/#futures_market_websocket_v2limitDepth
175
+ * @see https://doc.xt.com/#futures_market_websocket_v2increDepth
176
+ * @param {string} symbol unified symbol of the market to fetch the order book for
177
+ * @param {object} params extra parameters specific to the xt api endpoint
178
+ * @param {int} [params.levels] 5, 10, 20, or 50
179
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-book-structure} indexed by market symbols
180
+ */
181
+ unWatchOrderBook(symbol: string, params?: {}): Promise<OrderBook>;
101
182
  /**
102
183
  * @method
103
184
  * @name xt#watchOrders
@@ -161,5 +242,7 @@ export default class xt extends xtRest {
161
242
  handleMyTrades(client: Client, message: Dict): void;
162
243
  handleMessage(client: Client, message: any): void;
163
244
  ping(client: Client): string;
245
+ handleSubscriptionStatus(client: any, message: any): any;
246
+ handleUnSubscription(client: Client, subscription: Dict): void;
164
247
  handleErrorMessage(client: Client, message: Dict): void;
165
248
  }