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