ccxt 4.4.75 → 4.4.78

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 (114) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +8 -4
  4. package/dist/cjs/src/abstract/apex.js +9 -0
  5. package/dist/cjs/src/apex.js +1949 -0
  6. package/dist/cjs/src/base/Exchange.js +49 -3
  7. package/dist/cjs/src/binance.js +44 -220
  8. package/dist/cjs/src/bitget.js +139 -71
  9. package/dist/cjs/src/bitmex.js +4 -4
  10. package/dist/cjs/src/bitrue.js +48 -0
  11. package/dist/cjs/src/cex.js +1 -1
  12. package/dist/cjs/src/coinbase.js +32 -3
  13. package/dist/cjs/src/coincatch.js +68 -0
  14. package/dist/cjs/src/coinex.js +3 -0
  15. package/dist/cjs/src/coinlist.js +85 -1
  16. package/dist/cjs/src/hitbtc.js +3 -0
  17. package/dist/cjs/src/hyperliquid.js +13 -4
  18. package/dist/cjs/src/mexc.js +50 -57
  19. package/dist/cjs/src/okx.js +23 -8
  20. package/dist/cjs/src/paradex.js +3 -12
  21. package/dist/cjs/src/phemex.js +2 -1
  22. package/dist/cjs/src/poloniex.js +1 -1
  23. package/dist/cjs/src/pro/apex.js +1043 -0
  24. package/dist/cjs/src/pro/coinbase.js +4 -8
  25. package/dist/cjs/src/pro/gate.js +27 -2
  26. package/dist/cjs/src/pro/hollaex.js +2 -2
  27. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  28. package/dist/cjs/src/pro/p2b.js +2 -2
  29. package/dist/cjs/src/pro/tradeogre.js +283 -0
  30. package/dist/cjs/src/probit.js +1 -0
  31. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2645 -0
  32. package/dist/cjs/src/tradeogre.js +2 -1
  33. package/dist/cjs/src/upbit.js +299 -93
  34. package/dist/cjs/src/whitebit.js +1 -0
  35. package/dist/cjs/src/woo.js +3 -1
  36. package/dist/cjs/src/xt.js +131 -4
  37. package/js/ccxt.d.ts +11 -5
  38. package/js/ccxt.js +8 -4
  39. package/js/src/abstract/apex.d.ts +34 -0
  40. package/js/src/abstract/myokx.d.ts +4 -0
  41. package/js/src/abstract/okx.d.ts +4 -0
  42. package/js/src/abstract/upbit.d.ts +15 -1
  43. package/js/src/abstract/xt.d.ts +3 -0
  44. package/js/src/apex.d.ts +333 -0
  45. package/js/src/apex.js +1951 -0
  46. package/js/src/ascendex.d.ts +3 -3
  47. package/js/src/base/Exchange.d.ts +3 -0
  48. package/js/src/base/Exchange.js +49 -2
  49. package/js/src/binance.d.ts +9 -7
  50. package/js/src/binance.js +44 -220
  51. package/js/src/bitfinex.d.ts +3 -3
  52. package/js/src/bitflyer.d.ts +2 -2
  53. package/js/src/bitget.d.ts +2 -0
  54. package/js/src/bitget.js +139 -71
  55. package/js/src/bitmart.d.ts +4 -4
  56. package/js/src/bitmex.d.ts +3 -3
  57. package/js/src/bitmex.js +4 -4
  58. package/js/src/bitrue.js +48 -0
  59. package/js/src/cex.js +1 -1
  60. package/js/src/coinbase.d.ts +6 -4
  61. package/js/src/coinbase.js +32 -3
  62. package/js/src/coinbaseexchange.d.ts +1 -1
  63. package/js/src/coincatch.d.ts +11 -0
  64. package/js/src/coincatch.js +68 -0
  65. package/js/src/coinex.js +3 -0
  66. package/js/src/coinlist.d.ts +12 -1
  67. package/js/src/coinlist.js +85 -1
  68. package/js/src/cryptocom.d.ts +4 -4
  69. package/js/src/deribit.d.ts +4 -4
  70. package/js/src/derive.d.ts +3 -3
  71. package/js/src/digifinex.d.ts +4 -4
  72. package/js/src/hitbtc.js +3 -0
  73. package/js/src/htx.d.ts +4 -4
  74. package/js/src/hyperliquid.d.ts +1 -0
  75. package/js/src/hyperliquid.js +13 -4
  76. package/js/src/kraken.d.ts +3 -3
  77. package/js/src/krakenfutures.d.ts +2 -2
  78. package/js/src/kucoinfutures.d.ts +5 -5
  79. package/js/src/mexc.d.ts +1 -0
  80. package/js/src/mexc.js +50 -57
  81. package/js/src/okx.js +23 -8
  82. package/js/src/oxfun.d.ts +3 -3
  83. package/js/src/paradex.js +3 -12
  84. package/js/src/phemex.d.ts +3 -3
  85. package/js/src/phemex.js +2 -1
  86. package/js/src/poloniex.d.ts +3 -3
  87. package/js/src/poloniex.js +1 -1
  88. package/js/src/pro/apex.d.ts +160 -0
  89. package/js/src/pro/apex.js +1044 -0
  90. package/js/src/pro/coinbase.js +4 -8
  91. package/js/src/pro/gate.js +27 -2
  92. package/js/src/pro/hollaex.js +2 -2
  93. package/js/src/pro/hyperliquid.js +1 -1
  94. package/js/src/pro/p2b.js +2 -2
  95. package/js/src/pro/tradeogre.d.ts +49 -0
  96. package/js/src/pro/tradeogre.js +284 -0
  97. package/js/src/probit.js +1 -0
  98. package/js/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  99. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  100. package/js/src/tradeogre.js +2 -1
  101. package/js/src/upbit.d.ts +34 -4
  102. package/js/src/upbit.js +299 -93
  103. package/js/src/vertex.d.ts +3 -3
  104. package/js/src/whitebit.js +1 -0
  105. package/js/src/woo.d.ts +4 -4
  106. package/js/src/woo.js +3 -1
  107. package/js/src/woofipro.d.ts +4 -4
  108. package/js/src/xt.d.ts +23 -4
  109. package/js/src/xt.js +131 -4
  110. package/package.json +2 -2
  111. package/js/src/abstract/ace.d.ts +0 -18
  112. package/js/src/ace.d.ts +0 -158
  113. package/js/src/ace.js +0 -1181
  114. /package/js/src/abstract/{ace.js → apex.js} +0 -0
@@ -668,10 +668,12 @@ export default class coinbase extends coinbaseRest {
668
668
  const event = events[i];
669
669
  const updates = this.safeValue(event, 'updates', []);
670
670
  const marketId = this.safeString(event, 'product_id');
671
- const messageHash = 'level2::' + marketId;
671
+ // sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD, as they are aliases
672
+ const market = this.safeMarket(marketId);
673
+ const messageHash = 'level2::' + market['id'];
674
+ const symbol = market['symbol'];
672
675
  const subscription = this.safeValue(client.subscriptions, messageHash, {});
673
676
  const limit = this.safeInteger(subscription, 'limit');
674
- const symbol = this.safeSymbol(marketId);
675
677
  const type = this.safeString(event, 'type');
676
678
  if (type === 'snapshot') {
677
679
  this.orderbooks[symbol] = this.orderBook({}, limit);
@@ -681,9 +683,6 @@ export default class coinbase extends coinbaseRest {
681
683
  orderbook['datetime'] = datetime;
682
684
  orderbook['symbol'] = symbol;
683
685
  client.resolve(orderbook, messageHash);
684
- if (messageHash.endsWith('USD')) {
685
- client.resolve(orderbook, messageHash + 'C'); // sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
686
- }
687
686
  }
688
687
  else if (type === 'update') {
689
688
  const orderbook = this.orderbooks[symbol];
@@ -692,9 +691,6 @@ export default class coinbase extends coinbaseRest {
692
691
  orderbook['timestamp'] = this.parse8601(datetime);
693
692
  orderbook['symbol'] = symbol;
694
693
  client.resolve(orderbook, messageHash);
695
- if (messageHash.endsWith('USD')) {
696
- client.resolve(orderbook, messageHash + 'C'); // sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
697
- }
698
694
  }
699
695
  }
700
696
  }
@@ -1242,8 +1242,33 @@ export default class gate extends gateRest {
1242
1242
  for (let i = 0; i < data.length; i++) {
1243
1243
  const rawPosition = data[i];
1244
1244
  const position = this.parsePosition(rawPosition);
1245
- newPositions.push(position);
1246
- cache.append(position);
1245
+ const symbol = this.safeString(position, 'symbol');
1246
+ const side = this.safeString(position, 'side');
1247
+ // Control when position is closed no side is returned
1248
+ if (side === undefined) {
1249
+ const prevLongPosition = this.safeDict(cache, symbol + 'long');
1250
+ if (prevLongPosition !== undefined) {
1251
+ position['side'] = prevLongPosition['side'];
1252
+ newPositions.push(position);
1253
+ cache.append(position);
1254
+ }
1255
+ const prevShortPosition = this.safeDict(cache, symbol + 'short');
1256
+ if (prevShortPosition !== undefined) {
1257
+ position['side'] = prevShortPosition['side'];
1258
+ newPositions.push(position);
1259
+ cache.append(position);
1260
+ }
1261
+ // if no prev position is found, default to long
1262
+ if (prevLongPosition === undefined && prevShortPosition === undefined) {
1263
+ position['side'] = 'long';
1264
+ newPositions.push(position);
1265
+ cache.append(position);
1266
+ }
1267
+ }
1268
+ else {
1269
+ newPositions.push(position);
1270
+ cache.append(position);
1271
+ }
1247
1272
  }
1248
1273
  const messageHashes = this.findMessageHashes(client, type + ':positions::');
1249
1274
  for (let i = 0; i < messageHashes.length; i++) {
@@ -595,10 +595,10 @@ export default class hollaex extends hollaexRest {
595
595
  }
596
596
  onError(client, error) {
597
597
  this.options['ws-expires'] = undefined;
598
- this.onError(client, error);
598
+ super.onError(client, error);
599
599
  }
600
600
  onClose(client, error) {
601
601
  this.options['ws-expires'] = undefined;
602
- this.onClose(client, error);
602
+ super.onClose(client, error);
603
603
  }
604
604
  }
@@ -620,7 +620,7 @@ export default class hyperliquid extends hyperliquidRest {
620
620
  'datetime': this.iso8601(timestamp),
621
621
  'symbol': symbol,
622
622
  'id': id,
623
- 'order': undefined,
623
+ 'order': this.safeString(trade, 'oid'),
624
624
  'type': undefined,
625
625
  'side': side,
626
626
  'takerOrMaker': undefined,
package/js/src/pro/p2b.js CHANGED
@@ -497,10 +497,10 @@ export default class p2b extends p2bRest {
497
497
  }
498
498
  onError(client, error) {
499
499
  this.options['tickerSubs'] = this.createSafeDictionary();
500
- this.onError(client, error);
500
+ super.onError(client, error);
501
501
  }
502
502
  onClose(client, error) {
503
503
  this.options['tickerSubs'] = this.createSafeDictionary();
504
- this.onClose(client, error);
504
+ super.onClose(client, error);
505
505
  }
506
506
  }
@@ -0,0 +1,49 @@
1
+ import tradeogreRest from '../tradeogre.js';
2
+ import type { Int, OrderBook, Trade } from '../base/types.js';
3
+ import Client from '../base/ws/Client.js';
4
+ export default class tradeogre extends tradeogreRest {
5
+ describe(): any;
6
+ /**
7
+ * @method
8
+ * @name tradeogre#watchOrderBook
9
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
10
+ * @see https://tradeogre.com/help/api
11
+ * @param {string} symbol unified symbol of the market to fetch the order book for
12
+ * @param {int} [limit] the maximum amount of order book entries to return (not used by the exchange)
13
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
14
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
15
+ */
16
+ watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
17
+ handleOrderBook(client: Client, message: any): void;
18
+ handleDelta(orderbook: any, delta: any): void;
19
+ handleBidAsks(bookSide: any, bidAsks: any): void;
20
+ getCacheIndex(orderbook: any, deltas: any): any;
21
+ /**
22
+ * @method
23
+ * @name tradeogre#watchTrades
24
+ * @description watches information on multiple trades made in a market
25
+ * @see https://tradeogre.com/help/api
26
+ * @param {string} symbol unified market symbol of the market trades were made in
27
+ * @param {int} [since] the earliest time in ms to fetch trades for
28
+ * @param {int} [limit] the maximum number of trade structures to retrieve
29
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
30
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
31
+ */
32
+ watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
33
+ /**
34
+ * @method
35
+ * @name tradeogre#watchTradesForSymbols
36
+ * @see https://tradeogre.com/help/api
37
+ * @description get the list of most recent trades for a list of symbols
38
+ * @param {string[]} symbols unified symbol of the market to fetch trades for (empty array means all markets)
39
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
40
+ * @param {int} [limit] the maximum amount of trades to fetch
41
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
42
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
43
+ */
44
+ watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
45
+ handleTrade(client: Client, message: any): void;
46
+ parseWsTrade(trade: any, market?: any): Trade;
47
+ parseWsTradeSide(side: any): string;
48
+ handleMessage(client: Client, message: any): void;
49
+ }
@@ -0,0 +1,284 @@
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 tradeogreRest from '../tradeogre.js';
9
+ import { ArrayCache } from '../base/ws/Cache.js';
10
+ // ---------------------------------------------------------------------------
11
+ export default class tradeogre extends tradeogreRest {
12
+ describe() {
13
+ return this.deepExtend(super.describe(), {
14
+ 'has': {
15
+ 'ws': true,
16
+ 'watchTrades': true,
17
+ 'watchTradesForSymbols': true,
18
+ 'watchOrderBook': true,
19
+ 'watchOrderBookForSymbols': false,
20
+ 'watchOHLCV': false,
21
+ 'watchOHLCVForSymbols': false,
22
+ 'watchOrders': false,
23
+ 'watchMyTrades': false,
24
+ 'watchTicker': false,
25
+ 'watchTickers': false,
26
+ 'watchBidsAsks': false,
27
+ 'watchBalance': false,
28
+ 'createOrderWs': false,
29
+ 'editOrderWs': false,
30
+ 'cancelOrderWs': false,
31
+ 'cancelOrdersWs': false,
32
+ },
33
+ 'urls': {
34
+ 'api': {
35
+ 'ws': 'wss://tradeogre.com:8443',
36
+ },
37
+ },
38
+ 'options': {},
39
+ 'streaming': {},
40
+ });
41
+ }
42
+ /**
43
+ * @method
44
+ * @name tradeogre#watchOrderBook
45
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
46
+ * @see https://tradeogre.com/help/api
47
+ * @param {string} symbol unified symbol of the market to fetch the order book for
48
+ * @param {int} [limit] the maximum amount of order book entries to return (not used by the exchange)
49
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
50
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
51
+ */
52
+ async watchOrderBook(symbol, limit = undefined, params = {}) {
53
+ await this.loadMarkets();
54
+ const market = this.market(symbol);
55
+ const url = this.urls['api']['ws'];
56
+ const messageHash = 'orderbook' + ':' + market['symbol'];
57
+ const request = {
58
+ 'a': 'subscribe',
59
+ 'e': 'book',
60
+ 't': market['id'],
61
+ };
62
+ const orderbook = await this.watch(url, messageHash, this.extend(request, params), messageHash);
63
+ return orderbook.limit();
64
+ }
65
+ handleOrderBook(client, message) {
66
+ //
67
+ // initial snapshot is fetched with ccxt's fetchOrderBook
68
+ // the feed does not include a snapshot, just the deltas
69
+ //
70
+ // {
71
+ // "e": "book",
72
+ // "t": "ETH-USDT",
73
+ // "s": "10752324",
74
+ // "d": {
75
+ // "bids": { "1787.02497915": "0" },
76
+ // "asks": {}
77
+ // }
78
+ // }
79
+ //
80
+ const marketId = this.safeString(message, 't');
81
+ const symbol = this.safeSymbol(marketId);
82
+ if (!(symbol in this.orderbooks)) {
83
+ this.orderbooks[symbol] = this.orderBook({});
84
+ }
85
+ const storedOrderBook = this.orderbooks[symbol];
86
+ const nonce = this.safeInteger(storedOrderBook, 'nonce');
87
+ const deltaNonce = this.safeInteger(message, 's');
88
+ const messageHash = 'orderbook:' + symbol;
89
+ if (nonce === undefined) {
90
+ const cacheLength = storedOrderBook.cache.length;
91
+ const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 6);
92
+ if (cacheLength === snapshotDelay) {
93
+ this.spawn(this.loadOrderBook, client, messageHash, symbol, null, {});
94
+ }
95
+ storedOrderBook.cache.push(message);
96
+ return;
97
+ }
98
+ else if (nonce >= deltaNonce) {
99
+ return;
100
+ }
101
+ this.handleDelta(storedOrderBook, message);
102
+ client.resolve(storedOrderBook, messageHash);
103
+ }
104
+ handleDelta(orderbook, delta) {
105
+ // const timestamp = this.milliseconds (); // todo check if this is correct
106
+ // orderbook['timestamp'] = timestamp;
107
+ // orderbook['datetime'] = this.iso8601 (timestamp);
108
+ orderbook['nonce'] = this.safeInteger(delta, 's');
109
+ const data = this.safeDict(delta, 'd', {});
110
+ const bids = this.safeDict(data, 'bids', {});
111
+ const asks = this.safeDict(data, 'asks', {});
112
+ const storedBids = orderbook['bids'];
113
+ const storedAsks = orderbook['asks'];
114
+ this.handleBidAsks(storedBids, bids);
115
+ this.handleBidAsks(storedAsks, asks);
116
+ }
117
+ handleBidAsks(bookSide, bidAsks) {
118
+ const keys = Object.keys(bidAsks);
119
+ for (let i = 0; i < keys.length; i++) {
120
+ const price = this.safeString(keys, i);
121
+ const amount = this.safeNumber(bidAsks, price);
122
+ const bidAsk = [this.parseNumber(price), amount];
123
+ bookSide.storeArray(bidAsk);
124
+ // for (let i = 0; i < bidAsks.length; i++) {
125
+ // const bidAsk = this.parseBidAsk (bidAsks[i]);
126
+ // bookSide.storeArray (bidAsk);
127
+ // }
128
+ }
129
+ }
130
+ getCacheIndex(orderbook, deltas) {
131
+ const firstElement = deltas[0];
132
+ const firstElementNonce = this.safeInteger(firstElement, 's');
133
+ const nonce = this.safeInteger(orderbook, 'nonce');
134
+ if (nonce < firstElementNonce) {
135
+ return -1;
136
+ }
137
+ for (let i = 0; i < deltas.length; i++) {
138
+ const delta = deltas[i];
139
+ const deltaNonce = this.safeInteger(delta, 's');
140
+ if (deltaNonce === nonce) {
141
+ return i + 1;
142
+ }
143
+ }
144
+ return deltas.length;
145
+ }
146
+ /**
147
+ * @method
148
+ * @name tradeogre#watchTrades
149
+ * @description watches information on multiple trades made in a market
150
+ * @see https://tradeogre.com/help/api
151
+ * @param {string} symbol unified market symbol of the market trades were made in
152
+ * @param {int} [since] the earliest time in ms to fetch trades for
153
+ * @param {int} [limit] the maximum number of trade structures to retrieve
154
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
155
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
156
+ */
157
+ async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
158
+ await this.loadMarkets();
159
+ const market = this.market(symbol);
160
+ symbol = market['symbol'];
161
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
162
+ }
163
+ /**
164
+ * @method
165
+ * @name tradeogre#watchTradesForSymbols
166
+ * @see https://tradeogre.com/help/api
167
+ * @description get the list of most recent trades for a list of symbols
168
+ * @param {string[]} symbols unified symbol of the market to fetch trades for (empty array means all markets)
169
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
170
+ * @param {int} [limit] the maximum amount of trades to fetch
171
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
172
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
173
+ */
174
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
175
+ await this.loadMarkets();
176
+ symbols = this.marketSymbols(symbols, undefined, true);
177
+ const messageHashes = [];
178
+ let symbolsLength = 0;
179
+ if (symbols !== undefined) {
180
+ symbolsLength = symbols.length;
181
+ }
182
+ if (symbolsLength > 0) {
183
+ for (let i = 0; i < symbols.length; i++) {
184
+ const symbol = symbols[i];
185
+ const messageHash = 'trades:' + symbol;
186
+ messageHashes.push(messageHash);
187
+ }
188
+ }
189
+ else {
190
+ const messageHash = 'trades';
191
+ messageHashes.push(messageHash);
192
+ }
193
+ const request = {
194
+ 'a': 'subscribe',
195
+ 'e': 'trade',
196
+ 't': '*',
197
+ };
198
+ const url = this.urls['api']['ws'];
199
+ const trades = await this.watchMultiple(url, messageHashes, this.extend(request, params), ['trades']);
200
+ if (this.newUpdates) {
201
+ const first = this.safeDict(trades, 0);
202
+ const tradeSymbol = this.safeString(first, 'symbol');
203
+ limit = trades.getLimit(tradeSymbol, limit);
204
+ }
205
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
206
+ }
207
+ handleTrade(client, message) {
208
+ //
209
+ // {
210
+ // "e": "trade",
211
+ // "t": "LTC-USDT",
212
+ // "d": {
213
+ // "t": 0,
214
+ // "p": "84.50000000",
215
+ // "q": "1.28471270",
216
+ // "d": "1745392002"
217
+ // }
218
+ // }
219
+ //
220
+ const marketId = this.safeString(message, 't');
221
+ const market = this.safeMarket(marketId);
222
+ const data = this.safeDict(message, 'd', {});
223
+ const symbol = market['symbol'];
224
+ if (!(symbol in this.trades)) {
225
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
226
+ const stored = new ArrayCache(limit);
227
+ this.trades[symbol] = stored;
228
+ }
229
+ const cache = this.trades[symbol];
230
+ const trade = this.parseWsTrade(data, market);
231
+ cache.append(trade);
232
+ const messageHash = 'trades:' + symbol;
233
+ client.resolve(cache, messageHash);
234
+ client.resolve(cache, 'trades');
235
+ }
236
+ parseWsTrade(trade, market = undefined) {
237
+ //
238
+ // {
239
+ // "t": 0,
240
+ // "p": "84.50000000",
241
+ // "q": "1.28471270",
242
+ // "d": "1745392002"
243
+ // }
244
+ //
245
+ const timestamp = this.safeIntegerProduct(trade, 'd', 1000);
246
+ const sideEnum = this.safeString(trade, 't');
247
+ return this.safeTrade({
248
+ 'info': trade,
249
+ 'id': undefined,
250
+ 'timestamp': timestamp,
251
+ 'datetime': this.iso8601(timestamp),
252
+ 'symbol': this.safeString(market, 'symbol'),
253
+ 'order': undefined,
254
+ 'type': undefined,
255
+ 'side': this.parseWsTradeSide(sideEnum),
256
+ 'takerOrMaker': undefined,
257
+ 'price': this.safeString(trade, 'p'),
258
+ 'amount': this.safeString(trade, 'q'),
259
+ 'cost': undefined,
260
+ 'fee': {
261
+ 'currency': undefined,
262
+ 'cost': undefined,
263
+ },
264
+ }, market);
265
+ }
266
+ parseWsTradeSide(side) {
267
+ const sides = {
268
+ '0': 'buy',
269
+ '1': 'sell',
270
+ };
271
+ return this.safeString(sides, side, side);
272
+ }
273
+ handleMessage(client, message) {
274
+ const methods = {
275
+ 'book': this.handleOrderBook,
276
+ 'trade': this.handleTrade,
277
+ };
278
+ const event = this.safeString(message, 'e');
279
+ const method = this.safeValue(methods, event);
280
+ if (method !== undefined) {
281
+ method.call(this, client, message);
282
+ }
283
+ }
284
+ }
package/js/src/probit.js CHANGED
@@ -557,6 +557,7 @@ export default class probit extends Exchange {
557
557
  'active': active,
558
558
  'deposit': deposit,
559
559
  'withdraw': withdraw,
560
+ 'type': 'crypto',
560
561
  'fee': fee,
561
562
  'precision': this.parseNumber(this.parsePrecision(this.safeString(platform, 'precision'))),
562
563
  'limits': {