tardis-dev 13.16.0 → 13.18.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/consts.d.ts +4 -4
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +10 -4
- package/dist/consts.js.map +1 -1
- package/dist/handy.js +2 -2
- package/dist/handy.js.map +1 -1
- package/dist/mappers/delta.d.ts +65 -2
- package/dist/mappers/delta.d.ts.map +1 -1
- package/dist/mappers/delta.js +81 -17
- package/dist/mappers/delta.js.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 +3 -2
- package/dist/mappers/index.js.map +1 -1
- package/dist/mappers/okex.d.ts +25 -1
- package/dist/mappers/okex.d.ts.map +1 -1
- package/dist/mappers/okex.js +44 -14
- package/dist/mappers/okex.js.map +1 -1
- package/dist/realtimefeeds/delta.d.ts +1 -1
- package/dist/realtimefeeds/delta.d.ts.map +1 -1
- package/dist/realtimefeeds/delta.js +1 -1
- package/dist/realtimefeeds/delta.js.map +1 -1
- package/dist/realtimefeeds/okex.d.ts.map +1 -1
- package/dist/realtimefeeds/okex.js +7 -0
- package/dist/realtimefeeds/okex.js.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +10 -4
- package/src/handy.ts +2 -2
- package/src/mappers/delta.ts +121 -18
- package/src/mappers/index.ts +4 -3
- package/src/mappers/okex.ts +60 -14
- package/src/realtimefeeds/delta.ts +1 -1
- package/src/realtimefeeds/okex.ts +7 -0
package/src/mappers/okex.ts
CHANGED
|
@@ -97,6 +97,7 @@ export class OkexV5BookChangeMapper implements Mapper<OKEX_EXCHANGES, BookChange
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
*map(okexDepthDataMessage: OkexV5BookMessage, localTimestamp: Date): IterableIterator<BookChange> {
|
|
100
|
+
console.log(okexDepthDataMessage)
|
|
100
101
|
for (const message of okexDepthDataMessage.data) {
|
|
101
102
|
if (okexDepthDataMessage.action === 'update' && message.bids.length === 0 && message.asks.length === 0) {
|
|
102
103
|
continue
|
|
@@ -344,13 +345,14 @@ export class OkexV5DerivativeTickerMapper implements Mapper<'okex-futures' | 'ok
|
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
export class OkexV5LiquidationsMapper implements Mapper<OKEX_EXCHANGES, Liquidation> {
|
|
348
|
+
private _isFirstMessage = true
|
|
347
349
|
constructor(private readonly _exchange: Exchange) {}
|
|
348
350
|
|
|
349
351
|
canHandle(message: any) {
|
|
350
352
|
if (message.event !== undefined || message.arg === undefined) {
|
|
351
353
|
return false
|
|
352
354
|
}
|
|
353
|
-
return message.arg.channel === 'liquidations'
|
|
355
|
+
return message.arg.channel === 'liquidations' || message.arg.channel === 'liquidation-orders'
|
|
354
356
|
}
|
|
355
357
|
|
|
356
358
|
getFilters(symbols?: string[]) {
|
|
@@ -360,24 +362,55 @@ export class OkexV5LiquidationsMapper implements Mapper<OKEX_EXCHANGES, Liquidat
|
|
|
360
362
|
{
|
|
361
363
|
channel: 'liquidations',
|
|
362
364
|
symbols
|
|
365
|
+
} as any,
|
|
366
|
+
{
|
|
367
|
+
channel: 'liquidation-orders',
|
|
368
|
+
symbols
|
|
363
369
|
} as any
|
|
364
370
|
]
|
|
365
371
|
}
|
|
366
372
|
|
|
367
|
-
*map(
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
*map(
|
|
374
|
+
okexLiquidationMessage: OkexV5LiquidationMessage | OkexV5LiquidationOrderMessage,
|
|
375
|
+
localTimestamp: Date
|
|
376
|
+
): IterableIterator<Liquidation> {
|
|
377
|
+
if (okexLiquidationMessage.arg.channel === 'liquidation-orders') {
|
|
378
|
+
if (this._isFirstMessage) {
|
|
379
|
+
this._isFirstMessage = false
|
|
380
|
+
return
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
for (const okexLiquidation of (okexLiquidationMessage as OkexV5LiquidationOrderMessage).data) {
|
|
384
|
+
for (const detail of okexLiquidation.details) {
|
|
385
|
+
const liquidation: Liquidation = {
|
|
386
|
+
type: 'liquidation',
|
|
387
|
+
symbol: okexLiquidation.instId,
|
|
388
|
+
exchange: this._exchange,
|
|
389
|
+
id: undefined,
|
|
390
|
+
price: Number(detail.bkPx),
|
|
391
|
+
amount: Number(detail.sz),
|
|
392
|
+
side: detail.side === 'buy' ? 'buy' : 'sell',
|
|
393
|
+
timestamp: new Date(Number(detail.ts)),
|
|
394
|
+
localTimestamp: localTimestamp
|
|
395
|
+
}
|
|
396
|
+
yield liquidation
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
for (const okexLiquidation of (okexLiquidationMessage as OkexV5LiquidationMessage).data) {
|
|
401
|
+
const liquidation: Liquidation = {
|
|
402
|
+
type: 'liquidation',
|
|
403
|
+
symbol: okexLiquidationMessage.arg.instId,
|
|
404
|
+
exchange: this._exchange,
|
|
405
|
+
id: undefined,
|
|
406
|
+
price: Number(okexLiquidation.bkPx),
|
|
407
|
+
amount: Number(okexLiquidation.sz),
|
|
408
|
+
side: okexLiquidation.side === 'buy' ? 'buy' : 'sell',
|
|
409
|
+
timestamp: new Date(Number(okexLiquidation.ts)),
|
|
410
|
+
localTimestamp: localTimestamp
|
|
411
|
+
}
|
|
412
|
+
yield liquidation
|
|
379
413
|
}
|
|
380
|
-
yield liquidation
|
|
381
414
|
}
|
|
382
415
|
}
|
|
383
416
|
}
|
|
@@ -634,6 +667,19 @@ type OkexV5LiquidationMessage = {
|
|
|
634
667
|
data: [{ bkLoss: '0'; bkPx: '49674.2'; ccy: ''; posSide: 'short'; side: 'buy'; sz: '40'; ts: '1640140211925' }]
|
|
635
668
|
}
|
|
636
669
|
|
|
670
|
+
type OkexV5LiquidationOrderMessage = {
|
|
671
|
+
arg: { channel: 'liquidation-orders'; instType: 'FUTURES' }
|
|
672
|
+
data: [
|
|
673
|
+
{
|
|
674
|
+
details: [{ bkLoss: '0'; bkPx: '0.55205'; ccy: ''; posSide: 'short'; side: 'buy'; sz: '39'; ts: '1680173247614' }]
|
|
675
|
+
instFamily: 'XRP-USD'
|
|
676
|
+
instId: 'XRP-USD-230929'
|
|
677
|
+
instType: 'FUTURES'
|
|
678
|
+
uly: 'XRP-USD'
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
}
|
|
682
|
+
|
|
637
683
|
type OkexV5SummaryMessage = {
|
|
638
684
|
arg: { channel: 'opt-summary'; uly: 'ETH-USD' }
|
|
639
685
|
data: [
|
|
@@ -2,7 +2,7 @@ import { Filter } from '../types'
|
|
|
2
2
|
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
3
|
|
|
4
4
|
export class DeltaRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected readonly wssURL = 'wss://
|
|
5
|
+
protected readonly wssURL = 'wss://socket.delta.exchange'
|
|
6
6
|
|
|
7
7
|
protected mapToSubscribeMessages(filters: Filter<string>[]) {
|
|
8
8
|
return filters.map((filter) => {
|
|
@@ -36,12 +36,19 @@ export class OkexRealTimeFeed extends RealTimeFeedBase {
|
|
|
36
36
|
|
|
37
37
|
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
38
38
|
const args = filters
|
|
39
|
+
.filter((f) => f.channel != 'liquidations')
|
|
39
40
|
.map((filter) => {
|
|
40
41
|
if (!filter.symbols || filter.symbols.length === 0) {
|
|
41
42
|
throw new Error(`${this._exchange} RealTimeFeed requires explicitly specified symbols when subscribing to live feed`)
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
return filter.symbols.map((symbol) => {
|
|
46
|
+
if (filter.channel === 'liquidation-orders') {
|
|
47
|
+
return {
|
|
48
|
+
channel: filter.channel,
|
|
49
|
+
instType: symbol.endsWith('SWAP') ? 'SWAP' : 'FUTURES'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
45
52
|
return {
|
|
46
53
|
channel: filter.channel,
|
|
47
54
|
instId: symbol
|