tardis-dev 13.30.0 → 13.31.1

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.
@@ -0,0 +1,59 @@
1
+ import { batchObjects } from '../handy'
2
+ import { Filter } from '../types'
3
+ import { RealTimeFeedBase } from './realtimefeed'
4
+
5
+ abstract class BitgetRealTimeFeedBase extends RealTimeFeedBase {
6
+ protected throttleSubscribeMS = 100
7
+ protected readonly wssURL = 'wss://ws.bitget.com/v2/ws/public'
8
+
9
+ protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
10
+ const argsInputs = filters.flatMap((filter) => {
11
+ if (!filter.symbols || filter.symbols.length === 0) {
12
+ throw new Error('BitgetRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
13
+ }
14
+
15
+ return filter.symbols.map((symbol) => {
16
+ return {
17
+ instType: this.getInstType(symbol),
18
+ channel: filter.channel,
19
+ instId: symbol
20
+ }
21
+ })
22
+ })
23
+
24
+ const payload = [...batchObjects(argsInputs, 5)].map((args) => {
25
+ return {
26
+ op: 'subscribe',
27
+ args
28
+ }
29
+ })
30
+
31
+ return payload
32
+ }
33
+
34
+ protected messageIsError(message: any): boolean {
35
+ return message.event === 'error'
36
+ }
37
+
38
+ abstract getInstType(symbol: string): string
39
+ }
40
+
41
+ export class BitgetRealTimeFeed extends BitgetRealTimeFeedBase {
42
+ getInstType(_: string) {
43
+ return 'SPOT'
44
+ }
45
+ }
46
+
47
+ export class BitgetFuturesRealTimeFeed extends BitgetRealTimeFeedBase {
48
+ getInstType(symbol: string) {
49
+ if (symbol.endsWith('USDT')) {
50
+ return 'USDT-FUTURES'
51
+ }
52
+
53
+ if (symbol.endsWith('PERP')) {
54
+ return 'USDC-FUTURES'
55
+ }
56
+
57
+ return 'COIN-FUTURES'
58
+ }
59
+ }
@@ -50,6 +50,7 @@ import { BinanceEuropeanOptionsRealTimeFeed } from './binanceeuropeanoptions'
50
50
  import { OkexSpreadsRealTimeFeed } from './okexspreads'
51
51
  import { KucoinFuturesRealTimeFeed } from './kucoinfutures'
52
52
  import { DydxV4RealTimeFeed } from './dydx_v4'
53
+ import { BitgetFuturesRealTimeFeed, BitgetRealTimeFeed } from './bitget'
53
54
 
54
55
  export * from './realtimefeed'
55
56
 
@@ -110,7 +111,9 @@ const realTimeFeedsMap: {
110
111
  'binance-european-options': BinanceEuropeanOptionsRealTimeFeed,
111
112
  'okex-spreads': OkexSpreadsRealTimeFeed,
112
113
  'kucoin-futures': KucoinFuturesRealTimeFeed,
113
- 'dydx-v4': DydxV4RealTimeFeed
114
+ 'dydx-v4': DydxV4RealTimeFeed,
115
+ bitget: BitgetRealTimeFeed,
116
+ 'bitget-futures': BitgetFuturesRealTimeFeed
114
117
  }
115
118
 
116
119
  export function getRealTimeFeedFactory(exchange: Exchange): RealTimeFeed {