tardis-dev 16.2.0 → 16.2.2

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 (76) hide show
  1. package/dist/computable/computable.js.map +1 -1
  2. package/dist/consts.js +2 -2
  3. package/dist/consts.js.map +1 -1
  4. package/dist/handy.d.ts.map +1 -1
  5. package/dist/handy.js +1 -1
  6. package/dist/handy.js.map +1 -1
  7. package/dist/instrumentinfo.js +1 -1
  8. package/dist/instrumentinfo.js.map +1 -1
  9. package/dist/mappers/binance.d.ts.map +1 -1
  10. package/dist/mappers/binance.js.map +1 -1
  11. package/dist/mappers/bitget.d.ts +148 -1
  12. package/dist/mappers/bitget.d.ts.map +1 -1
  13. package/dist/mappers/bitget.js +160 -1
  14. package/dist/mappers/bitget.js.map +1 -1
  15. package/dist/mappers/bybit.d.ts.map +1 -1
  16. package/dist/mappers/bybit.js.map +1 -1
  17. package/dist/mappers/gateio.d.ts.map +1 -1
  18. package/dist/mappers/gateio.js.map +1 -1
  19. package/dist/mappers/gateiofutures.js.map +1 -1
  20. package/dist/mappers/huobi.d.ts.map +1 -1
  21. package/dist/mappers/huobi.js.map +1 -1
  22. package/dist/mappers/index.d.ts +9 -8
  23. package/dist/mappers/index.d.ts.map +1 -1
  24. package/dist/mappers/index.js +18 -9
  25. package/dist/mappers/index.js.map +1 -1
  26. package/dist/mappers/kucoin.d.ts.map +1 -1
  27. package/dist/mappers/kucoin.js.map +1 -1
  28. package/dist/mappers/okex.d.ts.map +1 -1
  29. package/dist/mappers/okex.js.map +1 -1
  30. package/dist/mappers/phemex.d.ts.map +1 -1
  31. package/dist/mappers/phemex.js +11 -2
  32. package/dist/mappers/phemex.js.map +1 -1
  33. package/dist/realtimefeeds/bitget.d.ts +4 -2
  34. package/dist/realtimefeeds/bitget.d.ts.map +1 -1
  35. package/dist/realtimefeeds/bitget.js +21 -7
  36. package/dist/realtimefeeds/bitget.js.map +1 -1
  37. package/dist/realtimefeeds/bitnomial.d.ts.map +1 -1
  38. package/dist/realtimefeeds/bitnomial.js.map +1 -1
  39. package/dist/realtimefeeds/coinbase.d.ts.map +1 -1
  40. package/dist/realtimefeeds/coinbase.js.map +1 -1
  41. package/dist/realtimefeeds/hitbtc.d.ts.map +1 -1
  42. package/dist/realtimefeeds/hitbtc.js.map +1 -1
  43. package/dist/realtimefeeds/huobi.d.ts.map +1 -1
  44. package/dist/realtimefeeds/huobi.js.map +1 -1
  45. package/dist/realtimefeeds/kucoinfutures.d.ts.map +1 -1
  46. package/dist/realtimefeeds/kucoinfutures.js.map +1 -1
  47. package/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
  48. package/dist/realtimefeeds/realtimefeed.js.map +1 -1
  49. package/dist/realtimefeeds/serum.d.ts.map +1 -1
  50. package/dist/realtimefeeds/serum.js.map +1 -1
  51. package/dist/replay.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/src/computable/computable.ts +14 -11
  54. package/src/consts.ts +2 -2
  55. package/src/handy.ts +30 -19
  56. package/src/instrumentinfo.ts +1 -1
  57. package/src/mappers/binance.ts +16 -8
  58. package/src/mappers/bitget.ts +237 -2
  59. package/src/mappers/bybit.ts +21 -16
  60. package/src/mappers/gateio.ts +4 -1
  61. package/src/mappers/gateiofutures.ts +2 -2
  62. package/src/mappers/huobi.ts +8 -6
  63. package/src/mappers/index.ts +39 -11
  64. package/src/mappers/kucoin.ts +4 -1
  65. package/src/mappers/okex.ts +24 -6
  66. package/src/mappers/phemex.ts +14 -4
  67. package/src/realtimefeeds/bitget.ts +24 -7
  68. package/src/realtimefeeds/bitnomial.ts +14 -11
  69. package/src/realtimefeeds/coinbase.ts +14 -11
  70. package/src/realtimefeeds/hitbtc.ts +10 -7
  71. package/src/realtimefeeds/huobi.ts +10 -2
  72. package/src/realtimefeeds/kucoinfutures.ts +4 -1
  73. package/src/realtimefeeds/realtimefeed.ts +5 -1
  74. package/src/realtimefeeds/serum.ts +14 -11
  75. package/src/replay.ts +2 -2
  76. package/src/types.ts +1 -1
@@ -4,10 +4,19 @@ import { RealTimeFeedBase } from './realtimefeed.ts'
4
4
 
5
5
  abstract class BitgetRealTimeFeedBase extends RealTimeFeedBase {
6
6
  protected throttleSubscribeMS = 100
7
- protected readonly wssURL = 'wss://ws.bitget.com/v2/ws/public'
7
+ protected readonly wssURL = 'wss://ws.bitget.com/v3/ws/public'
8
8
 
9
9
  protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
10
10
  const argsInputs = filters.flatMap((filter) => {
11
+ if (filter.channel === 'liquidation') {
12
+ return this.getLiquidationInstTypes().map((instType) => {
13
+ return {
14
+ instType,
15
+ topic: filter.channel
16
+ }
17
+ })
18
+ }
19
+
11
20
  if (!filter.symbols || filter.symbols.length === 0) {
12
21
  throw new Error('BitgetRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
13
22
  }
@@ -15,8 +24,8 @@ abstract class BitgetRealTimeFeedBase extends RealTimeFeedBase {
15
24
  return filter.symbols.map((symbol) => {
16
25
  return {
17
26
  instType: this.getInstType(symbol),
18
- channel: filter.channel,
19
- instId: symbol
27
+ topic: filter.channel,
28
+ symbol
20
29
  }
21
30
  })
22
31
  })
@@ -36,24 +45,32 @@ abstract class BitgetRealTimeFeedBase extends RealTimeFeedBase {
36
45
  }
37
46
 
38
47
  abstract getInstType(symbol: string): string
48
+
49
+ protected getLiquidationInstTypes(): string[] {
50
+ return []
51
+ }
39
52
  }
40
53
 
41
54
  export class BitgetRealTimeFeed extends BitgetRealTimeFeedBase {
42
55
  getInstType(_: string) {
43
- return 'SPOT'
56
+ return 'spot'
44
57
  }
45
58
  }
46
59
 
47
60
  export class BitgetFuturesRealTimeFeed extends BitgetRealTimeFeedBase {
48
61
  getInstType(symbol: string) {
49
62
  if (symbol.endsWith('USDT')) {
50
- return 'USDT-FUTURES'
63
+ return 'usdt-futures'
51
64
  }
52
65
 
53
66
  if (symbol.endsWith('PERP')) {
54
- return 'USDC-FUTURES'
67
+ return 'usdc-futures'
55
68
  }
56
69
 
57
- return 'COIN-FUTURES'
70
+ return 'coin-futures'
71
+ }
72
+
73
+ protected getLiquidationInstTypes() {
74
+ return ['usdt-futures', 'usdc-futures', 'coin-futures']
58
75
  }
59
76
  }
@@ -27,20 +27,23 @@ export class BitnomialRealTimeFeed extends RealTimeFeedBase {
27
27
  product_codes: filter.symbols
28
28
  }
29
29
  })
30
- .reduce((prev, current) => {
31
- const matchingExisting = prev.find((c) => c.name === current.name)
32
- if (matchingExisting !== undefined) {
33
- for (const symbol of current.product_codes) {
34
- if (matchingExisting.product_codes.includes(symbol) === false) {
35
- matchingExisting.product_codes.push(symbol)
30
+ .reduce(
31
+ (prev, current) => {
32
+ const matchingExisting = prev.find((c) => c.name === current.name)
33
+ if (matchingExisting !== undefined) {
34
+ for (const symbol of current.product_codes) {
35
+ if (matchingExisting.product_codes.includes(symbol) === false) {
36
+ matchingExisting.product_codes.push(symbol)
37
+ }
36
38
  }
39
+ } else {
40
+ prev.push(current)
37
41
  }
38
- } else {
39
- prev.push(current)
40
- }
41
42
 
42
- return prev
43
- }, [] as { name: string; product_codes: string[] }[])
43
+ return prev
44
+ },
45
+ [] as { name: string; product_codes: string[] }[]
46
+ )
44
47
 
45
48
  return [
46
49
  {
@@ -53,20 +53,23 @@ export class CoinbaseRealTimeFeed extends RealTimeFeedBase {
53
53
  product_ids: filter.symbols
54
54
  }
55
55
  })
56
- .reduce((prev, current) => {
57
- const matchingExisting = prev.find((c) => c.name === current.name)
58
- if (matchingExisting !== undefined) {
59
- for (const symbol of current.product_ids) {
60
- if (matchingExisting.product_ids.includes(symbol) === false) {
61
- matchingExisting.product_ids.push(symbol)
56
+ .reduce(
57
+ (prev, current) => {
58
+ const matchingExisting = prev.find((c) => c.name === current.name)
59
+ if (matchingExisting !== undefined) {
60
+ for (const symbol of current.product_ids) {
61
+ if (matchingExisting.product_ids.includes(symbol) === false) {
62
+ matchingExisting.product_ids.push(symbol)
63
+ }
62
64
  }
65
+ } else {
66
+ prev.push(current)
63
67
  }
64
- } else {
65
- prev.push(current)
66
- }
67
68
 
68
- return prev
69
- }, [] as { name: string; product_ids: string[] }[])
69
+ return prev
70
+ },
71
+ [] as { name: string; product_ids: string[] }[]
72
+ )
70
73
 
71
74
  if (this._hasCredentials) {
72
75
  const authParams = this.getAuthParams()
@@ -36,14 +36,17 @@ export class HitBtcRealTimeFeed extends RealTimeFeedBase {
36
36
  })
37
37
  })
38
38
  .flatMap((s) => s)
39
- .reduce((prev, current) => {
40
- const matchingExisting = prev.find((c) => c.method === current.method && c.symbol === current.symbol)
41
- if (matchingExisting === undefined) {
42
- prev.push(current)
43
- }
39
+ .reduce(
40
+ (prev, current) => {
41
+ const matchingExisting = prev.find((c) => c.method === current.method && c.symbol === current.symbol)
42
+ if (matchingExisting === undefined) {
43
+ prev.push(current)
44
+ }
44
45
 
45
- return prev
46
- }, [] as { method: string; symbol: string }[])
46
+ return prev
47
+ },
48
+ [] as { method: string; symbol: string }[]
49
+ )
47
50
 
48
51
  return subscriptions.map((subscription, index) => {
49
52
  return {
@@ -271,7 +271,11 @@ class HuobiOpenInterestClient extends PoolingClientBase {
271
271
  }
272
272
 
273
273
  class HuobiOptionsMarketIndexClient extends PoolingClientBase {
274
- constructor(exchange: string, private readonly _httpURL: string, private readonly _instruments: string[]) {
274
+ constructor(
275
+ exchange: string,
276
+ private readonly _httpURL: string,
277
+ private readonly _instruments: string[]
278
+ ) {
275
279
  super(exchange, 4)
276
280
  }
277
281
 
@@ -306,7 +310,11 @@ class HuobiOptionsMarketIndexClient extends PoolingClientBase {
306
310
  }
307
311
 
308
312
  class HuobiOptionsIndexClient extends PoolingClientBase {
309
- constructor(exchange: string, private readonly _httpURL: string, private readonly _instruments: string[]) {
313
+ constructor(
314
+ exchange: string,
315
+ private readonly _httpURL: string,
316
+ private readonly _instruments: string[]
317
+ ) {
310
318
  super(exchange, 4)
311
319
  }
312
320
 
@@ -109,7 +109,10 @@ export class KucoinFuturesSingleConnectionRealTimeFeed extends RealTimeFeedBase
109
109
  }
110
110
 
111
111
  class KucoinFuturesContractDetailsClient extends PoolingClientBase {
112
- constructor(exchange: string, private readonly _httpURL: string) {
112
+ constructor(
113
+ exchange: string,
114
+ private readonly _httpURL: string
115
+ ) {
113
116
  super(exchange, 6)
114
117
  }
115
118
 
@@ -377,7 +377,11 @@ export abstract class PoolingClientBase implements RealTimeFeedIterable {
377
377
  protected readonly debug: dbg.Debugger
378
378
  private _tid: NodeJS.Timeout | undefined = undefined
379
379
 
380
- constructor(exchange: string, private readonly _poolingIntervalSeconds: number, protected readonly onError?: (error: Error) => void) {
380
+ constructor(
381
+ exchange: string,
382
+ private readonly _poolingIntervalSeconds: number,
383
+ protected readonly onError?: (error: Error) => void
384
+ ) {
381
385
  this.debug = dbg(`tardis-dev:pooling-client:${exchange}`)
382
386
  }
383
387
 
@@ -40,20 +40,23 @@ export class SerumRealTimeFeed extends RealTimeFeedBase {
40
40
  markets: filter.symbols
41
41
  }
42
42
  })
43
- .reduce((prev, current) => {
44
- const matchingExisting = prev.find((c) => c.channel === current.channel)
45
- if (matchingExisting !== undefined) {
46
- for (const market of current.markets) {
47
- if (matchingExisting.markets.includes(market) === false) {
48
- matchingExisting.markets.push(market)
43
+ .reduce(
44
+ (prev, current) => {
45
+ const matchingExisting = prev.find((c) => c.channel === current.channel)
46
+ if (matchingExisting !== undefined) {
47
+ for (const market of current.markets) {
48
+ if (matchingExisting.markets.includes(market) === false) {
49
+ matchingExisting.markets.push(market)
50
+ }
49
51
  }
52
+ } else {
53
+ prev.push(current)
50
54
  }
51
- } else {
52
- prev.push(current)
53
- }
54
55
 
55
- return prev
56
- }, [] as { channel: string; markets: string[] }[])
56
+ return prev
57
+ },
58
+ [] as { channel: string; markets: string[] }[]
59
+ )
57
60
 
58
61
  return subs
59
62
  }
package/src/replay.ts CHANGED
@@ -35,8 +35,8 @@ export async function* replay<T extends Exchange, U extends boolean = false, Z e
35
35
  ? { localTimestamp: Buffer; message: Buffer } | undefined
36
36
  : { localTimestamp: Date; message: any } | undefined
37
37
  : U extends true
38
- ? { localTimestamp: Buffer; message: Buffer }
39
- : { localTimestamp: Date; message: any }
38
+ ? { localTimestamp: Buffer; message: Buffer }
39
+ : { localTimestamp: Date; message: any }
40
40
  > {
41
41
  validateReplayOptions(exchange, from, to, filters)
42
42
 
package/src/types.ts CHANGED
@@ -117,7 +117,7 @@ export type Liquidation = {
117
117
  readonly id: string | undefined
118
118
  readonly price: number
119
119
  readonly amount: number
120
- readonly side: 'buy' | 'sell' | 'unknown'
120
+ readonly side: 'buy' | 'sell' | 'unknown' // buy = short position liquidated, sell = long position liquidated
121
121
  readonly timestamp: Date
122
122
  readonly localTimestamp: Date
123
123
  }