tardis-dev 13.8.5 → 13.10.0
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/dist/apikeyaccessinfo.d.ts +1 -1
- package/dist/apikeyaccessinfo.d.ts.map +1 -1
- package/dist/combine.d.ts +2 -2
- package/dist/combine.d.ts.map +1 -1
- package/dist/computable/booksnapshot.d.ts +1 -1
- package/dist/computable/booksnapshot.d.ts.map +1 -1
- package/dist/computable/computable.d.ts +2 -2
- package/dist/computable/computable.d.ts.map +1 -1
- package/dist/computable/tradebar.d.ts +2 -2
- package/dist/computable/tradebar.d.ts.map +1 -1
- package/dist/consts.d.ts +1 -1
- package/dist/consts.js +2 -2
- package/dist/consts.js.map +1 -1
- package/dist/downloaddatasets.d.ts +2 -2
- package/dist/downloaddatasets.d.ts.map +1 -1
- package/dist/exchangedetails.d.ts +6 -6
- package/dist/exchangedetails.d.ts.map +1 -1
- package/dist/instrumentinfo.d.ts +2 -2
- package/dist/instrumentinfo.d.ts.map +1 -1
- package/dist/mappers/ascendex.d.ts +6 -6
- package/dist/mappers/ascendex.d.ts.map +1 -1
- package/dist/mappers/binance.d.ts +13 -13
- package/dist/mappers/binance.d.ts.map +1 -1
- package/dist/mappers/binanceoptions.d.ts +6 -6
- package/dist/mappers/binanceoptions.d.ts.map +1 -1
- package/dist/mappers/bitfinex.d.ts +8 -8
- package/dist/mappers/bitfinex.d.ts.map +1 -1
- package/dist/mappers/bitflyer.d.ts +3 -3
- package/dist/mappers/bitflyer.d.ts.map +1 -1
- package/dist/mappers/bitmex.d.ts +4 -4
- package/dist/mappers/bitmex.d.ts.map +1 -1
- package/dist/mappers/bitstamp.d.ts +4 -4
- package/dist/mappers/bitstamp.d.ts.map +1 -1
- package/dist/mappers/bybit.d.ts +9 -9
- package/dist/mappers/bybit.d.ts.map +1 -1
- package/dist/mappers/bybitspot.d.ts +3 -3
- package/dist/mappers/bybitspot.d.ts.map +1 -1
- package/dist/mappers/coinbase.d.ts +5 -5
- package/dist/mappers/coinbase.d.ts.map +1 -1
- package/dist/mappers/coinflex.d.ts +1 -1
- package/dist/mappers/coinflex.d.ts.map +1 -1
- package/dist/mappers/cryptocom.d.ts +7 -7
- package/dist/mappers/cryptocom.d.ts.map +1 -1
- package/dist/mappers/cryptocom.js +11 -0
- package/dist/mappers/cryptocom.js.map +1 -1
- package/dist/mappers/cryptofacilities.d.ts +5 -5
- package/dist/mappers/cryptofacilities.d.ts.map +1 -1
- package/dist/mappers/delta.d.ts +3 -3
- package/dist/mappers/delta.d.ts.map +1 -1
- package/dist/mappers/deribit.d.ts +3 -3
- package/dist/mappers/deribit.d.ts.map +1 -1
- package/dist/mappers/dydx.d.ts +5 -5
- package/dist/mappers/dydx.d.ts.map +1 -1
- package/dist/mappers/ftx.d.ts +5 -5
- package/dist/mappers/ftx.d.ts.map +1 -1
- package/dist/mappers/gateio.d.ts +4 -4
- package/dist/mappers/gateio.d.ts.map +1 -1
- package/dist/mappers/gateiofutures.d.ts +7 -7
- package/dist/mappers/gateiofutures.d.ts.map +1 -1
- package/dist/mappers/huobi.d.ts +15 -15
- package/dist/mappers/huobi.d.ts.map +1 -1
- package/dist/mappers/index.d.ts +1 -1
- package/dist/mappers/index.d.ts.map +1 -1
- package/dist/mappers/index.js +2 -1
- package/dist/mappers/index.js.map +1 -1
- package/dist/mappers/kucoin.d.ts +5 -5
- package/dist/mappers/kucoin.d.ts.map +1 -1
- package/dist/mappers/mapper.d.ts +2 -2
- package/dist/mappers/mapper.d.ts.map +1 -1
- package/dist/mappers/okex.d.ts +23 -23
- package/dist/mappers/okex.d.ts.map +1 -1
- package/dist/mappers/phemex.d.ts +46 -4
- package/dist/mappers/phemex.d.ts.map +1 -1
- package/dist/mappers/phemex.js +194 -62
- package/dist/mappers/phemex.js.map +1 -1
- package/dist/mappers/poloniex.d.ts +6 -6
- package/dist/mappers/poloniex.d.ts.map +1 -1
- package/dist/mappers/serum.d.ts +5 -5
- package/dist/mappers/serum.d.ts.map +1 -1
- package/dist/mappers/upbit.d.ts +2 -2
- package/dist/mappers/upbit.d.ts.map +1 -1
- package/dist/options.d.ts +1 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/orderbook.d.ts +1 -1
- package/dist/orderbook.d.ts.map +1 -1
- package/dist/realtimefeeds/cryptocom.d.ts.map +1 -1
- package/dist/realtimefeeds/cryptocom.js +5 -4
- package/dist/realtimefeeds/cryptocom.js.map +1 -1
- package/dist/realtimefeeds/index.d.ts.map +1 -1
- package/dist/realtimefeeds/index.js +1 -2
- package/dist/realtimefeeds/index.js.map +1 -1
- package/dist/realtimefeeds/phemex.d.ts.map +1 -1
- package/dist/realtimefeeds/phemex.js +8 -2
- package/dist/realtimefeeds/phemex.js.map +1 -1
- package/dist/realtimefeeds/realtimefeed.d.ts +2 -2
- package/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
- package/dist/realtimefeeds/realtimefeed.js +3 -3
- package/dist/realtimefeeds/realtimefeed.js.map +1 -1
- package/dist/replay.d.ts +2 -2
- package/dist/replay.d.ts.map +1 -1
- package/dist/stream.d.ts +2 -2
- package/dist/stream.d.ts.map +1 -1
- package/dist/types.d.ts +16 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +2 -2
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +2 -2
- package/src/mappers/cryptocom.ts +13 -0
- package/src/mappers/index.ts +2 -1
- package/src/mappers/phemex.ts +308 -88
- package/src/realtimefeeds/cryptocom.ts +5 -4
- package/src/realtimefeeds/index.ts +1 -2
- package/src/realtimefeeds/phemex.ts +11 -2
- package/dist/realtimefeeds/cryptocomderivatives.d.ts +0 -10
- package/dist/realtimefeeds/cryptocomderivatives.d.ts.map +0 -1
- package/dist/realtimefeeds/cryptocomderivatives.js +0 -50
- package/dist/realtimefeeds/cryptocomderivatives.js.map +0 -1
- package/src/realtimefeeds/cryptocomderivatives.ts +0 -49
package/src/mappers/phemex.ts
CHANGED
|
@@ -27,46 +27,114 @@ function getQtyScale(symbol: string) {
|
|
|
27
27
|
return 1
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const COINS_STARTING_WITH_S = ['SOL', 'SUSHI', 'SNX', 'SAND', 'SRM', 'SKLU', 'SXP', 'STORJ', 'SFP', 'STG']
|
|
31
|
+
function getInstrumentType(symbol: string) {
|
|
32
|
+
if (/\d+$/.test(symbol)) {
|
|
33
|
+
return 'future'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (COINS_STARTING_WITH_S.some((c) => symbol.startsWith(c)) || symbol.startsWith('S') === false) {
|
|
37
|
+
return 'perpetual'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return 'spot'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getApiSymbolId(symbolId: string) {
|
|
44
|
+
const type = getInstrumentType(symbolId)
|
|
45
|
+
if (type === 'spot' && symbolId.startsWith('S')) {
|
|
46
|
+
return symbolId.charAt(0).toLowerCase() + symbolId.slice(1)
|
|
47
|
+
}
|
|
48
|
+
if (symbolId.startsWith('U100')) {
|
|
49
|
+
return symbolId.charAt(0).toLowerCase() + symbolId.slice(1)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (symbolId === 'CETHUSD') {
|
|
53
|
+
return symbolId.charAt(0).toLowerCase() + symbolId.slice(1)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return symbolId
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getSymbols(symbols: string[]) {
|
|
60
|
+
const perpV2Symbols = symbols.filter((s) => getInstrumentType(s) === 'perpetual' && s.endsWith('USDT')).map(getApiSymbolId)
|
|
61
|
+
const otherSymbols = symbols.filter((s) => getInstrumentType(s) !== 'perpetual' || s.endsWith('USDT') == false).map(getApiSymbolId)
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
perpV2Symbols,
|
|
65
|
+
otherSymbols
|
|
33
66
|
}
|
|
34
|
-
return symbols.map((symbol) => {
|
|
35
|
-
if (symbol.startsWith('S')) {
|
|
36
|
-
return symbol.charAt(0).toLowerCase() + symbol.slice(1)
|
|
37
|
-
}
|
|
38
|
-
return symbol
|
|
39
|
-
})
|
|
40
67
|
}
|
|
41
68
|
|
|
42
69
|
export const phemexTradesMapper: Mapper<'phemex', Trade> = {
|
|
43
70
|
canHandle(message: PhemexTradeMessage) {
|
|
44
|
-
return 'trades' in message
|
|
71
|
+
return message.type === 'incremental' && ('trades' in message || 'trades_p' in message)
|
|
45
72
|
},
|
|
46
73
|
|
|
47
74
|
getFilters(symbols?: string[]) {
|
|
48
|
-
|
|
49
|
-
|
|
75
|
+
if (symbols == undefined || symbols.length === 0) {
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
channel: 'trades'
|
|
79
|
+
} as const,
|
|
80
|
+
{
|
|
81
|
+
channel: 'trades_p'
|
|
82
|
+
} as const
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const { perpV2Symbols, otherSymbols } = getSymbols(symbols)
|
|
87
|
+
|
|
88
|
+
const filters = []
|
|
89
|
+
|
|
90
|
+
if (perpV2Symbols.length > 0) {
|
|
91
|
+
filters.push({
|
|
92
|
+
channel: 'trades_p',
|
|
93
|
+
symbols: perpV2Symbols
|
|
94
|
+
} as const)
|
|
95
|
+
}
|
|
96
|
+
if (otherSymbols.length > 0) {
|
|
97
|
+
filters.push({
|
|
50
98
|
channel: 'trades',
|
|
51
|
-
symbols:
|
|
52
|
-
} as const
|
|
53
|
-
|
|
99
|
+
symbols: otherSymbols
|
|
100
|
+
} as const)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return filters
|
|
54
104
|
},
|
|
55
105
|
|
|
56
106
|
*map(message: PhemexTradeMessage, localTimestamp: Date): IterableIterator<Trade> {
|
|
57
|
-
|
|
58
|
-
const
|
|
107
|
+
if ('trades' in message) {
|
|
108
|
+
for (const [timestamp, side, priceEp, qty] of message.trades) {
|
|
109
|
+
const symbol = message.symbol
|
|
59
110
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
111
|
+
yield {
|
|
112
|
+
type: 'trade',
|
|
113
|
+
symbol: symbol.toUpperCase(),
|
|
114
|
+
exchange: 'phemex',
|
|
115
|
+
id: undefined,
|
|
116
|
+
price: priceEp / getPriceScale(symbol),
|
|
117
|
+
amount: qty / getQtyScale(symbol),
|
|
118
|
+
side: side === 'Buy' ? 'buy' : 'sell',
|
|
119
|
+
timestamp: fromNanoSecondsToDate(timestamp),
|
|
120
|
+
localTimestamp: localTimestamp
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} else if ('trades_p' in message) {
|
|
124
|
+
for (const [timestamp, side, price, qty] of message.trades_p) {
|
|
125
|
+
const symbol = message.symbol
|
|
126
|
+
|
|
127
|
+
yield {
|
|
128
|
+
type: 'trade',
|
|
129
|
+
symbol: symbol.toUpperCase(),
|
|
130
|
+
exchange: 'phemex',
|
|
131
|
+
id: undefined,
|
|
132
|
+
price: Number(price),
|
|
133
|
+
amount: Number(qty),
|
|
134
|
+
side: side === 'Buy' ? 'buy' : 'sell',
|
|
135
|
+
timestamp: fromNanoSecondsToDate(timestamp),
|
|
136
|
+
localTimestamp: localTimestamp
|
|
137
|
+
}
|
|
70
138
|
}
|
|
71
139
|
}
|
|
72
140
|
}
|
|
@@ -81,33 +149,75 @@ const mapBookLevelForSymbol =
|
|
|
81
149
|
}
|
|
82
150
|
}
|
|
83
151
|
|
|
152
|
+
function mapPerpBookLevel([price, amount]: [string, string]) {
|
|
153
|
+
return {
|
|
154
|
+
price: Number(price),
|
|
155
|
+
amount: Number(amount)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
84
159
|
export const phemexBookChangeMapper: Mapper<'phemex', BookChange> = {
|
|
85
160
|
canHandle(message: PhemexBookMessage) {
|
|
86
|
-
return 'book' in message
|
|
161
|
+
return 'book' in message || 'orderbook_p' in message
|
|
87
162
|
},
|
|
88
163
|
|
|
89
164
|
getFilters(symbols?: string[]) {
|
|
90
|
-
|
|
91
|
-
|
|
165
|
+
if (symbols == undefined || symbols.length === 0) {
|
|
166
|
+
return [
|
|
167
|
+
{
|
|
168
|
+
channel: 'book'
|
|
169
|
+
} as const,
|
|
170
|
+
{
|
|
171
|
+
channel: 'orderbook_p'
|
|
172
|
+
} as const
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const { perpV2Symbols, otherSymbols } = getSymbols(symbols)
|
|
177
|
+
const filters = []
|
|
178
|
+
|
|
179
|
+
if (perpV2Symbols.length > 0) {
|
|
180
|
+
filters.push({
|
|
181
|
+
channel: 'orderbook_p',
|
|
182
|
+
symbols: perpV2Symbols
|
|
183
|
+
} as const)
|
|
184
|
+
}
|
|
185
|
+
if (otherSymbols.length > 0) {
|
|
186
|
+
filters.push({
|
|
92
187
|
channel: 'book',
|
|
93
|
-
symbols:
|
|
94
|
-
} as const
|
|
95
|
-
|
|
188
|
+
symbols: otherSymbols
|
|
189
|
+
} as const)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return filters
|
|
96
193
|
},
|
|
97
194
|
|
|
98
195
|
*map(message: PhemexBookMessage, localTimestamp: Date): IterableIterator<BookChange> {
|
|
99
196
|
const symbol = message.symbol
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
197
|
+
if ('book' in message) {
|
|
198
|
+
const mapBookLevel = mapBookLevelForSymbol(symbol)
|
|
199
|
+
yield {
|
|
200
|
+
type: 'book_change',
|
|
201
|
+
symbol: symbol.toUpperCase(),
|
|
202
|
+
exchange: 'phemex',
|
|
203
|
+
isSnapshot: message.type === 'snapshot',
|
|
204
|
+
bids: message.book.bids.map(mapBookLevel),
|
|
205
|
+
asks: message.book.asks.map(mapBookLevel),
|
|
206
|
+
|
|
207
|
+
timestamp: fromNanoSecondsToDate(message.timestamp),
|
|
208
|
+
localTimestamp
|
|
209
|
+
}
|
|
210
|
+
} else if ('orderbook_p' in message) {
|
|
211
|
+
yield {
|
|
212
|
+
type: 'book_change',
|
|
213
|
+
symbol: symbol.toUpperCase(),
|
|
214
|
+
exchange: 'phemex',
|
|
215
|
+
isSnapshot: message.type === 'snapshot',
|
|
216
|
+
bids: message.orderbook_p.bids.map(mapPerpBookLevel),
|
|
217
|
+
asks: message.orderbook_p.asks.map(mapPerpBookLevel),
|
|
218
|
+
timestamp: fromNanoSecondsToDate(message.timestamp),
|
|
219
|
+
localTimestamp
|
|
220
|
+
}
|
|
111
221
|
}
|
|
112
222
|
}
|
|
113
223
|
}
|
|
@@ -116,64 +226,174 @@ export class PhemexDerivativeTickerMapper implements Mapper<'phemex', Derivative
|
|
|
116
226
|
private readonly pendingTickerInfoHelper = new PendingTickerInfoHelper()
|
|
117
227
|
|
|
118
228
|
canHandle(message: PhemexTicker) {
|
|
119
|
-
return 'market24h' in message
|
|
229
|
+
return 'market24h' in message || message.method === 'perp_market24h_pack_p.update'
|
|
120
230
|
}
|
|
121
231
|
|
|
122
232
|
getFilters(symbols?: string[]) {
|
|
123
|
-
|
|
124
|
-
|
|
233
|
+
if (symbols == undefined || symbols.length === 0) {
|
|
234
|
+
return [
|
|
235
|
+
{
|
|
236
|
+
channel: 'market24h'
|
|
237
|
+
} as const,
|
|
238
|
+
{
|
|
239
|
+
channel: 'perp_market24h_pack_p'
|
|
240
|
+
} as const
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const { perpV2Symbols, otherSymbols } = getSymbols(symbols)
|
|
245
|
+
const filters = []
|
|
246
|
+
|
|
247
|
+
if (perpV2Symbols.length > 0) {
|
|
248
|
+
filters.push({
|
|
249
|
+
channel: 'perp_market24h_pack_p',
|
|
250
|
+
symbols: perpV2Symbols
|
|
251
|
+
} as const)
|
|
252
|
+
}
|
|
253
|
+
if (otherSymbols.length > 0) {
|
|
254
|
+
filters.push({
|
|
125
255
|
channel: 'market24h',
|
|
126
|
-
symbols
|
|
127
|
-
} as const
|
|
128
|
-
|
|
256
|
+
symbols: otherSymbols
|
|
257
|
+
} as const)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return filters
|
|
129
261
|
}
|
|
130
262
|
|
|
131
263
|
*map(message: PhemexTicker, localTimestamp: Date): IterableIterator<DerivativeTicker> {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
264
|
+
if ('market24h' in message) {
|
|
265
|
+
const pendingTickerInfo = this.pendingTickerInfoHelper.getPendingTickerInfo(message.market24h.symbol, 'phemex')
|
|
266
|
+
const phemexTicker = message.market24h
|
|
267
|
+
pendingTickerInfo.updateFundingRate(phemexTicker.fundingRate / 100000000)
|
|
268
|
+
pendingTickerInfo.updatePredictedFundingRate(phemexTicker.predFundingRate / 100000000)
|
|
269
|
+
pendingTickerInfo.updateIndexPrice(phemexTicker.indexPrice / 10000)
|
|
270
|
+
pendingTickerInfo.updateMarkPrice(phemexTicker.markPrice / 10000)
|
|
271
|
+
pendingTickerInfo.updateOpenInterest(phemexTicker.openInterest)
|
|
272
|
+
pendingTickerInfo.updateLastPrice(phemexTicker.close / 10000)
|
|
273
|
+
pendingTickerInfo.updateTimestamp(fromNanoSecondsToDate(message.timestamp))
|
|
274
|
+
|
|
275
|
+
if (pendingTickerInfo.hasChanged()) {
|
|
276
|
+
yield pendingTickerInfo.getSnapshot(localTimestamp)
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
for (let [
|
|
280
|
+
symbol,
|
|
281
|
+
_openRp,
|
|
282
|
+
_highRp,
|
|
283
|
+
_lowRp,
|
|
284
|
+
lastRp,
|
|
285
|
+
_volumeRq,
|
|
286
|
+
_turnoverRv,
|
|
287
|
+
openInterestRv,
|
|
288
|
+
indexRp,
|
|
289
|
+
markRp,
|
|
290
|
+
fundingRateRr,
|
|
291
|
+
predFundingRateRr
|
|
292
|
+
] of message.data) {
|
|
293
|
+
const pendingTickerInfo = this.pendingTickerInfoHelper.getPendingTickerInfo(symbol, 'phemex')
|
|
294
|
+
|
|
295
|
+
pendingTickerInfo.updateFundingRate(Number(fundingRateRr))
|
|
296
|
+
pendingTickerInfo.updatePredictedFundingRate(Number(predFundingRateRr))
|
|
297
|
+
pendingTickerInfo.updateIndexPrice(Number(indexRp))
|
|
298
|
+
pendingTickerInfo.updateMarkPrice(Number(markRp))
|
|
299
|
+
pendingTickerInfo.updateOpenInterest(Number(openInterestRv))
|
|
300
|
+
pendingTickerInfo.updateLastPrice(Number(lastRp))
|
|
301
|
+
pendingTickerInfo.updateTimestamp(fromNanoSecondsToDate(message.timestamp))
|
|
302
|
+
|
|
303
|
+
if (pendingTickerInfo.hasChanged()) {
|
|
304
|
+
yield pendingTickerInfo.getSnapshot(localTimestamp)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
144
307
|
}
|
|
145
308
|
}
|
|
146
309
|
}
|
|
147
310
|
|
|
148
|
-
type PhemexTradeMessage =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
311
|
+
type PhemexTradeMessage =
|
|
312
|
+
| {
|
|
313
|
+
symbol: string
|
|
314
|
+
trades: [[number, 'Buy' | 'Sell', number, number]]
|
|
315
|
+
type: 'incremental' | 'snapshot'
|
|
316
|
+
}
|
|
317
|
+
| {
|
|
318
|
+
sequence: 79157171
|
|
319
|
+
symbol: 'BTCUSDT'
|
|
320
|
+
trades_p: [[1669198793402790477, 'Buy' | 'Sell', '16545.6', '0.7']]
|
|
321
|
+
type: 'snapshot' | 'incremental'
|
|
322
|
+
}
|
|
153
323
|
|
|
154
324
|
type PhemexBookLevel = [number, number]
|
|
155
325
|
|
|
156
|
-
type PhemexBookMessage =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
326
|
+
type PhemexBookMessage =
|
|
327
|
+
| {
|
|
328
|
+
book: {
|
|
329
|
+
asks: PhemexBookLevel[]
|
|
330
|
+
bids: PhemexBookLevel[]
|
|
331
|
+
}
|
|
161
332
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
333
|
+
symbol: string
|
|
334
|
+
timestamp: number
|
|
335
|
+
type: 'incremental' | 'snapshot'
|
|
336
|
+
}
|
|
337
|
+
| {
|
|
338
|
+
depth: 0
|
|
339
|
+
orderbook_p: {
|
|
340
|
+
asks: [string, string][]
|
|
341
|
+
bids: [string, string][]
|
|
342
|
+
}
|
|
343
|
+
sequence: 80321058
|
|
344
|
+
symbol: 'BTCUSDT'
|
|
345
|
+
timestamp: 1669198850490348246
|
|
346
|
+
type: 'snapshot' | 'incremental'
|
|
347
|
+
}
|
|
166
348
|
|
|
167
|
-
type PhemexTicker =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
349
|
+
type PhemexTicker =
|
|
350
|
+
| {
|
|
351
|
+
market24h: {
|
|
352
|
+
fundingRate: number
|
|
353
|
+
indexPrice: number
|
|
354
|
+
markPrice: number
|
|
355
|
+
openInterest: number
|
|
356
|
+
predFundingRate: number
|
|
357
|
+
symbol: string
|
|
358
|
+
close: number
|
|
359
|
+
}
|
|
177
360
|
|
|
178
|
-
|
|
179
|
-
|
|
361
|
+
timestamp: number
|
|
362
|
+
method: undefined
|
|
363
|
+
}
|
|
364
|
+
| {
|
|
365
|
+
data: [
|
|
366
|
+
[
|
|
367
|
+
'SOLUSDT',
|
|
368
|
+
'11.246',
|
|
369
|
+
'13.41',
|
|
370
|
+
'10.91',
|
|
371
|
+
'13.029',
|
|
372
|
+
'10445.82',
|
|
373
|
+
'127687.14224',
|
|
374
|
+
'0',
|
|
375
|
+
'13.03062296',
|
|
376
|
+
'13.03154351',
|
|
377
|
+
'0.0001',
|
|
378
|
+
'0.0001'
|
|
379
|
+
],
|
|
380
|
+
|
|
381
|
+
[
|
|
382
|
+
'BTCUSDT',
|
|
383
|
+
'15713.1',
|
|
384
|
+
'16626',
|
|
385
|
+
'15685.7',
|
|
386
|
+
'16545.6',
|
|
387
|
+
'1374.476',
|
|
388
|
+
'22296790.4579',
|
|
389
|
+
'0',
|
|
390
|
+
'16553.56998432',
|
|
391
|
+
'16554.73942506',
|
|
392
|
+
'0.0001',
|
|
393
|
+
'0.0001'
|
|
394
|
+
]
|
|
395
|
+
]
|
|
396
|
+
method: 'perp_market24h_pack_p.update'
|
|
397
|
+
timestamp: 1669198855202180601
|
|
398
|
+
type: 'incremental'
|
|
399
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Filter } from '../types'
|
|
|
2
2
|
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
3
|
|
|
4
4
|
export class CryptoComRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected wssURL = 'wss://stream.crypto.com/
|
|
5
|
+
protected wssURL = 'wss://stream.crypto.com/exchange/v1/market'
|
|
6
6
|
|
|
7
7
|
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
8
|
const channels = filters
|
|
@@ -12,7 +12,7 @@ export class CryptoComRealTimeFeed extends RealTimeFeedBase {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
return filter.symbols.map((symbol) => {
|
|
15
|
-
const suffix = filter.channel === 'book' ? '.
|
|
15
|
+
const suffix = filter.channel === 'book' ? '.50' : ''
|
|
16
16
|
return `${filter.channel}.${symbol}${suffix}`
|
|
17
17
|
})
|
|
18
18
|
})
|
|
@@ -24,14 +24,15 @@ export class CryptoComRealTimeFeed extends RealTimeFeedBase {
|
|
|
24
24
|
method: 'subscribe',
|
|
25
25
|
nonce: new Date().valueOf(),
|
|
26
26
|
params: {
|
|
27
|
-
channels: channels
|
|
27
|
+
channels: channels,
|
|
28
|
+
book_subscription_type: 'SNAPSHOT_AND_UPDATE'
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
]
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
protected messageIsError(message: any): boolean {
|
|
34
|
-
return message.code !== undefined && message.code !== 0
|
|
35
|
+
return message.code !== undefined && message.code !== 0 && message.code !== 40003
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
protected onMessage(msg: any) {
|
|
@@ -43,7 +43,6 @@ import { StarAtlasRealTimeFeed } from './staratlas'
|
|
|
43
43
|
import { MangoRealTimeFeed } from './mango'
|
|
44
44
|
import { BybitSpotRealTimeFeed } from './bybitspot'
|
|
45
45
|
import { CryptoComRealTimeFeed } from './cryptocom'
|
|
46
|
-
import { CryptoComDerivativesRealTimeFeed } from './cryptocomderivatives'
|
|
47
46
|
import { KucoinRealTimeFeed } from './kucoin'
|
|
48
47
|
|
|
49
48
|
export * from './realtimefeed'
|
|
@@ -96,7 +95,7 @@ const realTimeFeedsMap: {
|
|
|
96
95
|
mango: MangoRealTimeFeed,
|
|
97
96
|
'bybit-spot': BybitSpotRealTimeFeed,
|
|
98
97
|
'crypto-com': CryptoComRealTimeFeed,
|
|
99
|
-
'crypto-com-derivatives':
|
|
98
|
+
'crypto-com-derivatives': CryptoComRealTimeFeed,
|
|
100
99
|
kucoin: KucoinRealTimeFeed
|
|
101
100
|
}
|
|
102
101
|
|
|
@@ -7,16 +7,25 @@ export class PhemexRealTimeFeed extends RealTimeFeedBase {
|
|
|
7
7
|
|
|
8
8
|
protected readonly channelsMap = {
|
|
9
9
|
book: 'orderbook.subscribe',
|
|
10
|
+
orderbook_p: 'orderbook_p.subscribe',
|
|
10
11
|
trades: 'trade.subscribe',
|
|
12
|
+
trades_p: 'trade_p.subscribe',
|
|
11
13
|
market24h: 'market24h.subscribe',
|
|
12
|
-
spot_market24h: 'spot_market24h.subscribe'
|
|
14
|
+
spot_market24h: 'spot_market24h.subscribe',
|
|
15
|
+
perp_market24h_pack_p: 'perp_market24h_pack_p.subscribe'
|
|
13
16
|
} as any
|
|
14
17
|
|
|
15
18
|
protected mapToSubscribeMessages(filters: Filter<string>[]) {
|
|
16
19
|
let id = 0
|
|
17
20
|
return filters
|
|
21
|
+
|
|
18
22
|
.map((filter) => {
|
|
19
|
-
if (
|
|
23
|
+
if (
|
|
24
|
+
filter.symbols !== undefined &&
|
|
25
|
+
filter.channel !== 'market24h' &&
|
|
26
|
+
filter.channel !== 'spot_market24h' &&
|
|
27
|
+
filter.channel !== 'perp_market24h_pack_p'
|
|
28
|
+
) {
|
|
20
29
|
return filter.symbols.map((symbol) => {
|
|
21
30
|
return {
|
|
22
31
|
id: id++,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Filter } from '../types';
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed';
|
|
3
|
-
export declare class CryptoComDerivativesRealTimeFeed extends RealTimeFeedBase {
|
|
4
|
-
protected wssURL: string;
|
|
5
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[];
|
|
6
|
-
protected messageIsError(message: any): boolean;
|
|
7
|
-
protected onMessage(msg: any): void;
|
|
8
|
-
protected messageIsHeartbeat(msg: any): boolean;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=cryptocomderivatives.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptocomderivatives.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/cryptocomderivatives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,qBAAa,gCAAiC,SAAQ,gBAAgB;IACpE,SAAS,CAAC,MAAM,SAA4C;IAE5D,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,EAAE;IA2BlE,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI/C,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG;IAQ5B,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG;CAGtC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CryptoComDerivativesRealTimeFeed = void 0;
|
|
4
|
-
const realtimefeed_1 = require("./realtimefeed");
|
|
5
|
-
class CryptoComDerivativesRealTimeFeed extends realtimefeed_1.RealTimeFeedBase {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.wssURL = 'wss://deriv-stream.crypto.com/v1/market';
|
|
9
|
-
}
|
|
10
|
-
mapToSubscribeMessages(filters) {
|
|
11
|
-
const channels = filters
|
|
12
|
-
.map((filter) => {
|
|
13
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
14
|
-
throw new Error('CryptoComDerivativesRealTimeFeed requires explicitly specified symbols when subscribing to live feed');
|
|
15
|
-
}
|
|
16
|
-
return filter.symbols.map((symbol) => {
|
|
17
|
-
const suffix = filter.channel === 'book' ? '.50' : '';
|
|
18
|
-
return `${filter.channel}.${symbol}${suffix}`;
|
|
19
|
-
});
|
|
20
|
-
})
|
|
21
|
-
.flatMap((s) => s);
|
|
22
|
-
return [
|
|
23
|
-
{
|
|
24
|
-
id: 1,
|
|
25
|
-
method: 'subscribe',
|
|
26
|
-
nonce: new Date().valueOf(),
|
|
27
|
-
params: {
|
|
28
|
-
channels: channels,
|
|
29
|
-
book_subscription_type: 'SNAPSHOT_AND_UPDATE'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
messageIsError(message) {
|
|
35
|
-
return message.code !== undefined && message.code !== 0 && message.code !== 40003;
|
|
36
|
-
}
|
|
37
|
-
onMessage(msg) {
|
|
38
|
-
if (msg.method === 'public/heartbeat') {
|
|
39
|
-
this.send({
|
|
40
|
-
id: msg.id,
|
|
41
|
-
method: 'public/respond-heartbeat'
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
messageIsHeartbeat(msg) {
|
|
46
|
-
return msg.method === 'public/heartbeat';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.CryptoComDerivativesRealTimeFeed = CryptoComDerivativesRealTimeFeed;
|
|
50
|
-
//# sourceMappingURL=cryptocomderivatives.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptocomderivatives.js","sourceRoot":"","sources":["../../src/realtimefeeds/cryptocomderivatives.ts"],"names":[],"mappings":";;;AACA,iDAAiD;AAEjD,MAAa,gCAAiC,SAAQ,+BAAgB;IAAtE;;QACY,WAAM,GAAG,yCAAyC,CAAA;IA4C9D,CAAC;IA1CW,sBAAsB,CAAC,OAAyB;QACxD,MAAM,QAAQ,GAAG,OAAO;aACrB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBAClD,MAAM,IAAI,KAAK,CAAC,sGAAsG,CAAC,CAAA;aACxH;YAED,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACnC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;gBACrD,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,GAAG,MAAM,EAAE,CAAA;YAC/C,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QAEpB,OAAO;YACL;gBACE,EAAE,EAAE,CAAC;gBACL,MAAM,EAAE,WAAW;gBACnB,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;gBAC3B,MAAM,EAAE;oBACN,QAAQ,EAAE,QAAQ;oBAClB,sBAAsB,EAAE,qBAAqB;iBAC9C;aACF;SACF,CAAA;IACH,CAAC;IAES,cAAc,CAAC,OAAY;QACnC,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,CAAA;IACnF,CAAC;IAES,SAAS,CAAC,GAAQ;QAC1B,IAAI,GAAG,CAAC,MAAM,KAAK,kBAAkB,EAAE;YACrC,IAAI,CAAC,IAAI,CAAC;gBACR,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,MAAM,EAAE,0BAA0B;aACnC,CAAC,CAAA;SACH;IACH,CAAC;IACS,kBAAkB,CAAC,GAAQ;QACnC,OAAO,GAAG,CAAC,MAAM,KAAK,kBAAkB,CAAA;IAC1C,CAAC;CACF;AA7CD,4EA6CC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class CryptoComDerivativesRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected wssURL = 'wss://deriv-stream.crypto.com/v1/market'
|
|
6
|
-
|
|
7
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
-
const channels = filters
|
|
9
|
-
.map((filter) => {
|
|
10
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
11
|
-
throw new Error('CryptoComDerivativesRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return filter.symbols.map((symbol) => {
|
|
15
|
-
const suffix = filter.channel === 'book' ? '.50' : ''
|
|
16
|
-
return `${filter.channel}.${symbol}${suffix}`
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
.flatMap((s) => s)
|
|
20
|
-
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
id: 1,
|
|
24
|
-
method: 'subscribe',
|
|
25
|
-
nonce: new Date().valueOf(),
|
|
26
|
-
params: {
|
|
27
|
-
channels: channels,
|
|
28
|
-
book_subscription_type: 'SNAPSHOT_AND_UPDATE'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
protected messageIsError(message: any): boolean {
|
|
35
|
-
return message.code !== undefined && message.code !== 0 && message.code !== 40003
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected onMessage(msg: any) {
|
|
39
|
-
if (msg.method === 'public/heartbeat') {
|
|
40
|
-
this.send({
|
|
41
|
-
id: msg.id,
|
|
42
|
-
method: 'public/respond-heartbeat'
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
protected messageIsHeartbeat(msg: any) {
|
|
47
|
-
return msg.method === 'public/heartbeat'
|
|
48
|
-
}
|
|
49
|
-
}
|