tardis-dev 16.6.1 → 16.6.3

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.
@@ -1,73 +0,0 @@
1
- import { wait } from '../handy.ts'
2
- import { Filter } from '../types.ts'
3
- import { RealTimeFeedBase } from './realtimefeed.ts'
4
-
5
- export class AscendexRealTimeFeed extends RealTimeFeedBase {
6
- protected readonly wssURL = 'wss://ascendex.com/api/pro/v2/stream'
7
-
8
- protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
9
- const subs = filters
10
- .filter((f) => f.channel !== 'depth-snapshot-realtime')
11
- .map((filter) => {
12
- if (filter.channel === 'futures-pricing-data') {
13
- return [
14
- {
15
- op: 'sub',
16
- ch: 'futures-pricing-data'
17
- }
18
- ]
19
- }
20
-
21
- if (!filter.symbols || filter.symbols.length === 0) {
22
- throw new Error('AscendexRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
23
- }
24
-
25
- return filter.symbols.map((symbol) => {
26
- return {
27
- op: 'sub',
28
- ch: `${filter.channel}:${symbol}`
29
- }
30
- })
31
- })
32
- .flatMap((f) => f)
33
-
34
- return subs
35
- }
36
-
37
- protected messageIsError(message: any): boolean {
38
- return message.m === 'error'
39
- }
40
-
41
- protected sendCustomPing = () => {
42
- this.send({ op: 'ping' })
43
- }
44
-
45
- protected messageIsHeartbeat(msg: any) {
46
- return msg.m === 'pong'
47
- }
48
-
49
- protected async provideManualSnapshots(filters: Filter<string>[], shouldCancel: () => boolean) {
50
- const depthSnapshotChannel = filters.find((f) => f.channel === 'depth-snapshot-realtime')
51
- if (!depthSnapshotChannel) {
52
- return
53
- }
54
-
55
- await wait(100)
56
-
57
- for (let symbol of depthSnapshotChannel.symbols!) {
58
- if (shouldCancel()) {
59
- return
60
- }
61
-
62
- this.send({
63
- op: 'req',
64
- action: 'depth-snapshot-realtime',
65
- args: { symbol }
66
- })
67
-
68
- await wait(10)
69
- }
70
-
71
- this.debug('sent depth-snapshot-realtime "req" for: %s', depthSnapshotChannel.symbols)
72
- }
73
- }