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.
Files changed (90) hide show
  1. package/dist/apikeyaccessinfo.js +1 -1
  2. package/dist/apikeyaccessinfo.js.map +1 -1
  3. package/dist/clearcache.js +12 -12
  4. package/dist/clearcache.js.map +1 -1
  5. package/dist/combine.js +1 -1
  6. package/dist/combine.js.map +1 -1
  7. package/dist/computable/booksnapshot.d.ts.map +1 -1
  8. package/dist/computable/booksnapshot.js +1 -1
  9. package/dist/computable/booksnapshot.js.map +1 -1
  10. package/dist/computable/tradebar.d.ts.map +1 -1
  11. package/dist/computable/tradebar.js.map +1 -1
  12. package/dist/debug.js +1 -1
  13. package/dist/debug.js.map +1 -1
  14. package/dist/downloaddatasets.js +13 -13
  15. package/dist/downloaddatasets.js.map +1 -1
  16. package/dist/exchangedetails.js +1 -1
  17. package/dist/exchangedetails.js.map +1 -1
  18. package/dist/filter.js.map +1 -1
  19. package/dist/handy.js +8 -8
  20. package/dist/handy.js.map +1 -1
  21. package/dist/instrumentinfo.js +1 -1
  22. package/dist/instrumentinfo.js.map +1 -1
  23. package/dist/mappers/binance.d.ts.map +1 -1
  24. package/dist/mappers/binance.js +2 -2
  25. package/dist/mappers/binance.js.map +1 -1
  26. package/dist/mappers/binanceoptions.js +10 -10
  27. package/dist/mappers/binanceoptions.js.map +1 -1
  28. package/dist/mappers/bitflyer.js +1 -1
  29. package/dist/mappers/bitflyer.js.map +1 -1
  30. package/dist/mappers/coinbase.js +2 -2
  31. package/dist/mappers/coinbase.js.map +1 -1
  32. package/dist/mappers/ftx.js +2 -2
  33. package/dist/mappers/ftx.js.map +1 -1
  34. package/dist/mappers/huobi.d.ts.map +1 -1
  35. package/dist/mappers/huobi.js +11 -11
  36. package/dist/mappers/huobi.js.map +1 -1
  37. package/dist/mappers/okex.js +14 -14
  38. package/dist/mappers/okex.js.map +1 -1
  39. package/dist/mappers/phemex.d.ts.map +1 -1
  40. package/dist/mappers/phemex.js.map +1 -1
  41. package/dist/realtimefeeds/ascendex.js +2 -2
  42. package/dist/realtimefeeds/ascendex.js.map +1 -1
  43. package/dist/realtimefeeds/binance.js +1 -1
  44. package/dist/realtimefeeds/binance.js.map +1 -1
  45. package/dist/realtimefeeds/bitmex.js +1 -1
  46. package/dist/realtimefeeds/bitmex.js.map +1 -1
  47. package/dist/realtimefeeds/ftx.js +1 -1
  48. package/dist/realtimefeeds/ftx.js.map +1 -1
  49. package/dist/realtimefeeds/huobi.js +7 -7
  50. package/dist/realtimefeeds/huobi.js.map +1 -1
  51. package/dist/realtimefeeds/okex.js +1 -1
  52. package/dist/realtimefeeds/okex.js.map +1 -1
  53. package/dist/realtimefeeds/realtimefeed.js +9 -9
  54. package/dist/realtimefeeds/realtimefeed.js.map +1 -1
  55. package/dist/replay.d.ts.map +1 -1
  56. package/dist/replay.js +34 -36
  57. package/dist/replay.js.map +1 -1
  58. package/dist/stream.js +4 -4
  59. package/dist/stream.js.map +1 -1
  60. package/dist/worker.js +12 -12
  61. package/dist/worker.js.map +1 -1
  62. package/package.json +19 -18
  63. package/src/computable/booksnapshot.ts +4 -2
  64. package/src/computable/tradebar.ts +4 -1
  65. package/src/downloaddatasets.ts +188 -188
  66. package/src/filter.ts +69 -69
  67. package/src/instrumentinfo.ts +1 -1
  68. package/src/mappers/ascendex.ts +156 -156
  69. package/src/mappers/binance.ts +6 -3
  70. package/src/mappers/coinflex.ts +159 -159
  71. package/src/mappers/delta.ts +175 -175
  72. package/src/mappers/dydx.ts +303 -303
  73. package/src/mappers/gateio.ts +117 -117
  74. package/src/mappers/gateiofutures.ts +185 -185
  75. package/src/mappers/huobi.ts +4 -2
  76. package/src/mappers/phemex.ts +179 -177
  77. package/src/mappers/poloniex.ts +150 -150
  78. package/src/mappers/serum.ts +103 -103
  79. package/src/mappers/upbit.ts +104 -104
  80. package/src/realtimefeeds/ascendex.ts +65 -65
  81. package/src/realtimefeeds/coinflex.ts +29 -29
  82. package/src/realtimefeeds/delta.ts +27 -27
  83. package/src/realtimefeeds/dydx.ts +40 -40
  84. package/src/realtimefeeds/gateio.ts +41 -41
  85. package/src/realtimefeeds/gateiofutures.ts +90 -90
  86. package/src/realtimefeeds/poloniex.ts +28 -28
  87. package/src/realtimefeeds/realtimefeed.ts +2 -2
  88. package/src/realtimefeeds/upbit.ts +35 -35
  89. package/src/replay.ts +7 -8
  90. 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
- // experimental more lenient gzip decompression, behind env flag for now
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 = process.env.TARDIS_LENIENT_GZIP_DECOMPRESS
80
- ? {
81
- chunkSize: 128 * 1024,
82
- flush: constants.Z_SYNC_FLUSH,
83
- finishFlush: constants.Z_SYNC_FLUSH
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
@@ -92,7 +92,7 @@ async function* _streamNormalized<T extends Exchange, U extends MapperFactory<T,
92
92
  for await (const message of normalizedMessages) {
93
93
  yield message
94
94
  }
95
- } catch (error) {
95
+ } catch (error: any) {
96
96
  if (onError !== undefined) {
97
97
  onError(error)
98
98
  }