tardis-dev 12.6.2 → 12.6.7
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.js +1 -1
- package/dist/apikeyaccessinfo.js.map +1 -1
- package/dist/clearcache.js +12 -12
- package/dist/clearcache.js.map +1 -1
- package/dist/combine.js +1 -1
- package/dist/combine.js.map +1 -1
- package/dist/computable/booksnapshot.d.ts.map +1 -1
- package/dist/computable/booksnapshot.js +1 -1
- package/dist/computable/booksnapshot.js.map +1 -1
- package/dist/computable/tradebar.d.ts.map +1 -1
- package/dist/computable/tradebar.js.map +1 -1
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/downloaddatasets.js +13 -13
- package/dist/downloaddatasets.js.map +1 -1
- package/dist/exchangedetails.js +1 -1
- package/dist/exchangedetails.js.map +1 -1
- package/dist/filter.js.map +1 -1
- package/dist/handy.js +8 -8
- package/dist/handy.js.map +1 -1
- package/dist/instrumentinfo.js +1 -1
- package/dist/instrumentinfo.js.map +1 -1
- package/dist/mappers/binance.d.ts.map +1 -1
- package/dist/mappers/binance.js +2 -2
- package/dist/mappers/binance.js.map +1 -1
- package/dist/mappers/binanceoptions.js +10 -10
- package/dist/mappers/binanceoptions.js.map +1 -1
- package/dist/mappers/bitflyer.js +1 -1
- package/dist/mappers/bitflyer.js.map +1 -1
- package/dist/mappers/coinbase.js +2 -2
- package/dist/mappers/coinbase.js.map +1 -1
- package/dist/mappers/ftx.js +2 -2
- package/dist/mappers/ftx.js.map +1 -1
- package/dist/mappers/huobi.d.ts.map +1 -1
- package/dist/mappers/huobi.js +11 -11
- package/dist/mappers/huobi.js.map +1 -1
- package/dist/mappers/okex.js +14 -14
- package/dist/mappers/okex.js.map +1 -1
- package/dist/mappers/phemex.d.ts.map +1 -1
- package/dist/mappers/phemex.js.map +1 -1
- package/dist/realtimefeeds/ascendex.js +2 -2
- package/dist/realtimefeeds/ascendex.js.map +1 -1
- package/dist/realtimefeeds/binance.js +1 -1
- package/dist/realtimefeeds/binance.js.map +1 -1
- package/dist/realtimefeeds/bitmex.js +1 -1
- package/dist/realtimefeeds/bitmex.js.map +1 -1
- package/dist/realtimefeeds/ftx.js +1 -1
- package/dist/realtimefeeds/ftx.js.map +1 -1
- package/dist/realtimefeeds/huobi.js +7 -7
- package/dist/realtimefeeds/huobi.js.map +1 -1
- package/dist/realtimefeeds/okex.js +1 -1
- package/dist/realtimefeeds/okex.js.map +1 -1
- package/dist/realtimefeeds/realtimefeed.js +9 -9
- package/dist/realtimefeeds/realtimefeed.js.map +1 -1
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +34 -36
- package/dist/replay.js.map +1 -1
- package/dist/stream.js +4 -4
- package/dist/stream.js.map +1 -1
- package/dist/worker.js +12 -12
- package/dist/worker.js.map +1 -1
- package/package.json +19 -18
- package/src/computable/booksnapshot.ts +4 -2
- package/src/computable/tradebar.ts +4 -1
- package/src/downloaddatasets.ts +188 -188
- package/src/filter.ts +69 -69
- package/src/instrumentinfo.ts +1 -1
- package/src/mappers/ascendex.ts +156 -156
- package/src/mappers/binance.ts +6 -3
- package/src/mappers/coinflex.ts +159 -159
- package/src/mappers/delta.ts +175 -175
- package/src/mappers/dydx.ts +303 -303
- package/src/mappers/gateio.ts +117 -117
- package/src/mappers/gateiofutures.ts +185 -185
- package/src/mappers/huobi.ts +4 -2
- package/src/mappers/phemex.ts +179 -177
- package/src/mappers/poloniex.ts +150 -150
- package/src/mappers/serum.ts +103 -103
- package/src/mappers/upbit.ts +104 -104
- package/src/realtimefeeds/ascendex.ts +65 -65
- package/src/realtimefeeds/coinflex.ts +29 -29
- package/src/realtimefeeds/delta.ts +27 -27
- package/src/realtimefeeds/dydx.ts +40 -40
- package/src/realtimefeeds/gateio.ts +41 -41
- package/src/realtimefeeds/gateiofutures.ts +90 -90
- package/src/realtimefeeds/poloniex.ts +28 -28
- package/src/realtimefeeds/realtimefeed.ts +2 -2
- package/src/realtimefeeds/upbit.ts +35 -35
- package/src/replay.ts +7 -8
- package/src/stream.ts +1 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class DydxRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected readonly wssURL = 'wss://api.dydx.exchange/v3/ws'
|
|
6
|
-
|
|
7
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
-
const subs = filters
|
|
9
|
-
.map((filter) => {
|
|
10
|
-
if (filter.channel === 'v3_markets') {
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
type: 'subscribe',
|
|
14
|
-
channel: 'v3_markets'
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
20
|
-
throw new Error('DydxRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return filter.symbols.map((symbol) => {
|
|
24
|
-
return {
|
|
25
|
-
type: 'subscribe',
|
|
26
|
-
channel: filter.channel,
|
|
27
|
-
id: symbol,
|
|
28
|
-
includeOffsets: filter.channel === 'v3_orderbook' ? true : undefined
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
.flatMap((f) => f)
|
|
33
|
-
|
|
34
|
-
return subs
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
protected messageIsError(message: any): boolean {
|
|
38
|
-
return message.type === 'error'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
import { Filter } from '../types'
|
|
2
|
+
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
+
|
|
4
|
+
export class DydxRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
+
protected readonly wssURL = 'wss://api.dydx.exchange/v3/ws'
|
|
6
|
+
|
|
7
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
+
const subs = filters
|
|
9
|
+
.map((filter) => {
|
|
10
|
+
if (filter.channel === 'v3_markets') {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
type: 'subscribe',
|
|
14
|
+
channel: 'v3_markets'
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
20
|
+
throw new Error('DydxRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return filter.symbols.map((symbol) => {
|
|
24
|
+
return {
|
|
25
|
+
type: 'subscribe',
|
|
26
|
+
channel: filter.channel,
|
|
27
|
+
id: symbol,
|
|
28
|
+
includeOffsets: filter.channel === 'v3_orderbook' ? true : undefined
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
.flatMap((f) => f)
|
|
33
|
+
|
|
34
|
+
return subs
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected messageIsError(message: any): boolean {
|
|
38
|
+
return message.type === 'error'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class GateIORealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected readonly wssURL = 'wss://ws.gate.io/v3/'
|
|
6
|
-
|
|
7
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
-
const id = 1
|
|
9
|
-
const payload = filters.map((filter) => {
|
|
10
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
11
|
-
throw new Error('GateIORealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (filter.channel === 'depth') {
|
|
15
|
-
return {
|
|
16
|
-
id,
|
|
17
|
-
method: `${filter.channel}.subscribe`,
|
|
18
|
-
params: filter.symbols.map((s) => {
|
|
19
|
-
return [s, 30, '0']
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
return {
|
|
24
|
-
id,
|
|
25
|
-
method: `${filter.channel}.subscribe`,
|
|
26
|
-
params: filter.symbols
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return payload
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
protected messageIsError(message: any): boolean {
|
|
35
|
-
if (message.error !== null && message.error !== undefined) {
|
|
36
|
-
return true
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
import { Filter } from '../types'
|
|
2
|
+
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
+
|
|
4
|
+
export class GateIORealTimeFeed extends RealTimeFeedBase {
|
|
5
|
+
protected readonly wssURL = 'wss://ws.gate.io/v3/'
|
|
6
|
+
|
|
7
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
+
const id = 1
|
|
9
|
+
const payload = filters.map((filter) => {
|
|
10
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
11
|
+
throw new Error('GateIORealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (filter.channel === 'depth') {
|
|
15
|
+
return {
|
|
16
|
+
id,
|
|
17
|
+
method: `${filter.channel}.subscribe`,
|
|
18
|
+
params: filter.symbols.map((s) => {
|
|
19
|
+
return [s, 30, '0']
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
method: `${filter.channel}.subscribe`,
|
|
26
|
+
params: filter.symbols
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return payload
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected messageIsError(message: any): boolean {
|
|
35
|
+
if (message.error !== null && message.error !== undefined) {
|
|
36
|
+
return true
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class GateIOFuturesRealTimeFeed extends MultiConnectionRealTimeFeedBase {
|
|
5
|
-
protected *_getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void) {
|
|
6
|
-
const linearContractsFilters = filters.reduce(
|
|
7
|
-
this._only((s) => s.endsWith('_USDT')),
|
|
8
|
-
[] as Filter<string>[]
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
const inverseContractsFilters = filters.reduce(
|
|
12
|
-
this._only((s) => s.endsWith('_USDT') === false),
|
|
13
|
-
[] as Filter<string>[]
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
if (linearContractsFilters.length > 0) {
|
|
17
|
-
yield new GateIOFuturesSingleConnectionRealTimeFeed('usdt', exchange, linearContractsFilters, timeoutIntervalMS, onError)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (inverseContractsFilters.length > 0) {
|
|
21
|
-
yield new GateIOFuturesSingleConnectionRealTimeFeed('btc', exchange, inverseContractsFilters, timeoutIntervalMS, onError)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private _only(filter: (symbol: string) => boolean) {
|
|
26
|
-
return (prev: Filter<string>[], current: Filter<string>) => {
|
|
27
|
-
if (!current.symbols || current.symbols.length === 0) {
|
|
28
|
-
throw new Error('GateIOFuturesRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const symbols = current.symbols.filter(filter)
|
|
32
|
-
if (symbols.length > 0) {
|
|
33
|
-
prev.push({
|
|
34
|
-
channel: current.channel,
|
|
35
|
-
symbols
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
return prev
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
class GateIOFuturesSingleConnectionRealTimeFeed extends RealTimeFeedBase {
|
|
44
|
-
protected readonly wssURL: string
|
|
45
|
-
|
|
46
|
-
constructor(
|
|
47
|
-
wsURLSuffix: string,
|
|
48
|
-
exchange: string,
|
|
49
|
-
filters: Filter<string>[],
|
|
50
|
-
timeoutIntervalMS?: number,
|
|
51
|
-
onError?: (error: Error) => void
|
|
52
|
-
) {
|
|
53
|
-
super(exchange, filters, timeoutIntervalMS, onError)
|
|
54
|
-
this.wssURL = `wss://fx-ws.gateio.ws/v4/ws/${wsURLSuffix}`
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
58
|
-
const payload = filters.flatMap((filter) => {
|
|
59
|
-
if (filter.channel === 'order_book') {
|
|
60
|
-
return filter.symbols!.map((symbol) => {
|
|
61
|
-
return {
|
|
62
|
-
event: 'subscribe',
|
|
63
|
-
channel: `futures.${filter.channel}`,
|
|
64
|
-
payload: [symbol, '20', '0'],
|
|
65
|
-
time: Math.floor(new Date().valueOf() / 1000)
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
} else {
|
|
69
|
-
return [
|
|
70
|
-
{
|
|
71
|
-
event: 'subscribe',
|
|
72
|
-
channel: `futures.${filter.channel}`,
|
|
73
|
-
payload: filter.symbols,
|
|
74
|
-
time: Math.floor(new Date().valueOf() / 1000)
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
return payload
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
protected messageIsError(message: any): boolean {
|
|
84
|
-
if (message.error !== null && message.error !== undefined) {
|
|
85
|
-
return true
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return false
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import { Filter } from '../types'
|
|
2
|
+
import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed'
|
|
3
|
+
|
|
4
|
+
export class GateIOFuturesRealTimeFeed extends MultiConnectionRealTimeFeedBase {
|
|
5
|
+
protected *_getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void) {
|
|
6
|
+
const linearContractsFilters = filters.reduce(
|
|
7
|
+
this._only((s) => s.endsWith('_USDT')),
|
|
8
|
+
[] as Filter<string>[]
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
const inverseContractsFilters = filters.reduce(
|
|
12
|
+
this._only((s) => s.endsWith('_USDT') === false),
|
|
13
|
+
[] as Filter<string>[]
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if (linearContractsFilters.length > 0) {
|
|
17
|
+
yield new GateIOFuturesSingleConnectionRealTimeFeed('usdt', exchange, linearContractsFilters, timeoutIntervalMS, onError)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (inverseContractsFilters.length > 0) {
|
|
21
|
+
yield new GateIOFuturesSingleConnectionRealTimeFeed('btc', exchange, inverseContractsFilters, timeoutIntervalMS, onError)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private _only(filter: (symbol: string) => boolean) {
|
|
26
|
+
return (prev: Filter<string>[], current: Filter<string>) => {
|
|
27
|
+
if (!current.symbols || current.symbols.length === 0) {
|
|
28
|
+
throw new Error('GateIOFuturesRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const symbols = current.symbols.filter(filter)
|
|
32
|
+
if (symbols.length > 0) {
|
|
33
|
+
prev.push({
|
|
34
|
+
channel: current.channel,
|
|
35
|
+
symbols
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
return prev
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class GateIOFuturesSingleConnectionRealTimeFeed extends RealTimeFeedBase {
|
|
44
|
+
protected readonly wssURL: string
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
wsURLSuffix: string,
|
|
48
|
+
exchange: string,
|
|
49
|
+
filters: Filter<string>[],
|
|
50
|
+
timeoutIntervalMS?: number,
|
|
51
|
+
onError?: (error: Error) => void
|
|
52
|
+
) {
|
|
53
|
+
super(exchange, filters, timeoutIntervalMS, onError)
|
|
54
|
+
this.wssURL = `wss://fx-ws.gateio.ws/v4/ws/${wsURLSuffix}`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
58
|
+
const payload = filters.flatMap((filter) => {
|
|
59
|
+
if (filter.channel === 'order_book') {
|
|
60
|
+
return filter.symbols!.map((symbol) => {
|
|
61
|
+
return {
|
|
62
|
+
event: 'subscribe',
|
|
63
|
+
channel: `futures.${filter.channel}`,
|
|
64
|
+
payload: [symbol, '20', '0'],
|
|
65
|
+
time: Math.floor(new Date().valueOf() / 1000)
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
event: 'subscribe',
|
|
72
|
+
channel: `futures.${filter.channel}`,
|
|
73
|
+
payload: filter.symbols,
|
|
74
|
+
time: Math.floor(new Date().valueOf() / 1000)
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return payload
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected messageIsError(message: any): boolean {
|
|
84
|
+
if (message.error !== null && message.error !== undefined) {
|
|
85
|
+
return true
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class PoloniexRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected readonly wssURL = 'wss://api2.poloniex.com'
|
|
6
|
-
|
|
7
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]) {
|
|
8
|
-
const allSymbols = filters.flatMap((filter) => {
|
|
9
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
10
|
-
throw new Error('PoloniexRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
11
|
-
}
|
|
12
|
-
return filter.symbols
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
const uniqueSymbols = [...new Set(allSymbols)]
|
|
16
|
-
|
|
17
|
-
return uniqueSymbols.map((symbol) => {
|
|
18
|
-
return {
|
|
19
|
-
command: 'subscribe',
|
|
20
|
-
channel: symbol
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
protected messageIsError(message: any): boolean {
|
|
26
|
-
return message.error !== undefined && message.error !== null
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import { Filter } from '../types'
|
|
2
|
+
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
+
|
|
4
|
+
export class PoloniexRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
+
protected readonly wssURL = 'wss://api2.poloniex.com'
|
|
6
|
+
|
|
7
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]) {
|
|
8
|
+
const allSymbols = filters.flatMap((filter) => {
|
|
9
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
10
|
+
throw new Error('PoloniexRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
11
|
+
}
|
|
12
|
+
return filter.symbols
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const uniqueSymbols = [...new Set(allSymbols)]
|
|
16
|
+
|
|
17
|
+
return uniqueSymbols.map((symbol) => {
|
|
18
|
+
return {
|
|
19
|
+
command: 'subscribe',
|
|
20
|
+
channel: symbol
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected messageIsError(message: any): boolean {
|
|
26
|
+
return message.error !== undefined && message.error !== null
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -43,7 +43,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable {
|
|
|
43
43
|
this._filters = optimizeFilters(filters)
|
|
44
44
|
this.debug = dbg(`tardis-dev:realtime:${_exchange}`)
|
|
45
45
|
|
|
46
|
-
this._wsClientOptions = { perMessageDeflate: false, handshakeTimeout: 10 * ONE_SEC_IN_MS }
|
|
46
|
+
this._wsClientOptions = { perMessageDeflate: false, handshakeTimeout: 10 * ONE_SEC_IN_MS, skipUTF8Validation: true } as any
|
|
47
47
|
|
|
48
48
|
if (httpsProxyAgent !== undefined) {
|
|
49
49
|
this._wsClientOptions.agent = httpsProxyAgent
|
|
@@ -123,7 +123,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable {
|
|
|
123
123
|
clearInterval(staleConnectionTimerId)
|
|
124
124
|
}
|
|
125
125
|
yield { __disconnect__: true }
|
|
126
|
-
} catch (error) {
|
|
126
|
+
} catch (error: any) {
|
|
127
127
|
if (this._onError !== undefined) {
|
|
128
128
|
this._onError(error)
|
|
129
129
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class UpbitRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected readonly wssURL = 'wss://api.upbit.com/websocket/v1'
|
|
6
|
-
|
|
7
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
-
const subs = filters.map((filter) => {
|
|
9
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
10
|
-
throw new Error('UpbitRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
type: filter.channel,
|
|
15
|
-
codes: filter.symbols,
|
|
16
|
-
isOnlyRealtime: true
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const payload = [
|
|
21
|
-
[
|
|
22
|
-
{
|
|
23
|
-
ticket: new Date().valueOf().toString()
|
|
24
|
-
},
|
|
25
|
-
...subs
|
|
26
|
-
]
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
return payload
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
protected messageIsError(message: any): boolean {
|
|
33
|
-
return message.type === 'error'
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
import { Filter } from '../types'
|
|
2
|
+
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
+
|
|
4
|
+
export class UpbitRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
+
protected readonly wssURL = 'wss://api.upbit.com/websocket/v1'
|
|
6
|
+
|
|
7
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
+
const subs = filters.map((filter) => {
|
|
9
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
10
|
+
throw new Error('UpbitRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
type: filter.channel,
|
|
15
|
+
codes: filter.symbols,
|
|
16
|
+
isOnlyRealtime: true
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const payload = [
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
ticket: new Date().valueOf().toString()
|
|
24
|
+
},
|
|
25
|
+
...subs
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
return payload
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected messageIsError(message: any): boolean {
|
|
33
|
+
return message.type === 'error'
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/replay.ts
CHANGED
|
@@ -73,16 +73,15 @@ export async function* replay<T extends Exchange, U extends boolean = false, Z e
|
|
|
73
73
|
// as hardcoded value
|
|
74
74
|
const DATE_MESSAGE_SPLIT_INDEX = 28
|
|
75
75
|
|
|
76
|
-
//
|
|
76
|
+
// more lenient gzip decompression
|
|
77
77
|
// see https://github.com/request/request/pull/2492 and https://github.com/node-fetch/node-fetch/pull/239
|
|
78
78
|
|
|
79
|
-
const ZLIB_OPTIONS =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
: { chunkSize: 128 * 1024 }
|
|
79
|
+
const ZLIB_OPTIONS = {
|
|
80
|
+
chunkSize: 128 * 1024,
|
|
81
|
+
flush: constants.Z_SYNC_FLUSH,
|
|
82
|
+
finishFlush: constants.Z_SYNC_FLUSH
|
|
83
|
+
}
|
|
84
|
+
|
|
86
85
|
// helper flag that helps us not yielding two subsequent undefined/disconnect messages
|
|
87
86
|
let lastMessageWasUndefined = false
|
|
88
87
|
|
package/src/stream.ts
CHANGED